An edge detection method, device and equipment for an image and a storage medium

By employing structure-preserving filtering and adaptive parameter mapping for edge detection, the accuracy and robustness issues of edge detection in complex backgrounds are addressed, achieving stable and clean edge information output. This method is suitable for scenarios such as industrial vision inspection, robot-guided positioning, and weld recognition.

CN122089768APending Publication Date: 2026-05-26HEBEI UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HEBEI UNIV OF TECH
Filing Date
2026-02-05
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing edge detection technologies are inaccurate in complex textures and noisy backgrounds, lack robustness, struggle to output stable, clean, and connected edge information, have weak adaptive capabilities, and rely on manual parameter adjustment.

Method used

A structure-preserving filter is used to generate a smooth image. An adaptive parameter mapping is constructed based on the statistical properties of the first-order gradient magnitude map. Edge detection is performed using a fractal-fractional Sobel convolution kernel. Finally, a binary edge map is output through an adaptive global thresholding and double-threshold hysteresis connection strategy.

Benefits of technology

It improves the accuracy and stability of edge detection in complex backgrounds, reduces the reliance on manual parameter adjustment, enhances adaptability to scenes with uneven lighting and local contrast changes, and outputs stable, clean, and accurately positioned edge information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122089768A_ABST
    Figure CN122089768A_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for edge detection of images, relating to the field of image edge detection technology. The method includes: acquiring an input image and performing structure-preserving filtering on the input image to obtain a smoothed image; calculating a first-order gradient magnitude map based on the smoothed image; generating an adaptive parameter mapping based on the statistical characteristics of the first-order gradient magnitude map; obtaining an edge magnitude map based on the adaptive parameter mapping; determining a global threshold based on the edge magnitude map, and setting a high threshold and a low threshold based on the global threshold; and performing double-threshold hysteresis connection processing on the edge magnitude map based on the high threshold and the low threshold to output a binary edge map. This method can improve the detection accuracy of images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image edge detection technology, and in particular to a method, apparatus, device and storage medium for image edge detection. Background Technology

[0002] In automation and image analysis scenarios such as industrial vision inspection, robot guidance and positioning, weld seam and contour recognition, edge information is the foundation for target recognition, feature extraction, precise positioning, and geometric measurement. In practical applications, the acquired images are often in complex imaging environments, and are affected by a combination of adverse factors such as interference from object surface textures, random sensor noise, uneven lighting, and local contrast variations.

[0003] Various edge detection schemes have been developed in the existing technology. Typical edge detection methods can be mainly divided into the following categories: The first category is based on first-order gradient operators (such as Sobel, Prewitt, and Scharr operators), which are simple to implement but lack robustness against texture and noise; the second category is based on second-order derivatives (such as LoG and DoG operators), which are more sensitive to noise and are prone to producing undesirable bilateral responses at edges; the third category is multi-stage methods represented by the Canny algorithm, which improves the detection effect through smoothing, gradient calculation, non-maximum suppression, and double-threshold hysteresis connections, but its gradient calculation and suppression strategies are still sensitive to complex textures and subtle noise, and the overall process is fixed and highly dependent on parameter adjustment.

[0004] However, existing technologies are inaccurate when dealing with images with complex textures and noisy backgrounds. Summary of the Invention

[0005] This application provides a method, apparatus, device, and storage medium for edge detection of images, which can improve the detection accuracy of images.

[0006] To achieve the above objectives, this application adopts the following technical solution: Firstly, this application provides a method for edge detection of an image, including: The input image is acquired, and a structure-preserving filter is applied to the input image to obtain a smoothed image; Calculate the first-order gradient magnitude map based on the smoothed image; Based on the statistical characteristics of the first-order gradient magnitude map, an adaptive parameter mapping is generated; Based on the adaptive parameter mapping, the edge magnitude map is obtained; Based on the edge amplitude map, a global threshold is determined, and a high threshold and a low threshold are set based on the global threshold; Based on the high and low thresholds, the edge amplitude map is processed by double threshold hysteresis connection to output a binary edge map.

[0007] Optionally, obtaining the edge magnitude map based on the adaptive parameter mapping includes: Based on the adaptive parameters of each pixel in the adaptive parameter mapping, a corresponding fractal-fractional Sobel convolution kernel is generated; The smooth image is convolved using the convolution kernel to obtain the edge components in the horizontal and vertical directions, respectively. The edge amplitude map is calculated based on the edge components in the horizontal and vertical directions.

[0008] Optionally, performing structure-preserving filtering on the input image to obtain a smoothed image includes: Based on the input image, a smooth image is obtained by minimizing an objective function that includes a data fidelity term and a sparse regularization term for local variation deviations.

[0009] Optionally, generating the adaptive parameter mapping based on the statistical characteristics of the first-order gradient magnitude map includes: Calculate the first segmentation threshold and the second segmentation threshold based on the global minimum, maximum and average values ​​of the first-order gradient magnitude map; Based on the first-order gradient magnitude, the first segmentation threshold, and the second segmentation threshold at the pixel in the first-order gradient magnitude map, the adaptive parameters of the pixel are determined by the segmentation mapping rule.

[0010] Optionally, determining the adaptive parameters of the pixel based on the first-order gradient magnitude at the pixel in the first-order gradient magnitude map, the first segmentation threshold, and the second segmentation threshold through a segmentation mapping rule includes: When the magnitude of the first-order gradient at a pixel is less than the first segmentation threshold, the adaptive parameter takes the first preset value. When the magnitude of the first-order gradient at a pixel is greater than or equal to the first segmentation threshold and less than or equal to the second segmentation threshold, the adaptive parameter is set to a value that varies linearly between the second preset value and the third preset value. When the magnitude of the first-order gradient at a pixel is greater than the second segmentation threshold, the adaptive parameter takes the third preset value.

