Adaptive edge detection method fusing three-dimensional frequency domain and spatial domain information

Through an adaptive edge detection method that fuses three-dimensional frequency domain and spatial domain information, combined with hard threshold filtering and full variational guided filtering, the problem of inaccurate edge detection in the prior art is solved, and more efficient noise suppression and edge extraction effects are achieved.

CN119722717APending Publication Date: 2025-03-28HENAN POLYTECHNIC UNIV +1
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411769452.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

Existing edge detection methods have shortcomings in denoising and threshold selection, making it difficult to accurately and completely detect edges, especially when complex backgrounds or multiple noise sources.

Method used

Adaptive edge detection method that fuses three-dimensional frequency domain and spatial domain information is used to denoise through the combination of frequency domain and spatial domain, hard threshold filtering and improved fully variable-guided filtering are used, and adaptive threshold values ​​are calculated in combination with the maximum inter-class variance method to filter gradient values.

Benefits of technology

More accurate edge detection is achieved, and important structural information can be maintained while enhancing image details, avoiding excessive amplification of noise, and improving the robustness and adaptability of the detection effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119722717A_ABST
    Figure CN119722717A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of edge detection, and particularly discloses a self-adaptive edge detection method fusing three-dimensional frequency domain and spatial domain information, which comprises the following steps of: fusing a spatial domain, frequency and information, and denoising an input image in combination with improved total variation guided filtering; and then calculating the gradient of each pixel point, screening and extracting the pixel points in combination with an adaptive threshold, and obtaining a final edge through non-maximum suppression and 8-neighborhood screening. According to the invention, the noise suppression capability is improved, and the influence of the smoothing process on the edge is reduced; and aiming at the threshold selection problem of a traditional edge extraction algorithm, the maximum between-class variance method is used for simultaneously calculating two adaptive thresholds and screening gradient values, so that manual intervention is reduced, the detection effect is improved, the edge can be accurately detected, and important structural information can be kept and excessive amplification of noise can be avoided while image details are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of edge detection, and in particular relates to an adaptive edge detection method that integrates three-dimensional frequency domain and space domain information. Background Art

[0002] Edge detection technology is one of the most basic problems in the fields of computer vision, image processing and photogrammetry, and is widely used in various tasks such as image processing and image understanding, such as image recognition, image segmentation, image retrieval, face recognition, corner detection, road detection, medical imaging and target tracking, etc. Edges simplify the complexity of the algorithm and improve computational efficiency while retaining the feature information of the object.

[0003] Edge detection methods based on gradient changes usually have the following shortcomings: (1) Spatial domain denoising problem. In the task of edge detection, denoising can smooth the image, reduce the local fluctuations caused by noise, and make the real edge more prominent. However, mainstream edge extraction algorithms remove image noise in the spatial domain. In the spatial domain, simple methods such as mean filtering may cause image edges to be blurred and lose detail information. Especially when dealing with complex backgrounds or multiple noise sources, it may be difficult to effectively remove noise by relying solely on spatial domain methods. (2) Threshold selection problem during edge extraction. Fixed thresholds cannot adapt to changes in the image, such as changes in lighting, different contrasts, or noise. The setting of fixed thresholds relies too much on human experience. If the threshold is set too high, some subtle edges may be missed; if it is set too low, a lot of noise may be introduced, resulting in false detection. This will affect the final edge detection effect.

[0004] It can be seen that the existing edge detection methods are difficult to detect edges accurately and completely due to the above problems. Summary of the invention

[0005] In order to address the shortcomings of the prior art, the present invention aims to provide an adaptive edge detection method that integrates three-dimensional frequency domain and spatial domain information. The method integrates the information of the spatial domain and the frequency domain to denoise the image, combines the idea of ​​total variation to improve the guided filtering, improves the noise suppression capability, and reduces the impact of the smoothing process on the edge; and for the threshold selection problem of the traditional edge extraction algorithm, the maximum inter-class variance method is used to simultaneously calculate two adaptive thresholds, screen the gradient value, reduce manual intervention, improve the detection effect, accurately detect the edge, and can maintain important structural information and avoid excessive amplification of noise while enhancing image details.

[0006] In order to achieve the above object, the technical solution adopted by the present invention is:

[0007] An adaptive edge detection method integrating three-dimensional frequency domain and spatial domain information comprises the following steps:

[0008] S1: Use rgb2gray function to convert the input original image into grayscale;

[0009] S2: Frequency domain denoising: First create a 3D group, use 3D Fourier filtering to convert the 3D group to the 3D transform domain, use hard threshold filtering to filter the conversion parameters, and then perform inverse transformation and weighted aggregation to obtain a denoised image;

[0010] S3: Spatial domain denoising: In the spatial domain, the noisy image and the denoised image are input into the guided filtering improved by the total variation idea to denoise;

[0011] S4: Use the Sobel operator to calculate the gradient in the x and y directions;

[0012] S5: Non-maximum suppression: Use non-maximum suppression to filter out non-edge points;

