Aperture measurement method and device based on distortion compensation and adaptive mean blur

CN115689929BActive Publication Date: 2026-08-18AEROSPACE DONGFANGHONG SATELLITE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211351455.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-31
Publication Date
2026-08-18
Estimated Expiration
2042-10-31

AI Technical Summary

Technical Problem

[0003]为解决边缘模糊不能准确提取孔的边缘轮廓的问题,本发明提出一种基于畸变补偿和自适应均值模糊的孔径测量方法及装置,可以通过对生产流水线上的不同批次小尺寸孔径进行实时检测,大大节约了生产时间和资源成本,而且提高了生产流程中孔径测量的精度

Benefits of technology

[0049]This invention employs a distortion compensation algorithm to restore distorted images. Based on the principle of minimum variance, the distortion center of the image is determined using a template. Then, the radial and tangential matrices and distortion coefficients of the lens are calculated. In actual measurements, the imaging points are corrected, improving the solution accuracy and achieving high-precision aperture measurement. Experiments show that the method of this invention can effectively measure aperture dimensions. The measured aperture size is between 2mm and 6mm, with a measurement accuracy within ±0.03mm and a relative error of 0.25%, meeting the requirements for size measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115689929B_ABST
    Figure CN115689929B_ABST
Patent Text Reader

Abstract

The application discloses an aperture measurement method and device based on distortion compensation and self-adaptive mean blur, and comprises the following steps: S1, performing binaryzation processing on collected images, correcting the distortion, then performing smoothing processing on the images and extracting a target region; S2, performing edge detection on an aperture target in the target region to detect pixels of an aperture edge; S3, detecting the aperture edge pixels to determine contour pixels of the aperture edge, then comparing the contour pixels with a threshold value to remove useless pixels and identify and acquire aperture contour features; and S4, based on the aperture contour features, using a least square method to fit a circle to calculate aperture size parameters. The application can realize non-contact and high-precision measurement of the aperture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image measurement technology, and in particular to an aperture measurement method and apparatus based on distortion compensation and adaptive mean blurring. Background Technology

[0002] In recent years, the rapid growth in demand for precision instruments from the optics and electronics industries has spurred the development of high-precision machining technology. The accuracy of shaft-hole fits in precision instruments directly affects their overall performance. In recent years, computer vision-based aperture measurement and research have been widely applied in precision instrument assembly. However, factors such as lighting and camera settings cause distortion in aperture images compared to real images. For aperture measurement, which is widely used in precision instrument engineering, the variable testing environment and the presence of scratches and defects in the experiment can negatively impact the measured aperture. Therefore, to obtain high-precision dimensional parameters, distortion correction is necessary for the original aperture image. Furthermore, accurate extraction of edge contours is required to obtain high-precision aperture measurement results. Summary of the Invention

[0003] To address the problem of inaccurate extraction of hole edge contours due to edge blurring, this invention proposes a hole diameter measurement method and device based on distortion compensation and adaptive mean fuzziness. This method can perform real-time detection of small-sized holes from different batches on a production line, significantly saving production time and resource costs, and improving the accuracy of hole diameter measurement in the production process.

[0004] The technical solution of this invention is as follows:

[0005] An aperture measurement method based on distortion compensation and adaptive mean fuzzing includes: S1, binarizing the acquired image, performing distortion correction, smoothing the image, and extracting the target region; S2, performing edge detection on the aperture target in the target region to detect aperture edge pixels; S3, comparing the aperture edge pixel values ​​with a judgment threshold based on the aperture edge pixel values, removing useless pixels, and identifying and obtaining aperture edge features; S4, calculating and displaying aperture size parameters based on the aperture edge features using a least squares method to fit a circle.

[0006] Furthermore, in S1, the distortion correction includes: using a square template, tracking all curves within a specified number of pixels from the center point of the image, recording the coordinates of all curves, then calculating the variance of each curve, finding the curve with the smallest variance in the horizontal and vertical directions, and using the intersection of these curves with the smallest variance as the grid intersection point; then, calibrating the image grid intersection point to obtain the lens's intrinsic parameters, extrinsic parameters, and distortion coefficient matrix, and performing pixel compensation on the image based on this information to obtain the restored image.

[0007] Furthermore, in S2, edge detection is performed on the aperture target in the target region to detect the aperture edge pixels, specifically including:

