Fast gradient detection method based on pixel difference and application thereof

By adopting a fast gradient detection method based on pixel differences in the traditional edge detection method, and using Gaussian filtering and gradient detection operators for gradient calculation, the problems of high computational complexity and noise sensitivity of traditional methods are solved, and the accuracy of image gradient information is achieved. Robust calculation and edge detection, suitable for complex images and scenes with large noise interference.

CN118691633APending Publication Date: 2024-09-24UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410401703.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-03
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Traditional edge detection methods have high computational complexity, consume large amounts of hardware resources, are sensitive to noise, and are prone to false detections or missed detections in complex images and scenes with large noise interference, resulting in incomplete edge connections and affecting image analysis and processing.

Method used

A fast gradient detection method based on pixel differences is used. After Gaussian filtering, gradient detection is performed on the 3x3 square matrix of pixel values. Gradient detection operators in 4 directions are used for convolution operations to calculate the gradient amplitude value and direction, and perform non-linear gradient detection. Maximum suppression and dual threshold detection reduce computational complexity and hardware resource consumption.

Benefits of technology

It achieves accurate calculation of image gradient information, reduces computational complexity and hardware resource consumption, improves the accuracy and robustness of edge detection, and is suitable for real-time processing and resource-limited application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118691633A
    Figure CN118691633A
Patent Text Reader

Abstract

The invention belongs to the field of image processing, and mainly provides a method capable of accurately calculating image gradient information and reducing calculation complexity and hardware resource consumption. By improving a gradient calculation mode in a traditional edge detection algorithm, image gradient information needing to be transmitted to a downstream calculation module is reserved, and meanwhile the complexity of hardware circuit implementation is improved. A gradient detection operator as shown in the figure is provided to solve the difficulty of an original gradient information solving method in hardware implementation, gradient solving matrixes in four directions (0 degree, 45 degrees, 90 degrees and 135 degrees) are directly given, and gradients in eight directions in a 3 * 3 neighborhood are obtained through single parallel calculation. And finally, obtaining a gradient amplitude value and a gradient direction through non-negative truncation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of image processing, and in particular relates to a fast gradient detection method based on pixel difference and an application thereof. Background Art

[0002] Image processing technology plays a key role in computer vision, medical image analysis, autonomous driving and other fields. Among them, edge recognition, as an important branch of image processing, is of great significance in tasks such as target detection, image segmentation, and object recognition. Traditional edge recognition methods usually detect edges in images based on the gradient change of the image or the difference in pixel values, including operators such as Sobel, Prewitt, and Roberts. However, traditional methods have some limitations in processing complex images, scenes with large noise interference, or high real-time requirements: High computational complexity: Traditional edge detection methods usually need to use convolution or differential operations to calculate the gradient of the image. These operations have high computational complexity on large-size images and are not suitable for real-time processing or resource-constrained application scenarios. Sensitive to noise: Traditional edge detection methods are sensitive to noise in images. When there is large noise interference, it is easy to produce false detection or missed detection, which affects the accuracy and robustness of edge detection. Incomplete edge connection: In some cases, traditional edge detection methods will produce broken or discontinuous edges, resulting in incomplete edge connection, which is not conducive to subsequent image analysis and processing.

[0003] Gradient detection is a step in the traditional edge detection algorithm. This step will complete the calculation of the gradient size and direction of the image after Gaussian blur in the previous step. In essence, since the edge of the image is an area where the grayscale value changes dramatically, gradient detection is to calculate the speed and size of the pixel change in each direction, and finally find the size of the grayscale value of each pixel in the direction of the fastest change (the modulus of the gradient) and the angle of this direction (the gradient direction) based on the calculated results. Finally, according to the gradient size and direction extracted in this step, the next step of non-maximum suppression is carried out to detect edge points. In this algorithm process, the conventional method is as follows Figure 1 The method shown uses the Sobel operator to solve the gradient in the X and Y directions, and then solves the modulus and gradient direction. Due to the computational complexity of this method, it consumes a lot of hardware logic resources in hardware implementation due to the power and inverse trigonometric calculations. It is also impossible to parallelize the calculation of the gradient size and direction. The calculation delay is large. And due to the diversity of the gradient direction, the interpolation method needs to be introduced to calculate the adjacent grayscale values ​​of the gradient direction for maximum suppression.