[0013] S6: Calculate the adaptive threshold that divides the total gradient into three categories and screen the gradient value;

[0014] S7: Edge connection: connect the edge points obtained in step S6 to obtain an edge image.

[0015] Furthermore, the frequency domain denoising of the image in step S2 is specifically as follows:

[0016] S2-1: 3D group creation includes the following:

[0017] In the noisy image, first divide the entire image into N*N blocks; then start from the first N1*N1 block of the image and use it as the reference block; use the raster scanning method to select a sliding window in the neighborhood of the reference block each time to find the matching block; each time the sliding window is translated around the reference block; each translation distance is 3 pixels; for each reference block, repeat this process until all reference blocks are matched;

[0018] When measuring the similarity between two blocks, first perform a separable two-dimensional orthogonal transformation on the two blocks on the noisy image, and use the Euclidean distance to measure the distance between the reference block and the matching block, which is defined as follows:

[0019]

[0020] In the formula, represents the distance between the reference block and the matching block, is the Rth matching block of each 3D block, K l is the reference block, l represents the pixel value, N1 is the size of the block, express Normalized two-dimensional linear transformation, K l Normalized two-dimensional linear transformation;

[0021] The set of similar blocks is determined by the following formula:

[0022]

[0023] In the formula, is a collection of blocks similar to the reference block, R is a matching block, X1 is a collection of matching blocks to be searched; τ1 is a pre-set threshold, when the distance is less than the set threshold, it is considered a similar block and is stored in the collection middle;

[0024] Each reference block and its corresponding matching block are stacked to form a three-dimensional group;

[0025] S2-2: Normalized three-dimensional Fourier transform conversion data, including:

[0026] First, a two-dimensional discrete Fourier transform is applied to each two-dimensional image block, and then a one-dimensional discrete Fourier transform is applied to the third dimension after stacking; the mathematical expression of the Fourier transform is:

[0027]

[0028] Among them, F(u,v) and F(u) are transform coefficients; f(x) and f(x,y) are spatial domain samples; e is a natural constant, j is an imaginary unit, M refers to the width of the image in two-dimensional discrete Fourier transform and the length of the signal in one-dimensional discrete Fourier transform; N is the height of the image; u is the frequency index in the x direction in the frequency domain after the transform; v is the frequency index in the y direction in the frequency domain after the transform;

[0029] S2-3: Hard threshold filtering denoising, including:

[0030] The judgment formula for hard threshold filtering is:

[0031]

[0032] In the formula, τ2 is the pre-set threshold, F ′ is the coefficient after hard threshold filtering, F is the coefficient after three-dimensional DFT transformation, |F| is the absolute value of the coefficient after DFT transformation;

[0033] S2-4: Use inverse transform to obtain similar blocks after noise reduction;

[0034] The inverse transform method is: using one-dimensional discrete Fourier transform inverse transform and two-dimensional discrete Fourier transform transform;

[0035] The end result is:

[0036]

[0037] In the formula, F -1 is the inverse transformation, is the collection of similar blocks after processing;

[0038] S2-5: Image weighted aggregation estimation

[0039] The purpose of image weighted aggregation estimation is to restore noisy images based on the redundancy of images. The specific expression is:

[0040]

[0041] Where Y(l) is the estimated value of pixel l, X2 is the collection of all reference blocks, Yes R The weight of the corresponding reference block, l m is a block similar to the reference block, It is a block m Corresponding to the reference block l R The estimated value of is, extracting the two-dimensional filtered block corresponding to the reference block from the inverse transformed data array, is the number of non-zero coefficients after the hard threshold operation, σ 2 is the total sample variance of all blocks covering the position, Is to determine whether pixel x is in block l m The indicator function on .

[0042] Furthermore, the spatial domain denoising in step S3 specifically includes:

[0043] The image denoised in the frequency domain in step S2 is used as the guide image I and the original input image p, and the improved total variation guided filtering is used in the spatial domain to further denoise and smooth the edge of the image; the improved total variation guided filtering process is as follows:

[0044] Input the guide image I and the image to be filtered p, and use the mean filter to calculate the mean of the guide image I and the image to be filtered p in the local window w I and mean p , the cross-correlation mean corr of the product I*p of the guide image and the input image IP And the cross-correlation mean corr of the product I*I of the guide graph I ;

[0045] Then calculate the covariance cov of the guide image I and the image to be filtered p Ip :

[0046] cov IP =corrIP -mean I *mean p ;

[0047] Calculate the variance σ of the bootstrap map I k 2 :

[0048] σ k 2 =corr I -mean I *mean I ;

[0049] In the guided filtering a k and b k The total variation regularization term V is introduced TV , and its calculation formula is as follows:

[0050]

[0051] b k =mean p -a k *mean I ,

[0052] V TV (I) = ∑ i,g |I i+1,g -I i,g |+|I i,g+1 -I g,j |;