[0008] First, the center pixel value of the target region image is added together with the values ​​of its multiple neighboring pixels, and then the average value is calculated as the center pixel average. The target region image is divided into multiple windows, and a judgment threshold is set for each window. The method for determining the judgment threshold is as follows: calculate the histogram of each window, and use the histogram of each window to find the trough value between the two peaks in an image with two peaks as the judgment threshold for that window. Calculate the difference between each pixel in the target region and the center pixel average, and compare each difference with the judgment threshold for each window. If the difference is less than the judgment threshold, the pixel is retained for further processing; otherwise, the pixel is discarded.

[0009] The gradient is calculated using the first-order finite difference of a specified window to obtain two matrices of the partial derivatives of the target region image in the x and y directions in a Cartesian coordinate system with the image center as the origin, thus determining the gradient intensity and direction at the edge of the target region.

[0010] The gradient intensity of the obtained target region edge pixel is compared with the gradient intensity of two pixels along the positive and negative gradient directions; if the gradient intensity of the current target region edge pixel is the largest compared with the gradient intensity of other points in the same direction, the pixel is retained as the aperture edge pixel; otherwise, the pixel is removed.

[0011] The image is then further inspected, collecting the edges of the aperture until all edges of the entire target region are closed.

[0012] Furthermore, in S3, based on the aperture edge pixel values, a judgment threshold is used to compare the aperture edge pixel values, remove useless pixels, and identify and obtain aperture edge features. Specifically, this includes: traversing the aperture edge pixels, first deleting pixels that are more than a specified distance from the aperture edge pixels, then removing pixels in the smallest connected region in the image whose difference from the aperture edge pixels exceeds a specified value; finally, comparing the remaining pixels with the judgment threshold, retaining the pixel when the pixel value is greater than or equal to the judgment threshold, and deleting the pixel when the pixel value is less than the judgment threshold, thus obtaining the aperture edge features.

[0013] Furthermore, in S4, the aperture size parameters are calculated using the least squares method to fit a circle based on the aperture edge features. Specifically, this includes:

[0014] Let d be the aperture of the circle fitted by the pixel.

[0015]

[0016] Then, the aperture d of the fitted circle is converted into an aperture size expressed in millimeters; where,

[0017]

[0018]

[0019]

[0020] Among them, C, D, E, G, and H are intermediate parameters.

[0021]

[0022] D=N∑X c Y c -∑X c ∑Y c

[0023]

[0024]

[0025]

[0026] Among them, (X) c ,Y c ) is the set of pixels at the edge of the aperture, c∈(1,2,…,N).

[0027] An aperture measurement device based on distortion compensation and adaptive mean fuzzing includes: a target region extraction module, an aperture edge detection module, an aperture edge recognition module, and an aperture calculation module. The target region extraction module binarizes the acquired image, performs distortion correction, smooths the image, and extracts the target region. The aperture edge detection module detects the aperture target within the target region, identifying aperture edge pixels. The aperture edge recognition module compares the aperture edge pixel values ​​with a threshold value, removes useless pixels, and identifies aperture edge features. The aperture calculation module calculates and displays the aperture size parameters based on the aperture edge features using a least-squares method to fit a circle.

[0028] Furthermore, the specific method for distortion correction performed by the target region extraction module includes: using a square template, tracking all curves within a specified number of pixels from the image center point, recording the coordinates of all curves, then calculating the variance of each curve, and finding the curve with the smallest variance in the horizontal and vertical directions; using the intersection of these curves with the smallest variance as grid intersection points; then, calibrating the image grid intersection points to obtain the lens's intrinsic parameters, extrinsic parameters, and distortion coefficient matrix, and performing pixel compensation on the image based on this information to obtain the restored image.

[0029] Furthermore, the aperture edge detection module performs edge detection on the aperture target in the target region to detect aperture edge pixels, specifically including:

[0030] First, the center pixel value of the target region image is added together with the values ​​of its multiple neighboring pixels, and then the average value is calculated as the center pixel average. The target region image is divided into multiple windows, and a judgment threshold is set for each window. The method for determining the judgment threshold is as follows: calculate the histogram of each window, and use the histogram of each window to find the trough value between the two peaks in an image with two peaks as the judgment threshold for that window. Calculate the difference between each pixel in the target region and the center pixel average, and compare each difference with the judgment threshold for each window. If the difference is less than the judgment threshold, the pixel is retained for further processing; otherwise, the pixel is discarded.

