An edge detection method based on fusion image enhancement
By employing a side-window Gaussian filtering and adaptive threshold segmentation edge detection method, the problem of high computational complexity in traditional edge detection techniques is solved, achieving efficient and accurate edge detection results.
Patent Information
- Application Number
- CN202410017667.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-05
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-01-05
AI Technical Summary
Traditional edge detection techniques have high computational complexity when processing fused images, consuming a lot of time and computing resources. They also struggle to handle complex backgrounds and noise, and parameter selection is difficult, affecting the accuracy and efficiency of the images.
A side-window Gaussian filter traversal calculation is adopted using multiple edge models. Combining Gaussian filtering with first-order finite difference, global threshold segmentation is performed through adaptive coefficients to improve the accuracy and efficiency of edge detection.
It effectively enhances the high-frequency edge information of fused images, removes noise, improves image clarity and edge preservation, and enhances the accuracy and flexibility of edge detection.
Smart Images

Figure CN117974700B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an edge detection method based on image fusion enhancement. Background Technology
[0002] Edge detection based on fused image enhancement is a technique used to detect the edges of objects in an image. It is suitable for situations where edges may be unclear and details may be lost when processing fused images. By performing edge-preserving enhancement processing on the fused image to enhance edge contrast, the edges become more distinct and easier to detect. This technique is widely used in computer vision, image processing, and computer graphics.
[0003] Traditional image fusion techniques face challenges such as high-frequency data loss and blurred edge details during the fusion process. When images from different bands are fused, subtle but crucial information may be blurred or ignored, affecting image quality and accuracy. In fields requiring precise edge detection and detailed information acquisition, such as military target recognition, medical image analysis, and autonomous driving, accurate edge detection is a key factor determining system performance and reliability. Since directly obtaining fused image results often loses information from the original layers, it's impossible to perform edge detection on the original images separately and then overlay the results. Therefore, edge detection techniques based on fused image enhancement are significant, providing more reliable and accurate image analysis tools. Current edge detection techniques primarily process visible light images, using operators such as Canny, Sobel, and Laplacian. These algorithms offer high accuracy and stability, but perform poorly in special cases like infrared fused images and near-field / far-field fused images. Edge detection techniques based on fused image enhancement, however, can utilize multi-layer information to effectively improve the accuracy and robustness of edge detection.
[0004] While existing image enhancement-based edge detection techniques are quite mature, several problems remain. First, traditional image enhancement filters not only remove noise but also blur edges and other details, resulting in information loss. These methods often struggle with complex backgrounds and noise. Second, edge detection algorithms require different parameters for different images, posing challenges for practical applications. Furthermore, traditional edge-preserving filtering is computationally complex, consuming significant time and resources. Therefore, improving the accuracy and efficiency of edge detection in various scenarios remains a crucial technical challenge in this field. Summary of the Invention
[0005] This application provides an edge detection method based on fused image enhancement, which can be used to solve the technical problem that traditional edge-preserving filtering has high computational complexity and requires a lot of time and computing resources.
[0006] This application provides an edge detection method based on fused image enhancement, the method comprising:
[0007] Step 1: Use side-window Gaussian filtering with multiple edge models to perform traversal calculations and match them with the pixels to be calculated to obtain the corresponding new pixel values. When the difference between the new pixel value and the original pixel value is the smallest, the edge shape of the corresponding filter is closest to the edge shape of the block where the pixel to be calculated is located. At this time, the background image obtained has the least weakening of pixels at the edge.
[0008] Step 2: Calculate the average value m within the template using the grayscale values X(i,j) of the image pixels. x (i,j), and the difference of squares in the template Furthermore, the high-frequency portion is enhanced, using the standard deviation as the gain value and the mean m. x As a background part, the gain product of the high-frequency bytes is used to obtain f. h (i,j);
[0009] Step 3: Fuse the background and high-frequency images to obtain the enhanced image output;
[0010] Step 4: Calculate the magnitude and direction of the gradient using first-order finite difference;
[0011] Step 5: Perform non-maximum suppression on the gradient magnitude, retaining only the pixels with the maximum gradient magnitude;
[0012] Step 6: Perform global threshold segmentation on the image using adaptive coefficients. The selected thresholds are denoted as TL and TH. Based on the thresholds, edge pixels are divided into strong edges and weak edges. Weak edge pixels are edge-linked, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels. Finally, the edge detection image is obtained.
[0013] Further, in step 1, Gaussian filtering of eight edge models is used for traversal calculation, and each model is matched with the pixel to be calculated to obtain the corresponding new pixel value, including:
[0014] The side-window Gaussian filter traversal calculation includes:
[0015] Step 11, Construct side window filtering:
[0016] Construct 8 local side windows;
[0017] Among them, the rotation angle of the side window Where k∈[0,3], the side window radius ρ takes values between {0,r}; by adjusting the values of θ and ρ, side windows with different tilt angles are generated; based on the position of the processed pixel relative to the sub-window, local side windows in 8 directions are selected to traverse edge pixels in different directions;
[0018] When ρ = r, the processing pixels of the four types of side windows (upper (U), lower (D), left (L), and right (R)) are located on the edges of the local side windows. The side windows are represented as follows: When ρ = 0, the four side windows—Northwest (NW), Southwest (SW), Southeast (SE), and Northeast (NE)—are located on the four edges of the filter window, respectively. To represent; that is, the final set of 8 filtering side windows is W = {U, D, R, L, NW, SW, SE, NE}; the side window filtering output results are shown below:
[0019]
[0020]
[0021] Where, q i Indicates the input raw image, I n This is the output of the filter function window, where F represents the filter kernel function selected for the window, and N... n I represents the sum of weights. m The output image is after traversing the side-window filtering window, argmin n∈S This represents the minimum output value after traversing each side window;
[0022] Step 12: Add a 3×3 Gaussian filter to the side window filtering and iterate through the image pixels:
[0023] The two-dimensional Gaussian distribution function is shown below:
[0024]
[0025] x and y are variables in the function, representing the coordinates of a point on the plane; σ is the standard deviation of the Gaussian distribution, determining the width of the distribution; the function describes the distribution of the intensity value of a point on a plane in two directions, that is, the intensity at point (x, y) is more influenced by points closer to that point, and is controlled by the standard deviation σ; the Gaussian distribution function is used to generate the Gaussian filter template; for a two-dimensional discrete Gaussian filter template, it is obtained by discretizing the continuous Gaussian distribution function; the resulting Gaussian filter template matrix is as follows:
[0026]
[0027] The Gaussian template is convolved with the input image, and the center of the filtering window during the traversal process is always aligned with the pixel being processed; the corners of the side windows are aligned with the pixels being processed; thus, the eight side windows are defined as follows:
[0028] S1(x1,y1)={(u,v)||ux|≤r,y1-r≤v≤y1,ω U ∈S}
[0029] S2(x1,y1)={(u,v)||ux|≤r,y1≤v≤y1+r,ω D ∈S}
[0030] S3(x1,y1)={(u,v)|x1≤u≤x1+r,|v-y1|≤r,ω R ∈S}
[0031] S4(x1,y1)={(u,v)|x1-r≤u≤x1,|v-y1|≤r,ω L ∈S}
[0032] S5(x1,y1)={(u,v)|x1-r≤u≤x1,y1-r≤v≤r,ω NW ∈S}
[0033] S6(x1,y1)={(u,v)||x1≤u≤x1+r,y1-r≤v≤r,ω NE ∈S}
[0034] S7(x1,y1)={(u,v)|x1≤u≤x1+r,y1≤v≤y1+r,ω SE ∈S}
[0035] S8(x1,y1)={(u,v)|x1-r≤u≤x1,y1≤v≤y1+r,ω SW ∈S}
[0036] In the formula S i This represents the side window filtering windows in 8 directions. (x1,y1) represents the coordinates of the pixel being processed, (u,v) represents the effective range coordinates of the side window, and ω represents the side window in each direction. U, D, R, L, NW, NE, SE, and SW represent the eight directions respectively.
[0037] Based on the coordinate range of the eight side windows, calculate the Gaussian kernel template for each side window; obtain the eight filter outputs in the following formula through matrix convolution summation:
[0038]
[0039] in, This represents the output of the Gaussian side-window filter, where Gaussian represents the Gaussian filter kernel. The final output is obtained by minimizing the input and output, as shown below:
[0040]
[0041] In the above formula, Y SWG-Gaussian argmin represents the Gaussian filter output of the side window. n∈S This represents the minimum output value after traversing each side window.
[0042] Further, step 2, enhancing the high-frequency component, includes:
[0043] Step 21: Subtract the low-frequency image after Gaussian filtering from the original image to obtain the high-frequency component f. H ;
[0044] With pixel x(i,j) in the original image as the center, the local mean and variance within a window of size (2n+1)*(2n+1) are expressed as follows:
[0045]
[0046]
[0047] In the above formula, m x (i,j) represents the local mean. Let x(i,j)-m represent the variance, n be the window radius, and i and j be the coefficients related to the radius; x (i,j) represents the high-frequency detail portion;
[0048] Step 22: Perform a gain product on the high-frequency image to obtain the enhanced high-frequency edge image f. HG :
[0049] f HG =G[x(i,j)-m x (i,j)]
[0050]
[0051] Where G is the gain expression, σ x (i,j) represents the variance coefficient, and D is a constant coefficient, which is 0.1 in this embodiment.
[0052] Further, in step 3, the background and high-frequency image are fused to obtain the enhanced image output, including:
[0053] f G (i,j)=Y SWG-Gaussian(i,j) +f HG
[0054] Among them, f G (i,j) represents the enhanced image output.
[0055] Further, step 4, calculating the magnitude and direction of the gradient using first-order finite difference, includes:
[0056] The gradient value is approximated using first-order finite difference. The Sobel gradient operators in the x and y directions of the image are as follows:
[0057]
[0058]
[0059] The gradients in the x and y directions at the center point of the window are respectively:
[0060] P x = (a2 + 2a3 + a4) - (a0 + 2a7 + a6)
[0061] P y = (a0 + 2a1 + a2) - (a6 + 2a5 + a4)
[0062] The gradient direction at the center point of the window is:
[0063]
[0064] Further, in step 5, non-maximum suppression is performed on the gradient magnitude, retaining only the pixels with the maximum gradient magnitude, including:
[0065] In a 3x3 window matrix, if the center point a is the largest point max(m,n,a) among m,n,a in the same direction in the neighborhood, point a is retained and used as a potential edge point B(i,j); if it is not the largest point, it is suppressed.
[0066]
[0067] When the direction is selected between two adjacent pixels, a linear interpolation algorithm is used to obtain the two points m and n that need to be compared, and the suppression operation is repeated on the interpolated points m and n.
[0068] Further, step 6: Perform global threshold segmentation on the image using adaptive coefficients, with the selected thresholds denoted as TL and TH. Based on the thresholds, edge pixels are distinguished into strong edges and weak edges. Weak edge pixels are edge-linked, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels, ultimately obtaining the edge detection image, including:
[0069] Between-class variance σ 2 When taking the maximum value, the threshold level value is obtained:
[0070] σ 2 =p1*p2*(m1-m2) 2
[0071] In the above formula, m1 and m2 represent the mean values of the threshold TH dividing the image into two regions, and p1 and p2 represent the probability of a pixel being assigned to one of the two regions.
[0072] The selected dual thresholds are:
[0073] TL = max(0, (1.0 - sigma)level),
[0074] TH=max(255,(1.0+sigma)level),
[0075] In the above formula, TK is the low threshold, TH is the high threshold, and sigmaa is taken as an empirical value of 0.33;
[0076] Pixels with gradient magnitudes greater than the high threshold are marked as strong edge pixels, pixels with gradient magnitudes less than the low threshold are marked as non-edge pixels, and pixels with gradient magnitudes between the upper and lower thresholds are marked as weak edge pixels; edge linking is performed on weak edge pixels, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels.
[0077] Finally, the pixels marked as edge pixels are extracted to obtain the edge information of the image.
[0078] Compared with the prior art, the significant advantages of this invention are:
[0079] This invention applies image enhancement-based edge detection to the field of image fusion, enhancing and extracting high-frequency edge information that is blurred during the fusion process, which is beneficial to obtaining a more informative fused image.
[0080] This invention combines side-window filtering with Gaussian filtering algorithms to effectively remove various types of noise while maintaining image clarity, and to improve image quality in low-frequency backgrounds while preserving image edges.
[0081] This invention replaces the background image of the adaptive contrast image enhancement algorithm with a side-window Gaussian filter that better preserves edges, improving the image detail contrast and edge preservation after weighted fusion of high and low frequency images, which is beneficial for subsequent edge detection technology to accurately detect image edges.
[0082] This invention improves the traditional Canny operator by changing the dual threshold parameters from input threshold parameters to adaptive parameter acquisition, thereby enhancing the flexibility of the algorithm in various application scenarios. Since the threshold parameters are determined based on the statistical characteristics of the image, the performance and accuracy of Canny edge detection are also improved to a certain extent. Attached Figure Description
[0083] Figure 1 This is a schematic diagram illustrating the definition of a Gaussian filter side window provided in an embodiment of this application.
[0084] Figure 2 Infrared images, visible light images, and visible-infrared fused images are provided for embodiments of this application;
[0085] Figure 3 The embodiments of this application provide a comparison image between a fused light and infrared image after Gaussian filtering and a Gaussian image after side-window filtering;
[0086] Figure 4 A comparison image provided in this application, showing the low-frequency portion of the fused infrared image obtained by side-window filtering and the low-frequency image after adaptive contrast enhancement;
[0087] Figure 5 The embodiment of this application provides an enhanced image obtained by applying side-window filtering and adaptive enhancement of a high-frequency image to a fused infrared image;
[0088] Figure 6 The embodiments of this application provide edge images obtained by passing an infrared fusion image through the Canny operator;
[0089] Figure 7 The embodiments of this application provide edge images obtained by applying an enhanced algorithm to a fused infrared image and then using an improved adaptive dual-threshold Canny operator;
[0090] Figure 8 The foreground image, background image, and foreground-background fused image provided in the embodiments of this application;
[0091] Figure 9 A comparison image of the foreground-background fusion image provided in the embodiments of this application after Gaussian filtering and after Gaussian filtering through a side window;
[0092] Figure 10 A comparison image of the low-frequency portion of the foreground-background fusion obtained by side-window filtering and the low-frequency image after adaptive contrast enhancement, provided in an embodiment of this application.
[0093] Figure 11 The enhanced image obtained by foreground-background fusion in the embodiments of this application after side-window filtering and high-frequency image adaptive enhancement;
[0094] Figure 12 The edge image obtained by foreground-background fusion using the Canny operator is provided in the embodiments of this application.
[0095] Figure 13The foreground-background fusion provided in this application provides an edge image obtained by enhancing the algorithm and then applying an improved adaptive dual-threshold Canny operator.
[0096] Figure 14 A flowchart provided for an embodiment of this application. Detailed Implementation
[0097] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0098] The embodiments of this application will now be described in conjunction with the accompanying drawings.
[0099] In this embodiment, an edge detection method based on fused image enhancement includes the following steps:
[0100] Step 1: Use Gaussian filtering with multiple edge models to perform traversal calculations and match them with the pixels to be calculated to obtain the corresponding new pixel values. When the difference between the new pixel value and the original pixel value is the smallest, the edge shape of the corresponding filter is closest to the edge shape of the block where the pixel to be calculated is located. At this time, the background image obtained has the least weakening of pixels at the edge.
[0101] Specifically, the side-window Gaussian filtering process consists of the following steps:
[0102] Step 11, Construct side window filtering:
[0103] Construct 8 local side windows; the definition of a side window is as follows: Figure 1 As shown in (a).
[0104] Among them, the rotation angle of the side window Where k∈[0,3], the side window radius ρ takes values between {0,r}; by adjusting the values of θ and ρ, side windows with different tilt angles are generated; based on the hardware implementation feasibility analysis, this paper selects local side windows in 8 directions to traverse edge pixels in different directions according to the position of the processed pixel relative to the sub-window;
[0105] When ρ = r, the four types of side windows are as follows: top (U), bottom (D), left (L), and right (R). Figure 1 As shown in (b) and (c), in this case, the processed pixel is located on the edge of the local side window, avoiding pixel diffusion caused by irrelevant pixel values on the other side. The side windows are respectively represented as follows: When ρ = 0, the four types of side windows—northwest (NW), southwest (SW), southeast (SE), and northeast (NE)—are as follows: Figure 1 As shown in (d), they are located on the four edges of the filtering window, using... To represent; that is, the final set of 8 filtering side windows is W = {U, D, R, L, NW, SW, SE, NE}; the side window filtering output results are shown below:
[0106]
[0107]
[0108] Where, q i Indicates the input raw image, I n This is the output of the filter function window, where F represents the filter kernel function selected for the window, and N... n I represents the sum of weights. m The output image is after traversing the side-window filtering window, argmin n∈S This represents the minimum output value after traversing each side window;
[0109] Step 12: Add a 3×3 Gaussian filter to the side window filtering and iterate through the image pixels:
[0110] The two-dimensional Gaussian distribution function is shown below:
[0111]
[0112] x and y are variables in the function, representing the coordinates of a point on the plane; σ is the standard deviation of the Gaussian distribution, determining the width of the distribution; the function describes the distribution of the intensity value of a point on a plane in two directions, that is, the intensity at point (x, y) is more influenced by points closer to that point, and is controlled by the standard deviation σ; the Gaussian distribution function is used to generate the Gaussian filter template; for a two-dimensional discrete Gaussian filter template, it is obtained by discretizing the continuous Gaussian distribution function; the resulting Gaussian filter template matrix is as follows:
[0113]
[0114] The Gaussian template is convolved with the input image, and the center of the filtering window during the traversal process is always aligned with the pixel being processed. Since eight filter edge models are used, the corners of the side windows are aligned with the pixels being processed. Therefore, the eight defined side windows are:
[0115] S1(x1,y1)={(u,v)||ux|≤r,y1-r≤v≤y1,ω U ∈S}
[0116] S2(x1,y1)={(u,v)||ux|≤r,y1≤v≤y1+r,ω D ∈S}
[0117] S3(x1,y1)={(u,v)|x1≤u≤x1+r,|v-y1|≤r,ωR ∈S}
[0118] S4(x1,y1)={(u,v)|x1-r≤u≤x1,|v-y1|≤r,ω L ∈S}
[0119] S5(x1,y1)={(u,v)|x1-r≤u≤x1,y1-r≤v≤r,ω NW ∈S}
[0120] S6(x1,y1)={(u,v)||x1≤u≤x1+r,y1-r≤v≤r,ω NE ∈S}
[0121] S7(x1,y1)={(u,v)|x1≤u≤x1+r,y1≤v≤y1+r,ω SE ∈S}
[0122] S8(x1,y1)={(u,v)|x1-r≤u≤x1,y1≤v≤y1+r,ω SW ∈S}
[0123] In the above formula, S i This represents the side window filtering windows in 8 directions. (x1,y1) represents the coordinates of the pixel being processed, (u,v) represents the effective range coordinates of the side window, and ω represents the side window in each direction. U, D, R, L, NW, NE, SE, and SW represent the eight directions respectively.
[0124] Based on the coordinate range of the eight side windows, calculate the Gaussian kernel template for each side window; obtain the eight filter outputs in the following formula through matrix convolution summation:
[0125]
[0126] in, This represents the output of the Gaussian side-window filter, where Gaussian represents the Gaussian filter kernel. The final output is obtained by minimizing the input and output, as shown below:
[0127]
[0128] In the above formula, Y SWG-Gaussian Represents the Gaussian filter output of the side window, argmin n∈S This represents the minimum output value after traversing each side window. The image after Gaussian filtering by the side windows is shown below. Figure 2 As shown in (c).
[0129] Step 2: Calculate the average value m within the template using the grayscale values X(i,j) of the image pixels. x (i,j), and the difference of squares in the template Furthermore, the high-frequency portion is enhanced, using the standard deviation as the gain value and the mean m. x As the background part, at this time [x(k,l)-m x [i,j] represents the high-frequency detail portion; f is obtained by performing a gain product on the high-frequency bytes. h (i,j).
[0130] Specifically, high-frequency image enhancement involves the following steps:
[0131] Step 21: Subtract the low-frequency image after Gaussian filtering from the original image to obtain the high-frequency component f. H ;
[0132] With pixel x(i,j) in the original image as the center, and within a window of size (2n+1)*(2n+1), the local mean and variance are expressed as follows:
[0133]
[0134]
[0135] In the above formula, m x (i,j) represents the local mean. Let x(i,j)-m represent the variance, n be the window radius, and i and j be the coefficients related to the radius; x (i,j) represents the high-frequency detail portion;
[0136] Step 22: Perform a gain product on the high-frequency image to obtain the enhanced high-frequency edge image f. HG :
[0137] f HG =G[x(i,j)-m x (i,j)]
[0138]
[0139] Where G is the gain expression, σ x (i,j) represents the variance coefficient, and D is a constant coefficient, which is 0.1 in this embodiment.
[0140] In the high-frequency region of the image, the local mean square error is relatively large, resulting in a smaller gain value. After gaining, the image avoids being overly bright. However, in smooth regions of the image, the local mean square error is very small, leading to a larger gain value, which may amplify noise signals. Therefore, in this embodiment, the maximum gain is constrained, limiting the maximum value of G to below 10 to achieve better image quality.
[0141] Step 3: Fuse the background and high-frequency image to obtain the enhanced image output.
[0142] f G (i,j)=Y SWG-Gaussian(i,j) +f HG
[0143] Step 4: Calculate the magnitude and direction of the gradient using first-order finite difference.
[0144] The gradient value is approximated using first-order finite difference. The Sobel gradient operators in the x and y directions of the image are as follows:
[0145]
[0146]
[0147] The gradients in the x and y directions at the center point of the window are respectively:
[0148] P x = (a2 + 2a3 + a4) - (a0 + 2a7 + a6)
[0149] P y = (a0 + 2a1 + a2) - (a6 + 2a5 + a4)
[0150] The gradient direction at the center point of the window is:
[0151]
[0152] Step 5: Perform non-maximum suppression on the gradient magnitude, retaining only the pixels with the maximum gradient magnitude.
[0153] In a 3x3 window matrix, if the center point a is the largest point max(m,n,a) among m,n,a in the same direction in the neighborhood, point a is retained and used as a potential edge point B(i,j); if it is not the largest point, it is suppressed.
[0154]
[0155] When the direction is selected between two adjacent pixels, a linear interpolation algorithm is used to obtain the two points m and n that need to be compared. The above preservation and suppression operation is repeated on the interpolated points m and n to extract more accurate edge information.
[0156] Step 6: Perform global threshold segmentation on the image using adaptive coefficients. The selected thresholds are denoted as TL and TH. Based on the thresholds, edge pixels are divided into strong edges and weak edges. Weak edge pixels are edge-linked, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels. Finally, the edge detection image is obtained.
[0157] In the following formula, the inter-class variance σ 2When taking the maximum value, the threshold level value is obtained:
[0158] σ 2 =p1*p2*(m1-m2) 2
[0159] In the above formula, m1 and m2 represent the mean values of the threshold TH dividing the image into two regions, and p1 and p2 represent the probability of a pixel being assigned to one of the two regions.
[0160] The selected dual thresholds are:
[0161] TL = max(0, (1.0 - sigma)level),
[0162] TH=max(255,(1.0+sigma)level,
[0163] In the above formula, TL is the low threshold, TH is the high threshold, and sigma is taken as an empirical value of 0.33;
[0164] Pixels with gradient magnitudes greater than the high threshold are marked as strong edge pixels, pixels with gradient magnitudes less than the low threshold are marked as non-edge pixels, and pixels with gradient magnitudes between the upper and lower thresholds are marked as weak edge pixels; edge linking is performed on weak edge pixels, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels.
[0165] Finally, the pixels marked as edge pixels are extracted to obtain the edge information of the image.
[0166] The embodiments described above do not constitute a limitation on the scope of protection of this application.
Claims
1. An edge detection method based on fused image enhancement, characterized in that, The method includes: Step 1: Use side-window Gaussian filtering with multiple edge models to perform traversal calculations and match them with the pixels to be calculated to obtain the corresponding new pixel values. When the difference between the new pixel value and the original pixel value is the smallest, the edge shape of the corresponding filter is closest to the edge shape of the block where the pixel to be calculated is located. At this time, the background image obtained has the least weakening of pixels at the edge. Step 2, using the grayscale values of image pixels Calculate the mean within the template and the difference of squares in the template This further enhances the high-frequency components, using the standard deviation as the gain value and the mean value... As a background part, the high-frequency byte portion is obtained by performing a gain product. ; Step 3: Fuse the background and high-frequency images to obtain the enhanced image output; Step 4: Calculate the magnitude and direction of the gradient using first-order finite difference; Step 5: Perform non-maximum suppression on the gradient magnitude, retaining only the pixels with the maximum gradient magnitude; Step 6: Perform global thresholding on the image using adaptive coefficients, and denot the selected threshold as follows. The edge pixels are divided into strong edges and weak edges according to the threshold. Weak edge pixels are edge linked, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels, thus obtaining the edge detection image.
2. The method according to claim 1, characterized in that, Step 1: A Gaussian filter is used to perform traversal calculations using multiple edge models, and each model is matched with the pixel to be calculated to obtain the corresponding new pixel value, including: The side-window Gaussian filter traversal calculation includes: Step 11, Construct side window filtering: Construct 8 local side windows; Among them, the rotation angle of the side window ,in The side window radius ρ takes a value between {0, r}; by adjusting the values of θ and ρ, side windows with different tilt angles are generated; based on the position of the processed pixel relative to the sub-window, local side windows in 8 directions are selected to traverse edge pixels in different directions. When ρ=r, the processing pixels of the four types of side windows (upper (U), lower (D), left (L), and right (R)) are located on the edges of the local side windows. The side windows are represented as follows: , , , When ρ=0, the four side windows—Northwest (NW), Southwest (SW), Southeast (SE), and Northeast (NE)—are located on the four edges of the filter window, respectively. , , , To represent; that is, the final set of 8 filtering side windows is W={U, D, R, L, NW, SW, SE, NE}; the side window filtering output results are shown below: ; ; in, This indicates the input original image. This is the output of the filter function window, where F indicates the filter kernel function selected for the window. Represents the sum of weights, The output image is after the side window filtering window has been traversed. This represents the minimum output value after traversing each side window; Step 12, add 3 to the side window filter.
3. Gaussian filter, traversing image pixels: The two-dimensional Gaussian distribution function is shown below: ; x and y are variables in the function, representing the coordinates of a point on the plane; σ is the standard deviation of the Gaussian distribution, determining the width of the distribution; the function describes the distribution of the intensity value of a point on a plane in two directions, that is, the intensity at point (x, y) is more influenced by points closer to that point, and is controlled by the standard deviation σ; the Gaussian distribution function is used to generate the Gaussian filter template; for a two-dimensional discrete Gaussian filter template, it is obtained by discretizing the continuous Gaussian distribution function; the resulting Gaussian filter template matrix is as follows: ; The Gaussian template is convolved with the input image, and the center of the filtering window during the traversal process is always aligned with the pixel being processed; the corners of the side windows are aligned with the pixels being processed; thus, the eight side windows are defined as follows: ; ; ; ; ; ; ; ; In the formula This represents the side window filtering windows in eight directions, where (x1, y1) represents the coordinates of the pixel being processed, and (u, v) represents the effective range coordinates of the side window. The table indicates the side windows in each direction, with U, D, R, L, NW, NE, SE, and SW representing eight directions respectively. Based on the coordinate range of the eight side windows, calculate the Gaussian kernel template for each side window; obtain the eight filter outputs in the following formula through matrix convolution summation: ; in, This represents the output result of the Gaussian side window filter. This represents the Gaussian filter kernel; the final output is obtained by minimizing the input and output, as shown below: ; In the above formula This represents the Gaussian filter output from the side window. This represents the minimum output value after traversing each side window.
3. The method according to claim 1, characterized in that, Step 2, enhancing the high-frequency components includes: Step 21: Subtract the low-frequency image after Gaussian filtering from the original image to obtain the high-frequency component. ; pixels in the original image The local mean and variance of a region centered at a point and with a window size of (2n+1)*(2n+1) are expressed as follows: ; ; In the above formula, Represents the local mean. Represents variance, n is the window radius, and i and j are coefficients related to the radius; at this time... That is, the high-frequency details; Step 22: Perform a gain product on the high-frequency image to obtain the enhanced high-frequency edge image. : ; ; Where G is the gain expression. This represents the variance coefficient, where D is a constant coefficient with a value of 0.
1.
4. The method according to claim 1, characterized in that, Step 3: Fuse the background and high-frequency image to obtain the enhanced image output, including: ; in, For the enhanced image output.
5. The method according to claim 1, characterized in that, Step 4: Calculate the magnitude and direction of the gradient using first-order finite difference, including: The gradient value is approximated using first-order finite difference. The Sobel gradient operators in the x and y directions of the image are as follows: ; ; The gradients in the x and y directions at the center point of the window are respectively: ; ; The gradient direction at the center point of the window is: 。 6. The method according to claim 1, characterized in that, Step 5: Perform non-maximum suppression on the gradient magnitude, retaining only the pixels with the maximum gradient magnitude, including: In a 3x3 window matrix, if the center point a is in the same direction in the neighborhood... The largest point in the middle Point a is retained and used as a potential edge point. If it is not the maximum value, then suppress it; ; When the direction is chosen between two adjacent pixels, a linear interpolation algorithm is used to obtain the value to be compared. Two points, regarding the interpolated result Point repetition retains the suppression operation.
7. The method according to claim 1, characterized in that, Step 6: Perform global thresholding on the image using adaptive coefficients, and denot the selected threshold as follows. Based on a threshold, edge pixels are distinguished into strong edges and weak edges. Weak edge pixels are edge-linked, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels, ultimately yielding an edge detection image, including: Between-class variance When taking the maximum value, the threshold is obtained. value: ; In the above formula, , Represents threshold Divide the image into two regions and assign their respective means. , This indicates the probability that a pixel is divided into two regions; The selected dual thresholds are: ; ; In the above formula, For low threshold, For high threshold, Take the empirical value of 0.33; Pixels with gradient magnitudes greater than the high threshold are marked as strong edge pixels, pixels with gradient magnitudes less than the low threshold are marked as non-edge pixels, and pixels with gradient magnitudes between the upper and lower thresholds are marked as weak edge pixels; edge linking is performed on weak edge pixels, and weak edge pixels adjacent to strong edge pixels are marked as edge pixels. Finally, the pixels marked as edge pixels are extracted to obtain the edge information of the image.