[0053] In the formula, λ sf is a pre-set smoothing factor, ∈ is a pre-set regularization parameter; i and g are the indices of the input image I, I i+1,g ,I i,g and I i,g+1 represents the pixel value of the guidance image;

[0054] For coefficient a k and b k Take the average in the window w and get the linear coefficient μ a and μ b ;

[0055] Defined by the guided filter, the filtered image q is obtained:

[0056] q=μ a I+μ b

[0057] The size of the local window w is (2r+1)×(2r+1), and r is a pre-set parameter.

[0058] Furthermore, calculating the gradient in step S4 specifically includes:

[0059] The Sobel gradient operator is used to calculate the gradient value of each pixel in the x direction and the y direction of the image q obtained in step S3. and the gradient value of each pixel At the same time, calculate the gradient direction θ:

[0060]

[0061] Furthermore, step S5 uses non-maximum suppression to filter out non-edge points, including: comparing the gradient strength of the pixel point with the pixel points in the positive and negative directions of its gradient, and retaining the pixel point if the gradient strength is the largest, otherwise suppressing it;

[0062] For more accurate calculation, linear interpolation is usually used between two adjacent pixels that cross the gradient direction through the gradient direction in step S4 to obtain the pixel gradient to be compared.

[0063] Furthermore, step S6 specifically includes the following contents:

[0064] Calculate two adaptive gradient values ​​of the image q1 after processing in step S5; assume that the gradient of the image is between [1, L], and assume that the two adaptive thresholds are T1 and T2 respectively. The double thresholds T1 and T2 divide the pixels in the image into three categories: the first category is composed of pixels with gradient values ​​between [1, T1], the second category is composed of pixels with gradient values ​​between (T1, T2], and the third category is composed of pixels with gradient values ​​between (T2, L]; the specific steps are as follows:

[0065] S6-1: Calculate the average values ​​of three types of gradient values ​​ρ1, ρ2 and ρ3;

[0066] The average value of the three types of gradient values ​​is:

[0067]

[0068]

[0069] In the formula, n represents each gradient value in the image, t n represents the probability of the gradient n, w1, w2, and w3 represent the number of pixels in the three regions respectively;

[0070] S6-2: Calculate the total average gradient of the image;

[0071] The total average gradient u1 of the image is defined as follows:

[0072] u1=ρ1w1+ρ2w2+ρ3w3;

[0073] S6-3: Calculate the inter-class variance of the three categories

[0074] The inter-class variance of the three categories Define the following formula:

[0075]

[0076] S6-4: traverse all possible threshold combinations, and when the inter-class variance in step S4-3 reaches the maximum, determine the best threshold combination;

[0077] S6-5: Filter the image processed in step S5 according to the maximum threshold T1 and the minimum threshold T2 of step S6-4, and retain the pixel values ​​whose gradient values ​​exceed the maximum threshold T1;

[0078] Suppress pixel values ​​whose gradient values ​​are less than the minimum threshold T2;

[0079] S6-6: Edge point connection: further process the pixels filtered in step S6-5; For pixels, the connectivity in the eight neighborhoods of left, right, top, bottom, upper left, lower left, upper right, and lower right determines whether they are edge points; if there is a strong edge point in the connected neighborhood of the edge point, that is, a pixel point with a gradient greater than the highest threshold, the point is marked as an edge point.

[0080] The beneficial effects of the present invention are:

[0081] 1. The present invention can accurately detect the edges with richer details in the image by fusing the spatial domain and frequency domain information for denoising, using hard threshold filtering and improved total variation to guide the filtering information, and by calculating the adaptive threshold to filter the gradient value, thereby extracting accurate edge information.

[0082] 2. The denoising method of the present invention that integrates spatial domain and frequency domain information can make full use of the advantages of both, improve the effect of image denoising, retain more image details, and thus extract more accurate edges. The fusion of spatial domain and frequency domain has the advantages of better noise suppression, more accurate detail retention, and information fusion for image denoising.

[0083] 3. The present invention adopts the idea of ​​block matching when creating a three-dimensional group during frequency domain denoising. The block matching technology gathers similar image blocks together for three-dimensional transformation and filtering, thereby more effectively suppressing noise and retaining image details. Collaborative filtering in the three-dimensional transform domain adopts a nonlinear processing method, which can better retain the edge and texture information of the image by combining and processing similar blocks. At the same time, the hard threshold can better retain the characteristics of the signal when processing high-frequency noise, especially when some important parts of the signal do not want to be weakened.

[0084] 4. The present invention has a strong edge preservation ability and stronger denoising ability when using improved guided filtering for denoising. By introducing the total variation regularization term, the smoothness of the denoised image can be enhanced, the high-frequency components of the noise can be suppressed, and the impact of the smoothing process on the edge can be reduced, thereby improving the visual quality of the image.

[0085] 5. In the edge extraction stage of the present invention, using fixed maximum and minimum thresholds for edge screening may cause some problems, especially when dealing with different lighting conditions, texture complexity or image noise. Modifying these two thresholds to adaptive thresholds has the advantages of strong adaptability, noise robustness, improved edge detection accuracy, and reduced manual intervention. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] Figure 1 is a flow chart of the method of the present invention;