[0011] Optionally, determining a global threshold based on the edge magnitude map, and setting a high threshold and a low threshold based on the global threshold, includes: The Otsu method is used to analyze the edge magnitude map to obtain the global threshold; Set the global threshold to the high threshold; The low threshold is obtained by multiplying the global threshold by a coefficient between 0 and 1.

[0012] Optionally, the step of performing double-threshold hysteresis connection processing on the edge magnitude map based on the high threshold and the low threshold to output a binary edge map includes: Based on the high threshold, strong edge pixels are determined from the edge amplitude map; Based on the low threshold and the high threshold, weak edge candidate pixels are determined from the edge amplitude map; Based on the strong edge pixels, search for weak edge candidate pixels that are connected to the strong edge pixels in the neighborhood, and determine the connected weak edge candidate pixels as valid edge pixels. By combining all strong edge pixels with valid edge pixels, a binary edge map is obtained.

[0013] Secondly, this application provides an edge detection device for an image, comprising: An acquisition module is used to acquire an input image and perform structure-preserving filtering on the input image to obtain a smoothed image; The data processing module is used to calculate a first-order gradient magnitude map based on the smoothed image; generate an adaptive parameter mapping based on the statistical characteristics of the first-order gradient magnitude map; obtain an edge magnitude map based on the adaptive parameter mapping; determine a global threshold based on the edge magnitude map; and set a high threshold and a low threshold based on the global threshold. The output module is used to perform double-threshold hysteresis connection processing on the edge amplitude map based on the high threshold and the low threshold, and output a binary edge map.

[0014] Thirdly, this application provides a computing device, including a memory and a processor; The memory stores one or more computer programs, the one or more computer programs including instructions; when the instructions are executed by the processor, the computing device performs the method as described in any one of the first aspects.

[0015] Fourthly, this application provides a computer-readable storage medium for storing a computer program for performing the method as described in any one of the first aspects.

[0016] As can be seen from the above technical solution, this application has at least the following beneficial effects: In this application, firstly, by using structure-preserving filtering, the interference of object surface texture and random sensor noise is effectively suppressed by minimizing the objective function that includes data fidelity terms and local variation deviation sparse regularization terms, while accurately preserving the true structural boundaries of the image. This avoids the excessive blunting of edge information by traditional filtering and provides a clean and faithful input basis for subsequent detection. Secondly, a segmentation threshold is constructed based on the global statistical characteristics (minimum, maximum, and average values) of the first-order gradient magnitude map. An adaptive parameter mapping is generated through a segmented mapping rule, which enables the fractal-fractional Sobel convolution kernel to be dynamically adjusted according to the characteristics of the pixel region. This suppresses noise-induced pseudo-responses in flat regions, balances details and stability in weak edge regions, and avoids excessive magnification in strong edge regions. This improves the adaptability to scenes with uneven lighting and local contrast changes and solves the problem of insufficient robustness of traditional fixed-parameter operators. Third, the Otsu method is used to adaptively determine the global threshold and construct a high and low dual threshold system. Effective weak edges are filtered through neighborhood connectivity rules, which not only preserves the determinism of strong edges, but also completes the continuity of real edges, while suppressing isolated pseudo edges, thus overcoming the defects of edge breakage or redundancy in traditional methods.

[0017] In summary, this method significantly improves the accuracy, stability, and adaptability of edge detection in complex backgrounds, providing more reliable edge information support for target recognition, feature extraction, accurate positioning, and geometric measurement in scenarios such as industrial vision inspection, robot guided positioning, weld seam and contour recognition. It reduces the dependence on manual parameter adjustment and broadens the practical application scope of edge detection technology.

[0018] It should be understood that the descriptions of technical features, technical solutions, beneficial effects, or similar language in this application do not imply that all features and advantages can be achieved in any single embodiment. Rather, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution, or beneficial effect is included in at least one embodiment. Therefore, the descriptions of technical features, technical solutions, or beneficial effects in this specification do not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions, and beneficial effects described in this embodiment can be combined in any suitable manner. Those skilled in the art will understand that embodiments can be implemented without one or more specific technical features, technical solutions, or beneficial effects of a particular embodiment. In other embodiments, additional technical features and beneficial effects may be identified in specific embodiments that do not embody all embodiments. Attached Figure Description

[0019] Figure 1 A flowchart of an image edge detection method provided in this application embodiment; Figure 2 This is a schematic diagram of an image edge detection device provided in an embodiment of this application; Figure 3 This is a schematic diagram of a computing device provided in an embodiment of this application. Detailed Implementation

[0020] The terms "first," "second," and "third," etc., used in this application specification and accompanying drawings are used to distinguish different objects, not to limit a specific order.

[0021] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0022] To ensure clarity and conciseness in the description of the following embodiments, a brief introduction to the related technologies is given first: Edge detection refers to the identification of a set of pixels in an image whose grayscale values ​​change significantly. The contours formed by these pixels are the basis for target recognition, feature extraction, accurate localization, and geometric measurement, and are widely used in industrial vision inspection, robot guidance and localization, and other scenarios.

[0023] In practical applications such as industrial vision inspection, robot guidance and positioning, weld and contour recognition, existing edge detection technologies face significant performance bottlenecks: when faced with complex scene images affected by multiple factors such as object surface texture interference, random sensor noise, uneven lighting and local contrast changes, the detection accuracy and robustness are insufficient, making it difficult to output stable, clean and connected edge information, which in turn affects the reliability of subsequent target recognition, feature extraction and geometric measurement. At the same time, traditional methods have weak adaptability and high dependence on manual parameter adjustment, making it difficult to flexibly adapt to the detection needs of different scenarios.