[0031] The gradient is calculated using the first-order finite difference of a specified window to obtain two matrices of the partial derivatives of the target region image in the x and y directions in a Cartesian coordinate system with the image center as the origin, thus determining the gradient intensity and direction at the edge of the target region.

[0032] The gradient intensity of the obtained target region edge pixel is compared with the gradient intensity of two pixels along the positive and negative gradient directions; if the gradient intensity of the current target region edge pixel is the largest compared with the gradient intensity of other points in the same direction, the pixel is retained as the aperture edge pixel; otherwise, the pixel is removed.

[0033] The image is then further inspected, collecting the edges of the aperture until all edges of the entire target region are closed.

[0034] Furthermore, the aperture edge recognition module, based on the aperture edge pixel value, compares the aperture edge pixel value with a threshold value to remove useless pixels and identify and obtain aperture edge features. Specifically, this includes: traversing the aperture edge pixels, first deleting pixels that are more than a specified distance from the aperture edge pixel, then removing pixels in the image within the smallest connected component whose difference from the aperture edge pixel exceeds a specified value; finally, comparing the remaining pixels with the judgment threshold. If the pixel value is greater than or equal to the judgment threshold, the pixel is retained; if the pixel value is less than the judgment threshold, the pixel is deleted, thus obtaining the aperture edge features.

[0035] Furthermore, the aperture calculation module calculates and displays the aperture size parameters based on the aperture edge features using a least-squares method to fit a circle, specifically including:

[0036] Let d be the aperture of the circle fitted by the pixel.

[0037]

[0038] Then, the aperture d of the fitted circle is converted into an aperture size expressed in millimeters; where,

[0039]

[0040]

[0041]

[0042] Among them, C, D, E, G, and H are intermediate parameters.

[0043]

[0044] D=N∑X c Y c -∑X c ∑Y c

[0045]

[0046]

[0047]

[0048] Among them, (X) c ,Y c ) is the set of pixels at the edge of the aperture, c∈(1,2,…,N).

[0049] This invention employs a distortion compensation algorithm to restore distorted images. Based on the principle of minimum variance, the distortion center of the image is determined using a template. Then, the radial and tangential matrices and distortion coefficients of the lens are calculated. In actual measurements, the imaging points are corrected, improving the solution accuracy and achieving high-precision aperture measurement. Experiments show that the method of this invention can effectively measure aperture dimensions. The measured aperture size is between 2mm and 6mm, with a measurement accuracy within ±0.03mm and a relative error of 0.25%, meeting the requirements for size measurement. Attached Figure Description

[0050] Figure 1 This is a flowchart of a detection process for real-time image acquisition and aperture measurement. Detailed Implementation

[0051] This invention proposes an aperture measurement method and device based on distortion compensation and adaptive averaging.

[0052] The specific method flow of the aperture measurement method based on distortion compensation and adaptive mean fuzzy algorithm of this invention is as follows:

[0053] S1: The acquired image is subjected to distortion correction to obtain the restored real image. Then, through filtering and threshold segmentation, including binarization of the filtered image, the image is smoothed and the target region is extracted.

[0054] S2: The improved Canny operator based on custom threshold mean blurring with preserved edge information is used to perform edge detection on the aperture target in the target region, and the pixel value of the aperture edge is detected.

[0055] S3: Obtain and store the edge contour points of all apertures through edge detection, and then use the threshold to compare the pixels, remove useless points, and identify the aperture edge features;

[0056] S4: Based on the aperture edge features, the least squares method is used to fit a circle to calculate the aperture size parameters and obtain the detection results;

[0057] S5: Upload the returned detection results to the detection development platform built with PyQt5 for result display;

[0058] In one example, in S1, the distortion correction of the acquired image specifically involves: using a 3×3 square template, tracking all curves within 70 pixels of the image center point, and recording the coordinates of all curves. Then, by calculating the variance of each curve, the curve with the smallest variance in the horizontal and vertical directions is identified. The intersection point of the grid formed by these curves is found. It can be observed that only by determining the location of the distortion center can the surrounding pixels be iteratively calculated to solve for the camera's intrinsic and extrinsic parameters and distortion coefficients, ultimately performing distortion correction. Therefore, it is necessary to first determine the distortion center and then calculate the parameters for the pixels surrounding the center point. In the template recording the horizontal and vertical curves, 1 represents the current point as the foreground point, and X represents that it does not matter whether the current point is the foreground point. Extrinsic parameters involve the positional and motion relationships between points in 3D space and the camera. It is not a fixed parameter. Therefore, it needs to be calculated through camera calibration. Intrinsic parameters, on the other hand, are parameters related to the physical characteristics of the camera itself. Therefore, the intersection points of the image grid are calibrated to obtain the intrinsic parameters, extrinsic parameters, and distortion coefficient matrix of the lens. Then, pixel compensation processing is performed on the image based on these parameters to finally obtain the restored image.