[0087] Figure 2 is a matching graph of the reference block of the present invention;

[0088] Figure 3 The present invention uses linear interpolation to obtain a graph that participates in comparing pixel gradients;

[0089] Figure 4 This is a diagram showing edge points determined by 8 neighborhoods of the present invention;

[0090] Figure 5 The present invention adds 0.1% Gaussian noise to the original image to extract the edge and then process the result image;

[0091] Figure 6 This is a post-processing result diagram of the present invention in which 10% Gaussian noise is added to the original image to extract the edge. DETAILED DESCRIPTION

[0092] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention and are not intended to limit the scope of use of the present invention.

[0093] like Figure 1-4 As shown, the present invention proposes an adaptive edge detection method that integrates three-dimensional frequency domain and spatial domain information, integrates spatial domain and frequency information, and combines improved total variation guided filtering to denoise the input image; then calculates the gradient of each pixel point, combines adaptive threshold screening to extract pixel points, and obtains the final edge through non-maximum suppression and 8-neighborhood screening. The present invention has the characteristics of accurately detecting edges with richer details in the image. It denoises by integrating spatial domain and frequency domain information, uses hard threshold filtering and improved total variation guided filtering information, and calculates adaptive threshold filtering gradient values ​​to extract accurate edge information. Specifically, it includes the following steps:

[0094] Step S1: Use the rgb2gray function to perform grayscale conversion on the input original image.

[0095] Step S2: frequency domain denoising: first create a three-dimensional group, use three-dimensional Fourier filtering to convert the three-dimensional group to a three-dimensional transform domain, use hard threshold filtering to filter the conversion parameters, and then perform inverse transformation and weighted aggregation to obtain a denoised image.

[0096] Frequency domain denoising of images includes: 3D group creation, normalized 3D Fourier transform conversion data, hard threshold filtering denoising, inverse transformation and weighted aggregation estimation. Specifically:

[0097] S2-1: 3D group creation includes the following:

[0098] In the noisy image, first divide the entire image into N*N blocks; then start from the first N1*N1 block of the image and use it as the reference block; use the raster scanning method to select a sliding window in the neighborhood of the reference block each time to find the matching block; each time the sliding window translates around the reference block; each translation distance is 3 pixels; for each reference block, repeat this process until all reference blocks are matched.

[0099] When measuring the similarity between two blocks, first perform a separable two-dimensional orthogonal transformation on the two blocks on the noisy image, and use the Euclidean distance to measure the distance between the reference block and the matching block, which is defined as follows:

[0100]

[0101] In the formula, represents the distance between the reference block and the matching block, is the Rth matching block of each 3D block, K l is the reference block, l represents the pixel value, N1 is the size of the block, express Normalized two-dimensional linear transformation, K l Normalized two-dimensional linear transformation;

[0102] The set of similar blocks is determined by the following formula:

[0103]

[0104] In the formula, is a collection of blocks similar to the reference block, R is a matching block, X1 is a collection of matching blocks to be searched, τ1 is a pre-set threshold, and when the distance is less than the set threshold, it is considered a similar block and is stored in the collection middle;

[0105] Each reference block and its corresponding matching block are stacked to form a 3D group.

[0106] S2-2: The role of normalized three-dimensional linear transformation is to use the sparsity in the frequency domain to disperse the noise energy into more coefficients, while the signal energy is concentrated in fewer coefficients, thus providing a favorable basis for subsequent denoising processing; Normalized three-dimensional Fourier transform conversion data, specifically including:

[0107] First, a two-dimensional discrete Fourier transform is applied to each two-dimensional image block, and then a one-dimensional discrete Fourier transform is applied to the third dimension after stacking; the mathematical expression of the Fourier transform is:

[0108]

[0109] Among them, F(u,v) and F(u) are transform coefficients; f(x) and f(x,y) are spatial domain samples; e is a natural constant, j is an imaginary unit, M refers to the width of the image in two-dimensional discrete Fourier transform and the length of the signal in one-dimensional discrete Fourier transform; N is the height of the image; u is the frequency index in the x direction in the frequency domain after the transform; v is the frequency index in the y direction in the frequency domain after the transform.

[0110] S2-3: Hard threshold filtering denoising, including:

[0111] The judgment formula for hard threshold filtering is:

[0112]

[0113] In the formula, τ2 is the pre-set threshold, F ′ is the coefficient after hard threshold filtering, F is the coefficient after three-dimensional DFT transformation, and |F| is the absolute value of the coefficient after DFT transformation.

[0114] S2-4: Use inverse transform to obtain similar blocks after noise reduction;

[0115] The role of inverse transformation is to restore the denoised data to the spatial domain, so that the final output denoised image can retain the structure and details of the original image to the greatest extent; the inverse transformation method is: use one-dimensional discrete Fourier transform inverse transformation and two-dimensional discrete Fourier transform transformation;