[0004] In terms of hardware implementation, traditional edge detection algorithms usually involve complex convolution operations or differential operations, which require a lot of computing resources and hardware logic units in hardware implementation. Especially for large-size images, more hardware resources are needed to support edge detection calculations, which increases the complexity and cost of hardware design. Summary of the invention

[0005] In view of the above problems or deficiencies, in order to solve the problems of high computational complexity and high hardware resource consumption based on traditional edge detection methods, the present invention proposes a method that can accurately calculate image gradient information and reduce computational complexity and hardware resource consumption. By improving the gradient calculation method in the traditional edge detection algorithm, the image gradient information that needs to be passed to the downstream computing module is retained, while the complexity of hardware circuit implementation is improved.

[0006] The present invention provides a fast gradient detection method based on pixel difference, comprising the following steps:

[0007] Step S1: Obtain an original grayscale image, and perform Gaussian filtering on the grayscale image to be processed;

[0008] Step S2: fast gradient detection: judging the gradient amplitude and direction of a single pixel point on the processed image data;

[0009] Step S2.1: Perform convolution operations on the 3×3 pixel value square matrix centered on the pixel point at the corresponding positions of the gradient detection operator matrix at 0°, 45°, 90°, and 135° to obtain the gradient amplitude values ​​of the central pixel point corresponding to 0°, 45°, 90°, and 135°;

[0010] The gradient detection operator matrix is:

[0011]

[0012]

[0013] F 0° 、F 45° 、F 90° 、F 135° Respectively represent the 0°, 45°, 90°, and 135° gradient detection operator matrices;

[0014] Set the 3x3 pixel value matrix to:

[0015]

[0016] If we want to calculate the gradient amplitude value of the central pixel Z5 in the 0° direction, we can use the 0° direction gradient detection operator F 0°, then the Z1-Z3+Z4-Z6+Z7-Z9 operation will be performed to obtain the gradient amplitude value of the central pixel in the 0° direction;

[0017] Step S2.2: Take the inverse of the gradient amplitudes in the four directions obtained in step 2.1 to obtain the gradient amplitudes in the other four opposite directions of 180°, 225°, 270°, and 315°.

[0018] Step S2.3: Clear the negative values ​​of the gradient amplitude values ​​in all directions, compare the gradient amplitude values ​​in all directions to get the maximum value, use the maximum value as the final gradient amplitude value of the pixel, and use the corresponding direction as the gradient direction of the pixel;

[0019] Step S3: non-maximum suppression: using non-maximum suppression, the non-maximum value of the gradient amplitude in the gradient direction obtained in step S2 is set to 0 to remove noise points;

[0020] Step S4: double threshold detection; perform secondary filtering on the edge image obtained in step S3 to filter out edge points with small edge strength and short edge chain to obtain a binary edge image.

[0021] Furthermore, the specific steps of step S1 are as follows:

[0022] Convert the grayscale image into a pixel value matrix, take out a 3x3 area from the pixel value matrix to perform central pixel blurring, and use a two-dimensional Gaussian function convolution kernel to perform smoothing filtering on the image. The calculation formula for the two-dimensional Gaussian function kernel is as follows:

[0023]

[0024] Among them, x and y represent the horizontal and vertical distances from the center of the distance function. For images, it can be understood as the horizontal and vertical distances of a pixel relative to the center of the processing area. σ is the standard deviation of the Gaussian function. By adjusting the value of σ, the degree of filtering can be controlled to meet different image processing requirements. H(x,y,σ) represents the value of the Gaussian filter convolution kernel at the coordinate (x,y).

[0025] Generate a 3x3 Gaussian template according to the formula, and convolve the 3x3 pixel area with the 3x3 Gaussian template to get the grayscale value of the blurred center pixel.