[0024] The main problem stems from the superposition of multiple technical defects: on the one hand, traditional methods fail to effectively balance the contradiction between de-interference and edge preservation, lacking a targeted preprocessing mechanism, either directly calculating gradients on noisy images leading to a proliferation of false edges, or using strong smoothing filters to blunt real edges. On the other hand, fixed-parameter operators cannot dynamically adjust the response strategy according to the different characteristics of flat areas, weak edge areas and strong edge areas in the image. Furthermore, the design of single threshold screening and lack of connectivity verification is difficult to adapt to the differences in global grayscale distribution, which can easily lead to edge breakage or false edge redundancy. In addition, some multi-stage methods have fixed processes and lack flexibility, which further exacerbates the shortcomings of detection in complex scenarios.

[0025] In view of this, embodiments of this application provide an edge detection method for images, which can be executed by a processing device. The processing device can be a terminal or a server. Terminals include, but are not limited to, smartphones, tablets, laptops, personal digital assistants, or smart wearable devices. The server can be a cloud server, such as a central server in a central cloud computing cluster or an edge server in an edge cloud computing cluster. Alternatively, the server can be a server in a local data center. A local data center refers to a data center directly controlled by the user.

[0026] To address the main problems of existing edge detection technologies in complex imaging environments, such as difficulty in simultaneously eliminating interference and preserving edges, weak adaptability, and insufficient edge selection accuracy, this application firstly employs structure-preserving filtering technology to accurately preserve true structural boundaries while suppressing texture interference and random noise, thereby reducing the possibility of false edges from the source. Secondly, an adaptive parameter mapping is constructed based on the statistical characteristics of image gradients, providing pixel-level dynamic adjustment for the fractal-fractional Sobel operator. This allows the operator to adapt its response strategy according to the different characteristics of flat, weak, and strong edge regions, achieving accurate edge representation for complex scenes. Finally, an adaptive global threshold and dual-threshold hysteresis connection strategy are adopted to distinguish between true weak edges and isolated false edges through connectivity verification. This ensures edge continuity while suppressing redundant interference, ultimately outputting a stable, clean, and accurately positioned binary edge map, comprehensively improving the accuracy and robustness of edge detection in complex backgrounds.

[0027] To make the technical solution of this application clearer and easier to understand, the edge detection method for images provided by the embodiments of this application will be described below with reference to the accompanying drawings. Figure 1 As shown, this figure is a flowchart of an image edge detection method provided in an embodiment of this application. The method includes: S201. The processing device acquires the input image and performs structure-preserving filtering on the input image to obtain a smooth image.

[0028] Input images refer to raw images collected from real-world scenarios such as industrial vision inspection and robot guidance and positioning. They can be grayscale or color images (if they are color images, grayscale preprocessing must be performed first). The images may contain complex interference factors such as texture interference, random noise, and uneven lighting.

[0029] Structure-preserving filtering is a preprocessing technique that balances noise reduction and edge preservation. It works by constructing an objective function that includes data fidelity terms and sparse regularization terms for local variation deviations. This suppresses unwanted interference such as texture and noise in the image while preserving the true structural boundaries of the image to the maximum extent, thus avoiding the edge blunting problem caused by traditional filtering.

[0030] A smoothed image is an intermediate image obtained after structure-preserving filtering. Its characteristics are that redundant textures and random noise in the original image are removed, the image is cleaner overall, and the true structural boundary positions and intensities are not destroyed, providing high-quality input for subsequent gradient calculation and edge extraction.

[0031] First, industrial cameras, sensors, and other acquisition devices acquire the original image (i.e., the input image) in the actual application scenario, and then transmit it to a processing device with data processing capabilities. Subsequently, the processing device obtains a smooth image by minimizing an objective function that includes data fidelity terms and sparse regularization terms for local variation deviations based on the input image.

[0032] The data fidelity term is the part of the objective function used to constrain the difference between the smoothed image and the input image to be too large, ensuring that the smoothing process does not deviate from the true information of the original image.

[0033] The local variation deviation sparse regularization term is the part of the objective function used to suppress interference such as image texture and noise. By encouraging local relative deviations to approach 0, it suppresses abnormal gradient fluctuations in textured regions while preserving structural boundaries.

[0034] The objective function is a mathematical expression describing the constraints that a smoothed image must satisfy. By minimizing this function, the optimal smoothed image that simultaneously preserves true information and removes interference can be obtained.

[0035] This step requires first obtaining the local relative deviation from the local absolute deviation, and then constructing the objective function based on this. The complete steps and expression are as follows: The formula for calculating the local absolute deviation is:

[0036]

[0037] in, Indicates the local absolute deviation in the horizontal direction. Indicates the local absolute deviation in the vertical direction. This represents the image to be smoothed or its iterative result. This represents the gradient operator in the horizontal direction. This represents the gradient operator in the vertical direction. Indicates The local neighborhood centered on, Representing the neighborhood The number of pixels in Representing the neighborhood The pixel position in the image.

[0038] To further amplify the differences between texture and structure, relative deviation is used instead of absolute deviation. The expression for calculating local relative deviation is as follows:

[0039]

[0040] in, Indicates a local relative deviation in the horizontal direction. Indicates a local relative deviation in the vertical direction. This indicates a stable term that avoids a denominator of zero.

[0041] Based on local relative bias and data fidelity terms, the following global optimization problem is constructed:

[0042] in, This represents the output image after the structure has been smoothed. Represents the original input image. This represents the regularization intensity parameter, used to balance detail preservation and texture suppression. L2 norm is used to measure data fidelity. This represents the L1 norm, used for sparse regularization, which makes the relative bias approach zero.

[0043] S202. The processing device calculates the first-order gradient magnitude map based on the smoothed image.