[0116] The end result is:

[0117]

[0118] In the formula, F -1 is the inverse transformation, is the collection of similar blocks after processing;

[0119] S2-5: Image weighted aggregation estimation

[0120] The purpose of image weighted aggregation estimation is to restore noisy images based on the redundancy of images. The specific expression is:

[0121]

[0122] Where Y(l) is the estimated value of pixel l, X2 is the collection of all reference blocks, is the collection of blocks similar to the reference block, Yes R The weight of the corresponding reference block, l m is a block similar to the reference block, It is a block m Corresponding to the reference block l R The estimated value of is, extracting the two-dimensional filtered block corresponding to the reference block from the inverse transformed data array, is the number of non-zero coefficients after the hard threshold operation, σ 2 is the total sample variance of all blocks covering the position, Is to determine whether pixel l is in block l m The indicator function on .

[0123] The present invention adopts the idea of ​​block matching when creating a three-dimensional group during frequency domain denoising. The block matching technology gathers similar image blocks together for three-dimensional transformation and filtering, thereby being able to more effectively suppress noise and retain image details. Furthermore, three-dimensional transform domain collaborative filtering adopts a nonlinear processing method, which can better retain the edge and texture information of the image by combining and processing similar blocks. At the same time, the hard threshold can better retain the characteristics of the signal when processing high-frequency noise, especially when some important parts of the signal do not want to be weakened.

[0124] Step S3: Denoising in spatial domain: In the spatial domain, the noisy image and the image after primary denoising are input into the guided filtering improved by the total variation idea to denoise.

[0125] The denoising method of the present invention that combines spatial domain and frequency domain information can make full use of the advantages of both, improve the effect of image denoising, retain more image details, and thus extract more accurate edges. The advantages of combining spatial domain and frequency domain for image denoising are:

[0126] ① Better noise suppression: In the frequency domain, certain types of noise (such as high-frequency noise) can be removed more effectively. By combining the detail preservation ability of the spatial domain and the noise suppression ability of the frequency domain, better denoising effects can be achieved.

[0127] ② More accurate detail preservation: Spatial domain filtering may cause edge blurring, while frequency domain filtering can retain the edge features of the image while removing noise. Combining the two can make the denoised image clearer.

[0128] ③ Information fusion: In some applications, the information in the spatial domain and the frequency domain can be complementary. By fusing these two types of information, higher quality denoised images can be generated, especially when dealing with complex scenes.

[0129] Spatial domain denoising specifically includes:

[0130] The image denoised in the frequency domain in step S2 is used as the guide image I and the original input image p, and the improved total variation guided filtering is used in the spatial domain to further denoise and smooth the edges of the image. The improved total variation guided filtering process is as follows:

[0131] Input the guide image I and the image to be filtered p, and use the mean filter to calculate the mean of the guide image I and the image to be filtered p in the local window w I and mean p , the cross-correlation mean corr of the product I*p of the guide image and the input image IP And the cross-correlation mean corr of the product I*I of the guide graph I ;

[0132] Then calculate the covariance cov of the guide image I and the image to be filtered p Ip :

[0133] cov IP =corr IP -mean I *mean p ;

[0134] Calculate the variance σ of the bootstrap map I k 2 :

[0135] σ k 2 =corr I -mean I *mean I ;

[0136] In the guided filtering a k and b k The total variation regularization term V is introduced TV , and its calculation formula is as follows:

[0137]

[0138] b k =mean p-a k *mean I ,

[0139] V TV (I) = ∑ i,g |I i+1,g -I i,g |+|I i,g+1 -I i,g |;

[0140] In the formula, λ sf is a pre-set smoothing factor, ∈ is a pre-set regularization parameter; i and g are the indices of the input image I, I i+1,g ,I i,g and I i,g+1 represents the pixel value of the guidance image;

[0141] For coefficient a k and b k Take the average in the window w and get the linear coefficient μ a and μ b ;

[0142] Defined by the guided filter, the filtered image q is obtained:

[0143] q=μ a I+μ b

[0144] The size of the local window w is (2r+1)×(2r+1), and r is a pre-set parameter.

[0145] The advantages of using improved guided filtering for denoising in the present invention are:

[0146] ① Strong edge preservation ability: The idea of ​​guided filtering is to use a guide image I to generate weight W, and process the input image p to obtain the output image q, so that the gradient of the output image is similar to the guide image, but the grayscale is similar to the input image, see the following formula:

[0147]

[0148] Weight W ig (I) is only related to the guide image I. The guided filtering assumes that the output image and the guide image are a linear model locally. The expression of the weight is shown in the following formula:

[0149]

[0150] Where w is the window size and k(i,g) is the window w k The index set related to both pixel i and pixel g, l i and I gis the window w centered at pixel k in the guidance image k The intensity value of the inner pixel, μ k is the window w k The mean value, σ 2 k is the window w k The variance of