[0026] Furthermore, the specific steps of step S3 are as follows:

[0027] Step S3.1: Using the gradient amplitude value and gradient direction of the pixel point obtained in step S2 as a basis for judgment, the gradient amplitude values ​​of all the pixels in the 3x3 pixel point square matrix area centered on the pixel point are calculated in the same manner as in step 2;

[0028] Step S3.2: Perform non-maximum suppression of the central pixel value. Compare the gradient amplitudes of the two pixels corresponding to the central pixel value in the gradient direction with the gradient amplitude of the central pixel. If it is not the maximum gradient amplitude of the three pixels, set its grayscale value to 0.

[0029] Furthermore, the specific steps of step S4 are as follows:

[0030] Step S4.1: Set a high threshold and a low threshold, and use the relationship between the gradient amplitude of the current pixel and the high and low thresholds to determine whether it is an edge point;

[0031] Step S4.2: If the gradient amplitude value of the pixel point is higher than the high threshold, its grayscale value is set to the maximum value; if the gradient amplitude value of the pixel point is lower than the low threshold, its grayscale value is set to the minimum grayscale value; if the gradient amplitude value of the pixel point is between the high and low thresholds, the pixel gradient amplitude is searched from the 8-neighborhood of the pixel; if there is a pixel gradient amplitude value greater than the high threshold, its grayscale value is set to the maximum grayscale value, otherwise it is set to the minimum grayscale value;

[0032] Step S4.3: traverse all pixel points in the pixel value matrix to obtain the final binarization result of each pixel point; and return the processed binarization matrix to the host computer to realize edge image echo.

[0033] The present invention also provides a fast gradient detection device based on pixel difference, which includes a processor and an edge detection calculation kernel; wherein the edge detection calculation kernel can implement the above method.

[0034] The processor runs a LINUX system to complete image data scheduling, and reads image data from an external storage card into an internal space through a dynamic random access memory integrated on the processor. After the processor completes data preprocessing, it calls a data movement controller to send the image data to an edge detection calculation kernel, and puts the image data after calculation back into the memory space. The processor completes data postprocessing and completes result display.

[0035] A fast gradient detection method based on pixel difference refers to using a weighted or normalized method when calculating pixel differences to improve the accuracy of edge detection. The pixel difference value and pixel gradient information are combined to further optimize the effect of edge detection.

[0036] The present invention solves the difficulty of the original gradient information solution method in hardware implementation, by directly providing the gradient solution matrix in four directions (0°, 45°, 90°, 135°), and obtaining the gradient magnitude of the central pixel in eight directions in a 3x3 pixel area through a single parallel calculation. Finally, the maximum gradient magnitude is obtained by comparison to determine the gradient direction, and the gradient direction is transmitted to the downstream calculation module, so that the maximum suppression result of the pixel gray value in the neighborhood can be calculated more conveniently.

[0037] The beneficial effects of the present invention are as follows: The method proposed by the present invention realizes rapid detection of gradients by simplifying the technical means for the gradient detection operator in the traditional canny algorithm. It provides a solution that is easy to deploy and consumes low hardware resources for hardware implementation of edge detection algorithms, and can be applied to various image processing scenarios, including computer vision, medical image analysis, autonomous driving and other fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 This is a schematic diagram of the traditional gradient calculation implementation scheme;

[0039] Figure 2 A schematic diagram of a gradient detection operator provided by the present invention;

[0040] Figure 3 A specific flow chart of the image edge detection task implemented based on the fast gradient detection method provided by the present invention;

[0041] Figure 4 A schematic diagram of the hardware platform architecture provided by the present invention based on the method proposed in this article;

[0042] Figure 5 This is a schematic diagram of the edge detection implementation effect of the FPGA platform provided by the present invention. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific examples described here are only used to explain the present invention and do not limit the present invention.

[0044] like Figure 3 As shown, it is a flowchart of the present invention to implement the image edge detection task based on the fast gradient detection method, which includes the following steps:

