Subpixel edge detection method based on improved Franklin moment
By improving the subpixel edge detection method of Franklin moment, the problems of high computing complexity and time consumption in the prior art are solved, efficient and accurate edge detection is achieved, and the needs of high real-time applications are met.
Patent Information
- Application Number
- CN202311446430.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-02
- Publication Date
- 2025-05-06
AI Technical Summary
While improving detection accuracy, existing subpixel edge detection technology increases calculation complexity and time consumption, making it difficult to meet the application requirements of high real-time.
The subpixel edge detection method based on the improved Franklin moment is adopted to calculate the subpixel value by reading images, performing pixel-level edge detection, differential calculation and convolution operations, reducing convolution calculations in other directions, and improving calculation efficiency.
It significantly reduces the computing time, improves the accuracy and efficiency of edge detection, and meets the application requirements of high real-time performance.
Smart Images

Figure CN119941765A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of image processing, in particular to a sub-pixel edge detection method based on improved Franklin moment. Background Art
[0002] Edge detection is a basic problem in image processing, which aims to identify and extract the boundaries and edges in the image. It is an important step in computer vision tasks such as image segmentation, recognition and understanding. Edge detection technology has developed rapidly, and can be traced back to the 1950s, when scientists began to study how to use computers for image processing and recognition. With the continuous development of computer technology and artificial intelligence, edge detection technology has also been continuously improved and optimized. From the initial edge detection method based on simple threshold processing to the later edge detection method based on wavelet transform, Gabor filter, Sobel operator, and Canny operator, a relatively complete theoretical and technical system has gradually been formed. The application scope of edge detection is very wide, involving many fields such as industrial inspection, medical imaging, digital photography, remote sensing image processing, computer vision, etc. For example, in industrial inspection, edge detection technology can be used to detect the surface of the product to find defects and scratches; in medical imaging, edge detection technology can be used for organ segmentation and lesion detection; in digital photography, edge detection technology can be used for image clarity analysis and depth of field estimation.
[0003] Sub-pixel edge detection is an important technology in digital image processing. Its background is that with the development of computer vision industrial measurement technology, high-precision edge detection and edge positioning technology has emerged. In traditional computer vision industrial measurement, the accuracy of image edges is improved by increasing the sampling rate. However, the sampling rate cannot be increased infinitely. Too high a sampling rate not only fails to significantly improve the positioning accuracy, but also increases the production cost. In this case, sub-pixel-based edge detection technology was produced. Under the same hardware conditions, its positioning error is less than one pixel, which significantly improves the detection efficiency. Sub-pixel edge detection technology can improve the detection accuracy to the sub-pixel level. In modern society, where the requirements for accuracy in applications such as industrial detection are constantly increasing, traditional pixel-level edge detection methods can no longer meet the needs of actual measurement. Compared with other detection algorithms, the time used is too long and it is difficult to meet some high real-time requirements. Summary of the invention
[0004] In order to solve the above-mentioned shortcomings, the present invention provides an edge detection method based on improved Franklin moment to solve the technical problem.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0006] A sub-pixel edge detection method based on improved Franklin moment includes the following steps:
[0007] Step 1) reading the collected image;
[0008] Step 2) Perform pixel-level edge detection on the image to obtain target edge points;
[0009] Step 3) According to the relative positions of the edge points, the size of the edge pixel processing template is determined and the pixel value is calculated;
[0010] Step 4) performing differential calculation on the obtained pixel-level edge points; performing convolution operation based on the differential result using the second-order Franklin moment to obtain increments;
[0011] Step 5) Combine the increments to calculate the sub-pixel values of the corresponding points.
[0012] The method of determining the size of the edge pixel processing template according to the relative position of the edge point includes: traversing all edge points, sequentially calculating the location of the edge point (x s ,y s ) to P o1 , P o2 , P o3 , P o4 , P o5 , P o6 , P o7 , P o8 The distance l k ;
[0013]
[0014] Construct an all-zero matrix S and calculate the positioning edge (x s ,y s )’s pixel-level edge point S2(i, j):
[0015]
[0016] Select a template Among them, M 66 Even-numbered template of 6×6 size; M 77 Even-numbered templates with a 7×7 size.
[0017] Calculating pixel values using a template involves:
[0018] Calculate the template in the direction corresponding to the Franklin moment, set the image f(x, y) = 1, and record F nm The template is M nm ,have:
[0019]
[0020] Then, the even template M nm The result of the i-th row and j-th column is calculated according to the following formula:
[0021]
[0022] Then, odd template M nm The result of the i-th row and j-th column is calculated according to the following formula:
[0023]
[0024] The algorithm for the difference calculation is:
[0025] Traverse the obtained pixel points and perform differential calculation f on each pixel point (i, j) and the surrounding pixels c , f r :
[0026]
[0027] a) When |f c |≥|f r |, according to the image model, calculate the Franklin distances of different orders in the y direction, and deduce the results in the up and down directions:
[0028]
[0029] when hour
[0030]
[0031] when hour
[0032]
[0033] Combining the above formulas, we get
[0034]
[0035] b) When |f c |<|f r |, according to the image model, calculate the Franklin distances of different orders in the x direction, and derive the results in the left and right directions:
[0036]
[0037] when hour,
[0038]
[0039] when hour,
[0040]
[0041] Combining the above formulas, we get
[0042]
[0043] The combining increments to calculate the sub-pixel values of the corresponding points includes:
[0044] When |f c |≥|f r |, the sub-pixel coordinate formula after processing is:
[0045]
[0046] When |f c |<|f r |, the sub-pixel coordinate formula is:
[0047]
[0048] in, is the pixel coordinate before processing, is the sub-pixel coordinate value after processing.
[0049] The present invention has the following beneficial effects and advantages:
[0050] 1. Reduce the convolution calculation in other directions. The method of the present invention judges the connection between pixels and does not calculate the influence in the direction with no effect or weak effect. And only two templates and pixel values are needed for convolution calculation, and the correlation coefficient is solved by a first-order polynomial, which can effectively reduce the calculation time.
[0051] 2. Improved convolution operation. The method of the present invention improves convolution by finding whether a pixel point is in the edge direction and using a convolution template of an even size, thereby reducing the complexity of the convolution operation and ensuring the accuracy of the operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a module flow chart of the method of the present invention;
[0053] Figure 2 is the interval determination map of the pixel points;
[0054] Figure 3 is an even convolution template;
[0055] Figure 4 is the ideal step model of the image edge;
[0056] Figure 5 The original image and the result image before and after being processed by the method of the present invention. DETAILED DESCRIPTION
[0057] The method of the present invention is further described in detail below in conjunction with the accompanying drawings.
[0058] like Figure 1 As shown, the method of the present invention is a sub-pixel edge detection method based on improved Franklin moment, comprising the following steps:
[0059] The sub-pixel edge detection method of the present invention comprises the following steps:
[0060] Step 1) Read the collected image file;
[0061] Step 2) First, perform pixel-level edge detection on the image file to obtain pixel-level edge points of the target image; for example, the Canny operator can be used to detect edges.
[0062] Step 3) Calculate whether the pixel-level edge point is closer to the edge, make a judgment, and select a convolution template of corresponding size;
[0063] Step 4) performing a differential operation on the obtained pixel points, making a differential operation judgment, calculating the Franklin moment on the corresponding direction, and calculating the correlation coefficient l;
[0064] Step 5) Finally, the sub-pixel value of the target point is calculated based on the obtained parameters.
[0065] Among them, step 3.1) how to select the template:
[0066] like Figure 2 As shown, the method of the present invention needs to perform interval determination to determine whether the point uses an odd-size template or an even-size template.
[0067] First, define adjacent rectangular 4-pixel areas, with the centers of each pixel being P o1 , P o2 , P o3 , P o4 , distance from the intersection P o5 , P o6 , P o7 , P o8 ; Calculate pixel-level edge points (x t ,y t ) Distance P o1 , P o2 , P o3 , P o4 , P o5 , P o6 , Po7 , P o8 The distances between them are l1, l2, l3, l4, l5, l6, l7, l8;
[0068]
[0069] Construct an all-zero matrix S and calculate the positioning edge (x t ,y t )’s pixel-level edge point S2(i, j):
[0070]
[0071] The calculation result determines whether to use the odd-numbered template 7×7 or the even-numbered template 6×6 size template for calculation.
[0072]
[0073] Among them, step 3.2) calculation of even or odd templates:
[0074] Step 3.21) Calculation process of even template: Figure 3 As shown, this article will use odd and even templates to make judgments and then perform calculations, where the template calculation is as follows.
[0075] The Franklin function is defined as 2 The continuous orthogonal function system on [0, 1] is obtained by orthogonalizing a set of linearly independent truncated power bases. Consider the following linearly independent set {α j (x), 0≤x≤1}:
[0076]
[0077] in: i is a positive integer, t is all the integers that satisfy 2 t Maximum value of ≤2i-1. Truncated monomial notation Defined as:
[0078]
[0079] The above linearly independent group {α i (x), 0≤x≤1} After the Gram-Schmidt orthogonalization process, we get the Franklin function system denoted as The expressions of the first three terms are as follows:
[0080]
[0081]
[0082]
[0083] Calculate the Franklin moment template, set the image f(x, y) = 1, record F nm The template is M nm ,have:
[0084]
[0085] Then the even template M nm The result of the i-th row and j-th column is calculated according to the formula:
[0086]
[0087] Step 3.22) Calculation process of odd number template:
[0088] The steps are the same as for the even template, except that in the last step, the odd template M nm The result of the i-th row and j-th column is calculated according to the formula:
[0089]
[0090] Among them, in step 4), the algorithm for differential calculation is:
[0091] Traverse the obtained pixel points and perform differential calculation f on each pixel point and the surrounding pixels c , f r :
[0092]
[0093] Among them, f c is the mean pixel value in the y direction of the current pixel, f r is the pixel mean in the x direction of the current pixel;
[0094] When |f c |≥|f r |When:
[0095] Each pixel in the single-pixel edge can be considered as the pixel through which the edge projection passes. For any pixel (i, j), the edge projection passing through the pixel is approximated as the actual edge of the object. In practice, the edge of the inspection part must always be continuous and differentiable within a certain range, and the size of the pixel unit is also very small. It can be considered that the straight line will also pass through the adjacent rows of sub-pixels in the column where the sub-pixel (i, j) is located. Therefore, the column where the sub-pixel (i, j) is located and the adjacent upper and lower sub-pixels are taken as the research objects. Figure 4As shown in the figure, it is the ideal step model of the image edge. The square represents a unit pixel, the part of the straight line L contained by the square represents the ideal edge, the grayscale values on both sides of L in the square are h and h+k respectively, k is the grayscale difference, and l is the theoretical distance from the origin to the edge.
[0096] According to the image model, calculate the Franklin distance of different orders:
[0097]
[0098] when hour
[0099]
[0100] when
[0101]
[0102] Combining the above formulas, we can get
[0103]
[0104] When |f c |<|f r |
[0105] Consistent with the principle in the y direction, it can be deduced that in the x direction, according to the image model, the Franklin distances of different orders are calculated. At the same time, by analogy with the formula calculation in the up and down directions, the results in the left and right directions can be deduced as follows:
[0106]
[0107] when hour,
[0108]
[0109] when hour,
[0110]
[0111] Combining the above formulas, we can get
[0112]
[0113] Among them, step 5) is divided into the following cases, and the sub-pixel coordinates are calculated respectively.
[0114] When |f c |≥|f r |, the sub-pixel coordinate formula after processing can be derived as:
[0115]
[0116] When |f c |<|f r |, the sub-pixel coordinate formula can be derived as:
[0117]
[0118] in, is the pixel coordinate before processing, is the sub-pixel coordinate value after processing.
[0119] like Figure 5 As shown in the figure, the original image and the result image before and after the processing of the method of the present invention are shown. As shown in the figure, the method of the present invention can detect the edge of the object more accurately, and the time used is greatly reduced compared with other sub-pixel edge detection algorithms.
[0120] The above are only a few embodiments of the present application and do not constitute any form of limitation to the present application. Although the present application is disclosed as above with preferred embodiments, it is not intended to limit the present application. Any technician familiar with the profession, without departing from the scope of the technical solution of the present application, using the technical content disclosed above to make slight changes or modifications are equivalent to equivalent implementation cases and fall within the scope of the technical solution.
Claims
1. A sub-pixel edge detection method based on improved Franklin moment, characterized in that: The following steps are involved: Step 1) reading the collected image; Step 2) Perform pixel-level edge detection on the image to obtain target edge points; Step 3) According to the relative positions of the edge points, the size of the edge pixel processing template is determined and the pixel value is calculated; Step 4) performing differential calculation on the obtained pixel-level edge points; performing convolution operation based on the differential result using the second-order Franklin moment to obtain increments; Step 5) Combine the increments to calculate the sub-pixel values of the corresponding points.
2. The sub-pixel edge detection method based on improved Franklin moment according to claim 1, characterized in that: The method of determining the size of the edge pixel processing template according to the relative position of the edge point includes: traversing all edge points, sequentially calculating the location of the edge point (x s ,y s ) to P o1 , P o2 , P o3 , P o4 , P o5 , P o6 , P o7 , P o8 The distance l k ; Construct an all-zero matrix S and calculate the positioning edge (x s ,y s )’s pixel-level edge point S2(i,j): Select a template Among them, M 66 Even-numbered template of 6×6 size; M 77 Even-numbered templates with a 7×7 size.
3. The sub-pixel edge detection method based on improved Franklin moment according to claim 2, characterized in that: Calculating pixel values using a template involves: Calculate the template in the direction corresponding to the Franklin moment, set the image f(x,y) = 1, and record F nm The template is M nm ,have: Then, the even template M nm The result of the i-th row and j-th column is calculated according to the following formula: Then, odd template M nm The result of the i-th row and j-th column is calculated according to the following formula:
4. The sub-pixel edge detection method based on improved Franklin moment according to claim 1, characterized in that: The algorithm for the difference calculation is: Traverse the obtained pixel points and perform differential calculation f on each pixel point (i, j) and the surrounding pixels c ,f r : a) When |f c |≥|f r |, according to the image model, calculate the Franklin distances of different orders in the y direction, and deduce the results in the up and down directions: when hour when hour Combining the above formulas, we get b) When |f c |<|f r |, according to the image model, calculate the Franklin distances of different orders in the x direction, and derive the results in the left and right directions: when hour, when hour, Combining the above formulas, we get 5. The sub-pixel edge detection method based on improved Franklin moment according to claim 1, characterized in that: The combining increments to calculate the sub-pixel values of the corresponding points includes: When |f c |≥|f r |, the sub-pixel coordinate formula after processing is: When |f c |<|f r |, the sub-pixel coordinate formula is: in, is the pixel coordinate before processing, is the sub-pixel coordinate value after processing.