Image edge detection method, device and related equipment
By filtering and quantizing the gradient values and gradient angles of the image in edge detection, combined with density clustering and non-maximum suppression, the problem of noise influence is solved, and the accuracy of edge detection is improved.
Patent Information
- Application Number
- CN202111098587.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-18
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2041-09-18
AI Technical Summary
Edge detection technology is easily affected by image noise, resulting in poor detection performance.
By acquiring the gradient value and gradient angle of the target image, pixels with gradient values greater than a threshold are selected, their gradient angles are quantized to determine edge nodes, and noise is removed through methods such as density clustering and non-maximum suppression to improve detection performance.
It effectively removes the influence of image noise and improves the accuracy and effect of image edge detection.
Smart Images

Figure CN115830048B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision, and in particular to an image edge detection method and device and related equipment. BACKGROUND
[0002] In the intelligent human-computer interaction process, edge detection technology has become an important basis for image analysis such as image segmentation, target region recognition and region shape extraction. Edge detection technology plays an increasingly important role in scientific research, industrial production, military technology and health, and the research on edge detection technology has been increasingly valued by people. At present, the edge detection technology is easily affected by image noise, resulting in poor detection effect. SUMMARY
[0003] The embodiments of the present application provide an image edge detection method, device and related equipment, which solve the problem that the edge detection technology is easily affected by image noise.
[0004] To achieve the above object, in a first aspect, the embodiments of the present application provide an image edge detection method, comprising:
[0005] obtaining image features of a target image, the image features comprising gradient values and gradient angles of each pixel point in N pixel points in the target image, N being a positive integer;
[0006] determining M pixel points adjacent to the first target pixel point according to the first target pixel point, M being a positive integer, the first target pixel point being a pixel point with a gradient value greater than a first threshold in the N pixel points;
[0007] quantizing the gradient angles of the M pixel points to determine M quantized values of the M pixel points, M being a positive integer, the first target pixel point being the pixel point with the gradient value greater than the first threshold;
[0008] determining edge nodes of the target image according to the M quantized values;
[0009] detecting the target image according to the edge nodes to obtain an edge detection result.
[0010] In a second aspect, the embodiments of the present application provide an image edge detection device, comprising:
[0011] a first obtaining module configured to obtain image features of a target image, the image features comprising gradient values and gradient angles of each pixel point in N pixel points in the target image, N being a positive integer;
[0012] The first determining module is configured to determine M pixel points adjacent to the first target pixel point according to the first target pixel point, M being a positive integer, and the first target pixel point being a pixel point with a gradient value greater than a first threshold in the N pixel points.
[0013] The second determining module is configured to quantize gradient angles of the M pixel points to determine M quantized values of the M pixel points, M being a positive integer, and the first target pixel point being a pixel point with a gradient value greater than a first threshold.
[0014] The third determining module is configured to determine an edge node of the target image according to the M quantized values.
[0015] The fourth determining module is configured to detect the target image according to the edge node to obtain an edge detection result.
[0016] In a third aspect, an electronic device is provided, which includes a memory, a processor, and a program stored in the memory and capable of running on the processor; the processor is configured to read the program in the memory to implement the steps in the image edge detection method according to the first aspect.
[0017] In a fourth aspect, a readable storage medium is provided, which is used to store a program, and the program is executed by a processor to implement the steps in the image edge detection method according to the first aspect.
[0018] In the embodiments of the present application, the gradient value and the gradient angle of each pixel point in N pixel points in a target image are obtained, M pixel points adjacent to a first target pixel point with a gradient value greater than a first threshold in the N pixel points are determined according to the first target pixel point, the gradient angles of the M pixel points are quantized to determine M quantized values of the M pixel points, and an edge node of the target image is determined according to the M quantized values. The first target pixel point is screened according to the gradient value of the pixel point, the quantized values are obtained by quantizing the gradient angles of the pixel points, and the edge node is further screened according to the quantized values. Thus, the image noise points are removed in the process of screening the edge node according to the gradient value and the gradient angle of the pixel point, thereby solving the problem that the edge detection technology is easily affected by image noise points and improving the detection effect of image edge detection. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings in the specification are described as follows. Obviously, the following drawings are only embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0020] Figure 1is a structural schematic diagram of a system to which embodiments of the present application can be applied;
[0021] Figure 2 is a flowchart of an image edge detection method provided by embodiments of the present application;
[0022] Figure 3 is one of example images of a target image provided by embodiments of the present application;
[0023] Figure 4 is Figure 3 a schematic diagram of pixel gradient values of the target image of
[0024] Figure 5 is Figure 3 a schematic diagram of gradient angle quantization of the target image of
[0025] Figure 6 is Figure 3 a schematic diagram of a second edge node of the target image of
[0026] Figure 7 is Figure 3 a schematic diagram of an edge node set of the target image of
[0027] Figure 8 is the second of example images of a target image provided by embodiments of the present application;
[0028] Figure 9 is a structural schematic diagram of an image edge detection device provided by embodiments of the present application;
[0029] Figure 10 is a structural schematic diagram of an electronic device provided by embodiments of the present application. DETAILED DESCRIPTION
[0030] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. On the basis of the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0031] Referring to Figure 1 , Figure 1 is a structural diagram of a system to which embodiments of the present application can be applied, such as Figure 1As shown, it includes a smart camera 11, an industrial computer 12 and a machine 13. The smart camera 11 and the industrial computer 12 can communicate with each other. The smart camera 11 can detect a target image according to the method provided in the embodiments of the present application, and can send the detection result to the industrial computer 12. The industrial computer 12 and the machine 13 can also communicate with each other. The industrial computer 12 sends an instruction to the machine 13 according to the detection result, and controls the machine 13 to perform an operation according to the instruction.
[0032] Unlike the traditional industrial visual detection system that transmits a target image to an industrial computer for processing and analysis, the method provided in the embodiments of the present application can complete the processing, detection and analysis of the target image in the smart camera, and return the detection result to the industrial computer through a communication module. In this way, on the one hand, the paid software tool library can be avoided to be installed on the industrial computer, and the hardware and software performance requirements of the industrial computer are reduced. On the other hand, the data transmission pressure is also reduced.
[0033] The method provided in the embodiments of the present application can be stored in a chip. The chip can be a chip integrating computing and storage, and the chip has a corresponding calling and testing interface, which can facilitate subsequent fine tuning for different application scenarios. The chip is integrated in the smart camera 11.
[0034] Referring to Figure 2 , Figure 2 is one of the flow diagrams of the image edge detection method provided in the embodiments of the present application. Figure 2 The image edge detection method shown can be executed by the smart camera 11.
[0035] As shown in Figure 2 , the image edge detection method can include the following steps:
[0036] Step 201, obtaining image features of a target image, the image features including gradient values and gradient angles of each pixel point in N pixel points in the target image, N being a positive integer.
[0037] The method for obtaining the image features of the target image includes but is not limited to Sobel operator, Prewitt edge detection operator, Roberts edge detection operator, Canny edge detection operator and Laplace edge detection operator. The N first gradients in the x-axis direction and the N second gradients in the y-axis direction of the N pixel points can be obtained first, and then the N gradient values and the N gradient angles can be determined according to the N first gradients and the N second gradients.
[0038] In a specific implementation, the image features of the target image can be obtained by using a Sobel operator. The Sobel operator is a weighted difference of the gray values of the four fields above, below, left and right of each pixel point in the target image, and reaches an extreme value at the edge to detect the edge. The Sobel operator has two, one detects the horizontal edge, and the other detects the vertical edge. The Sobel operator can be used to determine the gradient value sobel_x of the x-axis direction and the gradient value sobel_y of the y-axis direction of each pixel point in the target image, sobel_x = Sobel (img, 1, 0), sobel_y = Sobel (img, 0, 1). Then, the gradient value of each pixel point is determined according to the gradient value of the x-axis direction and the gradient value of the y-axis direction of each pixel point and the gradient angle angle = arctan (sobel_y / sobel_x) of each pixel point.
[0039] The N pixel points are the initial edge nodes in the target image detected by the operator. In a specific implementation, the number of initial edge nodes of the target image obtained by the operator can also be adjusted by using a preset parameter value. For example, the preset parameter value is set as a lower limit value of the initial edge nodes, so that the number of initial edge nodes of the target image detected by the operator is greater than the preset parameter value.
[0040] If the target image is as shown in Figure 3 , after obtaining the image features of the target image by using the operator, the gradient graph corresponding to the target image can be obtained, and the gradient graph corresponding to the target image is as shown in Figure 4 .
[0041] In step 202, M pixel points adjacent to the first target pixel point are determined according to the first target pixel point, and M is a positive integer. The first target pixel point is a pixel point with a gradient value greater than a first threshold value in the N pixel points.
[0042] The first threshold value is a value set in advance according to actual conditions, and the pixel point with a gradient value greater than the first threshold value in the N pixel points is determined as the first target pixel point. If there is more than one first target pixel point, the M pixel points adjacent to each first target pixel point should be determined. In a specific implementation, the 9 pixel points in the 3x3 window adjacent to the first target pixel point can be determined as the M pixel points adjacent to the first target pixel point. Alternatively, the 16 pixel points in the 4x4 window adjacent to the first target pixel point can be determined as the M pixel points adjacent to the first target pixel point. The appropriate adjacent range can be selected according to actual needs, so as to determine the M pixel points adjacent to the first target pixel point.
[0043] In step 203, the gradient angles of the M pixel points are quantized to determine M quantized values of the M pixel points.
[0044] In practical implementation, the M pixels adjacent to the first target pixel can be arranged as follows: Figure 5 Quantization is performed as shown. Since the gradient angle of a pixel is angle = arctan(sobel_y / sobel_x), the gradient angle of a pixel can range from -180° to +180°. That is, the gradient angles of M pixels can be any value between -180° and +180°. Figure 5 The method shown divides 0° to +180° into eight equal intervals, and uses quantified values such as numbers to represent each interval. For example, 0° to +22.5°, including 0°, is represented by the number 0; 22.5° to +45°, including 22.5°, is represented by the number 1; 45° to +67.5°, including 45°, is represented by the number 2; 67.5° to +90°, including 67.5°, is represented by the number 3; 90° to +112.5°, including 90°, is represented by the number 4; 112.5° to +135°, including 122.5°, is represented by the number 5; 135° to +157.5°, including 135°, is represented by the number 6; and 157.5° to +180°, including both 157.5° and 180°, is represented by the number 7. The numbers 0 to 7 are the quantization values. Similarly, 0° to -180° can be divided into eight equal intervals, and each interval can be represented by a quantization value such as a number. The quantization process for 0° to -180° is similar to that for 0° to +180°, and will not be repeated here.
[0045] After quantizing the gradient angles of M pixels, the quantization value of each pixel is determined by dividing the gradient value of the pixel into equal intervals. For example, if the gradient angle of a pixel is +140.5°, the quantization value of that pixel is 6; and if the gradient angle of a pixel is +0°, the quantization value of that pixel is 0.
[0046] It should be noted that the above method is only one way to determine the quantization value of each pixel in M pixels. In the specific implementation, in the process of determining the quantization value of each pixel in M pixels, the range from -180° to +180° can also be divided into other equal parts, such as 18 equal parts or 12 equal parts; or different letters can be used as quantization values to represent each equal interval.
[0047] Step 204: Determine the edge nodes of the target image based on the M quantization values.
[0048] In practical implementation, the edge nodes of the target image can be determined based on the frequency of occurrence of each of the M quantization values. As an example, if the 9 pixels in a 3×3 window adjacent to the first target pixel are determined as the M pixels adjacent to the first target pixel, and then...Figure 5 In the illustrated manner, -180° to +180° is divided into 16 equal intervals, and first, the quantization values of 9 pixel points are obtained, and the frequencies of each quantization value are counted. For example, the quantization values of 9 pixel points are 1, 5, 0, 2, 5, 5, 5, 3, 3, and 2, the frequency of the quantization value 0 is 1, the frequency of the quantization value 1 is 1, the frequency of the quantization value 2 is 2, the frequency of the quantization value 3 is 2, the frequency of the quantization value 4 is 0, the frequency of the quantization value 5 is 4, the frequency of the quantization value 6 is 0, and the frequency of the quantization value 7 is 0. The pixel point corresponding to the quantization value with the largest frequency of the quantization value can be determined as the edge node of the target image.
[0049] In step 205, the target image is detected according to the edge node, and an edge detection result is obtained.
[0050] After the edge node of the target image is obtained, the density clustering method can be used to cluster, screen, and divide the edge node, and then the edge detection result in the target image is determined according to the clustering result.
[0051] In the embodiment of the present application, the gradient value and the gradient angle of each pixel point in N pixel points in the target image are obtained, the M pixel points adjacent to the first target pixel point with the gradient value greater than the first threshold value in the N pixel points are determined according to the first target pixel point, the gradient angle of the M pixel points is quantized, the M quantization values of the M pixel points are determined, and then the edge node of the target image is determined according to the M quantization values. The first target pixel point is screened out according to the gradient value of the pixel point, the quantization value is obtained by quantizing the gradient angle of the pixel point, and the edge node is further screened out according to the quantization value. In this way, in the process of screening the edge node according to the gradient value and the gradient angle of the pixel point, the image noise points are removed, thereby solving the problem that the edge detection technology is easily affected by the image noise points, and improving the detection effect of the image edge detection.
[0052] Optionally, the edge node of the target image is determined according to the M quantization values, including:
[0053] The frequency of each quantization value in the M quantization values is determined. This step can refer to the specific description of the corresponding part in the foregoing, and will not be described here.
[0054] The pixel point corresponding to the quantization value with the frequency greater than or equal to the first preset value is determined as the first edge node.
[0055] The first preset value is a value determined according to actual conditions, and the first preset value can be determined according to the number of the M pixel points adjacent to the first target pixel point. For example, the first preset value is an integer obtained by dividing the number of the M pixel points by 2, such as if 9 pixel points in a 3*3 window adjacent to the first target pixel point are determined as the M pixel points adjacent to the first target pixel point. Then the first preset value can be 5. For another example, if 16 pixel points in a 4*4 window adjacent to the first target pixel point are determined as the M pixel points adjacent to the first target pixel point. Then the first preset value can be 8.
[0056] In a specific implementation, if 9 pixel points in a 3*3 window adjacent to the first target pixel point are determined as the M pixel points adjacent to the first target pixel point, and the range of -180° to +180° is divided into 16 equal intervals in the manner shown in FIG. 1, the quantization values of the 9 pixel points are obtained first, and then the frequencies of the quantization values are counted. For example, the quantization values of the 9 pixel points are 1, 5, 0, 2, 5, 5, 5, 3, 5, and 2, the frequency of the quantization value 0 is 1, the frequency of the quantization value 1 is 1, the frequency of the quantization value 2 is 2, the frequency of the quantization value 3 is 1, the frequency of the quantization value 4 is 0, the frequency of the quantization value 5 is 5, the frequency of the quantization value 6 is 0, and the frequency of the quantization value 7 is 0. In this scenario, the first preset value can be 5, and the frequency of the quantization value 5 is equal to 5, so the pixel point corresponding to the quantization value 5 can be determined as the first edge node. Figure 5 In a specific implementation, if 9 pixel points in a 3*3 window adjacent to the first target pixel point are determined as the M pixel points adjacent to the first target pixel point, and the range of -180° to +180° is divided into 16 equal intervals in the manner shown in FIG. 1, the quantization values of the 9 pixel points are obtained first, and then the frequencies of the quantization values are counted. For example, the quantization values of the 9 pixel points are 1, 5, 0, 2, 5, 5, 5, 3, 5, and 2, the frequency of the quantization value 0 is 1, the frequency of the quantization value 1 is 1, the frequency of the quantization value 2 is 2, the frequency of the quantization value 3 is 1, the frequency of the quantization value 4 is 0, the frequency of the quantization value 5 is 5, the frequency of the quantization value 6 is 0, and the frequency of the quantization value 7 is 0. In this scenario, the first preset value can be 5, and the frequency of the quantization value 5 is equal to 5, so the pixel point corresponding to the quantization value 5 can be determined as the first edge node.
[0057] According to the first edge node, the edge node of the target image is determined. In a specific implementation, the first edge node can be directly determined as the edge node of the target image.
[0058] In the embodiments of the present application, the edge node of the target image is further determined according to the frequency of the pixel point quantization value, so that the image noise points are further removed in the process of screening the edge node according to the frequency of the pixel point quantization value, thereby solving the problem that the edge detection technology is easily affected by image noise points and improving the detection effect of image edge detection.
[0059] Optionally, the determining the edge node of the target image according to the first edge node comprises:
[0060] The gradient value of the second target pixel point is subjected to non-maximum suppression processing, and a second edge node is determined, the second target pixel point being a pixel point with a gradient value less than a second threshold in the first edge node.
[0061] The second threshold is a value determined based on the actual situation. It should be understood that the second threshold is greater than the first threshold. In the specific implementation, the gradient value of the first edge node is first compared with the second threshold, and the pixels in the first edge node whose gradient value is less than the second threshold are determined as the second target pixels. Then, non-maximum suppression is performed on the gradient value of the second target pixels. Non-maximum suppression (NMS), as the name suggests, suppresses elements that are not maxima, which can be understood as a local maximum search. This local area represents a neighborhood, which has two variable parameters: the dimension of the neighborhood and the size of the neighborhood. The second edge node candidates = NMS(magnitude, S, n_nms) is obtained by performing non-maximum suppression. candidates represents the second edge node, magnitude is the gradient value of each pixel, S represents the second threshold, and n_nms is the value of non-maximum suppression applied to a pixel position within its n_nms x n_nms window. n_nms defaults to 5.
[0062] The obtained second edge nodes can also be arranged in reverse order of gradient values. If the target image is like... Figure 3 As shown, by performing non-maximum suppression, the second edge node can be obtained as follows: Figure 6 As shown.
[0063] The edge nodes of the target image are determined based on the second edge node. In a specific implementation, the second edge node can be directly determined as the edge node of the target image.
[0064] In this embodiment, a second target pixel is selected from the first edge node according to a second threshold, and the gradient value of the second target pixel is subjected to non-maximum suppression processing to further select and determine the edge node of the target image. In this way, image noise is further removed during the above selection process, thereby solving the problem that edge detection technology is easily affected by image noise and improving the detection effect of image edge detection.
[0065] Optionally, determining the edge nodes of the target image based on the second edge node includes:
[0066] The pixel with the largest gradient value in the second edge node is determined as the node in the edge node set.
[0067] In practice, the second edge nodes can be arranged in reverse order of their gradient values. The first second edge node, i.e., the pixel with the largest gradient value among the second edge nodes, is then identified as the node in the edge node set.
[0068] If the distance between the first node in the second edge node and each second node in the edge node set is greater than the preset distance, the first node is determined as a node in the edge node set;
[0069] In a specific implementation, after the pixel point with the maximum gradient value in the second edge node is determined as a node in the edge node set, the distance between the second edge node ranked second and the node in the edge node set, i.e., the pixel point with the maximum gradient value in the second edge node, can be determined according to the descending order of the second edge node.
[0070] If the distance is greater than the preset distance, the second edge node ranked second is determined as a node in the edge node set, and the distance between the second edge node ranked third and the node in the edge node set is continuously determined, where the node in the edge node set includes the pixel point with the maximum gradient value in the second edge node and the second edge node ranked second. The two distances between the second edge node ranked third and the pixel point with the maximum gradient value in the second edge node and the second edge node ranked second are respectively determined. If the two distances are both greater than the preset distance, the second edge node ranked third is determined as an edge node in the edge node set. If one or both of the two distances are less than or equal to the preset distance, it indicates that the second edge node ranked third does not meet the requirement, and whether other nodes in the second edge node meet the requirement is continuously determined until all the second edge nodes are subjected to the above determination, and the determination ends.
[0071] If the distance is less than or equal to the preset distance, it indicates that the second edge node ranked second does not meet the requirement, and the distance between the second edge node ranked third and the node in the edge node set, i.e., the pixel point with the maximum gradient value in the second edge node, is continuously determined. The subsequent process is similar to the foregoing part, which is not described herein again.
[0072] The node in the edge node set is determined as an edge node of the target image. In a specific implementation, the node in the edge node set can be determined as an edge node of the target image.
[0073] If the second edge node is obtained as shown in Figure 6 , the second edge node is processed by using the method provided in the embodiment of the present application, and the node in the obtained edge node set is as shown in Figure 7 .
[0074] In this embodiment, the first node in the second edge node whose distance from each second node in the edge node set is greater than a preset distance is determined as a node in the edge node set, thereby further filtering and determining the edge nodes of the target image. In this way, image noise is further removed during the above filtering process, thereby solving the problem that edge detection technology is easily affected by image noise and improving the detection effect of image edge detection.
[0075] After determining the edge nodes, embodiments of this application can further perform detection on the target image based on the aforementioned edge nodes, such as detecting the exact location of circles or corners in the target image. Optionally, the step of detecting the target image based on the edge nodes to obtain edge detection results includes:
[0076] The edge nodes are divided into P target classes by density clustering, where P is a positive integer;
[0077] Since there are significant intervals between the locations of different edges in the target image, density clustering can be used to divide the edge nodes into P target classes. Figure 8 For example, the method provided in the embodiments of this application is first used to determine... Figure 8 The edge nodes of the target image shown are then divided into 5 target classes, denoted as Cluster1, ..., Cluster5, using density clustering. For each Cluster... i Let i = 1, 2, 3, 4, 5, and denote NC. i This represents the number of samples in this class.
[0078] Generate the angle template of the object to be detected in the target image;
[0079] by Figure 8 For example, if the purpose of detecting a target image is to determine the exact location of a circle within the image, then the object to be detected is a circle. First, an NC (Circular Object Detection) is generated. i The angle template for each circle's edge node is Temp. i , such as when NC i When = 0, Temp i The expression is {0,36,72,108,144,180,216,252,288,324}.
[0080] Determine the P correlation coefficients between the angle template and the gradient angles of the edge nodes in the P target classes;
[0081] by Figure 8 For example, determine Temp i The correlation coefficient between the gradient angles of nodes in the corresponding class. In determining Temp iBefore determining the correlation coefficient of the gradient angles of nodes in the corresponding class, the gradient angle quantization method described above can be used to quantize the angles of each node (i.e., pixel), and calculate the frequency of each quantized value to obtain the quantized angle_tmp with the highest frequency and its corresponding frequency_freq. Finally, angle_quant = 2. angle_tmp If angle_freq ≥ 5, then ELSE 0. The above process reduces the computational load when determining the correlation coefficient, thereby improving efficiency. The correlation coefficient results are shown in Table 1.
[0082] Correlation coefficient Full precision Quant_2 Quant_4 Quant_8 Quant_16 Cluster1 0.850 0.539 0.823 0.850 0.852 Cluster 2 (circle) 0.999 0.956 0.970 0.986 0.999 Cluster3 0.934 0.763 0.908 0.951 0.934 Cluster4 0.697 0.171 0.545 0.772 0.697 Cluster 5 0.894 0.590 0.911 0.900 0.894
[0083] Table 1
[0084] The edge detection results are obtained based on the P correlation coefficients.
[0085] by Figure 8 For example, the location corresponding to the class with the highest correlation coefficient is determined as the exact location of the object to be detected. As shown in Table 1, Cluster2 has the highest correlation coefficient, so the location of Cluster2 can be determined as the exact location of the circle in the target image.
[0086] See Figure 9 This application also provides an image edge detection device 300, comprising:
[0087] The first acquisition module 301 is used to acquire image features of the target image, wherein the image features include the gradient value and gradient angle of each pixel in N pixels of the target image, where N is a positive integer;
[0088] The first determining module 302 is used to determine M pixels adjacent to the first target pixel based on the first target pixel, where M is a positive integer, and the first target pixel is the pixel whose gradient value is greater than a first threshold among the N pixels.
[0089] The second determining module 303 is used to quantize the gradient angles of the M pixels and determine the M quantized values of the M pixels, where M is a positive integer, and the first target pixel is the pixel whose gradient value is greater than the first threshold.
[0090] The third determining module 304 is used to determine the edge nodes of the target image based on the M quantization values;
[0091] The fourth determining module 305 is used to detect the target image based on the edge nodes and obtain the edge detection result.
[0092] Optionally, the third determining module 304 includes:
[0093] The first determining unit is configured to determine a frequency of occurrence of each of the M quantized values;
[0094] The second determining unit is configured to determine, as a first edge node, a pixel point corresponding to a quantized value whose frequency is greater than or equal to a first preset value.
[0095] The third determining unit is configured to determine, according to the first edge node, an edge node of the target image.
[0096] Optionally, the third determining unit comprises:
[0097] performing non-maximum suppression processing on a gradient value of a second target pixel point to determine a second edge node, the second target pixel point being a pixel point in the first edge node whose gradient value is less than a second threshold value;
[0098] determine, according to the second edge node, an edge node of the target image.
[0099] Optionally, the third determining unit comprises:
[0100] determine, as a node in the edge node set, a pixel point in the second edge node whose gradient value is the largest;
[0101] if a distance between a first node in the second edge node and each second node in the edge node set is greater than a preset distance, determine the first node as a node in the edge node set;
[0102] determine, as an edge node of the target image, a node in the edge node set.
[0103] Optionally, the third determining unit comprises:
[0104] divide the edge nodes into P target classes by density clustering, P being a positive integer;
[0105] generate an angle template of an object to be detected in the target image;
[0106] determine P correlation coefficients of gradient angles of the edge nodes in the P target classes with respect to the angle template, respectively;
[0107] obtain an edge detection result according to the P correlation coefficients.
[0108] The image edge detection apparatus 300 can realize each process of the image edge detection method embodiment of the present application and achieve the same beneficial effects. To avoid repetition, details are not described herein.
[0109] An electronic device is provided in embodiments of the present application. As shown in Figure 10 The electronic device 400 includes a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor, and various components in the electronic device 400 are coupled together through a bus system 404. It can be understood that the bus system 404 is used to realize the connection and communication between the components.
[0110] The processor 401 is configured to obtain image features of a target image, the image features including gradient values and gradient angles of each pixel point in N pixel points in the target image, N being a positive integer;
[0111] According to the first target pixel point, M pixel points adjacent to the first target pixel point are determined, M being a positive integer, and the first target pixel point being a pixel point with a gradient value greater than a first threshold in the N pixel points;
[0112] The gradient angles of the M pixel points are quantized to determine M quantized values of the M pixel points, M being a positive integer, and the first target pixel point being the pixel point with the gradient value greater than the first threshold;
[0113] According to the M quantized values, edge nodes of the target image are determined;
[0114] According to the edge nodes, the target image is detected to obtain an edge detection result.
[0115] The processor 401 is further configured to determine a frequency of occurrence of each quantized value in the M quantized values;
[0116] The pixel point corresponding to the quantized value with a frequency greater than or equal to a first preset value is determined as a first edge node;
[0117] According to the first edge node, edge nodes of the target image are determined.
[0118] The processor 401 is further configured to perform non-maximum suppression on a gradient value of a second target pixel point to determine a second edge node, the second target pixel point being a pixel point with a gradient value less than a second threshold in the first edge node;
[0119] According to the second edge node, edge nodes of the target image are determined.
[0120] The processor 401 is further configured to determine a pixel point with the largest gradient value in the second edge node as a node in the edge node set;
[0121] If distances between a first node in the second edge node and each second node in the edge node set are greater than the preset distance, the first node is determined as a node in the edge node set.
[0122] The node in the edge node set is determined as an edge node of the target image.
[0123] The processor 401 is further configured to divide the edge node into P target classes by density clustering, P being a positive integer;
[0124] An angle template of the target image to be detected object is generated;
[0125] P correlation coefficients of the angle template and gradient angles of the edge node in the P target classes are respectively determined;
[0126] An edge detection result is obtained according to the P correlation coefficients.
[0127] The electronic device 400 provided by the embodiment of the present application can realize each process that can be realized by the image edge detection method embodiment of the present application, and achieve the same beneficial effects. To avoid repetition, details are not repeated here.
[0128] The embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to realize each process of the image edge detection method embodiment and achieve the same technical effects. To avoid repetition, details are not repeated here. The computer readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0129] The embodiments of the present application are described above in combination with the drawings, but the present application is not limited to the above specific embodiments. The above specific embodiments are only illustrative, but not restrictive. Those skilled in the art can make many forms under the inspiration of the present application without departing from the scope of the present application and the protection scope of the claims.
Claims
1. An image edge detection method characterized by, The method comprises the following steps: obtaining image features of a target image, the image features comprising gradient values and gradient angles of each pixel point in N pixel points in the target image, N being a positive integer; determining M pixel points adjacent to a first target pixel point according to the first target pixel point, M being a positive integer, the first target pixel point being a pixel point with a gradient value greater than a first threshold value in the N pixel points; quantizing the gradient angles of the M pixel points to determine M quantized values of the M pixel points, M being a positive integer, the first target pixel point being the pixel point with the gradient value greater than the first threshold value; determining edge nodes of the target image according to the M quantized values; detecting the target image according to the edge nodes to obtain an edge detection result; wherein the quantizing the gradient angles of the M pixel points to determine the M quantized values of the M pixel points comprises: after quantizing the gradient angles of the M pixel points, determining a number representing a division interval in which the gradient value of a pixel point is located as the quantized value of the pixel point; the determining the edge nodes of the target image according to the M quantized values comprises: determining frequencies of each of the M quantized values; determining, as first edge nodes, pixel points corresponding to the quantized values with frequencies greater than or equal to a first preset value; determining the edge nodes of the target image according to the first edge nodes.
2. The image edge detection method according to claim 1, wherein the determining the edge nodes of the target image according to the first edge nodes comprises: performing non-maximum suppression on the gradient values of second target pixel points to determine second edge nodes, the second target pixel points being pixel points with gradient values less than a second threshold value in the first edge nodes; determining the edge nodes of the target image according to the second edge nodes.
3. The image edge detection method according to claim 2, wherein the determining the edge nodes of the target image according to the second edge nodes comprises: determining, as nodes in an edge node set, pixel points with the largest gradient values in the second edge nodes; if distances between a first node in the second edge nodes and each second node in the edge node set are all greater than a preset distance, determining the first node as a node in the edge node set; determining the nodes in the edge node set as the edge nodes of the target image.
4. The image edge detection method of claim 1, wherein, the detecting the target image according to the edge nodes to obtain an edge detection result comprises: dividing the edge nodes into P target classes through density clustering, P being a positive integer; generating an angle template of an object to be detected in the target image; determining P correlation coefficients between the angle template and gradient angles of the edge nodes in the P target classes, respectively; obtaining an edge detection result according to the P correlation coefficients.
5. An image edge detection apparatus characterized by comprising: The method comprises the following steps: a first obtaining module is configured to obtain image features of a target image, the image features comprising gradient values and gradient angles of each pixel point in N pixel points in the target image, N being a positive integer; The first determining module is configured to determine M pixel points adjacent to the first target pixel point according to the first target pixel point, M being a positive integer, and the first target pixel point being a pixel point with a gradient value greater than a first threshold in the N pixel points. The second determining module is configured to quantize gradient angles of the M pixel points to determine M quantized values of the M pixel points, M being a positive integer, and the first target pixel point being the pixel point with the gradient value greater than the first threshold. The third determining module is configured to determine edge nodes of the target image according to the M quantized values. The fourth determining module is configured to detect the target image according to the edge nodes to obtain an edge detection result. The second determining module is configured to: After quantizing the gradient angles of the M pixel points, determine a number representing a division interval in which a gradient value of a pixel point is located as a quantized value of the pixel point. The third determining module includes: A first determining unit configured to determine a frequency of occurrence of each quantized value in the M quantized values. A second determining unit configured to determine, as a first edge node, a pixel point corresponding to a quantized value with a frequency greater than or equal to a first preset value. A third determining unit configured to determine edge nodes of the target image according to the first edge node.
6. The image edge detection apparatus according to claim 5, wherein The third determining unit includes: Perform non-maximum suppression on a gradient value of a second target pixel point to determine a second edge node, the second target pixel point being a pixel point with a gradient value less than a second threshold in the first edge node. Determine edge nodes of the target image according to the second edge node.
7. An electronic device comprising: The memory, the processor, and a program stored in the memory and capable of running on the processor; the processor is configured to read the program in the memory to implement steps in the image edge detection method according to any one of claims 1 to 4.
8. A readable storage medium for storing a program, characterized by The program is executed by the processor to implement steps in the image edge detection method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Method for color image edge detection on basis of multichannel information selection
CN103679737A
Unsupervised face recognition method based on fast density clustering algorithm
CN105740842A
Image edge detection method, device and equipment
CN113034525A