Image connected domain area high-precision measurement method based on polynomial fitting
Patent Information
- Application Number
- CN202611226921.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-13
- Publication Date
- 2026-10-30
AI Technical Summary
[0005]本发明的主要目的在于提供一种基于多项式拟合的图像连通域面积高精度测量方法,旨在解决现有连通域面积测量方法因图像像素离散化导致的边缘锯齿效应及缺乏针对不同边缘形态的自适应误差校正机制,致使测量精度不足且难以满足高精度应用场景的需求的技术问题
[0046]本发明提供了一种基于多项式拟合的图像连通域面积高精度测量方法,所述方法通过构建图像边缘轮廓模型并系统识别离散化误差类型,深入分析不同边缘形态对传统像素计数法的测量影响,实现了对边缘离散误差的精准建模;在此基础上,构建融合离散误差数据与自适应拟合校正参数的高精度测量模型,能够针对实时边缘特征动态优化多项式拟合策略,有效抑制锯齿、阶梯等离散效应带来的面积测量偏差;最终结合多项式拟合所得连续边缘曲线与格林公式进行积分计算,显著提升了连通域面积测量的精度与稳定性,克服了传统方法在复杂边缘形态下误差大、适应性差的问题,为图像形态分析提供了更可靠的数据支持。
Smart Images