[0059] In one instance, in S2, an adaptive mean fuzzing algorithm is chosen to improve edge detection. The improved edge detection method specifically includes:

[0060] An adaptive mean blurring operation is performed using an adaptive thresholding algorithm, which iteratively obtains the ideal judgment threshold under experimental conditions. This algorithm primarily involves dividing the image into one or more small regions, then further subdividing these regions. This process is repeated, iterating through the pixel values ​​of each region. A histogram is calculated for each region, and the trough between the two peaks in an image with two peaks is used as the threshold for that region. After determining the threshold for each region, a weighted average is applied to all the thresholds. Finally, the most suitable overall judgment threshold for the image is selected from the subdivided small regions, and this threshold is used as the basis for subsequent gradient direction and intensity determination.

[0061] Calculate the difference in grayscale value between each pixel in the target region and the center pixel, and compare each difference with a judgment threshold. If the difference is less than the judgment threshold, it is included in the mean blur calculation; otherwise, it is not included in the calculation.

[0062] The gradient is calculated using a 5×5 first-order finite difference to obtain two matrices of the partial derivatives of the target region image in the x and y directions, thus determining the gradient strength and direction.

[0063] The gradient intensity of the edge pixels of the target region is compared with that of two pixels along the positive and negative gradient directions. If the gradient intensity of the current pixel is the largest compared to the other two pixels, the pixel is retained as an edge point; otherwise, the pixel is suppressed.

[0064] A dual-threshold approach is used to filter the binarized image, continuously collecting new edges until the entire image edge is closed. Two thresholds are set: a high threshold and a low threshold. The edge attribute is determined based on the relationship between the gradient strength of the current target region's edge pixels and these two thresholds. If the gradient value of the current edge pixel is greater than or equal to the high threshold, the current edge pixel is marked as a strong edge. If the gradient value of the current edge pixel is between the two thresholds and connects with a strong edge, the edge is processed as an edge; otherwise, it is suppressed. If the gradient value of the current edge pixel is less than or equal to the low threshold, the current edge pixel is suppressed. New edges are continuously collected until the entire image edge is closed.

[0065] In one instance, in S3, a 2D parameter space is used to add directional information to the foreground points on the image, draw a straight line, and then determine the center of the circle. Therefore, for the aperture image in the experiment, all contour points are detected, without establishing any hierarchical relationship between them. Different regions are divided based on the distribution of the contour points. The contour points are traversed, first deleting contour points in regions far from the target contour. Then, contour points that do not conform to the minimum connected region within the target pixel size range, as well as contour points that do not conform to the final circular curve, are removed. Finally, a threshold is used to compare with the remaining pixels to delete or retain contour points.

[0066] In one example, in S4, the least squares method is used to fit a circular aperture based on contour points, thereby achieving high-precision measurement of the aperture. A mathematical model f(x) is selected for the least squares method to solve for the circle. The sum of squares of the differences between the y-values ​​of the sampling points and f(x) is calculated. The coefficient of f(x) corresponding to the minimum value of this sum is the coefficient of the curve to be solved.

[0067] The ideal curve equation for the aperture to be measured is shown in formula (1).

[0068] (xV) 2 +(yW) 2 =R 2 (1)

[0069] Where (x, y) are the edge coordinates of the aperture to be measured, R is the radius of the aperture to be measured, and the center of the ideal aperture is (V, W). Let v = -2V, w = -2W, l = V 2 +W 2 -R 2 The general equation for the aperture to be measured is:

[0070] x 2 +y 2 +vx+wy+l=0 (2)

[0071] Sample set (X) c ,Y c The distance from the midpoint of c∈(1,2,…,N) to the center of the aperture circle is shown in formula (3), where (X c ,Y c ) represents the coordinates of the obtained aperture arc edge points, and c represents the sequence number of the aperture edge points involved in the fitting.