[0151] From the above formula, we know that when I i and I g On both sides of the boundary, (I i -μ k ) and (I g -μ k ) have different signs, otherwise they have the same sign. The weight value on both sides of the boundary will be much smaller than the weight value on one side of the boundary. This means that the pixels on both sides of the edge are almost not averaged together. In this way, the pixels in the flat area have a larger weight and a significant smoothing effect. In this area, the guided filtering is equivalent to the mean filtering; while the pixels on both sides of the edge have a smaller weight and a weaker smoothing effect, which can also maintain the edge.

[0152] ② Strong denoising ability: The introduction of the total variation regularization term can enhance the smoothness of the denoised image. It can suppress the high-frequency components of the noise and reduce the impact of the smoothing process on the edges, thereby improving the visual quality of the image.

[0153] Step S4: Calculate the gradients in the x and y directions using the Sobel operator. Specifically, it includes:

[0154] The Sobel gradient operator is used to calculate the gradient value of each pixel in the x direction and the y direction of the image q obtained in step S3. and the gradient value of each pixel At the same time, calculate the gradient direction θ:

[0155]

[0156] Step S5: Non-maximum suppression: Use non-maximum suppression to filter out non-edge points.

[0157] Compare the gradient strength of the pixel with that of the pixels in the positive and negative directions of its gradient. If the pixel has the largest gradient strength, it is retained; otherwise, it is suppressed.

[0158] For more accurate calculation, linear interpolation is usually used between two adjacent pixels that cross the gradient direction in the gradient direction in step S4 to obtain the pixel gradient to be compared.

[0159] Step S6: Calculate the adaptive threshold for dividing the total gradient into three categories and filter the gradient value. Specifically, it includes the following contents:

[0160] Calculate two adaptive gradient values ​​of the image q1 after processing in step S5; assume that the gradient of the image is between [1, L], and assume that the two adaptive thresholds are T1 and T2 respectively. The double thresholds T1 and T2 divide the pixels in the image into three categories: the first category is composed of pixels with gradient values ​​between [1, T1], the second category is composed of pixels with gradient values ​​between (T1, T2], and the third category is composed of pixels with gradient values ​​between (T2, L]; the specific steps are as follows:

[0161] S6-1: Calculate the average values ​​of three types of gradient values ​​ρ1, ρ2 and ρ3;

[0162] The average value of the three types of gradient values ​​is:

[0163]

[0164] In the formula, n represents each gradient value in the image, t n represents the probability of the gradient n, w1, w2, and w3 represent the number of pixels in the three regions respectively;

[0165] S6-2: Calculate the total average gradient of the image;

[0166] The total average gradient u1 of the image is defined as follows:

[0167] u1=ρ1w1+ρ2w2+ρ3w3;

[0168] S6-3: Calculate the inter-class variance of the three categories

[0169] The inter-class variance of the three categories Define the following formula:

[0170]

[0171] S6-4: traverse all possible threshold combinations, and when the inter-class variance in step S4-3 reaches the maximum, determine the best threshold combination;

[0172] S6-5: Filter the image processed in step S5 according to the maximum threshold T1 and the minimum threshold T2 of step S6-4, and retain the pixel values ​​whose gradient values ​​exceed the maximum threshold T1;

[0173] Suppress pixel values ​​whose gradient values ​​are less than the minimum threshold T2;

[0174] S6-6: Edge point connection: further process the pixels filtered in step S6-5; For pixels, the connectivity within the 8-neighborhood (left, right, top, bottom, top left, bottom left, top right, bottom right) is used to determine whether they are edge points; if there is a strong edge point (i.e., a pixel whose gradient is greater than the highest threshold) in the connected neighborhood of the edge point, the point is marked as an edge point.

[0175] In the edge extraction stage, using fixed maximum and minimum thresholds for edge screening may cause some problems, especially when dealing with different lighting conditions, texture complexity or image noise. The present invention modifies these two thresholds into adaptive thresholds, which has the following advantages:

[0176] ① Strong adaptability: The adaptive threshold can automatically adjust according to the local features and changes of the image, and can more effectively process areas of different brightness and contrast. This means that under the same algorithm, different parts of the image can have different thresholds, thereby better capturing edge details.

[0177] ② Noise robustness: Adaptive thresholds can better cope with noise problems. Fixed thresholds may lead to false detection of edges or neglect of real edges in noisy areas, while adaptive thresholds can be adjusted according to local image features to reduce the occurrence of such situations.

[0178] ③ Improve the accuracy of edge detection: By dynamically calculating the threshold, the adaptive method can improve the accuracy of edge detection, reduce false detection and missed detection, and make the extracted edges more accurate.

[0179] ④ Reduce manual intervention: The adaptive threshold method reduces the dependence on manual experience. The processing of different scenes and images no longer requires manual adjustment of the threshold, which reduces the complexity of operation and improves processing efficiency.

[0180] Step S7: Edge connection: Connect the edge points obtained in step S6 to obtain an edge image.