[0044] The first-order gradient refers to the first-order rate of change of pixel gray values ​​in the horizontal, vertical, and other directions in an image. It is an indicator that describes the degree of abrupt change in pixel gray values. The more drastic the change in gray values ​​(such as at the edge), the larger the gradient value; the more gradual the change in gray values ​​(such as in flat areas or areas with weak texture), the smaller the gradient value.

[0045] A gradient magnitude map is a grayscale image obtained by calculating the first-order gradient (including horizontal and vertical components) of each pixel in an image through vector magnitude. The grayscale value of each pixel in the image corresponds to the gradient intensity of the original pixel, which intuitively reflects the salience of edges at different locations in the image.

[0046] The processing device takes the smoothed image obtained above as input and calculates the first-order gradient components of each pixel in the image in the horizontal and vertical directions using a gradient calculation algorithm (such as Sobel difference). Then, it synthesizes the two directional gradient components of each pixel to obtain the gradient intensity value of each pixel. Finally, it arranges the gradient intensity values ​​of all pixels according to their original image pixel positions to form a gradient magnitude map. This gradient magnitude map reflects the saliency of the edges of the real structure in the smoothed image, avoiding pseudo-gradient interference caused by texture noise while fully preserving the gradient features of the real edges, providing a statistical basis for the subsequent generation of adaptive parameter mapping.

[0047] Taking the Sobel operator as an example, the first-order gradient component in the horizontal direction The calculation formula is as follows:

[0048] in, This represents the first-order gradient component map of the image in the horizontal direction. This represents the Sobel convolution kernel in the horizontal direction. This represents a two-dimensional convolution operation.

[0049] Taking the Sobel operator as an example, the first-order gradient component in the vertical direction The calculation formula is as follows:

[0050] in, This represents the first-order gradient component map of the image in the vertical direction. This represents the Sobel convolution kernel in the vertical direction.

[0051] First-order gradient magnitude plot The calculation formula is as follows:

[0052] in, This represents the first-order gradient magnitude map, indicating the edge intensity of each pixel in the image.

[0053] S203. The processing device generates an adaptive parameter mapping based on the statistical characteristics of the first-order gradient magnitude map.

[0054] Statistical characteristics refer to the global numerical distribution features of the first-order gradient magnitude map, including the global minimum, maximum, and average values ​​of the gradient magnitude, which are used to reflect the gradient change patterns in different regions of the image.

[0055] Adaptive parameter mapping is a dynamic parameter distribution generated on a per-pixel basis (i.e., each pixel corresponds to a unique parameter). This parameter can be adaptively adjusted according to the gradient characteristics of the region where the pixel is located (flat region, weak edge region, strong edge region), and is the basis for subsequent construction of fractal-fractional Sobel convolution kernels.

[0056] Specifically, the processing device calculates the first segmentation threshold and the second segmentation threshold based on the global minimum, maximum and average values ​​of the first-order gradient magnitude map; and determines the adaptive parameters of the pixel based on the first-order gradient magnitude, the first segmentation threshold and the second segmentation threshold at the pixel in the first-order gradient magnitude map through a segmentation mapping rule.

[0057] The processing device first extracts three key global statistical features from the first-order gradient magnitude map: the global minimum, global maximum, and global average of the gradient magnitude. Based on these three values, and through preset calculation rules, such as introducing linear calculations of scaling factors, two critical values, the first segmentation threshold and the second segmentation threshold, are calculated. These critical values ​​act like scales, clearly dividing the gradient magnitude of the entire map into three intervals: below the first segmentation threshold, between the first and second segmentation thresholds, and above the second segmentation threshold.

[0058] Two segmentation thresholds are calculated through a linear combination:

[0059] in, This represents the first segmentation threshold, used to distinguish between low-gradient and medium-gradient regions. Represents the first-order gradient magnitude plot The average value of all pixels in the image. Represents the first-order gradient magnitude plot The minimum value in, This represents the combination coefficient of the first segmentation threshold.

[0060]

[0061] in, This represents the second segmentation threshold, used to distinguish between medium-gradient and high-gradient regions. This represents the combination coefficient of the second segmentation threshold. Represents the first-order gradient magnitude plot The maximum value in.

[0062] After the region is divided, the processing device will operate on each pixel in the first-order gradient magnitude map one by one: first read the gradient magnitude corresponding to the pixel, then determine the gradient interval to which it belongs, and finally assign adaptive parameters to the pixel that match the interval to which it belongs according to the pre-set segmentation mapping rules.

[0063] The segmentation mapping rule is as follows: When the magnitude of the first-order gradient at a pixel is less than the first segmentation threshold, the adaptive parameter is set to the first preset value; when the magnitude of the first-order gradient at a pixel is greater than or equal to the first segmentation threshold and less than or equal to the second segmentation threshold, the adaptive parameter is set to a value that varies linearly between the second preset value and the third preset value; when the magnitude of the first-order gradient at a pixel is greater than the second segmentation threshold, the adaptive parameter is set to the third preset value.

[0064] When the magnitude of the first-order gradient of a pixel is less than the first segmentation threshold, it indicates that the pixel is in a region with a gentle gradient change (such as a flat region or a weak noise region). At this time, the adaptive parameter takes the first preset value (which is a large value) to suppress the weak pseudo-response that may be induced by noise in this region and ensure the stability of edge detection. When the magnitude of the first-order gradient of a pixel is between the first segmentation threshold and the second segmentation threshold, it means that the pixel is located in a weak edge or fine structure region with moderate gradient change. At this time, the adaptive parameter will change linearly with the gradient magnitude between the second preset value and the third preset value. This can capture the detailed information of weak edges and avoid the increase of false edges caused by over-response, thus achieving a balance between detail preservation and stability. When the magnitude of the first-order gradient of a pixel is greater than the second segmentation threshold, it indicates that the pixel corresponds to a strong edge region with drastic gradient changes. At this time, the adaptive parameter takes the third preset value (a smaller value) to avoid the strong edge being over-amplified and producing overshoot or halo effect, thus ensuring the accuracy of strong edge positioning.