[0072]

[0073] The difference between the square of the distance from the edge of the aperture to the center of the ideal aperture circle and the square of the radius of the circle is:

[0074]

[0075] make Q(v,w,l) represents the squared error of the aperture to be measured, so it is not necessary to solve for the square root of the aperture. The values ​​of v, w, and l corresponding to the minimum of Q(v,w,l) are the parameters of the aperture to be measured. Taking the partial derivatives of Q(v,w,l) with respect to v, w, and l respectively, and setting the partial derivatives to 0, we obtain the equation satisfied by the extreme point:

[0076]

[0077]

[0078]

[0079] Solve equations (5), (6), and (7). To facilitate the solution, we use C, D, E, G, and H to transform intermediate parameters. Let...

[0080]

[0081] D=N∑ X c Y c -∑ X c ∑ Y c (9)

[0082]

[0083]

[0084]

[0085] Solving equations (8), (9), (10), (11), and (12), we can obtain:

[0086]

[0087]

[0088]

[0089] The obtained v, w, and l are the parameters of the circle to be measured that needs to be fitted, therefore the aperture d is:

[0090]

[0091] To calculate the actual size of the aperture to be measured from the image, we convert the pixel-level dimensions to millimeters in physical space. Calibration is performed on a standard circular plate of known dimensions, specifically including:

[0092] A standard circular calibration plate with a known aperture size is placed in the same experimental environment as the aperture measurement, and the aperture is collected and measured.

[0093] Repeat the above steps to repeatedly measure the standard aperture, obtain the number of aperture pixels in each measurement, and then calculate the average number of aperture pixels. The detected aperture is m. i (i = 1, 2, ..., n) pixels, where i is the number of measurements, and the average number of pixels is calculated as m pixels;

[0094] If the actual aperture of the standard circle is l mm, then the pixel equivalent is:

[0095] In one example, in S5, a real-time detection platform built with PyQt5 establishes threads for inputting the image to be detected and outputting the detected image, so that the image to be detected and the detected image are displayed simultaneously and the measurement results are shown.

[0096] This invention also proposes an aperture measurement device based on distortion compensation and an adaptive mean fuzzy algorithm, comprising:

[0097] The target region extraction module performs distortion correction after binarizing the acquired image, then smooths the image and extracts the target region.

[0098] An aperture edge detection module performs edge detection on the aperture target in the target area and detects the aperture edge pixel value;

[0099] An aperture edge recognition module, based on the aperture edge pixel values, then compares the aperture edge pixel values ​​with a threshold, removes useless pixels, and identifies and obtains aperture edge features;

[0100] The aperture calculation module calculates and displays the aperture size parameters based on the aperture edge features using the least squares method to fit a circle.

[0101] The specific method for distortion correction by the target region extraction module includes: using a square template, tracking all curves within a specified number of pixels from the image center point, recording the coordinates of all curves, then calculating the variance of each curve, and finding the curve with the smallest variance in the horizontal and vertical directions; using the intersection of these curves with the smallest variance as grid intersection points; then, calibrating the image grid intersection points to obtain the lens's intrinsic parameters, extrinsic parameters, and distortion coefficient matrix, and performing pixel compensation on the image based on this information to obtain the restored image.

[0102] The aperture edge detection module performs edge detection on the aperture target in the target region, detecting aperture edge pixels, specifically including:

[0103] First, the center pixel value of the target region image is added together with the values ​​of its multiple neighboring pixels, and then the average value is calculated as the center pixel average. The target region image is divided into multiple windows, and a judgment threshold is set for each window. The method for determining the judgment threshold is as follows: calculate the histogram of each window, and use the histogram of each window to find the trough value between the two peaks in an image with two peaks as the judgment threshold for that window. Calculate the difference between each pixel in the target region and the center pixel average, and compare each difference with the judgment threshold for each window. If the difference is less than the judgment threshold, the pixel is retained for further processing; otherwise, the pixel is discarded.

[0104] The gradient is calculated using the first-order finite difference of a specified window to obtain two matrices of the partial derivatives of the target region image in the x and y directions in a Cartesian coordinate system with the image center as the origin, thus determining the gradient intensity and direction at the edge of the target region.

[0105] The gradient intensity of the obtained target region edge pixel is compared with the gradient intensity of two pixels along the positive and negative gradient directions; if the gradient intensity of the current target region edge pixel is the largest compared with the gradient intensity of other points in the same direction, the pixel is retained as the aperture edge pixel; otherwise, the pixel is removed.