[0181] In order to verify the effectiveness of the proposed edge extraction algorithm, the present invention adds 0.1% and 10% Gaussian noise to the original image and extracts the edge of the image. The processing results are shown in Figure 5 and Figure 6 .

[0182] from Figure 6 It can be seen that the edge detection algorithm proposed in the present invention correctly detects more edge details. This is because the proposed detection algorithm uses adaptive edge extraction and retains more image details.

[0183] The adaptive edge detection method that integrates three-dimensional frequency domain and spatial domain information proposed in the present invention integrates the information of spatial domain and frequency domain to denoise the image, and improves the guided filtering by combining the idea of ​​total variation, thereby improving the noise suppression capability and reducing the influence of the smoothing process on the edge; and in view of the threshold selection problem of the traditional edge extraction algorithm, the maximum inter-class variance method is used to simultaneously calculate two adaptive thresholds, screen the gradient value, reduce manual intervention, improve the detection effect, accurately detect the edge, and can maintain important structural information while enhancing the image details and avoid excessive amplification of the noise.

[0184] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. An adaptive edge detection method integrating three-dimensional frequency domain and spatial domain information, characterized in that: The following steps are involved: S1: Use rgb2gray function to convert the input original image into grayscale; S2: Frequency domain denoising: First create a 3D group, use 3D Fourier filtering to convert the 3D group to the 3D transform domain, use hard threshold filtering to filter the conversion parameters, and then perform inverse transformation and weighted aggregation to obtain a denoised image; S3: Spatial domain denoising: In the spatial domain, the noisy image and the denoised image are input into the guided filtering improved by the total variation idea to denoise; S4: Use the Sobel operator to calculate the gradient in the x and y directions; S5: Non-maximum suppression: Use non-maximum suppression to filter out non-edge points; S6: Calculate the adaptive threshold that divides the total gradient into three categories and screen the gradient value; S7: Edge connection: connect the edge points obtained in step S6 to obtain an edge image.

2. The adaptive edge detection method for fusing three-dimensional frequency domain and spatial domain information according to claim 1, characterized in that: In step S2, the image is subjected to frequency domain primary denoising as follows: S2-1: 3D group creation includes the following: In the noisy image, first divide the entire image into N*N blocks; then start from the first N1*N1 block of the image and use it as the reference block; use the raster scanning method to select a sliding window in the neighborhood of the reference block each time to find the matching block; each time the sliding window is translated around the reference block; each translation distance is 3 pixels; for each reference block, repeat this process until all reference blocks are matched; When measuring the similarity between two blocks, first perform a separable two-dimensional orthogonal transformation on the two blocks on the noisy image, and use the Euclidean distance to measure the distance between the reference block and the matching block, which is defined as follows: In the formula, represents the distance between the reference block and the matching block, is the Rth matching block of each 3D block, K l is the reference block, l represents the pixel value, N1 is the size of the block, express Normalized two-dimensional linear transformation, θ 2D (K l ) represents K l Normalized two-dimensional linear transformation; The set of similar blocks is determined by the following formula: In the formula, is a collection of blocks similar to the reference block, R is a matching block, X1 is a collection of matching blocks to be searched; τ1 is a pre-set threshold, when the distance is less than the set threshold, it is considered a similar block and is stored in the collection middle; Each reference block and its corresponding matching block are stacked to form a three-dimensional group; S2-2: Normalized three-dimensional Fourier transform conversion data, including: First, a two-dimensional discrete Fourier transform is applied to each two-dimensional image block, and then a one-dimensional discrete Fourier transform is applied to the third dimension after stacking; the mathematical expression of the Fourier transform is: Among them, F(u,v) and F(u) are transform coefficients; f(x) and f(x,y) are spatial domain samples; e is a natural constant, j is an imaginary unit, M refers to the width of the image in two-dimensional discrete Fourier transform and the length of the signal in one-dimensional discrete Fourier transform; N is the height of the image; u is the frequency index in the x direction in the frequency domain after the transform; v is the frequency index in the y direction in the frequency domain after the transform; S2-3: Hard threshold filtering denoising, including: The judgment formula for hard threshold filtering is: Where τ2 is a preset threshold, F′ is the coefficient after hard threshold filtering, F is the coefficient after three-dimensional DFT transformation, and |F| is the absolute value of the coefficient after DFT transformation; S2-4: Use inverse transform to obtain similar blocks after noise reduction; The inverse transform method is: using one-dimensional discrete Fourier transform inverse transform and two-dimensional discrete Fourier transform transform; The end result is: In the formula, F -1 is the inverse transformation, is the collection of similar blocks after processing; S2-5: Image weighted aggregation estimation The purpose of image weighted aggregation estimation is to restore noisy images based on the redundancy of images. The specific expression is: Where Y(l) is the estimated value of pixel l, X2 is the collection of all reference blocks, and ω xR Yes R The weight of the corresponding reference block, l m is a block similar to the reference block, It is a block m Corresponding to the reference block l R The estimated value of is, extracting the two-dimensional filtered block corresponding to the reference block from the inverse transformed data array, is the number of non-zero coefficients after the hard threshold operation, σ 2 is the total sample variance of all blocks covering the position, Is to determine whether pixel l is in block l m The indicator function on .