[0045] Step S1: Obtain the original grayscale image and perform Gaussian filtering on the grayscale image to be processed. The specific steps are as follows:

[0046] Convert the grayscale image into a pixel value matrix, take out a 3x3 area from the pixel value matrix to perform central pixel blurring, and use a two-dimensional Gaussian function convolution kernel to perform smoothing filtering on the image. The calculation formula for the two-dimensional Gaussian function kernel is as follows:

[0047]

[0048] Among them, x and y represent the horizontal and vertical distances from the center of the distance function. For images, it can be understood as the horizontal and vertical distances of a pixel relative to the center of the processing area. σ is the standard deviation of the Gaussian function. By adjusting the value of σ, the degree of filtering can be controlled to meet different image processing requirements. H(x,y,σ) represents the value of the Gaussian filter convolution kernel at the coordinate (x,y).

[0049] Generate a 3x3 Gaussian template according to the formula, and convolve the 3x3 pixel area with the 3x3 Gaussian template to get the grayscale value of the blurred center pixel.

[0050] Step S2: fast gradient detection: judging the gradient amplitude and direction of a single pixel point on the processed image data;

[0051] Step S2.1: To calculate the gradient magnitude and direction of the central pixel, the 3x3 pixel value matrix centered on the pixel is compared with Figure 2 The 0°, 45°, 90°, and 135° gradient detection operator matrices shown perform convolution operations at corresponding positions to obtain the gradient amplitude values ​​of the central pixel corresponding to 0°, 45°, 90°, and 135°.

[0052] The gradient detection operator matrix is:

[0053]

[0054]

[0055] Among them, F 0° 、F 45° 、F 90° 、F 135° Respectively represent the 0°, 45°, 90°, and 135° gradient detection operator matrices;

[0056] For example, we set the 3x3 pixel value matrix to

[0057]

[0058] We need to calculate the gradient amplitude value of the central pixel Z5 in the 0° direction. Then according to the 0° direction gradient detection operator F 0°, we will perform Z1-Z3+Z4-Z6+Z7-Z9 operations to obtain the gradient amplitude value of the center pixel in the 0° direction.

[0059] Step S2.2: Take the inverse of the gradient amplitudes in the four directions obtained in step 2.1 to obtain the gradient amplitudes in the other four opposite directions (180°; 225°; 270°; 315°).

[0060] Step S2.3: Clear the obtained gradient amplitude values ​​in all directions to zero. After comparing the gradient amplitude values ​​in all directions to obtain the maximum value, the maximum value is used as the final gradient amplitude value of the pixel point, and the corresponding direction is used as the gradient direction of the pixel point. For example, the maximum value of the final gradient amplitude value of a pixel is 27, and the corresponding gradient operator is Figure 2 The 0° operator shown in Figure 2 shows that the gradient magnitude of the pixel is 27 and the gradient direction is 0°.

[0061] Step S3: non-maximum suppression: using non-maximum suppression, the non-maximum values ​​in the gradient direction obtained in step S2 are set to 0 to remove noise points;

[0062] Step S3.1: Using the gradient amplitude value and gradient direction of the pixel point obtained in step 2 as a basis for judgment, the gradient amplitude values ​​of all pixel points in the 3x3 pixel point square area centered on the pixel point are calculated in the same manner as in step 2.

[0063] Step S3.2: Perform non-maximum suppression of the central pixel value. Compare the gradient amplitudes of the two pixels corresponding to the central pixel value in the gradient direction with the gradient amplitude of the central pixel. If it is not the maximum gradient amplitude of the three pixels, set its grayscale value to 0.

[0064] For example, the result calculated according to step 2 for a certain pixel is that the gradient direction is 45° and the gradient amplitude is 27. Then we calculate the gradient direction and gradient amplitude of all pixels in the 3x3 square matrix area centered on the pixel, and compare the gradient amplitude of the pixel to the upper right and lower left of the pixel. If the gradient amplitude of the pixel is not the maximum value, its gray value is set to 0.

