Image edge extraction method and device, computer device and storage medium
By generating unit location vector maps and edge digital feature maps, and combining them with the local nonmaximum suppression algorithm, the problem of existing edge detection algorithms being sensitive to noise and illumination changes is solved, and better edge detection robustness is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNIV OF MINING & TECH (BEIJING)
- Filing Date
- 2022-12-12
- Publication Date
- 2026-06-16
AI Technical Summary
Existing edge detection algorithms are sensitive to noise and changes in lighting, have poor robustness, and are difficult to effectively detect image edge information in complex environments.
By generating unit location vector maps and edge digital feature maps, and combining them with local nonmaximum suppression algorithms, the impact of noise and illumination changes on edge detection is reduced, thereby improving robustness.
It effectively reduces the impact of noise and illumination changes on edge detection, thus improving the robustness of edge detection.
Smart Images

Figure CN115760895B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image edge extraction method, apparatus, computer device, and readable storage medium. Background Technology
[0002] Edge detection algorithms are the most fundamental and important image processing tools in the field of image processing, and an essential component of image processing technology. Edge detection technology extracts edge information from an image by preprocessing it, thereby significantly reducing the amount of data required for subsequent image processing and simplifying the image analysis process.
[0003] Edge detection is primarily used in many fields, including medicine, robotics, meteorology, and pattern recognition systems. Currently, most edge detection algorithms are designed solely based on the strength of gradient vectors. However, the strength of gradient vectors is typically sensitive to noise and changes in illumination within an image. Therefore, in situations with changing external environments or high noise levels, current edge detection algorithms cannot robustly detect edge information in images. Summary of the Invention
[0004] Therefore, it is necessary to provide an image edge extraction method, apparatus, computer device, and readable storage medium to address the above-mentioned technical problems. This method uses the structural information of the edges to reduce the impact of noise and illumination changes on edge detection, resulting in better robustness.
[0005] In a first aspect, this application provides an image edge extraction method, the method comprising:
[0006] The original image is preprocessed to obtain its gradient information;
[0007] A unit position vector map is generated by locating the center point of the image template, and then an edge digital feature map is generated based on the gradient information of the image and the unit position vector map; the image template is generated based on the size of the original image.
[0008] The local nonmaxima suppression algorithm is used to find the local maximum value of the edge digit feature map, thereby locating the edge position information of the edge digit feature map.
[0009] In one embodiment, the preprocessing of the original image to obtain gradient information of the original image includes:
[0010] Convert the original image to a grayscale image;
[0011] The grayscale image is subjected to noise reduction processing;
[0012] The Sobel horizontal and vertical operators are used to perform convolution operations with the denoised grayscale image to generate the horizontal gradient component map and the vertical gradient component map of the image.
[0013] In one embodiment, generating a unit position vector map by locating the center point of an image template includes:
[0014] Establish a coordinate system on the image template, and place the origin of the coordinate system at the center point of the image template;
[0015] Generate a corresponding unit position vector map based on the relationship between the position of each pixel on the image template and the origin of the coordinate system.
[0016] In one embodiment, generating an edge digital feature map based on the unit location vector map and the gradient information of the image includes:
[0017] The unit position vector map is slid pixel by pixel on the gradient vector map to generate the edge digital features of each pixel; the gradient vector map is a graphical representation of the gradient component map;
[0018] By combining all the aforementioned edge digit features, an edge digit feature map is generated.
[0019] In one embodiment, generating an edge digital feature map based on the unit location vector map and the gradient information of the image includes:
[0020] The horizontal and vertical component maps of the unit position vector map are rotated 180 degrees; the horizontal and vertical component maps are digital representations of the unit position vector map.
[0021] The rotated horizontal component image and the vertical component image are convolved with the horizontal gradient component image and the vertical gradient component image, respectively, to generate edge digital features;
[0022] By combining all the aforementioned edge digit features, an edge digit feature map is generated.
[0023] In one embodiment, the step of using a local nonmaxima suppression algorithm to find the local maximum value of the edge digit feature map, thereby locating the edge position information of the edge digit feature map, includes:
[0024] The horizontal gradient component map and the vertical gradient component map are used to provide a reference direction for the local nonmaximum suppression algorithm;
[0025] Based on the reference direction and adjacent pixels, determine whether the current pixel is a local maximum.
[0026] A binarized image is generated based on the judgment result, wherein the edges of the binarized image are composed of single pixels.
[0027] Secondly, this application provides an image edge extraction apparatus, the apparatus comprising:
[0028] The preprocessing module is used to preprocess the original image to obtain the gradient information of the original image;
[0029] The image processing module is used to generate a unit position vector map by locating the center point of the image template, and then generate an edge digital feature map based on the gradient information of the unit position vector map and the image; the image template is generated based on the size of the original image.
[0030] The edge finding module is used to find the local maximum value of the edge digital feature map by employing the local nonmaximum suppression algorithm, thereby locating the edge position information of the edge digital feature map.
[0031] Thirdly, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the methods described above.
[0032] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the following steps.
[0033] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, performs the following steps.
[0034] The aforementioned image edge extraction method, apparatus, computer equipment, and storage medium preprocess the input image to obtain the gradient information of the original image. Then, a unit position vector map is generated by locating the center point of the image template. Based on the unit position vector map and the gradient information of the image, an edge digital feature map is generated. Finally, a local non-maximum suppression algorithm is used to search for the local maxima of the edge digital feature map and suppress all gradient values except for the local maxima, thereby highlighting the edges of the edge digital feature map. This method, by processing the edge structure information of the edge feature map, can reduce the influence of noise and illumination changes on edge detection and has better robustness. Attached Figure Description
[0035] Figure 1 This is a schematic diagram of the image edge extraction method in the first embodiment;
[0036] Figure 2 This is a schematic diagram of the image edge extraction method in the second embodiment;
[0037] Figure 3 This is a schematic diagram of the image edge extraction method in the third embodiment;
[0038] Figure 4 This is a schematic diagram of the image edge extraction method in the fourth embodiment;
[0039] Figure 5 This is a schematic diagram of the image edge extraction method in the fifth embodiment;
[0040] Figure 6 This is a schematic diagram of the image edge extraction method in the sixth embodiment;
[0041] Figure 7 This is a schematic diagram of an image edge extraction device module according to one embodiment;
[0042] Figure 8 This is a schematic diagram illustrating the process of obtaining an image gradient component map in one embodiment.
[0043] Figure 9 This is a schematic diagram illustrating the process of generating a unit location vector map in one embodiment;
[0044] Figure 10 This is a schematic diagram illustrating the process of obtaining an edge digital feature map in one embodiment;
[0045] Figure 11 This is a schematic diagram illustrating the process of obtaining the edge digital feature map in another embodiment;
[0046] Figure 12 This is a reference schematic diagram for determining local maxima in one embodiment;
[0047] Figure 13 This is an internal structural diagram of a computer device according to one embodiment. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0049] like Figure 1 As shown, in one embodiment, an image edge extraction method includes the following steps:
[0050] Step S110: Preprocess the original image to obtain the gradient information of the original image.
[0051] Specifically, in the image preprocessing stage, the image needs to be converted into a grayscale image required for subsequent processing. At the same time, noise reduction processing can be performed on the grayscale image as needed to facilitate the subsequent extraction of gradient information from the image.
[0052] Step S120: A unit position vector map is generated by locating the center point of the image template, and then an edge digital feature map is generated based on the gradient information of the image and the unit position vector map; the image template is generated based on the original image size.
[0053] Step S130: The local nonmaximum suppression algorithm is used to find the local maximum value of the edge digital feature map, thereby locating the edge position information of the edge digital feature map.
[0054] Specifically, non-maximum suppression (NMS) suppresses elements that are not local maxima, which can be understood as a search for local maxima. "Local" refers to a neighborhood, which has two variable parameters: its dimension and its size. NMS helps suppress all gradient values except for local maxima (by setting them to 0), indicating the location of the strongest intensity change. Ultimately, by identifying the local maxima, the edge location information of the edge digit feature map is obtained.
[0055] The aforementioned image edge extraction method preprocesses the input image to obtain the gradient information of the original image. Then, it generates a unit position vector map by locating the center point of the image template. Based on the unit position vector map and the gradient information of the image, it generates an edge digital feature map. Finally, it uses a local non-maximum suppression algorithm to search for local maxima in the edge digital feature map and suppresses all gradient values except for local maxima, thereby highlighting the edges of the edge digital feature map. This method, by processing the edge structure information of the edge feature map, can reduce the impact of noise and illumination changes on edge detection, and has better robustness.
[0056] like Figure 2 As shown, in this embodiment, the original image is preprocessed to obtain its gradient information, including the following steps:
[0057] Step S111: Convert the original image to a grayscale image.
[0058] Step S112: Denoise reduction processing is performed on the grayscale image.
[0059] Specifically, a two-dimensional Gaussian low-pass filter is used to perform Gaussian low-pass filtering on the processed grayscale image, thereby reducing the impact of noise in the image on subsequent edge processing.
[0060] Step S113: The Sobel horizontal and vertical operators are used to perform convolution operations with the denoised grayscale image to generate the horizontal gradient component map and the vertical gradient component map of the image.
[0061] Specifically, the formula for calculating the horizontal gradient component map is:
[0062]
[0063] In the formula, S X This represents the Sobe1 level operator. This represents the convolution operator, and I represents a grayscale image.
[0064] The formula for calculating the vertical gradient component map is:
[0065]
[0066] In the formula, S Y This represents the Sobel vertical operator. This represents the convolution operator, and I represents a grayscale image.
[0067] The above process of using the Sobel operator to convolve with the denoised grayscale image to obtain the gradient component map of the image is as follows: Figure 8 As shown.
[0068] like Figure 3 As shown, in this embodiment, generating a unit position vector map by locating the center point of the image template includes the following steps:
[0069] Step S121: Establish a coordinate system on the image template and place the origin of the coordinate system at the center point of the image template.
[0070] Specifically, a local coordinate system C is defined on the image template P. P The origin of the coordinate system is located at the center point (0, 0) of the template, as shown below. Figure 9 As shown, the size of the image template is defined as (2N+1)×(2N+1). In practical applications, the size of N can be set according to the original image.
[0071] Step S122: Generate a corresponding unit position vector map based on the relationship between the position of each pixel on the image template and the origin of the coordinate system.
[0072] Specifically, Figure 9 The X-axis points horizontally, and the Y-axis points vertically. The figure shows the position coordinates of the four corner pixels on the template. Then, a corresponding unit position vector map L is generated based on the position coordinates of each pixel. Let p... m,nLet (m, n) represent the pixel at position (m, n) in the template. Then, the corresponding unit position vector at that position can be represented as:
[0073]
[0074] In the formula,
[0075] like Figure 4 As shown, in this embodiment, generating an edge digital feature map based on the unit location vector map and the gradient information of the image includes the following steps:
[0076] Step S123: The unit position vector map is slid pixel by pixel on the gradient vector map to generate the edge digital features of each pixel; the gradient vector map is a graphical representation of the gradient component map.
[0077] Specifically, such as Figure 10 As shown, the vector element of the image gradient vector map G at pixel coordinates (i, j) is represented by V. i,j =(G X|i,j G Y|i,j ) indicates that G X|i,j and G Y|i,j Representing graph G X and G Y The gradient component value at coordinates (i, j). If the center point O of the image template P at the current moment coincides with the image coordinates (i, j), then the edge digital features at the image position (i, j) can be calculated by the following formula:
[0078] (k and l are not both zero)
[0079] In the formula, the operator × represents the vector cross product operation, and ||·|| is the modulo operator.
[0080] Step S124: Integrate all edge digit features to generate an edge digit feature map.
[0081] The above process, when calculating the digital features of image edges, requires cross product operations between vectors. Therefore, when the image size is large, this can lead to a sharp increase in computational cost, significantly increasing image processing time. To improve processing speed, the above calculation process can be transformed into a convolution operation, thus saving processing time. For example... Figure 5 As shown, in this embodiment, generating an edge digital feature map based on the unit location vector map and the gradient information of the image includes the following steps:
[0082] Step S123: Rotate the horizontal and vertical component maps of the unit location vector map by 180 degrees; the horizontal and vertical component maps are digital representations of the unit location vector map.
[0083] Specifically, such as Figure 11 As shown, let L X and L Y These represent the horizontal and vertical components of the unit position vector map L obtained using image template P. First, L... X and L Y Rotate 180 degrees counterclockwise.
[0084] Step S124: The rotated horizontal component map and vertical component map are convolved with the horizontal gradient component map and vertical gradient component map respectively to generate edge digital features.
[0085] Specifically, calculate the rotated L X With G X The convolution between them is calculated using the following formula:
[0086]
[0087] In the formula, L X G represents the horizontal component of a unit location vector map. Y This represents the vertical gradient component plot. This represents the convolution operator.
[0088] Calculate L after rotation Y With G Y The convolution between them is calculated using the following formula:
[0089]
[0090] In the formula, L y G represents the vertical component of a unit position vector diagram. X Represents the horizontal gradient component map. This represents the convolution operator.
[0091] The digital feature value E of the image edge at position (i, j) in the image i,j It can be rewritten as follows:
[0092] (k and l are not both zero)
[0093] In the formula, |·| is the absolute value operator.
[0094] Step S125: Integrate all edge digit features to generate an edge digit feature map.
[0095] The image edge digital feature map E obtained through the above steps suffers from issues such as edge coarseness and weak edge interference. To effectively locate the edge position information, a local nonmaximum suppression algorithm is needed to find local maxima and thus accurately locate the edge information. For example... Figure 6As shown, in this embodiment, the local nonmaximum suppression algorithm is used to find the local maximum value of the edge digit feature map, thereby locating the edge position information of the edge digit feature map, including the following steps:
[0096] Step S131: Use the horizontal gradient component map and the vertical gradient component map to provide a reference direction for the local nonmaximum suppression algorithm.
[0097] Specifically, using G X and G Y To provide a directional reference for the local nonmaximum suppression algorithm, the calculation formula is as follows:
[0098]
[0099] In the formula,
[0100] Step S132: Determine whether the current pixel is a local maximum value based on the reference direction and adjacent pixels.
[0101] Specifically, such as Figure 12 As shown, the method uses the reference direction (i.e., the gradient vector direction) and the eight neighboring pixels around the current pixel to determine whether the current pixel is a local maximum. These eight neighboring pixels can be divided into four groups (left-right, top-left and bottom-right, top-bottom, bottom-left and top-right), corresponding to the four directions of 0°, 45°, 90°, and 135°, respectively. Based on the calculated gradient direction of the current pixel, the two pixels closest to this direction are selected from the eight neighboring pixels. Then, it is determined whether the edge numerical feature value of the current pixel is greater than the edge numerical feature values of these two pixels simultaneously. If so, the pixel value is set to 1; otherwise, the pixel value is set to 0.
[0102] Step S133: Generate a binarized image based on the judgment result. The edges of the binarized image are composed of single pixels.
[0103] like Figure 7 As shown, in one embodiment, an image edge extraction device includes a preprocessing module 110, an image processing module 120, and an edge finding module 130.
[0104] The preprocessing module 110 is used to preprocess the original image to obtain the gradient information of the original image.
[0105] The image processing module 120 is used to generate a unit position vector map by locating the center point of the image template, and then generate an edge digital feature map based on the gradient information of the image and the unit position vector map; the image template is generated based on the original image size.
[0106] The edge finding module 130 is used to find the local maximum value of the edge digital feature map by using the local nonmaximum suppression algorithm, thereby locating the edge position information of the edge digital feature map.
[0107] In this embodiment, the preprocessing module 110 is specifically used to: convert the original image into a grayscale image; perform noise reduction processing on the grayscale image; and perform convolution operations with the noise-reduced grayscale image using the Sobel horizontal operator and vertical operator respectively, thereby generating the horizontal gradient component map and the vertical gradient component map of the image.
[0108] In one embodiment, the image processing module 120 is specifically used to: establish a coordinate system on the image template and place the origin of the coordinate system at the center point of the image template; generate a corresponding unit position vector map based on the relationship between the position of each pixel on the image template and the origin; slide the unit position vector map pixel by pixel on the gradient vector map to generate the edge digital features of each pixel; the gradient vector map is a graphical representation of the gradient component map; and combine all edge digital features to generate an edge digital feature map.
[0109] In another embodiment, the image processing module 120 is specifically used to: establish a coordinate system on the image template and place the origin of the coordinate system at the center point of the image template; generate a corresponding unit position vector map based on the relationship between the position of each pixel on the image template and the origin; rotate the horizontal component map and the vertical component map of the unit position vector map by 180 degrees; the horizontal component map and the vertical component map are digital representations of the unit position vector map; perform convolution operations with the horizontal gradient component map and the vertical gradient component map respectively using the rotated horizontal component map and the vertical gradient component map to generate edge digital features; and combine all edge digital features to generate an edge digital feature map.
[0110] In this embodiment, the edge finding module 130 is specifically used to: provide a reference direction for the local nonmaximum suppression algorithm using the horizontal gradient component map and the vertical gradient component map; determine whether the current pixel is a local maximum based on the reference direction and adjacent pixels; generate a binarized image based on the determination result; and the edges of the binarized image are edges composed of single pixels.
[0111] In one embodiment, a computer device is provided, which may be a smart terminal, and its internal structure diagram may be as follows: Figure 13As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements an image edge extraction method.
[0112] Those skilled in the art will understand that Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0113] In one embodiment, a computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps in the above-described method embodiments. In another embodiment, a computer storage medium stores a computer program, the computer program being executed by a processor to implement the steps in the above-described method embodiments.
[0114] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0115] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0116] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0117] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. An image edge extraction method, characterized in that, The method includes: The original image is preprocessed to obtain its gradient information; A unit position vector map is generated by locating the center point of the image template, and then an edge digital feature map is generated based on the gradient information of the image and the unit position vector map; the image template is generated based on the size of the original image. The local nonmaxima suppression algorithm is used to find the local maximum value of the edge digit feature map, thereby locating the edge position information of the edge digit feature map; The preprocessing of the original image to obtain its gradient information includes: Convert the original image to a grayscale image; The grayscale image is subjected to noise reduction processing; The Sobel horizontal and vertical operators are used to perform convolution operations with the denoised grayscale image, respectively, to generate the horizontal gradient component map and the vertical gradient component map of the image. The method of generating a unit position vector map by locating the center point of an image template includes: Establish a coordinate system on the image template, and place the origin of the coordinate system at the center point of the image template; Generate a corresponding unit position vector map based on the relationship between the position of each pixel on the image template and the origin of the coordinate system; The step of generating an edge digital feature map based on the unit location vector map and the gradient information of the image includes: The unit position vector map is slid pixel by pixel on the gradient vector map to generate the edge digital features of each pixel; the gradient vector map is a graphical representation of the horizontal gradient component map and the vertical gradient component map; By combining all the aforementioned edge digit features, an edge digit feature map is generated.
2. The image edge extraction method according to claim 1, characterized in that, The step of generating an edge digital feature map based on the unit location vector map and the gradient information of the image includes: The horizontal and vertical component maps of the unit position vector map are rotated 180 degrees; the horizontal and vertical component maps are digital representations of the unit position vector map. The rotated horizontal component image and the vertical component image are convolved with the horizontal gradient component image and the vertical gradient component image, respectively, to generate edge digital features; By combining all the aforementioned edge digit features, an edge digit feature map is generated.
3. The image edge extraction method according to claim 2, characterized in that, The step of using a local nonmaximum suppression algorithm to find the local maximum value of the edge digit feature map, thereby locating the edge position information of the edge digit feature map, includes: The horizontal gradient component map and the vertical gradient component map are used to provide a reference direction for the local nonmaximum suppression algorithm; Based on the reference direction and adjacent pixels, determine whether the current pixel is a local maximum. A binarized image is generated based on the judgment result, wherein the edges of the binarized image are composed of single pixels.
4. An image edge extraction apparatus for implementing the steps of the method according to any one of claims 1 to 3, characterized in that, The device includes: The preprocessing module is used to preprocess the original image to obtain the gradient information of the original image; The image processing module is used to generate a unit position vector map by locating the center point of the image template, and then generate an edge digital feature map based on the gradient information of the unit position vector map and the image; the image template is generated based on the size of the original image. The edge finding module is used to find the local maximum value of the edge digital feature map by employing the local nonmaximum suppression algorithm, thereby locating the edge position information of the edge digital feature map.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.