[0106] The image is then further inspected, collecting the edges of the aperture until all edges of the entire target region are closed.

[0107] The aperture edge recognition module, based on the aperture edge pixel values, compares the threshold values ​​with the aperture edge pixel values ​​to remove useless pixels and identify and obtain aperture edge features. Specifically, it includes: traversing the aperture edge pixels; first, deleting pixels that are more than a specified distance from the aperture edge pixel; then, removing pixels in the image within the smallest connected component whose difference from the aperture edge pixel exceeds a specified value; finally, comparing the remaining pixels with the judgment threshold. If the pixel value is greater than or equal to the judgment threshold, the pixel is retained; if the pixel value is less than the judgment threshold, the pixel is deleted, thus obtaining the aperture edge features.

[0108] Furthermore, the aperture calculation module calculates and displays the aperture size parameters based on the aperture edge features using a least-squares method to fit a circle, specifically including:

[0109] Let d be the aperture of the circle fitted by the pixel.

[0110]

[0111] Then, the aperture d of the fitted circle is converted into an aperture size expressed in millimeters; where,

[0112]

[0113]

[0114]

[0115] Among them, C, D, E, G, and H are intermediate parameters.

[0116]

[0117] D=N∑X c Y c -∑X c ∑Y c

[0118]

[0119]

[0120]

[0121] Among them, (X) c ,Y c ) is the set of pixels at the edge of the aperture, c∈(1,2,…,N).

[0122] This invention employs a distortion compensation algorithm to restore distorted images. Based on the principle of minimum variance, the distortion center of the image is determined using a template. Then, the radial and tangential matrices of the lens and the distortion coefficients are calculated. In actual measurements, the imaging points are corrected to improve the solution accuracy.

[0123] This invention replaces Gaussian blur with mean blurring using an adaptive threshold that preserves edges in the Canny operator, while incorporating a 5×5 convolution kernel. This preserves areas with weak edge information and isolated effective edge points, improving the accuracy of the contour and the precision of the aperture calculation.

[0124] The contents not described in detail in this specification are common knowledge to those skilled in the art.

Claims

1. An aperture measurement method based on distortion compensation and adaptive mean fuzziness, characterized in that, include: S1. After binarizing the acquired image, distortion correction is performed, then the image is smoothed and the target region is extracted. S2. Perform edge detection on the aperture target in the target area to detect the aperture edge pixels; S3. Based on the aperture edge pixel value, compare the aperture edge pixel value with the judgment threshold, remove useless pixels, and identify and obtain aperture edge features; S4. Based on the aperture edge features, the aperture size parameters are calculated and displayed by fitting a circle using the least squares method. In S2, edge detection is performed on the aperture target in the target region to detect the aperture edge pixels, specifically including: First, the center pixel value of the target region image is added together with the values ​​of its multiple neighboring pixels, and the average value is taken as the center pixel average. Then, the target region image is divided into multiple windows, and a judgment threshold is set for each window. The difference between each pixel in the target region and the center pixel average is calculated, and each difference is compared with the judgment threshold of each window. If the difference is less than the judgment threshold, the pixel is retained for further processing; otherwise, the pixel is discarded. The method for determining the judgment threshold is as follows: the histogram of each window is calculated, and the trough value between the two peaks in an image with two peaks in the histogram of each window is taken as the judgment threshold of that window. The gradient is calculated using the first-order finite difference of a specified window to obtain two matrices of the partial derivatives of the target region image in the x and y directions in a Cartesian coordinate system with the image center as the origin, thus determining the gradient intensity and direction at the edge of the target region. The gradient intensity of the obtained target region edge pixel is compared with the gradient intensity of two pixels along the positive and negative gradient directions; if the gradient intensity of the current target region edge pixel is the largest compared with the gradient intensity of other points in the same direction, the pixel is retained as the aperture edge pixel; otherwise, the pixel is removed. Continue to detect and collect the edges of the aperture until all edges of the entire target area are closed.

2. The method according to claim 1, characterized in that: In S1, the distortion correction includes: Using a square template, all curves within a specified number of pixels from the image center are tracked and their coordinates are recorded. Then, the variance of each curve is calculated, and the curves with the smallest variance in the horizontal and vertical directions are identified. The intersection of these curves with the smallest variance is taken as the grid intersection point. Then, the image grid intersection points are calibrated to obtain the lens's intrinsic parameters, extrinsic parameters, and distortion coefficient matrix. Based on this information, pixel compensation is performed on the image to obtain the restored image.