3. The adaptive edge detection method for fusing three-dimensional frequency domain and spatial domain information according to claim 1, characterized in that: The spatial domain denoising in step S3 specifically includes: The image denoised in the frequency domain in step S2 is used as the guide image I and the original input image p, and the improved total variation guided filtering is used in the spatial domain to further denoise and smooth the edge of the image; the improved total variation guided filtering process is as follows: Input the guide image I and the image to be filtered p, and use the mean filter to calculate the mean of the guide image I and the image to be filtered p in the local window w I and mean p , the cross-correlation mean corr of the product I*p of the guide image and the input image IP And the cross-correlation mean corr of the product I*I of the guide graph I ; Then calculate the covariance cov of the guide image I and the image to be filtered p Ip : cov IP =corr IP -mean I *mean p ; Calculate the variance σ of the bootstrap map I k 2 : σ k 2 =odd I -mean I *mean I ; In the guided filtering a k and b k The total variation regularization term V is introduced TV , and its calculation formula is as follows: b k =mean p -a k *mean I , V TV (I)=∑ i,g |I i+1,g -I i,g |+|I i,g+1 -I i,g |; In the formula, λ sf is a pre-set smoothing factor, ∈ is a pre-set regularization parameter; i and g are the indices of the input image I, I i+1,g ,I i,g and I i,g+1 represents the pixel value of the guidance image; For coefficient a k and b k Take the average in the window w and get the linear coefficient μ a and μ b ; Defined by the guided filter, the filtered image q is obtained: q=μ a ·I+μ b The size of the local window w is (2r+1)×(2r+1), and r is a pre-set parameter.

4. The adaptive edge detection method for fusing three-dimensional frequency domain and spatial domain information according to claim 3, characterized in that: The calculation of the gradient in step S4 specifically includes: The Sobel gradient operator is used to calculate the gradient value of each pixel in the x direction and the y direction of the image q obtained in step S3. and the gradient value of each pixel At the same time, calculate the gradient direction θ:

5. The adaptive edge detection method for fusing three-dimensional frequency domain and spatial domain information according to claim 1, characterized in that: Step S5 uses non-maximum suppression to filter out non-edge points, including: comparing the gradient strength of the pixel point with the pixel points in the positive and negative directions of its gradient, and retaining the pixel point if the gradient strength is the largest, otherwise suppressing it; For more accurate calculation, linear interpolation is usually used between two adjacent pixels that cross the gradient direction in the gradient direction in step S4 to obtain the pixel gradient to be compared.

6. The adaptive edge detection method for fusing three-dimensional frequency domain and spatial domain information according to claim 5, characterized in that: Step S6 specifically includes the following contents: Calculate two adaptive gradient values ​​of the image q1 after processing in step S5; assume that the gradient of the image is between [1, L], and assume that the two adaptive thresholds are T1 and T2 respectively. The double thresholds T1 and T2 divide the pixels in the image into three categories: the first category is composed of pixels with gradient values ​​between [1, T1], the second category is composed of pixels with gradient values ​​between (T1, T2], and the third category is composed of pixels with gradient values ​​between (T2, L]; the specific steps are as follows: S6-1: Calculate the average values ​​of three types of gradient values ​​ρ1, ρ2 and ρ3; The average value of the three types of gradient values ​​is: In the formula, n represents each gradient value in the image, t n represents the probability of the gradient n, w1, w2, and w3 represent the number of pixels in the three regions respectively; S6-2: Calculate the total average gradient of the image; The total average gradient u1 of the image is defined as follows: u1=ρ1w1+ρ2w2+ρ3w3; S6-3: Calculate the inter-class variance of the three categories The inter-class variance of the three categories Define the following formula: S6-4: traverse all possible threshold combinations, and when the inter-class variance in step S4-3 reaches the maximum, determine the best threshold combination; S6-5: Filter the image processed in step S5 according to the maximum threshold T1 and the minimum threshold T2 of step S6-4, and retain the pixel values ​​whose gradient values ​​exceed the maximum threshold T1; Suppress pixel values ​​whose gradient values ​​are less than the minimum threshold T2; S6-6: Edge point connection: further process the pixels filtered in step S6-5; For pixels, the connectivity in the eight neighborhoods of left, right, top, bottom, upper left, lower left, upper right, and lower right determines whether they are edge points; if there is a strong edge point in the connected neighborhood of the edge point, that is, a pixel point with a gradient greater than the highest threshold, the point is marked as an edge point.

Citation Information

Cited By

  • Transistor detection image correction and optimization method based on multiple dimensions

    CN119941588A

  • Method and system for rapidly screening endomycetes in peanuts

    CN119992539A

  • Infrared image noise reduction method and system for gas leakage detection

    CN121504759A