Figure CN123015648A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a high-precision method for measuring the area of connected regions in an image based on polynomial fitting. Background Technology
[0002] In the fields of computer vision and image processing, connected component area measurement is one of the key technologies in applications such as morphological analysis, target recognition, and size measurement. Traditional connected component area measurement methods typically employ pixel counting, which estimates the area by counting the number of pixels contained within or at the boundaries of the connected component. This method is simple to implement and computationally efficient, but it has significant limitations in high-precision measurement scenarios. Especially when there are discretized phenomena such as jagged or stepped edges, the inherent spatial sampling errors during image digitization lead to systematic deviations in the measurement results, severely affecting the accuracy and repeatability of area measurements.
[0003] With the increasing demands for measurement accuracy in fields such as industrial inspection and medical image analysis, coarse-grained area estimation based on pixel arrays is no longer sufficient to meet practical needs. While existing technologies employ sub-pixel edge detection or curve fitting methods to smooth edges and improve accuracy, most methods fail to adequately consider the diversity and non-uniformity of discretization errors under different edge shapes (such as straight lines, arcs, and acute angles), lacking effective identification and targeted correction mechanisms for error types. This results in unstable fitting performance, particularly in complex contours or low-resolution images where significant errors persist. Furthermore, traditional methods often rely on fixed-order fitting models, failing to dynamically adjust the fitting strategy based on actual edge features, thus limiting their adaptability to varying scenarios.
[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this invention is to provide a high-precision measurement method for the area of connected regions in images based on polynomial fitting. This method aims to solve the technical problems of insufficient measurement accuracy and difficulty in meeting the requirements of high-precision application scenarios caused by the edge jaggedness effect due to image pixel discretization and the lack of adaptive error correction mechanisms for different edge shapes in existing connected region area measurement methods.
[0006] To achieve the above objectives, this invention provides a high-precision measurement method for the area of connected components in an image based on polynomial fitting, the method comprising:
[0007] The edge pixel data of the target image is acquired using an image acquisition device, and an image edge contour model is constructed based on the edge pixel data.
[0008] Based on the edge traversal algorithm, the edge contour model is analyzed, the discretization error types affecting the measurement of the connected region area are identified, and the edge discrete features are extracted to obtain discrete error data.
[0009] Based on the discrete error data, the influence of different edge shapes on the area of connected regions measured by the pixel counting method is analyzed to obtain discretization influence data;
[0010] A high-precision measurement model for the area of connected regions is constructed. Based on the discretized influence data, fitting correction parameters under different edge morphologies are determined. The discrete error data and the fitting correction parameters under different edge morphologies are then imported into the area measurement model for learning and training.
[0011] The real-time edge pixel coordinate data of the target image is obtained, and the real-time edge pixel coordinate data is imported into the area measurement model to identify and correct the discretization error in the real-time edge, so as to obtain polynomial fitting edge curve data.
[0012] Based on the polynomial fitted edge curve data, the area integral is calculated using Green's formula to obtain the area measurement result, and the target image is then subjected to morphological analysis based on the area measurement result.
[0013] Optionally, the step of acquiring edge pixel data of the target image based on the image acquisition device and constructing an image edge contour model based on the edge pixel data specifically involves:
[0014] Centered on the target connected component, the acquired original image is subjected to edge detection and binarization processing, and the pixels in the image are filtered by a preset edge extraction algorithm.
[0015] Based on the pixels after the filtering operation, the edge pixel data of the target image is obtained. The edge pixel data includes the horizontal and vertical coordinates of different pixels on the edge, the pixel arrangement order, and the pixel adjacency relationship.
[0016] An ordered array construction algorithm is introduced. Based on the algorithm, edge pixel data is constructed into a pixel coordinate array. The pixel coordinate array is then processed to unify the orientation, resulting in an edge coordinate array with a unified orientation.
[0017] Calculate the curvature change of the pixels in the edge coordinate array, perform extreme point detection on the curvature change to obtain extreme points and corresponding feature indices, and select key pixels that can cover the edge change features to form a new feature point set according to the curvature magnitude.
[0018] The edge coordinate array is mapped to a two-dimensional rectangular coordinate system to generate the edge contour distribution map and edge gradient direction map of the target connected domain, thus obtaining the image edge contour model.
[0019] Optionally, the edge contour model analysis based on the edge traversal algorithm identifies the discretization error types affecting the measurement of the connected region area and extracts the discrete edge features to obtain discrete error data, specifically as follows:
[0020] Obtain the historical edge contour model of the target connected component, discretize the historical edge contour model and label the error types, and extract the geometric features of the discretized historical edge contour map by the difference operation method;
[0021] Based on the local window analysis method, spatial domain features of historical edge contour distribution map are extracted. The spatial domain features include pixel distribution features and normal vector direction features under different edge curvatures. The geometric features and spatial domain features are transformed into multi-dimensional feature vectors.
[0022] A discretized error type identification model is constructed based on the support vector machine algorithm, the difference operation method, and the local window analysis method. The multidimensional feature vector is imported into the discretized error type identification model for training. The edge contour model is imported into the trained discretized error type identification model for identification, and the discretized error type identification result is obtained.
[0023] Based on the discretization error type identification results, edge discrete features for each discretization error type are determined. The edge discrete features include pixel deviation features, fitting residual features, and curvature features for each discretization error type, thereby obtaining discrete error data.
[0024] Optionally, the geometric features include sawtooth wave features, step features, and pixel offset features under different edge orientations.
[0025] Optionally, the step of analyzing the impact of different edge shapes on the measurement of connected region area based on the pixel counting method according to the discrete error data to obtain discretized impact data specifically includes:
[0026] Based on the discrete error data, different types of discretization errors are classified according to pixel deviation features, fitting residual features, and curvature features to form a discretization error type library;
[0027] Based on the discretization error type library, different error types are randomly combined to generate a discretization error type test group containing one or more combinations of discretization error types;
[0028] Based on the graphics simulation software, virtual edge test signals are generated for each discretization error type test group under different edge morphology conditions, and standard geometric graphic signals are generated. The virtual edge test signals are applied to the standard geometric graphic signals to simulate discretization interference and generate discretization edge pixel test data.
[0029] The discretized edge pixel test data is imported into the connected region area measurement system for area calculation. The accuracy of the connected region area measurement is determined when the target connected region is affected by one type of discretization error under different edge shapes or by multiple types of discretization errors under different edge shapes. The measurement accuracy data is obtained.
[0030] The measurement accuracy data is used to construct a discretized error type-edge morphology condition-measurement accuracy impact data table to obtain the discretized impact data of connected region area measurement.
[0031] Optionally, the step of constructing a high-precision measurement model for the area of connected components involves determining fitting correction parameters for different edge morphologies based on the discretized influence data, and then importing the discrete error data and the fitting correction parameters for different edge morphologies into the area measurement model for learning and training. Specifically:
[0032] Acquire data on the impact of area measurement accuracy on image morphology analysis, and determine a measurement accuracy threshold based on the morphology analysis impact data;
[0033] Based on the measurement accuracy threshold, the discretization impact data is analyzed. Discretization error types below the measurement accuracy threshold, corresponding edge morphology conditions, and corresponding measurement accuracy are extracted to form a new discretization error type-edge morphology condition-measurement accuracy impact data table, thus obtaining the substantial discretization impact data that affects the morphological analysis of connected region area measurement.
[0034] Based on the morphological analysis impact data and the substantive discretization impact data, the degree of influence of different discretization error types on the morphological analysis of connected components under different edge morphological conditions is determined, and the degree of influence data is obtained.
[0035] Obtain the functional data of each polynomial fitting module in the connected domain area measurement system for discretization error correction, and determine the fitting correction parameters for different discretization error types under different edge morphology conditions based on the influence data and functional data. The fitting correction parameters include polynomial order parameters and node smoothing parameters.
[0036] A convolutional neural network is constructed, and the fitting correction parameters of different discretization error types under different edge morphology conditions are imported into the convolutional neural network for training. The trained convolutional neural network is combined with the discretization error type identification model and connected to the area measurement system to obtain a high-precision measurement model of the connected region area.
[0037] Optionally, the step of obtaining real-time edge pixel coordinate data of the target image and importing the real-time edge pixel coordinate data into the area measurement model to identify and correct discretization errors in the real-time edges, thereby obtaining polynomial-fitted edge curve data, specifically involves:
[0038] The real-time edge pixel coordinate data of the target image is obtained, and the real-time edge pixel coordinate data is imported into the area measurement model to identify the discretization error type and error degree in the real-time edge, and obtain the discretization error identification result.
[0039] Based on the discretization error identification results, real-time fitting correction parameters are determined. The area measurement model performs piecewise polynomial fitting correction processing on the real-time edge pixel coordinate data in real time according to the real-time fitting correction parameters to obtain polynomial fitting edge curve data.
[0040] Optionally, the step of calculating the area integral using Green's formula based on the polynomial-fitted edge curve data to obtain the area measurement result, and then performing morphological analysis on the target image based on the area measurement result, specifically involves:
[0041] Parametric equations are constructed on the polynomial fitted edge curve data to generate continuous closed edge curve equation data, including horizontal axis parametric equations and vertical axis parametric equations.
[0042] Based on Green's formula, line integral operations are performed on the equation data of continuous closed edge curves to calculate the area of the closed region of the target connected domain. Combined with pixel equivalent data, the actual physical area is determined, and the area measurement result is obtained.
[0043] The area measurement results are compared with a preset area threshold to generate a target morphological feature evaluation report, and an image post-processing strategy is formulated based on the morphological feature evaluation report.
[0044] Furthermore, to achieve the above objectives, the present invention also provides a high-precision measurement device for the area of connected components of an image based on polynomial fitting. The device includes: a memory, a processor, and a high-precision measurement program for the area of connected components of an image based on polynomial fitting, which is stored in the memory and can run on the processor. The high-precision measurement program for the area of connected components of an image based on polynomial fitting is configured to implement the steps of the high-precision measurement method for the area of connected components of an image based on polynomial fitting as described above.
[0045] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a high-precision measurement program for the area of connected components of an image based on polynomial fitting. When executed by a processor, the high-precision measurement program for the area of connected components of an image based on polynomial fitting implements the steps of the high-precision measurement method for the area of connected components of an image based on polynomial fitting as described above.
[0046] This invention provides a high-precision measurement method for the area of connected components in images based on polynomial fitting. The method constructs an image edge contour model and systematically identifies discretization error types, deeply analyzing the impact of different edge morphologies on the measurement of traditional pixel counting methods, thus achieving accurate modeling of edge discretization errors. Based on this, a high-precision measurement model is constructed that integrates discrete error data with adaptive fitting correction parameters. This model can dynamically optimize the polynomial fitting strategy for real-time edge features, effectively suppressing area measurement deviations caused by discretization effects such as jagged edges and staircases. Finally, the continuous edge curve obtained from polynomial fitting is combined with Green's formula for integral calculation, significantly improving the accuracy and stability of connected component area measurement. This overcomes the problems of large errors and poor adaptability of traditional methods under complex edge morphologies, providing more reliable data support for image morphology analysis. Attached Figure Description
[0047] Figure 1 This is a flowchart illustrating an embodiment of the high-precision measurement method for the area of connected components in an image based on polynomial fitting according to the present invention.
[0048] Figure 2 This is a flowchart illustrating another embodiment of the high-precision measurement method for the area of connected regions in an image based on polynomial fitting according to the present invention.
[0049] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0050] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0051] Reference Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the high-precision measurement method for the area of connected regions in an image based on polynomial fitting according to the present invention.
[0052] In one embodiment, the high-precision measurement method for the area of connected components in an image based on polynomial fitting includes:
[0053] Step S100: Obtain edge pixel data of the target image based on the image acquisition device, and construct an image edge contour model based on the edge pixel data.
[0054] The image acquisition device can be a hardware device used to acquire digital images of the target scene, providing raw image data as the basic input for subsequent edge extraction and area measurement. In this embodiment, the image acquisition device can spatially sample the optical scene using a photoelectric sensor and convert it into discrete pixel data. For example, the image acquisition device can include, but is not limited to, visible light cameras, infrared thermal imagers, and X-ray imaging devices. The edge pixel data of the target image can be a set of pixels representing object boundaries extracted from the target image, serving as the initial discrete data source for constructing a continuous edge contour model. Further, the edge pixel data of the target image can identify boundary pixels from the raw image using edge detection operators such as Canny, Sobel, or gradient-based methods. The image edge contour model can be an ordered boundary representation structure composed of edge pixel data, used to describe the geometric shape of connected regions, providing structured input for subsequent error identification and fitting. In a specific embodiment, the image edge contour model can connect edge pixels into closed or open contour chains based on spatial adjacency. Further, the image edge contour model can collaborate with edge traversal algorithms to provide traversal paths and form a discrete-to-continuous mapping relationship with polynomial-fitted edge curve data.
[0055] Obtaining edge pixel data of a target image using an image acquisition device can be achieved by acquiring the original image and then extracting boundary pixels using an edge detection algorithm. Further, this operation can be implemented by first acquiring a grayscale image and then extracting edges using the Canny operator, or by directly thresholding edges from the gradient magnitude map of a color image. This achieves the technical effect of obtaining initial discrete boundary information for constructing a contour model. Constructing an image edge contour model based on the edge pixel data can be achieved by organizing the extracted edge pixels into an ordered contour chain according to their spatial adjacency. Further, this operation can be implemented by using Freeman chain code to encode the contours and constructing a graph-based contour representation, thereby achieving a structured boundary representation that facilitates subsequent traversal and analysis.
[0056] Step S200: Based on the edge traversal algorithm, the edge contour model is analyzed, the discretization error types affecting the measurement of the area of the connected region are identified, and the edge discrete features are extracted to obtain discrete error data.
[0057] The edge traversal algorithm can be a computational process that sequentially visits all boundary pixels along the image edge contour. It can be used to systematically scan edges to support error type identification and feature extraction. In a specific embodiment, the edge traversal algorithm can employ chain code tracing, contour tracing, or graph search strategies to achieve pixel-level sequential traversal. For example, the edge traversal algorithm may include, but is not limited to, 8-neighborhood chain code tracing, depth-first contour tracing, and breadth-first boundary expansion. The discretization error type can be a systematic deviation category caused by the non-realistic geometric shape of edges on the pixel grid due to image digitization. It can be used to distinguish different edge distortion modes and guide the selection of subsequent correction strategies. For example, the discretization error type may include, but is not limited to, sawtooth step error, circular arc discretization truncation error, and acute angle vertex offset error. The edge discrete features can be quantitative or qualitative attributes reflecting the discretization performance of edges in the pixel grid. They can be used as constituent elements of discrete error data to characterize the spatial distribution characteristics of errors. In an exemplary embodiment, the edge discrete features can be extracted from the contour using indicators such as local curvature, rate of change of direction, and pixel spacing distribution. For example, discrete edge features may include, but are not limited to, local orientation abrupt changes, curvature discrete fluctuations, and uneven pixel chain lengths. Discrete error data can be a structured information set composed of identified discretized error types and their corresponding discrete edge features, which can be used to provide prior error knowledge for high-precision measurement models and support adaptive correction. Furthermore, discrete error data can be used in conjunction with high-precision connected region area measurement models as one of their inputs; and together with different edge morphologies, it determines the fitting correction parameters.
[0058] Edge contour model analysis based on edge traversal algorithms can involve sequentially visiting each edge pixel and its neighborhood along the contour, recording local geometric characteristics. Furthermore, this operation can be implemented using recursive depth-first traversal and an iterative chain code parser, achieving the technical effect of scanning the entire boundary to support error identification. Identifying and extracting discrete edge features from discretized error types affecting connected region area measurement can be achieved by determining error categories based on local edge orientation, curvature changes, etc., and quantifying relevant features. Further, this operation can be implemented by identifying jagged errors through local orientation histogram clustering and detecting acute angle vertex offsets using curvature sign changes, thereby generating discrete error data suitable for modeling.
[0059] Step S300: Analyze the impact of different edge shapes on the area of connected regions measured by the pixel counting method based on the discrete error data to obtain discretized impact data.
[0060] Different edge morphologies can be the geometric shapes of connected region boundaries in continuous space, which can be used to determine the manifestation of discretization errors and their impact on area measurement. For example, different edge morphologies can include, but are not limited to, straight line segments, arc segments, acute angles of polygons, and free curve segments. Measuring the area of a connected region based on pixel counting is a traditional method that estimates its area by counting the total number of pixels contained within the connected region. This can be used as a benchmark method for analyzing the generation of discretization impact data. For example, measuring the area of a connected region based on pixel counting can include, but is not limited to, counting internally filled pixels, counting pixels surrounding the boundary, and counting four-connected regions. Discretization impact data can be mapping data describing the deviation of discretization errors from pixel counting area measurement results under different edge morphologies. This can be used to reveal the correlation between errors and geometric shapes, guiding the setting of correction parameters. Furthermore, discretization impact data can be directly correlated with fitting correction parameters, providing a basis for their determination.
[0061] Analyzing the impact of different edge morphologies on the measurement of connected region area using pixel counting based on discrete error data can be achieved by comparing the synthesized edges with known geometric shapes with their corresponding pixel counts to establish an error mapping. Furthermore, this operation can be implemented by generating digital images using ideal circles / straight lines and statistically analyzing area deviations, then regressing an error model based on real labeled data. This achieves the technical effect of generating discrete impact data and revealing the correlation between morphology and error.
[0062] Step S400: Construct a high-precision measurement model for the area of connected regions. Determine the fitting correction parameters under different edge morphologies based on the discretized influence data. Import the discrete error data and the fitting correction parameters under different edge morphologies into the area measurement model for learning and training.
[0063] The fitting correction parameters can be adjustable coefficients or strategy configurations used to adjust the polynomial fitting process to compensate for discrete errors under specific edge morphologies. They can be used to enable the polynomial fitting to specifically approximate true continuous edges and reduce area integration bias. In one specific embodiment, the fitting correction parameters can be dynamically set based on discretized influence data, and may include polynomial order, weight allocation, local window size, etc. The high-precision connected region area measurement model can be a computational framework that integrates discrete error data and fitting correction parameters to generate corrected continuous edges and calculate their area. It can be used to achieve error identification, correction, and high-precision area output for real-time edges. In an exemplary embodiment, the high-precision connected region area measurement model can be formed by importing discrete error data and fitting correction parameters into the model for training or rule configuration. Exemplarily, the high-precision connected region area measurement model can include, but is not limited to, rule-based reasoning correction models, machine learning-based regression models, and hybrid parameter optimization models. Furthermore, the high-precision connected region area measurement model can receive real-time edge pixel coordinate data of the target image and output polynomial-fitted edge curve data.
[0064] Constructing a high-precision measurement model for connected region area can be achieved by integrating error identification, parameter selection, and fitting calculation modules into a unified processing framework. Furthermore, this operation can be implemented by building a rule-based correction system and designing an end-to-end neural network regression model, thereby achieving the technical effect of providing end-to-end high-precision area measurement capabilities. Determining the fitting correction parameters for different edge morphologies based on discretized influence data can be achieved by querying or calculating the optimal fitting configuration matching the current edge morphology. Further, this operation can be achieved by matching preset parameter combinations using table lookup methods and optimizing the local fitting order and weights online, thereby achieving the technical effect of adaptive adjustment of the fitting strategy. Importing discrete error data and fitting correction parameters for different edge morphologies into the area measurement model for learning and training can be achieved by optimizing the model's internal parameters or rule base using historical data. Further, this operation can be achieved by using supervised learning to train the correction network and using reinforcement learning to optimize the parameter selection strategy, thereby improving the model's generalization ability for error correction.
[0065] Step S500: Obtain real-time edge pixel coordinate data of the target image, import the real-time edge pixel coordinate data into the area measurement model to identify and correct the discretization error in the real-time edge, and obtain polynomial fitting edge curve data.
[0066] The real-time edge pixel coordinate data of the target image can be a sequence of spatial coordinates of the currently extracted edge pixels in the target image under test. This can be used as real-time input to the area measurement model to trigger error correction and fitting processes. The polynomial-fitted edge curve data can be a corrected continuous edge representation, a closed or open curve described by a piecewise or global polynomial function. This can provide a smooth, continuous boundary for accurate integration, replacing discrete pixel chains. In one specific embodiment, the polynomial-fitted edge curve data can be generated by polynomial regression fitting of the real-time edge pixel coordinates under the guidance of fitting correction parameters. Furthermore, the polynomial-fitted edge curve data can serve as the input boundary for Green's theorem integration calculation, directly affecting the area measurement results.
[0067] Obtaining real-time edge pixel coordinate data of the target image can be achieved by performing edge detection on a new input image and outputting a coordinate sequence. Furthermore, this operation can be implemented by extracting edges frame-by-frame from a real-time video stream or by batch processing a set of static images, thus providing the technical effect of current boundary data to be processed. Importing the real-time edge pixel coordinate data into an area measurement model to identify and correct discretization errors in the real-time edges can be achieved by the model automatically analyzing the input edges and calling the corresponding correction parameters for fitting and optimization. Furthermore, this operation can be achieved by fitting each edge sub-segment piecewise and stitching them together, and globally optimizing the polynomial expression of the entire contour, thus achieving the technical effect of outputting a continuous edge curve that approximates the real geometry.
[0068] Step S600: Based on the polynomial fitting edge curve data, area integral calculation is performed using Green's formula to obtain the area measurement result. Based on the area measurement result, morphological analysis is performed on the target image.
[0069] Green's formula can be a mathematical formula that transforms the area of a region enclosed by a closed curve in a plane into an integral along the boundary line. It can be used to achieve accurate area calculation without pixel-level discrete errors based on continuous edge curves. The area measurement result can be the actual area value of a connected region obtained through integration, which can be used as a quantitative basis for morphological analysis, for size assessment, classification, or quality judgment. For example, the area measurement result may include, but is not limited to, absolute area values, relative area ratios, and normalized area indices. Morphological analysis of a target image can be a qualitative or quantitative assessment of the shape characteristics of a target object in the image based on area and other geometric features. It can be used to support decision-making in downstream tasks such as industrial inspection and medical diagnosis. For example, the morphological analysis of a target image may include, but is not limited to, area-perimeter ratio analysis, shape compactness analysis, and contour symmetry analysis.
[0070] Area integration is performed using Green's formula on edge curve data fitted by a polynomial. This can be achieved by substituting continuous curve parameters into Green's formula for numerical integration. Furthermore, this operation can be implemented through direct analytical integration of the parameterized polynomial or by applying numerical integration formulas to discrete sampling points, thus achieving high-precision area values without pixel-level discrete errors. Morphological analysis of the target image based on the area measurement results can be performed by combining area with other geometric features for shape evaluation or classification. Further, this operation can be achieved by calculating the area-to-perimeter ratio to determine cell morphology or by screening defective regions based on area thresholds, thereby supporting downstream application decision-making.
[0071] In one specific embodiment, the edge pixels of the image connected components are arranged into an array in a counter-clockwise order. , where N is the total number of pixels in the original edge. Every 3 consecutive counterclockwise edge pixels form a fitting group. Polynomial fitting is performed independently within each group. The 3 points exactly meet the minimum requirements for fitting a second-order polynomial (quadratic curve), uniquely determining a quadratic curve and ensuring that there is no bias in the fitting within the group. Initially, each pixel is moved backward to form a group, with each group consisting of 3 consecutive pixels. The end point of the previous group equals the starting point of the next group (adjacent groups share 1 pixel), fully covering all edge pixels. Since each group consists of 3 pixels and groups share 1 pixel, the number of pixels required for K groups is: K × 2 + 1, i.e., K = (N - 1) / 2. From... Initially, groups are formed every two pixels, with three consecutive pixels in each group. Groups share a common endpoint / starting point. Eventually, K groups completely cover N=2K+1 edge pixels, and the endpoint of the last group is naturally... , and the starting point of the first group The loop is closed. If the total number of edge pixels N is not odd, the last pixel must be removed. This will not affect the accuracy of the contour. Based on the above, the pixels in the k-th group (k=0, 1, 2, 3, ..., K-1) are: The last group's finish line The original edge naturally closed loop to This forms a complete closed group.
[0072] Furthermore, by performing intra-group second-order parametric polynomial fitting on each group of 3 pixels, the fitting curve does not require additional correction due to the common point characteristic between groups. For the k-th group... Allocate indexes within the group Let t=0 be the starting point of the group (the ending point of the previous group), t=1 be the midpoint of the group, and t=2 be the ending point of the group (the starting point of the next group). Fitting second-order polynomial curves about t to the x and y axes respectively yields:
[0073] ;
[0074] All parameters are independent and unrelated to parameters within other groups. Because the pixels in each group are connected end-to-end, the following condition is met. , Furthermore, the first derivative of each second-order fitted curve must be equal at the point where the two curves are connected. , The last group satisfies At this point, all fitted curves completely overlap at their common point, with no seams; the last set of endpoints... Closed loop to the starting point of the first group The overall fitted profile is a continuous closed curve.
[0075] Finally, after obtaining the edge figure formed by the fitting polynomial curves of the edge pixels of the connected region of the image, the closed contour of the area of the connected region of the image is divided into K consecutive second-order parametric curves with the first and last points overlapping (1 segment per group, t∈[0,2]), and the cross product integrals at the junctions between groups have no overlap and no omissions. Therefore, the total area S = 1 / 2 × the sum of the cross product line integrals of all groups of curves, that is, the area of the closed figure can be calculated using Green's formula:
[0076]
[0077] Substituting the above case again, the total area S of the connected components of the image is calculated as half of the sum of all integrals, thus yielding the formula:
[0078]
[0079] The formula yields This is the high-precision value of the area of the connected components of the image.
[0080] Taking semiconductor wafer defect detection as an example, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can extract connected regions of micron-level particles or scratches from wafer surface images. Traditional pixel counting methods underestimate the area due to edge jaggedness. This solution identifies stepped discrete errors by constructing an edge contour model, generates smooth edge curves by combining fitting correction parameters corresponding to arc segments, and obtains the true area using Green's formula for accurate integration, thereby accurately determining whether the defect exceeds the process tolerance and improving yield control accuracy. For another example, in the scenario of medical cell image analysis, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can measure the area of connected regions of red blood cells in blood smear images. Since cell edges are approximately circular but exhibit obvious jaggedness at low resolution, this solution identifies the type of circular arc discrete truncation error, calls a high-order polynomial fitting strategy to reconstruct continuous boundaries, and calculates the area using Green's formula, avoiding misdiagnosis of anemia due to pixel counting deviations and improving the reliability of clinical diagnosis.
[0081] In one embodiment, edge pixel data of the target image is acquired based on an image acquisition device, and an image edge contour model is constructed based on the edge pixel data, specifically as follows:
[0082] Centered on the target connected component, the acquired original image is subjected to edge detection and binarization processing, and the pixels in the image are filtered by a preset edge extraction algorithm.
[0083] The original image can be an unprocessed digital image directly acquired by an image acquisition device, serving as the input source for edge detection and binarization. The target connected component can be a set of spatially connected pixels with the same attributes in the image, used to define the spatial range for edge extraction and contour modeling. Edge detection and binarization can be jointly performed image preprocessing operations; detecting edges first and then converting to a black-and-white binary image can highlight boundary information and simplify the complexity of subsequent pixel selection. Furthermore, edge detection and binarization can be achieved by first global binarizing and then cropping the target region, or by first locating connected components and then performing local edge detection, thereby focusing on the effective area, suppressing background interference, and improving edge quality. Pixels can be the smallest spatial sampling unit in the image, serving as the basic elements constituting edge pixel data. The preset edge extraction algorithm can be a deterministic computation method for accurately extracting boundary pixels from a binary image, used to improve the reliability of edge pixel data under noisy or weak edge conditions. Furthermore, the preset edge extraction algorithm can be implemented by extracting the outer contour after using morphological opening and closing operations and applying a thinning algorithm to retain the single-pixel wide edge, thereby removing false edges and noise points and ensuring the accuracy of edge pixel data.
[0084] The edge pixel data of the target image is obtained based on the pixels after the filtering operation. The edge pixel data includes the horizontal and vertical coordinates of different pixels on the edge, the pixel arrangement order, and the pixel adjacency relationship.
[0085] The horizontal and vertical coordinates can represent the position of a pixel in the image coordinate system, providing the positioning information needed for edge geometry modeling. The pixel arrangement order can represent the sequence of edge pixels along the contour, supporting sequential operations such as ordered traversal and curvature calculation. Pixel adjacency relationships can represent the spatial connection between adjacent edge pixels, ensuring contour continuity and topological correctness. Furthermore, pixel adjacency relationships can include, but are not limited to, 4-adjacency, 8-adjacency, and mixed adjacency relationships. Obtaining edge pixel data of the target image based on the filtered pixels can involve collecting and retaining pixel coordinates, order, and adjacency information to form structured data. Further, this operation can be achieved by simultaneously recording chain codes and coordinates, outputting only coordinates but reconstructing adjacency relationships, thereby generating an edge description containing complete topological information.
[0086] An ordered array construction algorithm is introduced. Based on the algorithm, edge pixel data is constructed into a pixel coordinate array. The pixel coordinate array is then processed to unify the orientation, resulting in an edge coordinate array with a unified orientation.
[0087] The ordered array construction algorithm can be a computational process that organizes discrete edge pixels into an array with a clear order and index structure, which can be used to achieve structured storage and efficient access of edge data. In one embodiment, the ordered array construction algorithm may include, but is not limited to, linked list to array conversion algorithms, circular buffer construction algorithms, index mapping algorithms, etc. The pixel coordinate array can be a sequence of edge pixel coordinates stored in array form, which can be used as an intermediate data structure for orientation unification and curvature analysis. The edge coordinate array with unified orientation can be a coordinate array in which all edge pixels are arranged in a consistent direction, such as counterclockwise, which can be used to eliminate directional ambiguity and ensure the consistency between curvature sign and extreme value detection. For example, the edge coordinate array with unified orientation may include, but is not limited to, unifying to a counterclockwise direction, unifying to a clockwise direction, etc. Introducing an ordered array construction algorithm, and constructing a pixel coordinate array based on the algorithm, can be a process of converting unordered or linked storage of edge points into a linear index array. Furthermore, this operation can be implemented by recursively traversing the contour to generate an array and using a queue to iteratively construct a sequential array, thereby facilitating subsequent numerical calculations and index access. The pixel coordinate array is oriented to obtain a uniformly oriented edge coordinate array. This can be achieved by determining the area sign or starting point rules and adjusting the traversal direction. Furthermore, this operation can be implemented by calculating the directed area to determine the direction and reversing it, then fixing the arrangement to start from the leftmost point and proceed counter-clockwise, thus ensuring consistency in the sign of curvature calculations and extremum detection.
[0088] Calculate the curvature change of pixels in the edge coordinate array, perform extreme point detection on the curvature change, obtain extreme points and corresponding feature indices, and select key pixels that can cover the edge change features to form a new feature point set based on the curvature magnitude.
[0089] The curvature change can be the amount of change in the degree of local bending of the edge with the position of the contour. It can be used to reflect the dynamic characteristics of the edge geometry and to identify key structural points. Extreme points can be the edge locations where the curvature change sequence achieves a local maximum or minimum value. They can be used to identify key turning points in the edge shape, such as corners and apexes. The feature index can be the position number of the extreme point in the edge coordinate array. It can be used to support the rapid location and extraction of key pixels. Key pixels can be pixels located at extreme points that represent the geometric features of the edge. They can be used to form the basic units of the feature point set, reducing redundant fitting points. In a specific embodiment, key pixels can include, but are not limited to, corner-type key points, apex-type key points, and endpoints of line segments. The feature point set can be a sparse but representative subset of edges composed of key pixels. It can be used to provide anchor points for polynomial piecewise fitting, improving fitting efficiency and accuracy. Furthermore, the feature point set can include, but is not limited to, adaptive curvature sampling point sets, uniformly spaced enhanced point sets, and hybrid key-uniform point sets.
[0090] Calculating the curvature change of pixels in the edge coordinate array can be achieved by calculating the curvature value of each point based on local three-point or multi-point fitting. Further, this operation can be implemented by calculating curvature using the discrete difference formula and estimating the radius of curvature through local circle fitting, thereby quantifying the degree of edge curvature and identifying regions with drastic geometric changes. Extreme point detection is performed on the curvature changes to obtain extreme points and their corresponding feature indices. This can be achieved by scanning the curvature sequence and marking the locations of local maxima and minima. Further, this operation can be implemented using a sliding window comparison method and applying first-order derivative zero-crossing detection, thereby locating key geometric feature points of the edge. Based on the curvature magnitude, key pixels that can cover the edge change features are selected to form a new feature point set, which can be achieved by retaining points whose absolute curvature value exceeds a threshold or are extreme values. Further, this operation can be implemented by adaptive threshold selection of key points and joint filtering based on curvature and gradient direction, thereby constructing a sparse but highly informative set of fitting control points.
[0091] By mapping the edge coordinate array to a two-dimensional Cartesian coordinate system, an edge contour distribution map and an edge gradient direction map of the target connected domain are generated, resulting in an image edge contour model.
[0092] The two-dimensional Cartesian coordinate system can be a standard Cartesian coordinate system used to represent the spatial position of an image plane, providing a unified geometric reference for the edge contour distribution map and gradient direction map. The edge contour distribution map can be a graphical representation of the spatial distribution of edge pixels in a two-dimensional coordinate system, visually displaying the shape of connected components and aiding in error analysis and model validation. The edge gradient direction map can be a vector field map representing the normal or tangential gradient direction of each point on the edge, providing local edge orientation information and aiding in error type identification and fitting weight allocation. Mapping the edge coordinate array to a two-dimensional Cartesian coordinate system to generate the edge contour distribution map and edge gradient direction map of the target connected component can be achieved by converting pixel coordinates into points and vectors in a standard coordinate system and visualizing them. Furthermore, this operation can be achieved by simultaneously drawing point distributions and gradient arrows, and generating contour raster maps and orientation heatmaps respectively, thus forming structured geometric and directional features that can be used by subsequent models. The resulting image edge contour model can be a composite model formed by integrating the edge contour distribution map and the edge gradient direction map. Furthermore, this operation can be achieved by storing the model in the form of a multi-channel tensor and saving geometric and directional attributes in a graph structure, thereby providing high-dimensional input for discrete error identification and adaptive fitting.
[0093] Taking precision parts dimensional inspection as an example, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can be used in microscopic images of metal parts where the target connected region is a hole to be measured. Traditional methods often result in an underestimation of the area due to jagged edges. This embodiment performs local edge detection and binarization centered on the hole, extracts single-pixel wide edges using the Zhang-Suen algorithm, and constructs a coordinate array in a unified counterclockwise direction. Curvature calculation reveals four near-right-angled minimum points, from which key pixel sets are extracted. Finally, an edge model containing contour distribution and gradient direction is generated, enabling subsequent polynomial fitting to accurately reconstruct the rounded transition region, and the area obtained by Green's integral is closer to the true value. For another example, in the scenario of pathological tissue section analysis, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can be used in tumor cell nucleus images where the nucleus contour exhibits an irregular convex-concave shape. This approach focuses on the target connected domain. After edge detection and refinement, an ordered coordinate array is constructed. After unifying the direction, the curvature is calculated, and multiple high-curvature convex and concave extreme points are identified to form a feature point set. Combined with the gradient direction map, convex and concave structures are distinguished, so that subsequent fitting can specifically handle different curvature regions, avoid excessive smoothing that leads to area distortion, and improve the accuracy of cell atypia assessment.
[0094] In one embodiment, based on the edge traversal algorithm, the edge contour model is analyzed to identify the discretization error types affecting the measurement of the connected region area and extract the edge discrete features to obtain discrete error data, specifically:
[0095] The historical edge contour model of the target connected region is obtained, and the historical edge contour model is discretized and labeled with error types. The geometric features of the discretized historical edge contour map after error type labeling are extracted by the difference operation method. The geometric features include sawtooth wave features, step features, and pixel offset features under different edge directions.
[0096] The historical edge contour model of the target connected domain can be edge contour data of connected domains with known real geometric shapes, which can be used as a benchmark data source for training the discretization error type recognition model and provide a basis for error labeling. In this embodiment, the historical edge contour model of the target connected domain can obtain its continuous boundary through high-resolution imaging, ideal image rendering, or manual annotation, and form a corresponding pixel-level contour after digitization. Discretization error type labeling can be used to classify the discretization distortion patterns presented by each local region in the historical edge contour model, which can be used to provide supervision signals for feature extraction and model training. Furthermore, discretization error type labeling can be done by comparing the digitized contour with the original continuous boundary, and manually or semi-automatically labeling error types such as jagged edges, steps, and offsets. The difference operation method can be a mathematical tool that characterizes local geometric changes by calculating the first-order or higher-order differences of the edge coordinate sequence, which can be used to quantify discrete distortion phenomena such as abrupt edge direction changes and step jumps. In a specific embodiment, the difference operation method can include first-order forward difference, second-order central difference, non-uniform step size difference, etc.
[0097] The geometric features of a historical edge contour map can be a set of geometric attributes reflecting discrete distortion extracted from the labeled historical contours through differential operations. These attributes can be used to characterize structural deviations caused by sampling under different edge orientations. Furthermore, the geometric features of a historical edge contour map can include sawtooth wave features, step-like features, and pixel offset features. Sawtooth wave features can be alternating small offset patterns in different directions caused by pixel grid constraints on oblique or curved edges, and can be used to characterize the discretization performance of non-axis-aligned edges. For example, sawtooth wave features can include positive slope sawtooth, negative slope sawtooth, periodic oscillating sawtooth, etc. Step-like features can be platform-like jump structures formed by integer coordinate constraints on approximately horizontal or vertical edges, and can be used to reflect the discretization characteristics of axis-aligned edges. Pixel offset features can be the systematic displacement of the actual edge position relative to the ideal continuous boundary on the pixel grid, and can be used to quantify the positional deviation caused by discretization.
[0098] Obtaining the historical edge contour model of the target connected component can be achieved by retrieving existing connected component contour data with realistic geometric references from a database or simulation system. Furthermore, obtaining the historical edge contour model of the target connected component can be achieved by loading cell contours from high-resolution microscopic images or reading digital versions of ideal part contours generated by CAD, thereby establishing a benchmark dataset required for error analysis. Discretizing the historical edge contour model and labeling its error types can be done by comparing the digital contour with the original continuous boundary and marking its main discrete distortion patterns in local areas. Further, discretizing the historical edge contour model and labeling its error types can be achieved through interactive manual labeling of various error regions or rule-based automatic labeling, such as detecting jagged patterns on 45-degree diagonal lines, thereby generating the labeled data required for supervised learning. Extracting the geometric features of the discretized historical edge contour map using difference operations can be achieved by calculating differences between the labeled contour coordinate sequences to identify patterns such as abrupt changes in direction and platform jumps. Furthermore, the geometric features of the historical edge contour map after discretization error type labeling can be extracted by the difference operation method. This can be achieved by calculating the first-order difference of adjacent pixel coordinates to identify the step and using the second-order difference to detect the sawtooth fluctuation frequency, thereby quantifying the discrete geometric distortion of edges with different orientations.
[0099] Based on the local window analysis method, spatial domain features of historical edge contour distribution map are extracted. Spatial domain features include pixel distribution features and normal vector direction features under different edge curvatures. Geometric features and spatial domain features are transformed into multi-dimensional feature vectors.
[0100] The local window analysis method can be a computational strategy that statistically analyzes pixel distribution characteristics within a local neighborhood of the edge contour. It can be used to capture spatial structural information related to the degree of edge curvature and normal vector variation. The spatial domain features of the historical edge contour distribution map can be spatial statistical attributes reflecting the local geometric complexity of the edge, obtained through local window analysis. These can be used to supplement geometric features and enhance the ability to discriminate errors in curved edges. Furthermore, the spatial domain features of the historical edge contour distribution map can include pixel distribution features and normal vector direction features. Pixel distribution features can be the spatial arrangement density or clustering pattern of edge pixels within the local window, which can be used to reflect the influence of local edge curvature on pixel sampling. For example, pixel distribution features can include sparse linear distribution, dense arcuate distribution, corner cluster distribution, etc. Normal vector direction features can be the directional consistency or rate of change of the local edge normal vector, which can be used to characterize edge smoothness and the degree of discrete perturbation. In a specific embodiment, normal vector direction features can include constant normal segments, gradually changing normal segments, and abrupt normal vector points.
[0101] Multidimensional feature vectors can be numerical representation vectors formed by fusing geometric and spatial domain features. They can be used as input to machine learning models to uniformly express the criteria for distinguishing different error types. Furthermore, multidimensional feature vectors are derived from the geometric features of historical edge contour maps and the spatial domain features of historical edge contour distribution maps, and are input into a discretized error type recognition model. Extracting spatial domain features from historical edge contour distribution maps using local window analysis methods can involve statistically analyzing pixel density, fitting normal vectors, and analyzing their changes within the local neighborhood of the contour. Further, extracting spatial domain features from historical edge contour distribution maps using local window analysis methods can be achieved by calculating the pixel covariance matrix within a sliding window to estimate the principal direction and statistically analyzing the standard deviation of the normal vector angle, thereby capturing spatial structural information related to curvature. Converting geometric and spatial domain features into multidimensional feature vectors can be achieved by concatenating the extracted features into a fixed-length numerical vector in a preset order. Further, converting geometric and spatial domain features into multidimensional feature vectors can be achieved by directly concatenating the original feature values, normalizing the features, and then concatenating them, thus forming a unified input format that can be processed by machine learning models.
[0102] A discretized error type identification model is constructed based on the support vector machine algorithm, the difference operation method, and the local window analysis method. The multidimensional feature vector is imported into the discretized error type identification model for training, and the edge contour model is imported into the trained discretized error type identification model for identification, so as to obtain the discretized error type identification result.
[0103] Among them, the Support Vector Machine (SVM) algorithm can be a supervised learning classification method based on the maximum margin principle, which can be used to construct error type discrimination boundaries in a high-dimensional feature space. The discretized error type identification model can be a computational model built based on algorithms such as SVM, used to automatically identify the discretized error category in a new edge contour. It can be used to automatically identify the error type of unknown edge contours, supporting subsequent targeted correction. In this embodiment, the discretized error type identification model is trained using labeled multi-dimensional feature vectors to learn the mapping relationship between error types and features. The discretized error type identification result can be the output of the discretized error category to which each local region of the current edge contour belongs, which can be used to guide the extraction of edge discrete features and the generation of discrete error data.
[0104] A discretized error type recognition model is constructed based on the Support Vector Machine (SVM) algorithm, differencing method, and local window analysis method. This can be achieved by using multi-dimensional feature vectors as input and error type labels as output to train an SVM classifier. Furthermore, this model can be further improved by using an RBF kernel SVM to handle nonlinear features and combining feature selection to reduce redundant dimensions, thus establishing a mapping model from features to error types. Training the discretized error type recognition model with multi-dimensional feature vectors can involve inputting the feature vectors of labeled samples into the model to optimize the classification hyperplane parameters. Alternatively, this can be achieved by using cross-validation to select the optimal regularization parameters and using SMOTE to handle class imbalance, thereby completing the model's learning process and enabling it to generalize. Finally, importing edge contour models into the trained discretized error type recognition model can be done by extracting the same features from new contours and inputting them into the trained model, outputting the error type for each region. Furthermore, the edge contour model can be imported into the discretized error type recognition model after training for identification. This can be achieved by extracting features segment by segment and classifying them, and by performing sliding window prediction on the entire contour. This allows for the automatic identification of error patterns for unknown edges.
[0105] Based on the discretization error type identification results, the edge discrete features of each discretization error type are determined. The edge discrete features include pixel deviation features, fitting residual features, and curvature features for each discretization error type, thus obtaining discrete error data.
[0106] Among these features, pixel deviation features can be the average or maximum deviation of edge pixels from the ideal continuous boundary under a specific error type, which can be used to quantify the direct impact of the error on area measurement. Fitting residual features can be the fitting error statistics for a specific error type region under standard polynomial fitting, which can be used to reflect the degree of interference of the error on traditional fitting methods. Curvature features can be the local curvature estimate or range of variation for the region corresponding to a specific error type, which can be used to correlate error type with edge geometric complexity. Determining the edge discrete features for each discretized error type based on the discretized error type identification results can be achieved by calculating the corresponding pixel deviation, fitting residual, curvature, and other attributes for each identified error region. Furthermore, determining the edge discrete features for each discretized error type based on the discretized error type identification results can be achieved by aggregating statistical features of similar error regions and calculating the feature mean weighted by error confidence, thereby generating structured discrete error data to support subsequent adaptive correction.
[0107] Taking precision parts dimensional inspection as an example, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can address the challenge of distinguishing between the jagged error of a 45-degree bevel and the step effect at rounded corners in metal part edge images using traditional methods. This embodiment utilizes historically labeled contours to train a discretized error type recognition model, automatically identifying the bevel region as jagged fluctuations and the rounded corner region as step-like features. It then extracts their pixel deviation and curvature features respectively, generating targeted discrete error data. This allows subsequent polynomial fitting to apply high-frequency compensation to the bevel and low-order smoothing to the rounded corners, ultimately obtaining a high-precision area measurement result that meets tolerance requirements through Green's formula. For another example, in the scenario of pathological section cell nucleus analysis, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can address the issue in low-magnification microscopic images where cell nucleus edges exhibit mixed errors due to resolution limitations: straight segments appear step-like, curved segments appear jagged, and pixel shifts exist at the nucleolus junction. This scheme automatically segments three types of regions using a discretized error type identification model, extracts the corresponding fitting residual features and normal vector direction features, and forms multidimensional discrete error data. This data guides the area measurement model to adopt differentiated fitting strategies for different regions, significantly improving the consistency of cell nuclear area measurement and supporting more reliable pathological grading.
[0108] In one embodiment, the impact of different edge shapes on the measurement of connected region area based on pixel counting method is analyzed according to discrete error data to obtain discretized impact data, specifically:
[0109] Based on the discrete error data, different types of discretization errors are classified according to pixel deviation features, fitting residual features, and curvature features, forming a discretization error type library;
[0110] Among them, pixel deviation features can describe the spatial offset characteristics of edge pixels relative to the ideal continuous boundary, and can be used to quantify the manifestation of discretization error in the positional dimension, supporting error classification. Fitting residual features can describe the residual distribution characteristics between the actual pixel points and the fitted curve after polynomial fitting of the discrete edge, reflecting the degree of adaptation of the current fitting model to a specific error type and assisting in error type identification. Curvature features can describe the performance characteristics of the local curvature of the edge under discrete sampling, including the curvature estimate and its volatility, and can be used to distinguish curvature distortion patterns caused by sampling under different geometric shapes. The discretization error type library can be a set of error patterns formed by the structured classification of discretization errors based on multi-dimensional features, and can be used to provide standardized error templates for test group generation and error identification. In a specific embodiment, the discretization error type library can be constructed by clustering or rule-based partitioning of discrete error data according to pixel deviation features, fitting residual features, and curvature features.
[0111] Based on discrete error data, different types of discretized errors are classified according to pixel deviation features, fitting residual features, and curvature features. This can be achieved by extracting these three features for each error type and classifying them through clustering or rule matching. Furthermore, this operation is implemented by using K-means clustering of the three feature vectors and classifying error categories based on decision tree rules, thereby achieving a multi-dimensional quantitative representation of discrete errors and improving classification precision. A discretized error type library is formed, which can be achieved by structurally storing the classification results as a queryable set of error templates. Further, this operation can be achieved by constructing a JSON-formatted error template library and establishing an SQL relational table to store error features and labels, thereby creating a standardized error pattern library to support subsequent test group generation.
[0112] Based on the discretization error type library, different error types are randomly combined to generate a discretization error type test group containing one or more combinations of discretization error types;
[0113] The discretized error type test group can be a test configuration formed by randomly combining one or more error types selected from the discretized error type library. It can be used to simulate single or compound discretized interference scenarios that may occur in real images. In an exemplary embodiment, the discretized error type test group can be constructed by extracting and integrating multiple error patterns from the error type library using a combination algorithm. Randomly combining different error types according to the discretized error type library can involve randomly selecting one or more error types from the library for combination. Furthermore, this operation can be achieved by generating combinations using Monte Carlo sampling and enumerating subsets according to a preset combination strategy, thereby covering both single and compound error scenarios and enhancing test diversity. Generating a discretized error type test group containing combinations of one or more discretized error types can be achieved by encapsulating the combination results into independent test configuration units. Further, this operation can be achieved by generating a test group configuration file and constructing a test group object instance, thereby forming a reproducible error test unit.
[0114] Based on the graphical simulation software, virtual edge test signals are generated for each discretization error type test group under different edge morphology conditions, and standard geometric graphic signals are generated. The virtual edge test signals are applied to the standard geometric graphic signals to simulate discretization interference and generate discretization edge pixel test data.
[0115] The graphical simulation software can be a computer simulation tool used to generate controllable geometric figures and apply digital interference. It can be used to support the synthesis of test images with specified discrete errors under known ideal conditions. Different edge morphology conditions can be standard geometric boundary types and their parameter configurations set during the testing process. They can be used as variable dimensions for error impact analysis to control geometric morphology factors in the experiment. The virtual edge test signal can be an ideal continuous boundary signal generated in the simulation environment for a specific discretization error type test group and edge morphology conditions. It can be used as a reference signal for applying discretization interference to ensure that the source of error is controllable. The standard geometric figure signal can be an ideal geometric shape representation with accurate analytical area and known continuous boundaries. It can be used to provide a true area reference for subsequent accuracy calculations. The simulated discretization interference can be an error pattern represented by the virtual edge test signal superimposed on the standard geometric figure signal to simulate the image digitization process. It can be used to generate test data that approximates the edges of the real image but with controllable errors. The discretized edge pixel test data can be a set of edge pixel coordinates containing specified error types generated after simulated discretization interference. It can be used as input to a connected domain area measurement system to evaluate the impact of errors.
[0116] Generating virtual edge test signals for each discretized error type test group under different edge morphology conditions using graphical simulation software can generate corresponding ideal continuous boundaries for each test group-morphology combination in the simulation environment. Furthermore, this operation can be achieved by calling an SVG engine to generate parametric curves and using OpenCV to draw ideal contours, thus providing a reference signal for error injection. Generating standard geometric shape signals can involve creating geometric shapes with analytical areas, such as circles and squares. Further, this operation can be achieved by using mathematical formulas to generate boundary points and calling a geometry library to create standard shapes, thus providing true area values for accuracy calculation. Applying virtual edge test signals to the standard geometric shape signals to simulate discretized interference can be achieved by pixelating or perturbing the ideal boundaries according to the error mode specified by the virtual test signals. Further, this operation can be achieved by performing nearest-neighbor sampling on the ideal boundaries on the pixel grid and introducing direction quantization and step-wise rules, thus generating discrete edges with controllable errors. Generating discretized edge pixel test data can be achieved by outputting a sequence of perturbed edge pixel coordinates. Furthermore, this operation can be achieved by saving it as a PNG binary image and exporting it as a coordinate list file, thereby forming a test dataset that can be used as input for an area measurement system.
[0117] Discretized edge pixel test data is imported into the connected region area measurement system for area calculation. The accuracy of connected region area measurement is determined when the target connected region is affected by one type of discretization error under different edge shapes or by multiple types of discretization errors under different edge shapes. Measurement accuracy data is obtained.
[0118] The connected component area measurement system can be software or algorithm modules that perform area calculations. It can be a traditional pixel counting method or other benchmark methods, and can be used to run on controlled test data to obtain measurement results for accuracy evaluation. The target connected component can be a specific connected region in the test data whose area is being measured. It can be used as the object of area measurement, and its true area is determined by standard geometric signals. One type of discretization error can be an instance of a single error pattern in a discretization error type library, and can be used to construct test scenarios under the influence of a single error. Further, one type of discretization error can include only zigzag error, only staircase error, only vertex offset error, etc. Multiple types of discretization errors can be a superposition of two or more discretization error types, and can be used to simulate the situation where complex edges are simultaneously affected by multiple distortion mechanisms during the digitization process. For example, multiple types of discretization errors can include superposition of similar errors, coupling of dissimilar errors, spatial local aliasing, etc. Measurement accuracy data can be a quantified value of the relative closeness between the area measurement result and the true area under given error type and edge morphology conditions, and can be used to reflect the intensity of the influence of a specific error-morphology combination on measurement performance.
[0119] Importing discretized edge pixel test data into a connected component area measurement system for area calculation can be achieved by using existing area measurement methods (such as pixel counting) to process the test data. Furthermore, this operation can be implemented by calling the OpenCV `contourArea` function and using a custom fill counting algorithm, thus obtaining measurement results under specific error interference. Determining the accuracy of connected component area measurement under different edge morphologies caused by one type of discretization error or under the simultaneous influence of multiple types of discretization errors under different edge morphologies can be achieved by comparing the measurement results with the true area of a standard geometric figure and calculating the accuracy index. Further, this operation can be achieved by calculating the relative error percentage and statistically analyzing the mean and variance of errors from multiple experiments, thus quantifying the impact of error-morphology combinations on measurement performance. Obtaining measurement accuracy data can be achieved by summarizing the accuracy results under all test combinations. Further, this operation can be achieved by storing the results as a CSV table and constructing an in-memory dictionary of results, thus forming a systematic evaluation dataset.
[0120] By constructing a data table of discretized error types, edge morphology conditions, and the impact of measurement accuracy on measurement accuracy, discretized impact data of connected region area measurement is obtained.
[0121] The discretization error type-edge morphology condition-measurement accuracy impact data table can be a three-dimensional mapping structure that organizes measurement accuracy data according to error type and edge morphology condition. It can serve as a concrete carrier of discretization impact data, guiding subsequent selection of correction parameters. In a specific embodiment, this impact data table can include relational database tables, multidimensional tensor structures, lookup index tables, etc. The discretization impact data can be structured knowledge describing the combined effect of discretization error type and edge morphology on area measurement accuracy. It can be used to provide error-morphology-performance correlation priors for high-precision measurement models, supporting adaptive correction. Furthermore, the discretization impact data can be directly used to determine fitting correction parameters, serving as one of the key inputs for high-precision connected domain area measurement models. Constructing the discretization error type-edge morphology condition-measurement accuracy impact data table from measurement accuracy data can be done by organizing data according to triplet dimensions and establishing a queryable mapping. Further, this operation can be achieved by constructing a Pandas multi-level indexed DataFrame and establishing an SQLite three-dimensional relational table, thereby forming a structured error impact knowledge base. Obtaining the discretization impact data for connected domain area measurement can be achieved by using the impact data table as the final output. Furthermore, this operation can be achieved by serializing and saving it as a model configuration file and embedding it into the lookup table of the calibration module, thereby providing a calibration basis for subsequent high-precision measurement models.
[0122] Taking precision parts dimensional inspection as an example, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can address the issue of jagged edges and acute angle vertex offsets in micron-level gear image analysis. This embodiment identifies this composite error pattern through a discretized error type library and uses an influence data table to find the typical accuracy reduction pattern at the intersection of arcs and polygons. This allows for the incorporation of targeted fitting correction parameters into the area measurement model, effectively restoring the true tooth area and avoiding misjudgments of qualified products due to underestimation by traditional methods. For another example, in the scenario of quantitative analysis of cell nuclei in pathological sections, the high-precision measurement method for connected region area based on polynomial fitting in this embodiment can address the issue of mixed errors (step and curvature distortion) at cell nucleus edges in low-magnification microscopic images due to resolution limitations. This solution simulates this composite interference through a discretized error type test group, generating test data under the corresponding elliptical shape. The constructed influence data table reveals that this type of error leads to an average area underestimation of 12%. Based on this, a compensation factor is introduced into the high-precision measurement model, significantly improving the reliability of cell proliferation index calculation.
[0123] In one embodiment, a high-precision measurement model for the area of connected regions is constructed. Fitting correction parameters for different edge morphologies are determined based on discretized influence data. The discrete error data and the fitting correction parameters for different edge morphologies are then imported into the area measurement model for learning and training. Specifically:
[0124] Obtain data on the impact of area measurement accuracy on image morphology analysis, and determine the measurement accuracy threshold based on the morphology analysis impact data;
[0125] The data on the impact of area measurement accuracy on image morphology analysis can be correlational data describing how the area measurement error of connected components affects the performance of downstream morphology analysis tasks. This data can be used to provide a basis for setting measurement accuracy thresholds and to identify error ranges sensitive to the analysis results. In an exemplary embodiment, the data on the impact of area measurement accuracy on image morphology analysis can include, but is not limited to, data on the impact of cell classification accuracy, defect identification misjudgment rate, and shape matching deviation. The morphology analysis impact data can be a set of key indicators extracted from the data on the impact of area measurement accuracy on image morphology analysis to guide threshold setting. This data can be used to support the determination of measurement accuracy thresholds and focus on error ranges that have a significant impact on practical applications. The measurement accuracy threshold can be a critical value for area measurement accuracy that substantially interferes with morphology analysis in the discretized impact data. It can be used as a filtering condition to distinguish between acceptable errors and errors requiring correction. Furthermore, the measurement accuracy threshold can include, but is not limited to, medical diagnostic tolerance thresholds, industrial testing tolerance thresholds, and scientific metrological benchmark thresholds.
[0126] Obtaining data on the impact of area measurement accuracy on image morphology analysis can be achieved by running morphology analysis tasks at different area error levels and recording performance changes. Further, this can be done by injecting controllable area bias into the labeled dataset and evaluating classification accuracy, then generating error-performance curves through Monte Carlo simulations. This establishes a quantitative correlation between area accuracy and downstream task reliability. Determining the measurement accuracy threshold based on the morphology analysis impact data can be achieved by analyzing the inflection point where task performance significantly declines and setting the corresponding accuracy value as the threshold. Further, determining the measurement accuracy threshold based on the morphology analysis impact data can be achieved by using ROC curves to determine the optimal operating point and setting a hard threshold based on task tolerance requirements, thus clearly defining the boundaries of the error range that needs to be corrected.
[0127] Based on the measurement accuracy threshold, the discretization impact data is analyzed. Discretization error types below the measurement accuracy threshold, corresponding edge morphology conditions, and corresponding measurement accuracy are extracted to form a new discretization error type-edge morphology condition-measurement accuracy impact data table, thus obtaining the substantial discretization impact data on the morphological analysis impact of connected region area measurement.
[0128] Among them, edge morphology conditions can be specific constraints or contextual environments representing particular edge geometry in an image, which can be used to refine error occurrence scenarios under different edge morphologies and improve the targeting of correction parameters. In a specific embodiment, edge morphology conditions may include, but are not limited to, isolated line segment conditions, dense arc cluster conditions, and acute-angle adjacent polygon conditions. Measurement accuracy can be the relative or absolute closeness between the measured area of a connected region and the actual area, and can be used as a quantitative indicator to assess the harmfulness of discretization errors. For example, measurement accuracy may include, but is not limited to, relative error rate, absolute deviation value, and confidence interval coverage. The impact data table of discretization error type - edge morphology conditions - measurement accuracy can be a structured data table storing triple relationships, recording the measurement accuracy caused by a specific error type under specific edge conditions, and can be used to transform the original discretization impact data into accurate input features that can be used for modeling. Furthermore, the impact data table of discretization error type - edge morphology conditions - measurement accuracy can serve as the basis for generating substantial discretization impact data and provide the original correlation basis for the impact degree data. Substantial discretization impact data can be a subset of discretization errors that have a non-negligible impact on morphological analysis, retained after being filtered by a measurement accuracy threshold. This subset can be used to focus on error scenarios that truly require correction and to avoid redundant or irrelevant samples in model learning. In an exemplary embodiment, substantial discretization impact data may include, but is not limited to, high-severity jagged error data, critical arc truncation error data, and acute angle offset data of decision boundaries.
[0129] Analyzing discretization impact data based on a measurement accuracy threshold can involve filtering records in the original discretization impact data whose measurement accuracy is below the threshold. Furthermore, this analysis can be achieved through database query filtering and in-memory conditional traversal filtering, focusing on error samples that pose a substantial threat to morphological analysis. Extracting the discretization error types below the measurement accuracy threshold, along with their corresponding edge morphological conditions and measurement accuracies, can be done by extracting triplet information from the filtering results: error type, edge morphological condition, and measurement accuracy. Further, this extraction can be achieved by constructing a structured dictionary and generating a CSV format intermediate file, thus forming structured input elements to support subsequent modeling.
[0130] Creating a new discretization error type-edge morphological condition-measurement accuracy impact data table can be achieved by organizing the extracted triples into a tabular format for easy querying and training. Furthermore, this new discretization error type-edge morphological condition-measurement accuracy impact data table can be implemented using relational database tables or Pandas DataFrame in-memory tables, thus achieving a standardized expression of error impact. Obtaining substantial discretization impact data on the morphological analysis effect of connected region area measurement can be considered as the final form of substantial discretization impact data. Furthermore, obtaining substantial discretization impact data on the morphological analysis effect of connected region area measurement can be achieved by directly referencing the data table or encapsulating it into a data loader interface, thereby completing the transformation from raw data to effective training samples.
[0131] Based on the morphological analysis impact data and the substantive discretization impact data, the degree of influence of different discretization error types on the morphological analysis of connected components under different edge morphology conditions is determined, and the degree of influence data is obtained.
[0132] The impact data can quantify the hazard weights posed by different discretization error types to connected component morphology analysis tasks under various edge morphology conditions. This can guide the priority allocation of fitting correction parameters, tilting resources towards errors with higher impact. Determining the impact of different discretization error types on connected component morphology analysis under various edge morphology conditions based on morphology analysis impact data and substantive discretization impact data can be achieved by combining task sensitivity and error occurrence frequency to calculate a comprehensive impact weight. Furthermore, determining the impact of different discretization error types on connected component morphology analysis under various edge morphology conditions based on morphology analysis impact data and substantive discretization impact data can be achieved by using a weighted average method to fuse multi-source indicators and the analytic hierarchy process (AHP) to determine the weights, thereby generating impact data to guide the allocation of correction resources.
[0133] Obtain the functional data of each polynomial fitting module in the connected domain area measurement system for discretization error correction. Based on the influence data and functional data, determine the fitting correction parameters for different discretization error types under different edge morphology conditions. The fitting correction parameters include polynomial order parameters and node smoothing parameters.
[0134] The connected domain area measurement system can be a hardware and software integrated framework that executes the entire process from edge extraction to area output, providing a runtime environment and interface support for the polynomial fitting module. For example, the connected domain area measurement system can include, but is not limited to, embedded real-time measurement systems, cloud-based batch processing systems, and interactive analysis workstations. The polynomial fitting module can be a functional unit within the connected domain area measurement system responsible for performing local or global polynomial curve fitting. It can be used to achieve continuous approximation of discrete edges and is the core execution component for error correction. The discretization error correction functional data can be performance indicators describing the correction capability and applicable range of each polynomial fitting module for different types of discretization errors. It can be used to reflect the effectiveness of different fitting components under specific error scenarios and for parameter matching. The polynomial order parameter can be an integer order configuration that controls the complexity of the polynomial fitting function. It can be used to adjust the fitting curve's ability to follow local details and avoid overfitting or underfitting. The node smoothing parameter can be an adjustment coefficient that controls the curvature continuity or transition smoothness at nodes during the fitting process. It can be used to improve the geometric continuity of the fitting curve at connection points and reduce artificial oscillations.
[0135] Obtaining functional data on discretization error correction for each polynomial fitting module in a connected domain area measurement system can be achieved by testing the correction effect of each module on standard error samples and recording its performance. Furthermore, this functional data can be collected through offline benchmark testing and compared with module performance through online A / B testing, thus establishing a module capability profile and supporting parameter matching. Determining fitting correction parameters for different discretization error types under different edge morphology conditions based on impact data and functional data can involve matching high-impact errors with high-capability modules and assigning them optimal polynomial order parameters and node smoothing parameters. Further, determining fitting correction parameters for different discretization error types under different edge morphology conditions based on impact data and functional data can be achieved by matching parameter combinations using a rule engine and searching for optimal parameter configurations using optimization algorithms, thus enabling dynamic, task-oriented configuration of correction parameters.
[0136] A convolutional neural network is constructed, and the fitting correction parameters of different discretization error types under different edge morphology conditions are imported into the convolutional neural network for training. The trained convolutional neural network is then combined with the discretization error type identification model and connected to the area measurement system to obtain a high-precision measurement model for the area of connected regions.
[0137] The convolutional neural network (CNN) can be a deep learning model that automatically extracts spatial features through convolutional layers and maps them to output parameters. It can be used for end-to-end learning of the nonlinear mapping relationship between discretization error types, edge morphology conditions, and optimal fitting correction parameters. In a specific embodiment, the CNN may include, but is not limited to, lightweight MobileNet variants, U-Net encoder structures, and ResNet residual block combinations. The discretization error type identification model can be a classification or regression model used to automatically determine the discretization error type of an input edge contour. It can be used to provide error type labels or feature inputs to the CNN and drive adaptive correction. For example, the discretization error type identification model may include, but is not limited to, SVM classifiers based on handcrafted features, contour analysis models based on graph neural networks, and end-to-end CNN recognizers. Constructing a CNN can involve designing a network architecture containing convolutional layers, activation functions, and fully connected layers. Furthermore, CNNs can be constructed by fine-tuning based on pre-trained backbone networks or designing lightweight networks from scratch, thereby providing the ability to learn fitting correction parameters end-to-end.
[0138] The fitting correction parameters for different discretization error types under various edge morphology conditions are imported into a convolutional neural network (CNN) for training. This can be achieved through supervised training, using the error type and edge morphology conditions as inputs and the fitting correction parameters as outputs. Further, this can be accomplished through multi-task learning to simultaneously predict the order and smoothing parameters, and phased training (classification followed by regression), allowing the network to automatically generate correction parameters suitable for the current edge. The trained CNN is then combined with a discretization error type recognition model, where the recognition model's output is used as one of the CNN's inputs, forming a cascaded structure. Alternatively, this combination can be achieved by fusing the models into a single inference graph and linking the two models via API calls, thus realizing an end-to-end inference chain from the original edge to the correction parameters. Finally, the combined model is connected to an area measurement system to obtain a high-precision measurement model for the connected region area. This can be achieved by integrating the joint model into the area measurement system's correction module and replacing the original parameter setting logic. Furthermore, by connecting the combined model with the area measurement system to obtain a high-precision measurement model of the connected domain area, deep integration can be achieved by embedding it into the existing system as a plug-in and reconstructing the core modules of the system, thereby forming a complete high-precision measurement system with adaptive correction capabilities.
[0139] Taking the quantitative analysis of cell nuclear area in pathological sections as an example, this embodiment uses a high-precision measurement method for connected region area based on polynomial fitting. In breast cancer pathological images, cell nuclear area is a key indicator for grading. Traditional methods suffer from grading errors due to irregular arcs at the nuclear edges and limited resolution, resulting in pixel count deviations. This solution analyzes the impact of area error on grading accuracy, sets a 95% accuracy threshold, filters out low-accuracy samples in areas with densely packed sharp angles and slender arc segments, and constructs a data table of substantial impact. Combining the functional data of the polynomial fitting module in arc fidelity, a convolutional neural network is trained to automatically assign cubic polynomials and C1 smoothing parameters to different nuclear contours, ultimately outputting high-fidelity edge curves. After integration using Green's formula, the grading consistency is significantly improved.
[0140] In one embodiment, the step of acquiring real-time edge pixel coordinate data of the target image, importing the real-time edge pixel coordinate data into the area measurement model to identify and correct discretization errors in the real-time edges, and obtaining polynomial-fitted edge curve data, specifically involves:
[0141] The real-time edge pixel coordinate data of the target image is obtained, and the real-time edge pixel coordinate data is imported into the area measurement model to identify the discretization error type and error degree in the real-time edge, and obtain the discretization error identification result.
[0142] The discretization error type in real-time edge processing can be a specific discrete distortion pattern presented in the currently processed edge pixel coordinates, which can be used as part of the recognition result to guide the selection of correction strategies. In an exemplary embodiment, the discretization error type in real-time edge processing can include, but is not limited to, step-like discretization error, sawtooth-shaped directional oscillation error, vertex truncation error, etc. The error severity can be the severity of the discretization error in the local edge region or the quantization level of deviation from the true continuous boundary, which can be used together with the error type to determine the strength and form of the fitting correction parameters. The discretization error recognition result can be a joint judgment output of the discretization error type and its error severity in real-time edge processing, which can be used as a direct basis for generating real-time fitting correction parameters. For example, the discretization error recognition result can be generated by the area measurement model and used by its internal parameter determination module. Importing real-time edge pixel coordinate data into the area measurement model to identify the discretization error type and error severity in real-time edge processing can be done by performing local geometric analysis on the input edge within the area measurement model, simultaneously judging the error category and severity. Furthermore, this operation can identify sawtooth patterns and evaluate amplitude by calculating local orientation histograms through a sliding window, and detect acute angles and quantify truncation by utilizing changes in the sign of the curvature derivative. This can generate structured discretized error identification results, supporting the dynamic generation of subsequent parameters.
[0143] Based on the discretization error identification results, the real-time fitting correction parameters are determined. The area measurement model performs piecewise polynomial fitting correction processing on the real-time edge pixel coordinate data in real time according to the real-time fitting correction parameters to obtain polynomial fitting edge curve data.
[0144] The real-time fitting correction parameters can be dynamically generated polynomial fitting control parameters based on the local features of the current edge, which can be used to drive the piecewise polynomial fitting process to achieve targeted correction. In a specific embodiment, the real-time fitting correction parameters can be calculated in real time or obtained by looking up a table based on the discretization error identification results, and may include segmentation intervals, order, smoothing coefficients, etc. Further, the real-time fitting correction parameters may include, but are not limited to, local fitting order, segment boundary positions, weight decay coefficients, etc. For example, the real-time fitting correction parameters can be generated by the area measurement model based on the discretization error identification results and used to guide the piecewise polynomial fitting correction process. The piecewise polynomial fitting correction process can be a process of dividing the edge into several sub-segments, applying an appropriate polynomial to each segment independently for fitting and correcting discrete errors, which can be used to improve the fitting's adaptability to complex contours and avoid local distortion caused by global fitting. In this embodiment, the piecewise polynomial fitting correction process can adopt segmentation based on curvature extrema points, segmentation based on direction consistency, segmentation based on error mutation detection, etc.
[0145] Determining real-time fitting correction parameters based on discretization error identification results can involve mapping error type and severity to specific fitting configuration parameters. Further, this operation can be achieved by querying a pre-built error-parameter mapping table and optimizing the local polynomial order online to minimize the fitting residual, thus achieving precise matching between the fitting strategy and the current local edge characteristics. The area measurement model performs piecewise polynomial fitting correction on the real-time edge pixel coordinate data based on the real-time fitting correction parameters. This can be done by performing polynomial regression on each edge sub-segment and concatenating the segments according to the segmentation rules and fitting order indicated by the parameters. For example, this operation can be achieved by setting segmentation points and using low-order fitting in areas of drastic curvature change, using high-order global fitting in flat areas, and dynamically adjusting the fitting weights of each segment based on the error severity, thereby generating a geometrically continuous corrected curve that approximates the true boundary.
[0146] Taking low-resolution industrial part size inspection as an example, the high-precision measurement method of image connected region area based on polynomial fitting in this embodiment can be used in metal gasket images captured by a 2-megapixel camera, where the edges exhibit a significant step effect due to resolution limitations. This embodiment identifies the step-like discrete errors and their moderate error levels on straight line segments through an area measurement model, dynamically generates low-order linear fitting parameters, subdivides segments in the transition area, and reconstructs a smooth outer contour after piecewise polynomial correction. The area error obtained by the final integration is significantly lower than that of the traditional pixel counting method, meeting the micrometer-level tolerance detection requirements. For another example, in the scenario of cell nucleus segmentation in pathological sections, the high-precision measurement method of image connected region area based on polynomial fitting in this embodiment can be used in unevenly stained tissue sections where some cell nuclei have blurred and jagged edges. The system identifies this area in real time as having high-fluctuation jagged error and assesses its high error level, automatically enabling piecewise polynomial fitting with strong smoothing constraints. This preserves the true concave structure while suppressing false protrusions caused by noise, outputting a continuous boundary that more closely resembles biological morphology for area statistics.
[0147] In one embodiment, area integration is performed using Green's formula based on polynomial-fitted edge curve data to obtain area measurement results. Morphological analysis is then performed on the target image based on these area measurement results, specifically:
[0148] Parametric equations are constructed from polynomial-fitted edge curve data to generate continuous closed edge curve equation data, including horizontal axis parametric equations and vertical axis parametric equations.
[0149] The parameterized equations can be mathematical functions expressing the abscissa and ordinate of the curve with parameters as independent variables. They can be used to transform polynomial-fitted edge curves into continuous analytical expressions suitable for integration operations. In one embodiment, the parameterized equations may include, but are not limited to, arc-length parameterized equations, angle parameterized equations, and normalized-time parameterized equations. The abscissa parameterized equations can be functions describing the abscissa of points on the edge curve as a function of parameters, and can be used together with the ordinate parameterized equations to define the curve's geometric shape. The ordinate parameterized equations can be functions describing the ordinate of points on the edge curve as a function of parameters, and can be used in conjunction with the abscissa parameterized equations to fully characterize continuous edges. Further, the ordinate parameterized equations may include polynomial ordinate equations, trigonometric ordinate equations, piecewise smooth ordinate equations, etc. The continuous closed edge curve equation data can be a closed boundary analytical expression composed of the abscissa and ordinate parameterized equations, and can be used to provide a differentiable, continuous, and closed integration path for Green's theorem. In a specific embodiment, the continuous closed edge curve equation data may include a system of periodic parameterized equations, piecewise parameterized equations with forced connection of start and end points, implicit closure constraint equations, etc. Furthermore, the continuity of the equations of continuously closed edge curves serves as the direct input for line integral operations, ensuring the mathematical validity of Green's formula.
[0150] Constructing parameterized equations for polynomial-fitted edge curve data can involve converting discrete or piecewise polynomial expressions into x(t) and y(t) functions under a unified parameter t. Furthermore, this operation can be achieved by using arc-length reparameterization to ensure uniform parameter distribution and by using the original fitted nodes as the parameter basis to construct piecewise parametric equations, thus obtaining a continuous mathematical expression suitable for analytical integration. Generating continuous, closed edge curve equation data can be achieved by introducing periodic constraints during the fitting stage and performing smoothing closure interpolation at the ends of open curves, thereby forming mathematically strictly closed boundaries that satisfy the prerequisites for applying Green's theorem.
[0151] Based on Green's formula, line integral operations are performed on the equation data of continuous closed edge curves to calculate the area of the closed region of the target connected domain. Combined with pixel equivalent data, the actual physical area is determined, and the area measurement result is obtained.
[0152] Line integrals can be mathematical operations that integrate a vector field or scalar field along a given curve path. They can be used to transform area calculations into boundary integration processes within the framework of Green's theorem. The area of the closed region of the target connected domain can be a dimensionless planar region measure enclosed by continuous closed edge curves. This can be used as an intermediate calculation result to support subsequent physical unit conversions. Pixel equivalent data can be a scaling factor representing the size of a single pixel in the image in actual physical space. This can be used to convert dimensionless pixel areas into meaningful physical areas. In this embodiment, pixel equivalent data can be obtained through calibration experiments or device metadata, typically in the form of micrometers per pixel or millimeters per pixel. The actual physical area can be an area value with real-world units obtained after pixel equivalent conversion, which can be used to support quantitative judgment and decision-making in engineering or clinical scenarios.
[0153] Calculating the area of a closed region within a target connected domain can be achieved by performing a line integral and outputting a dimensionless area value. Furthermore, this operation can be implemented by directly outputting an analytical solution, outputting a numerical integral approximation with an error estimate, thereby obtaining the precise area in theoretical continuous space. Determining the actual physical area by combining pixel equivalent data can be achieved by multiplying the dimensionless area by the square of the pixel equivalent. Further, this operation can be implemented by scaling the anisotropic pixel equivalent in the x and y directions separately before integration, or by transforming the coordinates before integration, thus giving the area result a practical physical meaning.
[0154] The area measurement results are compared with the preset area threshold to generate a target morphological feature evaluation report, and an image post-processing strategy is formulated based on the morphological feature evaluation report.
[0155] The preset area threshold can be an area reference value set according to application requirements to determine whether the target shape is qualified or abnormal, and can be used as a criterion for shape evaluation. In an exemplary embodiment, the preset area threshold may include process tolerance thresholds, medical diagnostic standard thresholds, statistical distribution quantile thresholds, etc. The target shape feature evaluation report can be a structured shape judgment output generated based on the comparison of area measurement results and thresholds, and can be used to provide semantic decision-making basis for subsequent processing. For example, the target shape feature evaluation report may include a binary qualification judgment report, a multi-level risk rating report, a deviation quantification analysis report, etc. The image post-processing strategy can be a subsequent image operation or system response scheme triggered according to the shape evaluation results, and can be used to realize closed-loop control from measurement to action. Further, the image post-processing strategy may include image segmentation optimization strategy, target removal strategy, alarm triggering strategy, etc. Comparing the area measurement results with the preset area threshold can be to perform numerical size judgment or interval assignment judgment. Further, this operation can be achieved through single-threshold binary classification comparison, multi-threshold interval mapping, and fuzzy membership degree comparison, thereby generating a logical conclusion on whether the shape meets expectations. Generating a target morphological feature evaluation report can be achieved by formatting the comparison results into structured text or data records. Furthermore, this operation can be implemented by generating JSON-formatted evaluation loads and outputting annotated visual marker maps, thus providing readable and traceable evaluation output. Developing image post-processing strategies based on the morphological feature evaluation report can involve selecting corresponding downstream processing flows according to the report content. Furthermore, this operation can be achieved by automatically triggering a defect removal pipeline, adjusting subsequent image enhancement parameters, and reporting anomalies to the monitoring system, thereby enabling measurement-driven intelligent response.
[0156] Taking the quality inspection of precision parts dimensions as an example, the high-precision measurement method of image connected region area based on polynomial fitting in this embodiment can measure the area of tiny holes in a microscopic image. The system transforms the corrected polynomial edges into parametric equations, obtains the dimensionless area through Green's formula integration, and converts it into the actual physical area using the known 0.5 micrometers per pixel equivalent. If the result is less than the minimum allowable value of 80 square micrometers in the design specifications, a non-conforming assessment report is generated and the part is automatically marked as scrap, triggering the rejection mechanism. For another example, in the scenario of cell nuclear analysis in pathological sections, the high-precision measurement method of image connected region area based on polynomial fitting in this embodiment can perform high-precision area measurement of the connected regions of cell nuclei in tumor tissue sections. After parametric modeling and Green's integration, the physical area is obtained and compared with the atypical nuclear area threshold specified in medical guidelines. If it exceeds 120 square micrometers, it is judged as highly atypical. The system automatically generates a risk rating report and recommends further immunohistochemical testing, while simultaneously marking the area in the digital slide for pathologist review.
[0157] Furthermore, to achieve the above objectives, the present invention also provides a high-precision measurement device for the area of connected components of an image based on polynomial fitting. The device includes: a memory, a processor, and a high-precision measurement program for the area of connected components of an image based on polynomial fitting, which is stored in the memory and can run on the processor. The high-precision measurement program for the area of connected components of an image based on polynomial fitting is configured to implement the steps of the high-precision measurement method for the area of connected components of an image based on polynomial fitting as described above.
[0158] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a high-precision measurement program for the area of connected components of an image based on polynomial fitting. When executed by a processor, the high-precision measurement program for the area of connected components of an image based on polynomial fitting implements the steps of the high-precision measurement method for the area of connected components of an image based on polynomial fitting as described above.
[0159] Other embodiments or specific implementations of the high-precision measurement device for the area of connected regions of an image based on polynomial fitting described in this invention can be referred to the above-described method embodiments, and will not be repeated here.
[0160] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A high-precision method for measuring the area of connected components in an image based on polynomial fitting, characterized in that, The method includes: The edge pixel data of the target image is acquired using an image acquisition device, and an image edge contour model is constructed based on the edge pixel data. Based on the edge traversal algorithm, the edge contour model is analyzed, the discretization error types affecting the measurement of the connected region area are identified, and the edge discrete features are extracted to obtain discrete error data. Based on the discrete error data, the influence of different edge shapes on the area of connected regions measured by the pixel counting method is analyzed to obtain discretization influence data; A high-precision measurement model for the area of connected regions is constructed. Based on the discretized influence data, fitting correction parameters under different edge morphologies are determined. The discrete error data and the fitting correction parameters under different edge morphologies are then imported into the area measurement model for learning and training. The real-time edge pixel coordinate data of the target image is obtained, and the real-time edge pixel coordinate data is imported into the area measurement model to identify and correct the discretization error in the real-time edge, so as to obtain polynomial fitting edge curve data. Based on the polynomial fitted edge curve data, the area integral is calculated using Green's formula to obtain the area measurement result, and the target image is then subjected to morphological analysis based on the area measurement result.
2. The high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in claim 1, characterized in that, The step of acquiring edge pixel data of the target image based on the image acquisition device and constructing an image edge contour model based on the edge pixel data specifically involves: Centered on the target connected component, the acquired original image is subjected to edge detection and binarization processing, and the pixels in the image are filtered by a preset edge extraction algorithm. Based on the pixels after the filtering operation, the edge pixel data of the target image is obtained. The edge pixel data includes the horizontal and vertical coordinates of different pixels on the edge, the pixel arrangement order, and the pixel adjacency relationship. An ordered array construction algorithm is introduced. Based on the algorithm, edge pixel data is constructed into a pixel coordinate array. The pixel coordinate array is then processed to unify the orientation, resulting in an edge coordinate array with a unified orientation. Calculate the curvature change of the pixels in the edge coordinate array, perform extreme point detection on the curvature change to obtain extreme points and corresponding feature indices, and select key pixels that can cover the edge change features to form a new feature point set according to the curvature magnitude. The edge coordinate array is mapped to a two-dimensional rectangular coordinate system to generate the edge contour distribution map and edge gradient direction map of the target connected domain, thus obtaining the image edge contour model.
3. The high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in claim 1, characterized in that, The edge contour model analysis based on the edge traversal algorithm identifies the discretization error types affecting the measurement of the connected region area and extracts the discrete edge features to obtain discrete error data, specifically: Obtain the historical edge contour model of the target connected component, discretize the historical edge contour model and label the error types, and extract the geometric features of the discretized historical edge contour map by the difference operation method; Based on the local window analysis method, spatial domain features of historical edge contour distribution map are extracted. The spatial domain features include pixel distribution features and normal vector direction features under different edge curvatures. The geometric features and spatial domain features are transformed into multi-dimensional feature vectors. A discretized error type identification model is constructed based on the support vector machine algorithm, the difference operation method, and the local window analysis method. The multidimensional feature vector is imported into the discretized error type identification model for training. The edge contour model is imported into the trained discretized error type identification model for identification, and the discretized error type identification result is obtained. Based on the discretization error type identification results, edge discrete features for each discretization error type are determined. The edge discrete features include pixel deviation features, fitting residual features, and curvature features for each discretization error type, thereby obtaining discrete error data.
4. The high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in claim 3, characterized in that, The geometric features include sawtooth wave features, step-like features, and pixel offset features under different edge orientations.
5. The high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in claim 1, characterized in that, The step of analyzing the impact of different edge shapes on the area of connected components measured using the pixel counting method based on the discrete error data yields discretized impact data, specifically: Based on the discrete error data, different types of discretization errors are classified according to pixel deviation features, fitting residual features, and curvature features to form a discretization error type library; Based on the discretization error type library, different error types are randomly combined to generate a discretization error type test group containing one or more combinations of discretization error types; Based on the graphics simulation software, virtual edge test signals are generated for each discretization error type test group under different edge morphology conditions, and standard geometric graphic signals are generated. The virtual edge test signals are applied to the standard geometric graphic signals to simulate discretization interference and generate discretization edge pixel test data. The discretized edge pixel test data is imported into the connected region area measurement system for area calculation. The accuracy of the connected region area measurement is determined when the target connected region is affected by one type of discretization error under different edge shapes or by multiple types of discretization errors under different edge shapes. The measurement accuracy data is obtained. The measurement accuracy data is used to construct a discretized error type-edge morphology condition-measurement accuracy impact data table to obtain the discretized impact data of connected region area measurement.
6. The high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in claim 1, characterized in that, The construction of a high-precision measurement model for the area of connected regions involves determining fitting correction parameters for different edge morphologies based on the discretized influence data, and then importing the discrete error data and the fitting correction parameters for different edge morphologies into the area measurement model for learning and training. Specifically: Acquire data on the impact of area measurement accuracy on image morphology analysis, and determine a measurement accuracy threshold based on the morphology analysis impact data; Based on the measurement accuracy threshold, the discretization impact data is analyzed. Discretization error types below the measurement accuracy threshold, corresponding edge morphology conditions, and corresponding measurement accuracy are extracted to form a new discretization error type-edge morphology condition-measurement accuracy impact data table, thus obtaining the substantial discretization impact data that affects the morphological analysis of connected region area measurement. Based on the morphological analysis impact data and the substantive discretization impact data, the degree of influence of different discretization error types on the morphological analysis of connected components under different edge morphological conditions is determined, and the degree of influence data is obtained. Obtain the functional data of each polynomial fitting module in the connected domain area measurement system for discretization error correction, and determine the fitting correction parameters for different discretization error types under different edge morphology conditions based on the influence data and functional data. The fitting correction parameters include polynomial order parameters and node smoothing parameters. A convolutional neural network is constructed, and the fitting correction parameters of different discretization error types under different edge morphology conditions are imported into the convolutional neural network for training. The trained convolutional neural network is combined with the discretization error type identification model and connected to the area measurement system to obtain a high-precision measurement model of the connected region area.
7. The high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in claim 1, characterized in that, The process involves acquiring real-time edge pixel coordinate data of the target image, importing this data into the area measurement model to identify and correct discretization errors in the real-time edges, and obtaining polynomial-fitted edge curve data. Specifically: The real-time edge pixel coordinate data of the target image is obtained, and the real-time edge pixel coordinate data is imported into the area measurement model to identify the discretization error type and error degree in the real-time edge, and obtain the discretization error identification result. Based on the discretization error identification results, real-time fitting correction parameters are determined. The area measurement model performs piecewise polynomial fitting correction processing on the real-time edge pixel coordinate data in real time according to the real-time fitting correction parameters to obtain polynomial fitting edge curve data.
8. The high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in claim 1, characterized in that, The area measurement result is obtained by performing area integration using Green's formula based on the polynomial fitted edge curve data. The morphological analysis of the target image is then performed based on the area measurement result. Specifically: Parametric equations are constructed on the polynomial fitted edge curve data to generate continuous closed edge curve equation data, including horizontal axis parametric equations and vertical axis parametric equations. Based on Green's formula, line integral operations are performed on the equation data of continuous closed edge curves to calculate the area of the closed region of the target connected domain. Combined with pixel equivalent data, the actual physical area is determined, and the area measurement result is obtained. The area measurement results are compared with a preset area threshold to generate a target morphological feature evaluation report, and an image post-processing strategy is formulated based on the morphological feature evaluation report.
9. A high-precision measurement device for the area of connected components in an image based on polynomial fitting, characterized in that, The device includes: a memory, a processor, and a high-precision measurement program for the area of connected components in an image based on polynomial fitting, stored in the memory and executable on the processor, the high-precision measurement program for the area of connected components in an image based on polynomial fitting configured to implement the steps of the high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a high-precision measurement program for the area of connected components in an image based on polynomial fitting, which, when executed by a processor, implements the steps of the high-precision measurement method for the area of connected components in an image based on polynomial fitting as described in any one of claims 1 to 8.