3. The method according to claim 1, characterized in that, In S3, based on the aperture edge pixel values, a judgment threshold is then compared with the aperture edge pixel values ​​to remove useless pixels and identify and obtain aperture edge features, specifically including: The aperture edge pixels are traversed. First, pixels that are more than a specified distance from the aperture edge pixels are deleted. Then, pixels in the smallest connected region in the image whose difference from the aperture edge pixels exceeds a specified value are removed. Finally, the remaining pixels are compared with the judgment threshold. If the pixel value is greater than or equal to the judgment threshold, the pixel is retained. If the pixel value is less than the judgment threshold, the pixel is deleted. Finally, the aperture edge features are obtained.

4. An aperture measurement device based on distortion compensation and adaptive mean fuzziness, characterized in that, include: The module includes a target region extraction module, an aperture edge detection module, an aperture edge recognition module, and an aperture calculation module. The target region extraction module performs distortion correction after binarizing the acquired image, then smooths the image and extracts the target region. The aperture edge detection module performs edge detection on the aperture target in the target area and detects the aperture edge pixels. The aperture edge recognition module compares the aperture edge pixel values ​​with a threshold value to remove useless pixels and identify aperture edge features. The aperture calculation module calculates and displays the aperture size parameters based on the aperture edge features by fitting a circle using the least squares method. The aperture edge detection module performs edge detection on the aperture target in the target region and detects the aperture edge pixels, specifically including: First, the center pixel value of the target region image is added together with the values ​​of its multiple neighboring pixels, and the average value is taken as the center pixel average. Then, the target region image is divided into multiple windows, and a judgment threshold is set for each window. The difference between each pixel in the target region and the center pixel average is calculated, and each difference is compared with the judgment threshold of each window. If the difference is less than the judgment threshold, the pixel is retained for further processing; otherwise, the pixel is discarded. The method for determining the judgment threshold is as follows: the histogram of each window is calculated, and the trough value between the two peaks in an image with two peaks in the histogram of each window is taken as the judgment threshold of that window. The gradient is calculated using the first-order finite difference of a specified window to obtain two matrices of the partial derivatives of the target region image in the x and y directions in a Cartesian coordinate system with the image center as the origin, thus determining the gradient intensity and direction at the edge of the target region. The gradient intensity of the obtained target region edge pixel is compared with the gradient intensity of two pixels along the positive and negative gradient directions; if the gradient intensity of the current target region edge pixel is the largest compared with the gradient intensity of other points in the same direction, the pixel is retained as the aperture edge pixel; otherwise, the pixel is removed. Continue to detect and collect the edges of the aperture until all edges of the entire target area are closed.

5. The apparatus according to claim 4, characterized in that, The specific method for the distortion correction performed by the target region extraction module includes: Using a square template, all curves within a specified number of pixels from the image center are tracked and their coordinates are recorded. Then, the variance of each curve is calculated, and the curves with the smallest variance in the horizontal and vertical directions are identified. The intersection of these curves with the smallest variance is taken as the grid intersection point. Then, the image grid intersection points are calibrated to obtain the lens's intrinsic parameters, extrinsic parameters, and distortion coefficient matrix. Based on this information, pixel compensation is performed on the image to obtain the restored image.

6. The apparatus according to claim 4, characterized in that, The aperture edge recognition module, based on the aperture edge pixel values, compares the aperture edge pixel values ​​with a threshold, removes useless pixels, and identifies and obtains aperture edge features, specifically including: The aperture edge pixels are traversed. First, pixels that are more than a specified distance from the aperture edge pixels are deleted. Then, pixels in the smallest connected region in the image whose difference from the aperture edge pixels exceeds a specified value are removed. Finally, the remaining pixels are compared with a judgment threshold. If the pixel value is greater than or equal to the judgment threshold, the pixel is retained. If the pixel value is less than the judgment threshold, the pixel is deleted. Finally, the aperture edge features are obtained.

Citation Information

Patent Citations

  • Method for accurately positioning vision in cleaning robot of condenser

    CN101354785A

  • Machine vision-based defect detection method of chemical fiber spinning nozzle hole

    CN110441318A