[0065] For each pixel gradient magnitude Assign adaptive parameters according to the following rules Generate adaptive parameter mapping:

[0066] in, Represents pixels Adaptive parameters at the location, Represents pixels The magnitude of the first gradient at that point. This represents the first preset value, and its value range is generally [value range missing]. , This represents the second preset value, and its value range is generally [value range missing]. , This represents the third preset value, and its value range is generally [value range missing]. ,Require This is to ensure that sensitivity increases as the gradient increases.

[0067] S204. The processing device obtains the edge amplitude map based on the adaptive parameter mapping.

[0068] Adaptive parameter mapping generates pixel-level parameter distribution results based on the global statistical features and piecewise mapping rules of the first-order gradient magnitude map from the previous step. Each pixel position in the image corresponds to a unique adaptive parameter, which dynamically changes according to whether the pixel is located in a low-gradient flat region, a medium-gradient weak edge region, or a high-gradient strong edge region. This parameter serves as the basis for the subsequent adaptive adjustment of the gradient operator.

[0069] The edge magnitude map is a feature image obtained after adaptive gradient calculation. The value of each pixel in the image represents the edge response intensity at that location. Compared with the gradient results of traditional fixed operators, it suppresses false edges caused by noise and texture, strengthens real weak edges, and stabilizes strong edge signals. It is the direct input for subsequent dual threshold screening.

[0070] Specifically, the processing device generates a corresponding fractal-fractional Sobel convolution kernel based on the adaptive parameters of each pixel in the adaptive parameter mapping; it then performs convolution operations on the smooth image using the convolution kernel to obtain the edge components in the horizontal and vertical directions; and finally calculates the edge magnitude map based on the edge components in the horizontal and vertical directions.

[0071] First, the processing device iterates through every pixel in the image, reads the corresponding adaptive parameter, and then uses this parameter as the basis for adjustment to generate a fractal that matches that pixel in real time. Fractional Sobel convolution kernel. Unlike the traditional fixed-weight Sobel convolution kernel, the internal coefficients of this convolution kernel change with adaptive parameters, enabling differentiated response settings for flat regions, weak edge regions, and strong edge regions, ensuring that appropriate gradient calculation strengths are obtained in different regions.

[0072] The derivation of the convolution kernel is based on the generalized Grünwald-Letnikov (GL) fractional derivative framework. For a one-dimensional function... ,That The fractional derivative of order GL is defined as:

[0073] in, Representation function of GL fractional derivative, Indicates the order of a fraction. , Denotes the coefficients of the generalized binomial. Represents the reference point of the function. Indicates the index of the summation term. Indicates taking The integer part.

[0074] The expression for the generalized binomial coefficient is:

[0075] in, The Gamma function is a generalization of factorial in the real number field.

[0076] In discrete image processing, step size is used. And truncate to a finite number of items Its expression is:

[0077] in, Indicates step size, Indicates the number of truncated terms. Represents the set of positive integers.

[0078] For the follow-up Neighborhood implementation, take And only retain Two items, resulting in the simplified form:

[0079] This formula shows that the fractional-order difference can be understood as a weighted difference between the current pixel and its neighboring pixels, with the weights determined by the order parameter. Control (when) It degenerates into a classical first-order difference.

[0080] To further characterize the local structural complexity of the image, a fractal dimension parameter is introduced. Its fractal derivative is defined as:

[0081] in, The independent variable of the function is... Represents the fractal dimension parameter. Representation function The fractal derivative of .

[0082] Combining the fractional derivative with the fractal scale yields the GL fractal-fractional derivative (GL-FFD):

[0083] To facilitate discrete implementation, in Under smaller conditions, for Using an approximation:

[0084] Substituting into the GL-FFD formula, we get:

[0085] In two-dimensional discrete images In the middle, the pixel spacing is set to 1, corresponding to direction and The directional GL-FFD is approximated as:

[0086] in, Represents a two-dimensional discrete image. Represents pixel coordinates, This represents the grayscale value at the corresponding position.

[0087] Extending GL-FFD to Sobel's directional difference and orthogonal directional smoothing framework yields a generalized directional expression:

[0088] in, This represents the fractal-fractional edge operator in the horizontal direction. These represent the fractal-fractional edge operators in the vertical direction, respectively. Related to mask size ( hour ), Indicates the index of the summation term of the direction operator. This indicates the offset in the orthogonal direction. This represents the pixel offset in the horizontal direction. This represents the pixel offset in the vertical direction. Indicates in calculation Time The direction is offset from the index of the local neighborhood sampling points. This indicates that in the calculation The index offset of the local neighborhood sampling points along the y-direction.

[0089] To satisfy the zero-sum mask property, fix At this time, the horizontal and vertical directions The convolution template is:

[0090] in, This represents a 3×3 fractal-fractional Sobel convolution kernel in the horizontal direction. This represents a 3×3 fractal-fractional Sobel convolution kernel in the vertical direction.

[0091] Next, the processing device uses these pixel-wise adaptively adjusted convolution kernels to perform convolution operations on the previously denoised and edge-preserving smoothed image, calculating the edge components in the horizontal and vertical directions. The horizontal component mainly reflects the gray-level abrupt changes in the left-right direction, while the vertical component reflects the gray-level abrupt changes in the up-down direction. The components in both directions together record the edge information in different orientations of the image. Because the convolution kernel is adaptively adjusted, it can effectively suppress noise pseudo-responses in flat areas during the operation, while strengthening the effective signal in weak edge areas.