[0065] Step S4: double threshold detection; perform secondary filtering on the edge image obtained in step 3 to filter out edge points with small edge strength and short edge chain to obtain a binary edge image.

[0066] Step S4.1: Set a high threshold and a low threshold, and use the relationship between the gradient amplitude of the current pixel and the high and low thresholds to determine whether it is an edge point;

[0067] Step S4.2: If the gradient amplitude value of the pixel point is higher than the high threshold, its grayscale value is set to the maximum grayscale value of 255, so as to form a high-contrast image with non-edge points in the subsequent step, thereby achieving a better visual effect of the edge image; if the gradient amplitude value of the pixel point is lower than the low threshold, its grayscale value is set to the minimum grayscale value of 0; if the gradient amplitude value of the pixel point is between the high and low thresholds, the pixel gradient amplitude is searched from the 8-neighborhood of the pixel, and if there is a pixel gradient amplitude value greater than the high threshold, its grayscale value is set to 255, otherwise it is set to 0;

[0068] Step S4.3: traverse all pixel points in the pixel value matrix to obtain the final binarization result of each pixel point; and return the processed binarization matrix to the host computer to realize edge image echo.

[0069] The fast gradient detection method based on pixel difference proposed in this invention will complete the generation of hardware circuit description language (HDL) through high-level language synthesis. After completing the simulation verification, the real edge computing scenario will be built using this FPGA hardware platform. Its basic hardware circuit architecture diagram is mainly composed of an ARM processor and a packaged edge detection computing kernel. Figure 4 As shown in the figure, the hardware circuit mainly consists of an ARM core, a data transfer controller with a streaming data interface, an edge computing core implemented based on this method, and an external DRAM memory read-write controller. The LINUX system running on the ARM core completes image data scheduling through the python runtime environment. The image data is read from the external storage card into the internal space through the DDR controller (dynamic random access memory) integrated on the core. After the core completes data preprocessing, it calls DMA (data transfer controller) to send the image data to the computing core through the streaming AXI Stream interface, and puts the image data back to the memory space after the calculation is completed. The ARM core completes the data post-processing and completes the result echo.

[0070] Figure 5 This is the edge detection result echo picture realized by the present invention after the above process. There are two crucial conditions for the present invention to solve the problem. One is that the picture for edge detection has been reasonably convolved with a Gaussian kernel, so that the switching work is normal. The second is that the hardware circuit based on the present invention has completed sufficient functional verification.

[0071] In summary, the fast gradient detection method based on pixel difference in the present invention has improved the traditional Canny algorithm and proposed a new solution from the size and direction of the gradient. It realizes the accurate generation of the size and direction of the image gradient data, and reduces the computational complexity of hardware implementation, thereby reducing resource consumption and power consumption loss.

[0072] It is to be understood that the present invention is described by some embodiments, and it is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the scope of protection of the present invention.

Claims

1. A fast gradient detection method based on pixel difference, characterized in that: The following steps are involved: Step S1: Obtain an original grayscale image, and perform Gaussian filtering on the grayscale image to be processed; Step S2: fast gradient detection: judging the gradient amplitude and direction of a single pixel point on the processed image data; Step S2.1: Perform convolution operations on the 3×3 pixel value matrix centered on the pixel point with the 0°, 45°, 90°, and 135° gradient detection operator matrixes at corresponding positions to obtain the gradient amplitude values ​​of the central pixel point corresponding to 0°, 45°, 90°, and 135°; The gradient detection operator matrix is: F 0° 、F 45° 、F 90° 、F 135° Respectively represent the 0°, 45°, 90°, and 135° gradient detection operator matrices; Set the 3x3 pixel value matrix to: Step S2.2: Take the inverse of the gradient amplitudes in the four directions obtained in step 2.1 to obtain the gradient amplitudes in the other four opposite directions of 180°, 225°, 270°, and 315°; Step S2.3: Clear the negative values ​​of the gradient amplitude values ​​in all directions, compare the gradient amplitude values ​​in all directions to get the maximum value, use the maximum value as the final gradient amplitude value of the pixel, and use the corresponding direction as the gradient direction of the pixel; Step S3: non-maximum suppression: using non-maximum suppression, the non-maximum value of the gradient amplitude in the gradient direction obtained in step S2 is set to 0 to remove noise points; Step S4: double threshold detection; perform secondary filtering on the edge image obtained in step S3 to filter out edge points with small edge strength and short edge chain to obtain a binary edge image.