[0092] The convolution calculation of edge components can be expressed as:

[0093] in, It represents the horizontal edge component and records the grayscale changes in the left and right directions; It represents the vertical edge component and records the grayscale changes in the up and down directions; , For the corresponding convolution kernel in relative coordinates The weighting coefficient at the location.

[0094] Finally, the processing device synthesizes the horizontal and vertical edge components for each pixel location to obtain the edge response intensity at that location. Arranging the edge response intensities of all pixels according to the coordinates of the original image forms the final edge amplitude map. This amplitude map accurately reflects the true edge strength distribution of the image, eliminating interference from noise and texture while fully preserving subtle structural edges, providing reliable feature data for subsequent double-threshold hysteresis connection processing and extraction of the final binary edge map.

[0095] Each pixel Edge amplitude at the location Calculated by the following formula:

[0096] in, Represents pixels The edge amplitude.

[0097] Arrange the edge magnitude values ​​of all pixels according to their original image coordinates to form an edge magnitude map. :

[0098] in, Represents the edge amplitude map. Represents the height and width of an image; amplitude graph Through adaptive parameter adjustment and convolution synthesis, it has strong edge-to-non-edge discrimination, providing high-quality input for subsequent thresholding processing.

[0099] S205. The processing device determines the global threshold based on the edge amplitude map, and sets the high threshold and low threshold based on the global threshold.

[0100] The global threshold is a unified threshold calculated based on the pixel value distribution of the entire edge amplitude map (such as statistical features such as grayscale histogram, mean, variance, etc.). It is used to roughly distinguish pixels that may be on the edge and pixels that are not on the edge, and serves as the benchmark for setting high and low thresholds.

[0101] The high threshold is a higher threshold set based on the global threshold. It is used to filter strong edge pixels with high confidence. Only pixels with edge amplitude exceeding the high threshold will be directly identified as defined edges.

[0102] The low threshold is a lower threshold set based on the global threshold. It is used to filter weak edge pixels that may be edges. Pixels with edge amplitude between the low threshold and the high threshold will be temporarily marked as candidate edges. Further determination on whether to retain them will be made in combination with the connectivity of strong edges.

[0103] Specifically, the Otsu method is used to analyze the edge magnitude map to obtain a global threshold; the global threshold is set as a high threshold; and the global threshold is multiplied by a coefficient between 0 and 1 to obtain a low threshold.

[0104] First, the processing device uses the Otsu method (i.e., the maximum inter-class variance method) to analyze the edge amplitude map. This method automatically counts the pixel value distribution of the edge amplitude map. By calculating the variance between edge pixels and non-edge pixels under different thresholds, it finds the threshold that maximizes the inter-class variance. This threshold is the global threshold (it maximizes the distinguishability between the two types of pixels and is the optimal benchmark for dividing edges and non-edges).

[0105] Next, the obtained global threshold is directly set as a high threshold. Pixels with edge amplitude exceeding this high threshold are strong edges with high confidence and will be directly identified as defined edges.

[0106] Finally, the global threshold is multiplied by a coefficient between 0 and 1 (e.g., 0.5) to calculate the low threshold. Pixels with edge amplitudes between the low and high thresholds are considered weak edge candidates, and their retention will be determined by combining the connectivity of strong edges. Pixels with amplitudes below the low threshold will be classified as non-edges.

[0107] This approach achieves adaptive threshold calculation through the Otsu method, and then uses tiered filtering based on high and low thresholds to ensure the accuracy of strong edges while providing a basis for retaining weak edges.

[0108] S206. The processing device performs double-threshold hysteresis connection processing on the edge amplitude map based on the high threshold and the low threshold, and outputs a binary edge map.

[0109] Dual-threshold hysteresis connectivity is a staged edge filtering algorithm. First, a high threshold is used to filter out strong edge pixels. Then, using these strong edges as seeds, a low threshold is used to filter out candidate weak edge pixels connected to them. Finally, the strong edges and connected weak edges are merged into a complete edge; weak edges not connected to strong edges are discarded. This method avoids the problem of missing weak edges with single-threshold methods and also filters out isolated noisy pseudo-edges.

[0110] The binary edge map is the final output edge result map. The map contains only two types of pixel values ​​(usually 0 and 255, or 0 and 1). 1 / 255 represents pixels that are judged as edges, and 0 represents non-edge pixels. It is a binary and visual representation of the edges of the original image.

[0111] Specifically, the processing device determines strong edge pixels from the edge amplitude map based on a high threshold; determines weak edge candidate pixels from the edge amplitude map based on a low threshold and a high threshold; searches for weak edge candidate pixels connected to the strong edge pixels in the neighborhood based on the strong edge pixels, and determines the connected weak edge candidate pixels as valid edge pixels; and combines all strong edge pixels with valid edge pixels to obtain a binary edge map.

[0112] The first step is to filter out strong edge pixels from the edge amplitude map based on a high threshold. As long as the edge amplitude of a pixel exceeds the high threshold, it is directly determined as a confirmed edge pixel. These points are reliable seeds for subsequent filtering.

[0113] The second step is to combine the low threshold and the high threshold to determine candidate pixels for weak edges. Pixels whose edge amplitude is between the low threshold and the high threshold will not be directly determined as edges, but will be temporarily marked as candidate weak edges. These pixels may be real weak edges or noisy pseudo edges.

[0114] The third step is to start from the identified strong edge pixels and search for weak edge candidate pixels in their neighborhood (e.g., a 3×3 range). If a weak edge candidate is connected to a strong edge pixel (i.e., adjacent or indirectly connected through other weak edge candidates), it is determined to be a valid edge pixel. Weak edge candidates that are not connected to any strong edge are determined to be noise and eliminated.

[0115] Finally, all strong edge pixels are merged with the selected valid edge pixels and uniformly marked as edges, while the remaining pixels are marked as non-edges. The final output is a binary edge map that contains only two states: edge and non-edge.

[0116] This process ensures edge accuracy through a high threshold, retains true weak edges through connectivity filtering, and filters out isolated noise interference, making the final edge results more complete and reliable.

[0117] Based on the above description, this application has the following beneficial effects: In this application, firstly, by using structure-preserving filtering, the interference of object surface texture and random sensor noise is effectively suppressed by minimizing the objective function that includes data fidelity terms and local variation deviation sparse regularization terms, while accurately preserving the true structural boundaries of the image. This avoids the excessive blunting of edge information by traditional filtering and provides a clean and faithful input basis for subsequent detection. Secondly, a segmentation threshold is constructed based on the global statistical characteristics (minimum, maximum, and average values) of the first-order gradient magnitude map. An adaptive parameter mapping is generated through a segmented mapping rule, which enables the fractal-fractional Sobel convolution kernel to be dynamically adjusted according to the characteristics of the pixel region. This suppresses noise-induced pseudo-responses in flat regions, balances details and stability in weak edge regions, and avoids excessive magnification in strong edge regions. This improves the adaptability to scenes with uneven lighting and local contrast changes and solves the problem of insufficient robustness of traditional fixed-parameter operators. Third, the Otsu method is used to adaptively determine the global threshold and construct a high and low dual threshold system. Effective weak edges are filtered through neighborhood connectivity rules, which not only preserves the determinism of strong edges, but also completes the continuity of real edges, while suppressing isolated pseudo edges, thus overcoming the defects of edge breakage or redundancy in traditional methods.

[0118] In summary, this method significantly improves the accuracy, stability, and adaptability of edge detection in complex backgrounds, providing more reliable edge information support for target recognition, feature extraction, accurate positioning, and geometric measurement in scenarios such as industrial vision inspection, robot guided positioning, weld seam and contour recognition. It reduces the dependence on manual parameter adjustment and broadens the practical application scope of edge detection technology.

[0119] The above text combined Figure 1 The edge detection method for images provided in the embodiments of this application has been described in detail. The apparatus and devices provided in the embodiments of this application will be described below with reference to the accompanying drawings.

[0120] like Figure 2 As shown, this figure is a schematic diagram of an edge detection device for an image provided in an embodiment of this application. The device includes: The acquisition module 301 is used to acquire an input image and perform structure-preserving filtering on the input image to obtain a smooth image; The data processing module 302 is used to calculate a first-order gradient magnitude map based on the smoothed image; generate an adaptive parameter mapping based on the statistical characteristics of the first-order gradient magnitude map; obtain an edge magnitude map based on the adaptive parameter mapping; determine a global threshold based on the edge magnitude map; and set a high threshold and a low threshold based on the global threshold. The output module 303 is used to perform double threshold hysteresis connection processing on the edge amplitude map according to the high threshold and the low threshold, and output a binary edge map.

[0121] Optionally, the data processing module 302 is specifically used to generate a corresponding fractal-fractional Sobel convolution kernel based on the adaptive parameters of each pixel in the adaptive parameter mapping. The smooth image is convolved using the convolution kernel to obtain the edge components in the horizontal and vertical directions, respectively. The edge amplitude map is calculated based on the edge components in the horizontal and vertical directions.

[0122] Optionally, the data processing module 302 is specifically used to obtain a smooth image based on the input image by minimizing an objective function that includes a data fidelity term and a sparse regularization term for local variation deviations.

[0123] Optionally, the data processing module 302 is specifically used to calculate the first segmentation threshold and the second segmentation threshold based on the global minimum, maximum and average values ​​of the first-order gradient magnitude map; Based on the first-order gradient magnitude, the first segmentation threshold, and the second segmentation threshold at the pixel in the first-order gradient magnitude map, the adaptive parameters of the pixel are determined by the segmentation mapping rule.

[0124] Optionally, the data processing module 302 is specifically used to take the first preset value of the adaptive parameter when the magnitude of the first gradient at the pixel is less than the first segmentation threshold. When the magnitude of the first-order gradient at a pixel is greater than or equal to the first segmentation threshold and less than or equal to the second segmentation threshold, the adaptive parameter is set to a value that varies linearly between the second preset value and the third preset value. When the magnitude of the first-order gradient at a pixel is greater than the second segmentation threshold, the adaptive parameter takes the third preset value.

[0125] Optionally, the data processing module 302 is specifically used to analyze the edge magnitude map using the Otsu method to obtain the global threshold; Set the global threshold to the high threshold; The low threshold is obtained by multiplying the global threshold by a coefficient between 0 and 1.

[0126] Optionally, the output module 303 is specifically used to determine strong edge pixels from the edge amplitude map based on the high threshold. Based on the low threshold and the high threshold, weak edge candidate pixels are determined from the edge amplitude map; Based on the strong edge pixels, search for weak edge candidate pixels that are connected to the strong edge pixels in the neighborhood, and determine the connected weak edge candidate pixels as valid edge pixels. By combining all strong edge pixels with valid edge pixels, a binary edge map is obtained.

[0127] The image edge detection apparatus according to the embodiments of this application can correspondingly execute the method described in the embodiments of this application, and the other operations and / or functions of each module / unit of the image edge detection apparatus are respectively implemented to achieve Figure 1 For the sake of brevity, the corresponding processes of each method in the illustrated embodiments will not be described in detail here.

[0128] This application also provides a computing device. For example... Figure 3 As shown in the figure, this is a schematic diagram of a computing device provided in an embodiment of this application. The computing device 700 includes a bus 701, a processor 702, a communication interface 703, and a memory 704. The processor 702, the memory 704, and the communication interface 703 communicate with each other via the bus 701.