2. The fast gradient detection method based on pixel difference according to claim 1, characterized in that: The specific steps of step S1 are as follows: The grayscale image is converted into a pixel value matrix, a 3x3 area is taken out from the pixel value matrix for central pixel blurring, and a two-dimensional Gaussian function convolution kernel is used to perform smoothing filtering on the image; the calculation formula of the two-dimensional Gaussian function kernel is as follows: Where x and y represent the horizontal and vertical distances of the pixel relative to the center of the processing area; σ is the standard deviation of the Gaussian function; H(x, y, σ) represents the value of the Gaussian filter convolution kernel at the coordinate (x, y); Generate a 3x3 Gaussian template according to the formula, and convolve the 3x3 pixel area with the 3x3 Gaussian template to get the grayscale value of the blurred center pixel.

3. The fast gradient detection method based on pixel difference according to claim 1, characterized in that: The specific steps of step S3 are as follows: Step S3.1: Using the gradient amplitude value and gradient direction of the pixel point obtained in step S2 as a basis for judgment, the gradient amplitude values ​​of all the pixels in the 3x3 pixel point square matrix area centered on the pixel point are calculated in the same manner as in step S2; Step S3.2: Perform non-maximum suppression on the central pixel value; compare the gradient amplitudes of the two pixels corresponding to the gradient direction of the central pixel value with the gradient amplitude of the central pixel. If it is not the maximum gradient amplitude of the three pixels, set its grayscale value to 0.

4. The fast gradient detection method based on pixel difference according to claim 1, characterized in that: The specific steps of step S4 are as follows: Step S4.1: Set a high threshold and a low threshold, and use the relationship between the gradient amplitude of the current pixel and the high and low thresholds to determine whether it is an edge point; Step S4.2: If the gradient amplitude value of the pixel point is higher than the upper threshold, its grayscale value is set to the grayscale maximum value; if the gradient amplitude value of the pixel point is lower than the lower threshold, its grayscale value is set to the grayscale minimum value; If the gradient amplitude value of the pixel point is between the high and low thresholds, the pixel gradient amplitude is searched from the 8-neighborhood of the pixel. If there is a pixel gradient amplitude value greater than the high threshold, its grayscale value is set to the maximum grayscale value, otherwise it is set to the minimum grayscale value; Step S4.3: traverse all pixel points in the pixel value matrix to obtain the final binarization result of each pixel point; The processed binary matrix is ​​returned to the host computer to realize edge image echo.

5. The fast gradient detection method based on pixel difference according to claim 1, characterized in that: The maximum grayscale value is set to 255, and the minimum grayscale value is set to 0.

6. A fast gradient detection device based on pixel difference, characterized in that: The device includes a processor and an edge detection computing kernel; wherein the edge detection computing kernel implements the method according to any one of claims 1-5.

7. The fast gradient detection device based on pixel difference according to claim 6, characterized in that: The processor runs a LINUX system to complete image data scheduling, and reads image data from an external storage card into an internal space through a dynamic random access memory integrated on the processor. After the processor completes data preprocessing, it calls a data movement controller to send the image data to an edge detection calculation kernel, and puts the image data after calculation back into the memory space. The processor completes data postprocessing and completes result display.

Citation Information

Patent Citations

  • Local sorted orientation histogram descriptor-based image correspondence point extraction method

    CN105631860A

  • Improved-canny-operator-based part image edge extraction method

    CN107220988A

  • A method for enhancing image edge characteristics based on an improved prewitt operator

    CN109559323A

  • Canny edge detection method based on edge self-growth

    CN111127498A

  • Noise image denoising and dynamic target enhancement method based on time-space domain joint filtering

    CN116523778A