[0129] The 701 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 3 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0130] The processor 702 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).

[0131] The communication interface 703 is used for communication with external devices.

[0132] Memory 704 may include volatile memory, such as random access memory (RAM). Memory 704 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0133] The memory 704 stores executable code, and the processor 702 executes the executable code to perform the aforementioned edge detection method for the image.

[0134] Specifically, in achieving Figure 2 In the case of the illustrated embodiment, and Figure 2When the modules or units of the image edge detection device described in the embodiment are implemented by software, the execution... Figure 2 The software or program code required for the functions of each module / unit can be partially or entirely stored in memory 704. Processor 702 executes the program code corresponding to each unit stored in memory 704 to perform the aforementioned edge detection method for the image.

[0135] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct a computing device to perform the aforementioned image edge detection method.

[0136] This application also provides a computer program product comprising one or more computer instructions. When the computer instructions are loaded and executed on a computing device, all or part of the processes or functions described in this application are generated.

[0137] The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, or data center to another website, computer, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means.

[0138] When the computer program product is executed by a computer, the computer performs any of the aforementioned edge detection methods for images. The computer program product can be a software installation package; when any of the aforementioned edge detection methods for images needs to be used, the computer program product can be downloaded and executed on the computer.

[0139] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.

[0140] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be covered within the scope of protection of this application.

Claims

1. A method for edge detection of an image, characterized in that, The method includes: The input image is acquired, and a structure-preserving filter is applied to the input image to obtain a smoothed image; Calculate the first-order gradient magnitude map based on the smoothed image; Based on the statistical characteristics of the first-order gradient magnitude map, an adaptive parameter mapping is generated; Based on the adaptive parameter mapping, the edge magnitude map is obtained; Based on the edge amplitude map, a global threshold is determined, and a high threshold and a low threshold are set based on the global threshold; Based on the high and low thresholds, the edge amplitude map is processed by double threshold hysteresis connection to output a binary edge map.

2. The method according to claim 1, characterized in that, The step of obtaining the edge magnitude map based on the adaptive parameter mapping includes: Based on the adaptive parameters of each pixel in the adaptive parameter mapping, a corresponding fractal-fractional Sobel convolution kernel is generated; The smooth image is convolved using the convolution kernel to obtain the edge components in the horizontal and vertical directions, respectively. The edge amplitude map is calculated based on the edge components in the horizontal and vertical directions.

3. The method according to claim 1, characterized in that, The process of performing structure-preserving filtering on the input image to obtain a smoothed image includes: Based on the input image, a smooth image is obtained by minimizing an objective function that includes a data fidelity term and a sparse regularization term for local variation deviations.

4. The method according to claim 1, characterized in that, The process of generating an adaptive parameter mapping based on the statistical characteristics of the first-order gradient magnitude map includes: Calculate the first segmentation threshold and the second segmentation threshold based on the global minimum, maximum and average values ​​of the first-order gradient magnitude map; Based on the first-order gradient magnitude, the first segmentation threshold, and the second segmentation threshold at the pixel in the first-order gradient magnitude map, the adaptive parameters of the pixel are determined by the segmentation mapping rule.

5. The method according to claim 4, characterized in that, The step of determining the adaptive parameters of the pixel based on the first-order gradient magnitude, the first segmentation threshold, and the second segmentation threshold at the pixel in the first-order gradient magnitude map, through a segmentation mapping rule, includes: When the magnitude of the first-order gradient at a pixel is less than the first segmentation threshold, the adaptive parameter takes the first preset value. When the magnitude of the first-order gradient at a pixel is greater than or equal to the first segmentation threshold and less than or equal to the second segmentation threshold, the adaptive parameter is set to a value that varies linearly between the second preset value and the third preset value. When the magnitude of the first-order gradient at a pixel is greater than the second segmentation threshold, the adaptive parameter takes the third preset value.

6. The method according to claim 1, characterized in that, The step of determining a global threshold based on the edge magnitude map, and setting a high threshold and a low threshold based on the global threshold, includes: The Otsu method is used to analyze the edge magnitude map to obtain the global threshold; Set the global threshold to the high threshold; The low threshold is obtained by multiplying the global threshold by a coefficient between 0 and 1.

7. The method according to claim 1, characterized in that, The step of performing double-threshold hysteresis connection processing on the edge magnitude map based on the high threshold and the low threshold to output a binary edge map includes: Based on the high threshold, strong edge pixels are determined from the edge amplitude map; Based on the low threshold and the high threshold, weak edge candidate pixels are determined from the edge amplitude map; Based on the strong edge pixels, search for weak edge candidate pixels that are connected to the strong edge pixels in the neighborhood, and determine the connected weak edge candidate pixels as valid edge pixels. By combining all strong edge pixels with valid edge pixels, a binary edge map is obtained.

8. An edge detection device for an image, characterized in that, The device includes: An acquisition module is used to acquire an input image and perform structure-preserving filtering on the input image to obtain a smoothed image; The data processing module is used to calculate a first-order gradient magnitude map based on the smoothed image; generate an adaptive parameter mapping based on the statistical characteristics of the first-order gradient magnitude map; obtain an edge magnitude map based on the adaptive parameter mapping; determine a global threshold based on the edge magnitude map; and set a high threshold and a low threshold based on the global threshold. The output module is used to perform double-threshold hysteresis connection processing on the edge amplitude map based on the high threshold and the low threshold, and output a binary edge map.

9. A computing device, characterized in that, Including memory and processor; The memory stores one or more computer programs, the one or more computer programs including instructions; when the instructions are executed by the processor, the computing device performs the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program for performing the method as described in any one of claims 1 to 7.