Image edge detection method and device, electronic equipment, chip and medium

By determining and correcting the initial edge information of each pixel point in image edge detection, using gradient detection and filtering processing, the missed detection and false detection problems in image edge detection are solved, the detection accuracy is improved and the edge angle and confidence are output.

CN120339312APending Publication Date: 2025-07-18BEIJING X RING TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510399570.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

In the prior art, image edge detection is prone to missed detection and missed detection, and the output information is single, making it difficult to accurately reflect changes in edge direction.

Method used

By determining the initial edge information of each pixel point in the image to be detected, and correcting it based on the initial edge information of the neighboring pixel point, the target edge direction, angle and confidence are determined using gradient detection and filtering processing.

Benefits of technology

It improves the accuracy of image edge detection, outputs edge angle and confidence, provides effective reference information for subsequent image processing, and reduces noise interference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120339312A_ABST
    Figure CN120339312A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an image edge detection method, and relates to the technical field of image processing, and the method comprises the steps: determining the initial edge information of each pixel point in a to-be-detected image; target edge information of a first pixel point is determined based on initial edge information of a neighborhood pixel point corresponding to the first pixel point in the to-be-detected image, and the target edge information comprises a target edge direction, a target edge angle and a target edge confidence coefficient. According to the method provided by the invention, the initial edge information is corrected by considering the initial edge information of each pixel point and the initial edge information of the neighborhood pixel points, so that the accuracy of edge detection is improved; meanwhile, the edge angle and the edge confidence coefficient are output, and effective reference information is provided for subsequent image processing operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of image processing technologies, and in particular, to an image edge detection method and apparatus, an electronic device, a chip, and a medium. Background Art

[0002] Image edge detection has wide applications in the field of image / video processing. For example, technologies such as image texture enhancement, video deinterlacing, and salient region detection all require detecting the edge texture information of an image. However, in related technologies, mainly hard thresholds are set. On the one hand, since noise is inevitably introduced into the judgment process, it may lead to the problem of false detection. On the other hand, the edge detection output information is single and the edge direction changes greatly within the neighborhood, which is prone to the problem of missed detection. Summary of the Invention

[0003] The present disclosure provides an image edge detection method and apparatus, an electronic device, a chip, and a medium to solve the problems of missed detection and false detection that may occur in related technologies.

[0004] An embodiment of the first aspect of the present disclosure proposes an image edge detection method, which includes: determining initial edge information of each pixel point in an image to be detected; determining target edge information of a first pixel point based on the initial edge information of the neighborhood pixel points corresponding to the first pixel point in the image to be detected, where the target edge information includes a target edge direction, a target edge angle, and a target edge confidence level.

[0005] In some embodiments of the present disclosure, determining the initial edge information of each pixel point in the image to be detected includes: for each pixel point in the image to be processed, converting the image to be processed into the image to be detected through a transformation matrix; performing gradient detection on a second pixel point in the image to be detected within a first neighborhood to obtain the initial edge information of the second pixel point.

[0006] In some embodiments of the present disclosure, performing gradient detection on a second pixel point in the image to be detected within a first neighborhood to obtain the initial edge information of the second pixel point includes: determining an initial gradient amplitude and an initial gradient direction of the second pixel point through gradient detection; determining an initial edge type of the second pixel point based on the initial gradient amplitude and the initial gradient direction; determining an initial edge angle and an initial edge confidence level of the second pixel point based on the initial edge type and the initial gradient amplitude, where the initial edge information includes at least one of an initial gradient amplitude, an initial edge type, an initial edge angle, and an initial edge confidence level.

[0007] In some embodiments of the present disclosure, the method further includes: determining a difference between a maximum pixel value and a minimum pixel value among pixel values corresponding to a plurality of pixel points within a first neighborhood; determining a first threshold corresponding to the difference based on a first preset mapping relationship, where the first threshold is a classification parameter for determining a target edge type.

[0008] In some embodiments of the present disclosure, determining the target edge information of a first pixel point based on the initial edge information of the neighborhood pixel points corresponding to the first pixel point in the image to be detected includes: respectively determining at least one fourth pixel point with an initial edge type of a first type and at least one fifth pixel point with an initial edge type of a second type according to a plurality of third pixel points within a second neighborhood corresponding to the first pixel point; determining a mean and a variance corresponding to the first type based on the initial edge angles of each pixel point among the at least one fourth pixel point, and determining a mean and a variance corresponding to the second type based on the initial edge angles of each pixel point among the at least one fifth pixel point; determining the target edge direction, target edge angle, and target edge confidence of the first pixel point through filtering based on at least one of the initial edge confidence, initial edge type, initial gradient amplitude, mean and variance corresponding to the first type, mean and variance corresponding to the second type, and the first threshold of each third pixel point among the plurality of third pixel points.

[0009] In some embodiments of the present disclosure, determining the target edge direction and target edge confidence of the first pixel point through filtering based on the initial edge confidence, initial edge type, and first threshold of each third pixel point among the plurality of third pixel points includes: respectively determining the sum of the initial edge confidences corresponding to a plurality of pixel points with initial edge types of a first type, a second type, a third type, a fourth type, and a fifth type among the plurality of third pixel points, and using the sum of the initial edge confidences corresponding to each type as a first set; in the case where the sum of the initial edge confidences corresponding to the fifth type is the maximum value in the first set, or the sum of the initial edge confidences corresponding to the first type, the second type, the third type, and the fourth type is less than the first threshold, determining the target edge type of the first pixel point as the fifth type, where the target edge direction of the first pixel point is the edge direction corresponding to the target edge type.

[0010] In some embodiments of the present disclosure, the method further includes: when the sum of the initial edge confidences corresponding to the third type is the maximum value in the first set and the sum of the initial edge confidences corresponding to the fourth type is the minimum value in the first set, determining the target edge type of the first pixel point as the third type; determining the angle corresponding to the third type as the target edge angle of the first pixel point; and determining the target edge confidence of the first pixel point based on the initial gradient magnitude of the central pixel point of the third neighboring pixel points corresponding to the first pixel point.

[0011] In some embodiments of the present disclosure, the method further includes: when the sum of the initial edge confidences corresponding to the first type is greater than the sum of the initial edge confidences corresponding to the second type and the variance corresponding to the first type is less than the variance corresponding to the second type, determining the target edge type of the first pixel point as the first type; determining the target edge angle of the first pixel point based on the mean corresponding to the first type; and determining the target edge confidence of the first pixel point based on the variance corresponding to the first type, the sum of the initial edge confidences corresponding to the first type, and the sum of the initial edge confidences corresponding to the second type.

[0012] In some embodiments of the present disclosure, the method further includes: respectively determining the number of pixel points with the initial edge type being the first type and the second type according to a plurality of sixth pixel points in the fourth neighborhood corresponding to the second pixel point; and correcting the initial edge type of the second pixel point based on the number of pixel points of the first type and the number of pixel points of the second type.

[0013] In the above embodiments, by considering the initial edge information of each pixel point and the initial edge information of neighboring pixel points, the initial edge information of each pixel point is corrected to obtain the target edge information, improving the accuracy of image edge detection; at the same time, the edge angle and edge confidence are output, providing effective reference information for subsequent image processing operations.

[0014] An embodiment of the second aspect of the present disclosure provides an image edge detection device, including: a determination module, configured to determine the initial edge information of each pixel point in the image to be detected; and a processing module, configured to determine the target edge information of the first pixel point based on the initial edge information of the neighboring pixel points corresponding to the first pixel point in the image to be detected, where the target edge information includes a target edge direction, a target edge angle, and a target edge confidence.

[0015] An embodiment of the third aspect of the present disclosure provides an electronic device, including: a processor and a memory for storing a computer program that can run on the processor, where the processor is configured to execute the method according to any one of the first aspect of the present disclosure when running the computer program.

[0016] A fourth aspect embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the method described in any one of the first aspects of the present disclosure.

[0017] A fifth aspect embodiment of the present disclosure provides a chip including at least one processor and a communication interface; the communication interface is configured to receive signals input to the chip or signals output from the chip, and the processor communicates with the communication interface and implements the method described in any one of the first aspects of the present disclosure through logic circuits or by executing code instructions.

[0018] In summary, the method proposed by the present disclosure can improve the accuracy of image edge detection and at the same time provide effective reference information for subsequent image processing operations.

[0019] It should be understood that the above general description and the following detailed description are only exemplary and explanatory and should not limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure and do not constitute an undue limitation to the present disclosure.

[0021] Figure 1 It is a flowchart of a method for an image edge detection method proposed by an embodiment of the present disclosure;

[0022] Figure 2 It is a schematic diagram of a process for determining initial edge information proposed by an embodiment of the present disclosure;

[0023] Figure 3 It is a schematic diagram of a process for determining target edge information proposed by an embodiment of the present disclosure;

[0024] Figure 4 It is a schematic diagram for determining edge types;

[0025] Figure 5 It is a schematic diagram of the structure of an image edge detection device proposed by an embodiment of the present disclosure;

[0026] Figure 6 It is a schematic diagram of an electronic device for implementing the above image edge detection method shown according to an exemplary embodiment;

[0027] Figure 7 It is a schematic diagram of the structure of a chip for implementing the above image edge detection method shown according to an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0028] Embodiments of the present disclosure will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary and are intended to explain the present disclosure, and should not be construed as a limitation of the present disclosure.

[0029] In the related art, for image edge detection, generally, after filtering and preprocessing the noise, relevant gradient detection operators are used for edge detection. However, affected by the noise pattern and noise intensity, such preprocessing cannot eliminate the influence of noise on edge judgment; the detection output results are generally judgment results and edge angles, but affected by factors such as local pixel gray values and edge complexity, the judgment results are not accurate.

[0030] Therefore, to solve the above technical problems, the present disclosure proposes an image edge detection method that omits the truncation of preprocessing and performs superimposed filtering processing on the same type of edge in a local neighborhood range, which can avoid the influence of significant noise of some pixel points in the local neighborhood on the edge direction judgment result; and combining the edge filtering results of the local neighborhood, the determined edge angle is more stable, and at the same time, the confidence of the edge result can be obtained.

[0031] The image edge detection method proposed in this application will be introduced in detail below with reference to the accompanying drawings.

[0032] Figure 1 It is a method flowchart of an image edge detection method proposed for an embodiment of the present disclosure. As Figure 1 shown, the method includes the following steps:

[0033] Step 101, determine the initial edge information of each pixel point in the image to be detected.

[0034] In some embodiments, the image to be detected is the image that needs to be subjected to edge detection in this method, which may be an image after image processing. For example, the three-channel data corresponding to the pixel points in the original image is converted into single-channel data, or the RGB data is converted into YUV data, HSV data, HSL data, and the corresponding data is selected as the data in the image to be detected for subsequent processing, or the RGB data is converted into a grayscale image. The specific conversion method is not limited in the present disclosure.

[0035] In some embodiments, determining the initial edge information of each pixel point in the image to be detected includes: for each pixel point in the image to be processed, converting the image to be processed into the image to be detected through a conversion matrix; for the second pixel point in the image to be detected, performing gradient detection in the first neighborhood to obtain the initial edge information of the second pixel point.

[0036] In some embodiments, the image to be processed may be an original image. Each pixel point in the image to be processed includes three-channel RGB data, that is, the data of the R channel, the G channel, and the B channel. The image to be detected is obtained by converting the RGB data, and it may be converting the RGB data into YUV data.

[0037] In some embodiments, for each pixel point in the image to be processed, converting the image to be processed into the image to be detected through a conversion matrix may be multiplying the RGB data corresponding to each pixel point by the conversion matrix to obtain YUV data, and taking the Y component therein as the data information of each pixel point in the image to be detected.

[0038] Exemplarily, input the RGB data of the image to be processed, and use the three-channel RGB data to convert and calculate the Y-domain information. The RGB data is converted into YUV data by using a standard conversion matrix, and the conversion matrix is: Y = 0.299R + 0.587G + 0.114B.

[0039] In some embodiments, the second pixel point may be any pixel point in the image to be detected. Performing gradient detection on the second pixel point within the second neighborhood may be using any one of methods such as the Sobel operator, the Prewitt operator, the Laplacian operator, the Scharr operator, the directional differential operator, Gaussian filtering, etc., or a combination of multiple methods to obtain the initial edge information of the second pixel point, and the present disclosure is not limited thereto.

[0040] In some embodiments, performing gradient detection on the second pixel point in the image to be detected within the first neighborhood to obtain the initial edge information of the second pixel point may be using a custom operator for gradient detection, which can achieve better anti-noise performance compared with the above methods.

[0041] In some embodiments, the first neighborhood may be a 3×3 neighborhood range, or a 4×4 neighborhood range, etc., and the specific value of the neighborhood range is not limited by the present disclosure.

[0042] In some embodiments, performing gradient detection on the second pixel point within the first neighborhood may be using a custom operator to perform gradient detection within the 3×3 neighborhood range corresponding to the second pixel point to obtain the initial edge information of the second pixel point, where the initial edge information is the initial detected edge information of each pixel point in the image to be detected.

[0043] Step 102, determine the target edge information of the first pixel point based on the initial edge information of the neighborhood pixel points corresponding to the first pixel point in the image to be detected.

[0044] In some embodiments, the target edge information includes a target edge direction, a target edge angle, and a target edge confidence level.

[0045] In some embodiments, the initial edge information may be the result of image edge detection for each pixel. However, due to possible interference during the detection process, the result may not be accurate enough. Therefore, the initial edge information needs to be corrected based on the initial edge information of the corresponding neighboring pixels to obtain the target edge information that can accurately reflect the edge situation of each pixel.

[0046] In some embodiments, the first pixel in the image to be detected may be any pixel in the image to be detected.

[0047] In some embodiments, the neighboring pixels corresponding to the first pixel may be the pixels within the 3×3 neighborhood range corresponding to the first pixel, or the pixels within the 4×4 neighborhood range corresponding to the first pixel, or the pixels within the 5×5 neighborhood range corresponding to the first pixel, etc. The value of the neighborhood range is not limited in this disclosure.

[0048] In some embodiments, determining the target edge information of the first pixel based on the initial edge information of the neighboring pixels corresponding to the first pixel in the image to be detected may be to correct the initial edge information of the first pixel using the initial edge information of the neighboring pixels corresponding to the first pixel to obtain the target edge information of the first pixel.

[0049] In some embodiments, the neighboring pixels corresponding to the first pixel may be all the pixels within the second neighborhood range of the first pixel, or all the pixels within the third neighborhood range of the first pixel. This disclosure does not limit this.

[0050] In the above embodiments, by considering the initial edge information of each pixel and the initial edge information of the neighboring pixels, the accuracy of edge detection is improved; at the same time, the edge angle and edge confidence are output, providing effective reference information for subsequent image processing operations.

[0051] Figure 2 It is a schematic flowchart of the process for determining the initial edge information proposed in the embodiments of this disclosure. Based on Figure 1 the embodiments shown, Figure 2 step 101 is further defined as follows. As shown in Figure 2 the method includes the following steps:

[0052] Step 201, determine the initial gradient magnitude and initial gradient direction of the second pixel through gradient detection.

[0053] In some embodiments, through gradient detection, the initial gradient magnitude and the initial gradient direction of the second pixel point can be determined. For example, within the first neighborhood range centered on the second pixel point, a custom operator can be used for gradient detection to obtain the initial gradient magnitude and the initial gradient direction of the second pixel point.

[0054] In some embodiments, within the first neighborhood range centered on the second pixel point, a first operator is used for gradient detection to obtain the initial gradient magnitude of the second pixel point, and a second operator is used for gradient detection to obtain the initial gradient direction of the second pixel point. Herein, the first operator and the second operator can be the same operator or different operators, and the present disclosure does not limit this.

[0055] In some embodiments, the initial gradient direction includes a vertical direction and a horizontal direction, and the initial gradient magnitude includes the initial gradient magnitude in the vertical direction and the initial gradient magnitude in the horizontal direction.

[0056] In some embodiments, the initial gradient magnitude can include the initial gradient magnitude in the horizontal direction and the initial gradient magnitude in the vertical direction, and the initial gradient direction can include the initial gradient direction in the horizontal direction and the initial gradient direction in the vertical direction. Herein, the value of the initial gradient direction is 1 or -1. For example, it can be stipulated that in the vertical direction, the upward direction is 1 and the downward direction is -1; in the horizontal direction, the leftward direction is 1 and the rightward direction is -1.

[0057] In some embodiments, for each pixel point in the image to be detected, by performing gradient detection within the first neighborhood centered on it, for example, by performing a convolution operation using a convolution kernel in the horizontal direction to obtain the initial gradient magnitude in the horizontal direction, and performing a convolution operation using a convolution kernel in the vertical direction to obtain the initial gradient magnitude in the vertical direction, the initial gradient magnitude and the initial gradient direction of each pixel point can be obtained.

[0058] For example, on the Y channel, the horizontal and vertical gradient magnitudes (grad_x, grad_y) and the gradient directions (sign_x, sign_y) of the input image pixel points are solved.

[0059] For example, the input image is processed by expanding its borders on the left, right, up, and down. The processing process mainly aims to meet the processing requirements of the pixel points at the image boundaries. Gradient detection is performed within a 3×3 range. For the point to be processed, a 3×3 neighborhood is taken with the current point as the center. For example The horizontal gradient magnitude grad_x and the vertical gradient magnitude grad_y are calculated, and the calculated gradient directions are denoted as sign_x and sign_y.

[0060] Step 202: Based on the initial gradient magnitude and the initial gradient direction, determine the initial edge type of the second pixel point.

[0061] In some embodiments, the initial edge types are divided into a first type, a second type, a third type, a fourth type, and a fifth type. Among them, the first type can be a first and third quadrant edge or a second and fourth quadrant edge; the second type can be a second and fourth quadrant edge or a first and third quadrant edge; the third type can be a vertical edge or a horizontal edge; the fourth type can be a horizontal edge or a vertical edge; and the fifth type is an edge-free type.

[0062] In some embodiments, determining the initial edge type of the second pixel point based on the initial gradient magnitude and the initial gradient direction can be determined according to a preset rule, where the preset rule can be to preset the mapping relationship between the values of the initial gradient magnitude, the initial gradient direction and the corresponding initial edge type.

[0063] In some embodiments, the preset rule can be that in the initial gradient magnitude, if the initial gradient magnitude in the horizontal direction is greater than the initial gradient magnitude in the vertical direction, it is the type of vertical edge; if the initial gradient magnitude in the vertical direction is greater than the initial gradient magnitude in the horizontal direction, it is the type of horizontal edge; in the product of the gradient directions, if the initial gradient directions in both the horizontal and vertical directions are positive or both are negative, the product is positive, then it is a first and third quadrant edge; if the product is negative, then it is a second and fourth quadrant edge; if the gradient magnitude is less than the preset minimum value, it is the fifth type.

[0064] Exemplarily, as Figure 4 shown in the schematic diagram, the first and third quadrant edge is where the product of the gradient directions is positive, and the second and fourth quadrant edge is where the product of the gradient directions is negative.

[0065] Exemplarily, the image edges are divided into a total of five types: the first and third quadrant edge (AT_Edge), the second and fourth quadrant edge (TF_Edge), the vertical edge (Vert_Edge), the horizontal edge (Hori_Edge), and the edge-free type (None_Edge).

[0066] Use the product of the gradient directions and the proportional relationship of the gradient magnitudes to judge the actual direction of the pixel edge.

[0067]

[0068] Among them, Case1 is where the product of the gradient directions is positive; Case2 is where the product of the gradient directions is negative; Case3 is where the horizontal gradient magnitude is greater than the vertical gradient magnitude; Case4 is where the vertical gradient magnitude is greater than the horizontal gradient magnitude; Case5 is where the gradient magnitude is less than the preset minimum value.

[0069] In the above embodiments, through the preset rule, the initial edge type of each pixel point is judged to determine the initial edge angle and the initial edge confidence according to the initial edge type.

[0070] Step 203: Determine the initial edge angle and the initial edge confidence of the second pixel point based on the initial edge type and the initial gradient magnitude.

[0071] In some embodiments, the initial edge information includes at least one of an initial gradient magnitude, an initial edge type, an initial edge angle, and an initial edge confidence.

[0072] In some embodiments, the initial edge angle represents the specific edge direction of the second pixel point, the initial edge confidence represents whether the second pixel point is an edge and whether it is a large edge or a small edge, and the value of the initial edge confidence is a numerical value between 0 and 1.

[0073] Exemplarily, for the input image pixel points, after obtaining the gradient magnitudes and gradient directions in the horizontal and vertical directions, calculate the edge direction and edge confidence based on the gradient information.

[0074] In some embodiments, determining the initial edge angle and the initial edge confidence of the second pixel point based on the initial edge type and the initial gradient magnitude may be by using the ratio of the initial gradient magnitude in the horizontal direction to the initial gradient magnitude in the vertical direction as the tangent value of the edge angle, determining the positive or negative sign of the tangent value through the initial edge type, and obtaining the value of the edge angle through the arctangent function; based on the numerical value in the initial gradient magnitude, determine the value of the initial edge confidence through the first mapping table.

[0075] Exemplarily, after obtaining the edge type, further, the edge angle and edge confidence can be calculated based on the magnitude of the edge gradient, denoted as Edge_diag and Edge_confidence respectively. Among them, Edge_confidence is the confidence between 0 and 1 mapped from the gradient magnitude.

[0076] In some embodiments, the method further includes: determining the difference between the maximum pixel value and the minimum pixel value among the pixel values corresponding to multiple pixel points in the first neighborhood; determining a first threshold corresponding to the difference based on a first preset mapping relationship, and the first threshold is a classification parameter for determining the target edge type.

[0077] In some embodiments, among the pixel values corresponding to multiple pixel points in the first neighborhood, it may be to take the pixel values of 9 pixel points within a 3×3 neighborhood range centered on the second pixel point and determine the difference between the maximum pixel value and the minimum pixel value.

[0078] In some embodiments, the first preset mapping relationship may be a correspondence table between preset pixel value differences and thresholds. According to the determined difference above, through mapping, a first threshold is determined. The first threshold is used as the base threshold for edge determination or as a judgment parameter for determining the target edge type. In other words, the relationship between the first threshold and the relevant parameters of the pixel point can be used as the basis for judging the target edge type of the pixel point.

[0079] Exemplarily, within a 3×3 window, the neighborhood local maximum luminance difference luma_diff is calculated, and further mapped to obtain the edge determination base threshold edge_th.

[0080] In some embodiments, the method further includes: determining the number of pixel points with the initial edge type of the first type and the second type respectively according to multiple sixth pixel points within the fourth neighborhood corresponding to the second pixel point; and correcting the initial edge type of the second pixel point based on the number of pixel points of the first type and the number of pixel points of the second type.

[0081] In some embodiments, the fourth neighborhood may be the same range as the first neighborhood, or may also be other neighborhood ranges, such as a 4×4 neighborhood range.

[0082] In some embodiments, after determining the initial edge type of each pixel point in the image to be detected, the initial edge type of the second pixel point is corrected according to the initial edge types of multiple sixth pixel points within the third neighborhood centered on the second pixel point.

[0083] In some embodiments, among multiple sixth pixel points within the fourth neighborhood, the number of pixel points with the initial edge type of the first type and the number of pixel points with the initial edge type of the second type are determined. According to the number of pixel points of the first type and the number of pixel points of the second type, it is judged whether the initial edge type of the second pixel point is correct. If the judgment is incorrect, the second pixel point needs to be corrected, and the correction process is to re-execute the above steps of determining the initial edge type.

[0084] In some embodiments, for an edge, the edge directions in the same local area are consistent. Therefore, if the initial edge types of multiple sixth pixel points within the fourth neighborhood are all of the first type or all of the second type, it indicates that the judgment of the initial edge type of the second pixel point is correct. If there are both the first type and the second type among the multiple sixth pixel points, it indicates that the judgment of the initial edge type of the second pixel point is incorrect, and the initial edge type of the second pixel point needs to be re-determined.

[0085] Exemplarily, for 16 pixel points within a 4×4 range centered on the currently calculated pixel, the number of edge points of the first and third quadrant edges (AT_Edge) and the second and fourth quadrant edges (TF_Ddge) are respectively counted, and are denoted as num_AT and num_TF. If num AT = 16 or num TF = 16, the edge type of the current pixel point is correctly judged. If 0 < num AT < 16 and 0 < num TF < 16, the edge type of the current pixel point is wrongly judged, and the edge type needs to be re-determined.

[0086] In the above embodiment, according to the pixel points within the first neighborhood range centered on the current pixel point in the image to be detected, the initial edge information of the current pixel point can be determined while considering the neighborhood pixel points.

[0087] Figure 3 The flowchart of determining the target edge information proposed by the embodiments of the present disclosure. Based on Figures 1-2 the embodiment shown, Figure 3 for Figure 1 step 102 in Figure 3 is further defined as shown, and further includes the following steps.

[0088] Step 301, according to multiple third pixel points within the second neighborhood corresponding to the first pixel point, respectively determine at least one fourth pixel point with the initial edge type being the first type and at least one fifth pixel point with the initial edge type being the second type.

[0089] In some embodiments, the second neighborhood can be a preset range. For example, the second neighborhood can be a 4×4 neighborhood range, or a 5×5 neighborhood range, or a 6×6 neighborhood range, and the specific value is not limited in the present disclosure.

[0090] In some embodiments, according to multiple third pixel points within the second neighborhood corresponding to the first pixel point, determine at least one fourth pixel point with the initial edge type being the first type within the second neighborhood, and determine at least one fifth pixel point with the initial edge type being the second type.

[0091] In some embodiments, determining at least one fourth pixel point of the first type can be determining at least one pixel point belonging to the first and third quadrant edges, and determining at least one fifth pixel point of the second type can be determining at least one pixel point belonging to the second and fourth quadrant edges.

[0092] Exemplarily, for 16 pixel points within a 4×4 range centered on the currently calculated pixel, respectively determine the pixel points of the first and third quadrant edges (AT_Edge) and the second and fourth quadrant edges (TF_Edge).

[0093] In some embodiments, determining at least one fourth pixel point of the first type may be determining at least one pixel point belonging to the edge of the second and fourth quadrants, and determining at least one fifth pixel point of the second type may be determining at least one pixel point belonging to the edge of the first and third quadrants.

[0094] Step 302: Based on the initial edge angles of each pixel point in at least one fourth pixel point, determine the mean and variance corresponding to the first type, and based on the initial edge angles of each pixel point in at least one fifth pixel point, determine the mean and variance corresponding to the second type.

[0095] In some embodiments, based on the initial edge angles of each pixel point in at least one fourth pixel point corresponding to the first type, determine the mean and variance corresponding to the first type; and based on the initial edge angles of each pixel point in at least one fifth pixel point corresponding to the second type, determine the mean and variance corresponding to the second type.

[0096] In some embodiments, determining the mean and variance of the first type may be calculating the mean of the initial edge angles as the mean corresponding to the first type according to the initial edge angles of at least one fourth pixel point; and calculating the variance of the initial edge angles, and determining the value corresponding to the variance as the variance corresponding to the first type according to the second mapping table. The specific method for determining the mean and variance of the second type is the same as that of the first type.

[0097] Exemplarily, calculate the mean of the edge angles of two edge types, namely the edge of the first and third quadrants (AT_Edge) and the edge of the second and fourth quadrants (TF_Edge), denoted as avg_direction_AT and avg_direction_TF; calculate the variances of the two edge types, and perform mapping according to the calculation results, denoted as var_direction_AT and var_direction_TF respectively.

[0098] Step 303: Based on at least one of the initial edge confidence, initial edge type, initial gradient magnitude of each third pixel point among a plurality of third pixel points, the mean and variance corresponding to the first type, the mean and variance corresponding to the second type, and the first threshold, determine the target edge direction, target edge angle, and target edge confidence of the first pixel point through filtering processing.

[0099] In some embodiments, according to the initial edge information of a plurality of third pixel points in the second neighborhood corresponding to the first pixel point and the values determined in the above process, determining the target edge information of the first pixel point through filtering processing may be to gradually judge and determine the target edge information according to the following process.

[0100] The first step: Judge whether the first pixel point is of the no-edge type:

[0101] In some embodiments, based on the initial edge confidence, initial edge type, and first threshold of each third pixel among a plurality of third pixels, determining the target edge direction and target edge confidence of the first pixel through filtering processing includes: among the plurality of third pixels, respectively determining the sum of the initial edge confidences of the pixels corresponding to the first type, second type, third type, fourth type, and fifth type of the initial edge type, and using the sum of the initial edge confidences corresponding to each type as a first set; in the case where the sum of the initial edge confidences corresponding to the fifth type is the maximum value in the first set, or the sum of the initial edge confidences corresponding to the first type, the sum of the initial edge confidences corresponding to the second type, the sum of the initial edge confidences corresponding to the third type, and the sum of the initial edge confidences corresponding to the fourth type is less than the first threshold, determining the target edge type of the first pixel as the fifth type, where the target edge direction of the first pixel is the edge direction corresponding to the target edge type.

[0102] In some embodiments, among the plurality of third pixels, respectively determining the sum of the initial edge confidences of the pixels corresponding to the first type, second type, third type, fourth type, and fifth type of the initial edge type, and using the sum of the initial edge confidences corresponding to each type as a first set may be that within a second neighborhood centered on the first pixel, adding the initial edge confidences of the third pixels of the first type to obtain the sum of the initial edge confidences corresponding to the first type, adding the initial edge confidences of the third pixels of the second type to obtain the sum of the initial edge confidences corresponding to the second type, and so on, to obtain the sum of the initial edge confidences corresponding to each type as the first set, and the first set includes the sum of the edge confidences of five types.

[0103] Exemplarily, the edge directions and edge confidences in different directions of 16 pixels within a 4×4 range centered on the currently calculated pixel are statistically analyzed. The edge confidences of 5 edge types, namely Edge_confidence, sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge, and sum_type_no_edge, are respectively accumulated.

[0104] In some embodiments, the first threshold is Figure 2 the value determined in step 203.

[0105] In some embodiments, when the initial edge confidence sum corresponding to the fifth type is the maximum value in the first set, or when the sum of the initial edge confidence sums corresponding to the first type, the second type, the third type, and the fourth type is less than the first threshold, the target edge type of the first pixel is determined to be the fifth type. That is, by determining whether the sum of the initial edge confidences corresponding to the fifth type is the maximum among the sums of the initial edge confidences of the five types or whether the sum of the initial edge confidences of the other four types is less than the first threshold, it is determined whether the target edge type of the first pixel is the fifth type.

[0106] Exemplarily, in the first step, it is determined whether there is an edge, and the determination condition is:

[0107] sum_type_no_edg = max(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge,

[0108] sum_type_h_edge, sum_type_no_edge

[0109] Or

[0110] sum_type_at_edge + sum_type_tf_edge + sum_type_v_edge + sum_type_h_edge < edge_th

[0111] where edge_th is the edge base threshold calculated in S202.

[0112] When one of the above two conditions is met, it is then determined that this pixel is a non-edge point.

[0113] In the second step, it is determined whether the first pixel is a vertical edge:

[0114] In some embodiments, when determining whether the first pixel is a vertical edge, the third type is a vertical edge and the fourth type is a horizontal edge.

[0115] In some embodiments, if the initial edge confidence sum does not meet the above judgment conditions, the method further includes: when the initial edge confidence sum corresponding to the third type is the maximum value in the first set and the initial edge confidence sum corresponding to the fourth type is the minimum value in the first set, determining the target edge type of the first pixel as the third type; determining the angle corresponding to the third type as the target edge angle of the first pixel; and determining the target edge confidence of the first pixel based on the initial gradient magnitude of the central pixel of the third neighborhood pixels corresponding to the first pixel.

[0116] In some embodiments, within the second neighborhood, when the initial edge confidence sum corresponding to the third type is the maximum value in the first set and the initial edge confidence sum corresponding to the fourth type is the minimum value in the first set, the target edge type of the first pixel being the third type may be that the initial edge confidence sum of the vertical edge is the maximum value among the initial edge confidence sums of the five types and the initial edge confidence sum of the horizontal edge is the minimum value among the initial edge confidence sums of the five types, then the first pixel is a vertical edge.

[0117] In some embodiments, the target edge direction of the first pixel is the edge direction corresponding to the third type, that is, the target edge direction of the first pixel is the vertical direction.

[0118] In some embodiments, determining the angle corresponding to the third type as the target edge angle of the first pixel may be determining the target edge angle of the first pixel as the angle of the vertical edge, that is, 90°.

[0119] Exemplarily, when the condition of no edge type is not met, go to the second step to determine whether it is a vertical edge. The judgment conditions are:

[0120] sum_tpe_v_edge = max(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge); and

[0121] sum_type_h_edge = min(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge). When this condition is met, it is determined that the edge direction of the pixel is a vertical edge, and the edge judgment result is output.

[0122] In some embodiments, determining the target edge confidence of the first pixel point based on the initial gradient magnitude of the central pixel point of the third neighboring pixel points corresponding to the first pixel point may be to determine the central pixel points within the third neighborhood corresponding to the first pixel point, take the initial gradient magnitude of the central pixel points, and determine the target edge confidence of the first pixel point according to the initial gradient magnitude in the horizontal direction and the initial gradient magnitude in the vertical direction within this set.

[0123] In some embodiments, determining the target edge confidence of the first pixel point according to the initial gradient magnitude of the central pixel point may be to determine the corresponding value in the third mapping relationship table as the target edge confidence of the first pixel point according to the ratio of the initial gradient magnitude in the horizontal direction and the initial gradient magnitude in the vertical direction.

[0124] Exemplarily, under the condition of satisfying a vertical edge, further optimize the vertical edge confidence according to the gradient information of the central pixel point. Taking as an example, take out the vertical gradient magnitude grad_y and the horizontal gradient magnitude grad_x of P 22 . Further map sum_type_v_edge according to the proportional relationship between grad_y and grad_x, and obtain and output the vertical edge confidence edge_confidence.

[0125] Step 3: Determine whether the first pixel point is a horizontal edge:

[0126] In some embodiments, when determining whether the first pixel point is a horizontal edge, the third type is a horizontal edge and the fourth type is a vertical edge.

[0127] In some embodiments, if the initial edge confidence and value do not meet the above judgment conditions, the method further includes: when the initial edge confidence and value corresponding to the third type are the maximum value in the first set and the initial edge confidence and value corresponding to the fourth type are the minimum value in the first set, determining the target edge type of the first pixel point as the third type; determining the angle corresponding to the third type as the target edge angle of the first pixel point; determining the target edge confidence of the first pixel point based on the initial gradient magnitude of the central pixel point of the third neighboring pixel points corresponding to the first pixel point.

[0128] In some embodiments, within the second neighborhood, if the sum of the initial edge confidence levels corresponding to the third type is the maximum value in the first set, and the sum of the initial edge confidence levels corresponding to the fourth type is the minimum value in the first set, the target edge type of the first pixel is the third type. For example, if the sum of the initial edge confidence levels of the horizontal edge is the maximum value among the sum of the initial edge confidence levels of the five types, and the sum of the initial edge confidence levels of the vertical edge is the minimum value among the sum of the initial edge confidence levels of the five types, then the first pixel is a horizontal edge.

[0129] In some embodiments, the target edge direction of the first pixel is the edge direction corresponding to the third type, that is, the target edge direction of the first pixel is the horizontal direction.

[0130] In some embodiments, determining the angle corresponding to the third type as the target edge angle of the first pixel may be determining the target edge angle of the first pixel as the angle of the horizontal edge, that is, 180°.

[0131] Exemplarily, when the condition of the vertical edge is not satisfied, it is transferred to determine whether it is a horizontal edge, and the judgment condition is:

[0132] sum_type_h_edge = max(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge); and

[0133] sum_type_v_edge = min(sum_type_at_edga, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge). When this condition is satisfied, it is determined that the edge direction of the pixel is a horizontal edge, and the edge judgment result is output.

[0134] In some embodiments, based on the initial gradient magnitude of the central pixel of the third neighborhood pixels corresponding to the first pixel, the target edge confidence level of the first pixel may be determined. It may be to determine the central pixel within the third neighborhood corresponding to the first pixel, take the initial gradient magnitude of the central pixel, and determine the target edge confidence level of the first pixel according to the initial gradient magnitudes in the horizontal direction and the vertical direction within this set.

[0135] In some embodiments, determining the target edge confidence level of the first pixel according to the initial gradient magnitude of the central pixel may be to determine the corresponding value in the fourth mapping relationship table as the target edge confidence level of the first pixel according to the ratio of the initial gradient magnitudes in the horizontal direction and the vertical direction.

[0136] Exemplarily, under the condition of satisfying the horizontal edge, further optimize the vertical edge confidence according to the gradient information of the central pixel point. Take as an example, extract the vertical gradient amplitude grad_y and the horizontal gradient amplitude grad_x of P 22 . According to the proportional relationship between grad_y and grad_x, further map sum_type_h_edge to obtain and output the horizontal edge confidence edge_confidence.

[0137] Step 4: Determine whether the first pixel point is an edge in the first and third quadrants:

[0138] In some embodiments, when determining whether the first pixel point is an edge in the first and third quadrants, the first type is the edge in the first and third quadrants, and the second type is the edge in the second and fourth quadrants.

[0139] In some embodiments, if the sum of the initial edge confidences does not meet the above judgment conditions, the method further includes: when the sum of the initial edge confidences corresponding to the first type is greater than the sum of the initial edge confidences corresponding to the second type, and the variance corresponding to the first type is less than the variance corresponding to the second type, determine that the target edge type of the first pixel point is the first type; based on the mean value corresponding to the first type, determine the target edge angle of the first pixel point; based on the variance corresponding to the first type, the sum of the initial edge confidences corresponding to the first type, and the sum of the initial edge confidences corresponding to the second type, determine the target edge confidence of the first pixel point.

[0140] In some embodiments, when the sum of the initial edge confidences corresponding to the first type is greater than the sum of the initial edge confidences corresponding to the second type, and the variance corresponding to the first type is less than the variance corresponding to the second type, it may be that the sum of the initial edge confidences corresponding to the edge in the first and third quadrants is greater than the sum of the initial edge confidences corresponding to the edge in the second and fourth quadrants, and the variance corresponding to the edge in the first and third quadrants is less than the variance corresponding to the edge in the second and fourth quadrants, then determine that the target edge type of the first pixel point is the edge in the first and third quadrants.

[0141] Exemplarily, when the condition of the horizontal edge is not satisfied, go to Step 4 to determine whether it is an edge in the first and third quadrants (AT_Edge), and the judgment conditions are as follows:

[0142] sum_type_at_edge≥sum_type_tf_edge&&var_direction_AT<var_direction_TF. When this condition is met, it is determined that the edge direction of this pixel point is the edge in the first and third quadrants (AT_Edge).

[0143] In some embodiments, to determine the target edge angle of the first pixel point based on the mean value corresponding to the first type may be to use the mean value corresponding to the first type as the target edge angle of the first pixel point.

[0144] Exemplarily, output the edge type and output the edge angle at the same time. The edge angle is calculated as follows: Edge_angle = avg_direction_AT.

[0145] In some embodiments, to determine the target edge confidence of the first pixel point based on the variance corresponding to the first type, the initial edge confidence sum value corresponding to the first type, and the initial edge confidence sum value corresponding to the second type may be to multiply the difference between the initial edge confidence sum value corresponding to the first and third quadrant edges and the initial edge confidence sum value corresponding to the second and fourth quadrant edges by the variance corresponding to the first and third quadrant edges, and use the product as the target edge confidence of the first pixel point.

[0146] Exemplarily, on the premise of meeting the edge type of the first and third quadrant edges, calculate the edge confidence according to var_drirection_AT and the difference between the AT_Edge confidence and the TF_Edge confidence. The specific calculation is as follows: edge_confidence = var_direction_AT * (sum_type_at_edge - sum_type_tf_edge).

[0147] Step 5, determine whether the first pixel point is an edge of the second and fourth quadrants:

[0148] In some embodiments, when determining whether the first pixel point is an edge of the second and fourth quadrants, the first type is the edge of the second and fourth quadrants, and the second type is the edge of the first and third quadrants.

[0149] In some embodiments, if the initial edge confidence sum value does not meet the above judgment condition, the method further includes: when the initial edge confidence sum value corresponding to the first type is greater than the initial edge confidence sum value corresponding to the second type, and the variance corresponding to the first type is less than the variance corresponding to the second type, determine that the target edge type of the first pixel point is the first type; determine the target edge angle of the first pixel point based on the mean value corresponding to the first type; determine the target edge confidence of the first pixel point based on the variance corresponding to the first type, the initial edge confidence sum value corresponding to the first type, and the initial edge confidence sum value corresponding to the second type.

[0150] In some embodiments, when the initial edge confidence sum and value corresponding to the first type are greater than those corresponding to the second type, and the variance corresponding to the first type is less than the variance corresponding to the second type, it may be that the initial edge confidence sum and value corresponding to the edges in the second and fourth quadrants are greater than those corresponding to the edges in the first and third quadrants, and the variance corresponding to the edges in the second and fourth quadrants is less than the variance corresponding to the edges in the first and third quadrants. Then, it is determined that the target edge type of the first pixel is the edge in the second and fourth quadrants.

[0151] Exemplarily, when the conditions for the edges in the first and third quadrants are not met, it is determined whether it is an edge in the second and fourth quadrants (AT_Edge). The determination conditions are as follows: sum_type_tf_edge≥sum_type_at_edge&&var_direction_TF<var_direction_AT. When this condition is met, it is determined that the edge direction of this pixel is an edge in the second and fourth quadrants (AT_Edge), and the edge type is output.

[0152] In some embodiments, based on the mean value corresponding to the first type, determining the target edge angle of the first pixel may be taking the mean value corresponding to the first type as the target edge angle of the first pixel.

[0153] Exemplarily, the edge type is output, and at the same time, the edge angle is output. The edge angle is calculated as follows: Edge_angle = avg_direction_TF.

[0154] In some embodiments, based on the variance corresponding to the first type, the initial edge confidence sum and value corresponding to the first type, and the initial edge confidence sum and value corresponding to the second type, determining the target edge confidence of the first pixel may be multiplying the difference between the initial edge confidence sum and value corresponding to the first type and the initial edge confidence sum and value corresponding to the second type by the variance corresponding to the first type, and taking the product as the target edge confidence of the first pixel. That is, multiplying the difference between the initial edge confidence sum and value corresponding to the edges in the second and fourth quadrants and the initial edge confidence sum and value corresponding to the edges in the first and third quadrants by the variance corresponding to the edges in the second and fourth quadrants, and taking the product as the target edge confidence of the first pixel.

[0155] Exemplarily, on the premise of meeting the edge in the second and fourth quadrants, the edge confidence is calculated according to var_direction_TF and the difference between the TF_Edge confidence and the AT_Edge confidence. The specific calculation is as follows: edge_confidence = var_direction_TF*(sum_type_tf_edge - sum_type_at_edge).

[0156] In the above embodiments, by performing steps 301 to 303 on each pixel point in the image to be detected, the target edge information of each pixel point is determined, and the accuracy of the obtained target edge information is higher.

[0157] In summary, the image edge detection method proposed by the present disclosure can, after determining the initial edge information, determine the target edge information of each pixel point according to the initial edge information of each pixel point and the initial edge information of the neighboring pixel points, so as to correct the initial edge information and improve the accuracy of edge detection; through different types of edge filtering processing, the interference of noise on edge detection is effectively avoided, and the accuracy of edge detection is further improved; at the same time, the values of the edge angle and edge confidence are output, which can provide effective reference information for subsequent image processing.

[0158] The following are the specific embodiments of the image edge detection method:

[0159] S1: Input the RGB data of the image to be processed, and use the RGB three-channel data to convert and calculate the Y-domain information.

[0160] S2: Solve the horizontal and vertical direction gradient amplitudes (grad_x, grad_y) and gradient directions (sign_x, sign_y) of the input image pixel points on the Y channel, and calculate the edge direction and edge confidence according to the gradient information.

[0161] S201: Perform border expansion processing on the current image in the left-right, up-down directions. This processing mainly meets the processing requirements of the image boundary pixel points.

[0162] S202: Perform gradient detection within a 3×3 range. For the point to be processed, take a 3×3 neighborhood centered on the current point. For example Calculate the horizontal direction gradient amplitude grad_x and the vertical direction gradient amplitude grad_y, and record the calculated gradient directions as sign_x and sign_y.

[0163] S203: Calculate the neighborhood local maximum luminance difference luma_diff within the 3×3 window in step S202, and further map to obtain the edge judgment base threshold edge_th.

[0164] S204: The image edges are divided into a total of five types: the first and third quadrant edges (AT_Edge), the second and fourth quadrant edges (TF_Edge), the vertical edges (Vert_Edge), the horizontal edges (Hori_Edge), and the non-edge (None_dge). Use the product of the gradient directions and the proportional relationship of the gradient amplitudes to judge the actual direction of the pixel edge.

[0165]

[0166] Among them, Case1 means the product of gradient directions is positive; Case2 means the product of gradient directions is negative; Case3 means the horizontal gradient amplitude is greater than the vertical gradient amplitude; Case4 means the vertical gradient amplitude is greater than the horizontal gradient amplitude; Case5 means the gradient amplitude is less than the preset minimum value. As Figure 4 shown in the schematic diagram, the edges in the first and third quadrants are where the product of gradient directions is positive, and the edges in the second and fourth quadrants are where the product of gradient directions is negative.

[0167] S205: After obtaining the edge type, further, the edge angle and edge confidence can be calculated based on the amplitude of the edge gradient, denoted as dge_diag and dge_confidence respectively. Among them, Edge_confidence is the confidence from 0 to 1 mapped by the gradient amplitude.

[0168] S3: Statistically analyze the edge directions and edge confidences in different directions of 16 pixel points within a 4×4 range centered on the currently calculated pixel.

[0169] S 301: Accumulate the edge confidences Edge_confidence of 5 edge types respectively, denoted as sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge, sum_type_no_edge.

[0170] S302: Accumulate the edge angles of the edges in the first and third quadrants (AT_Edge) and the edges in the second and fourth quadrants (TF_Edge) respectively, denoted as sum_direction_AT and sum_direction_TF, and count the number of edge points in the two edge directions, denoted as num_AT and num_TF respectively.

[0171] S4: Perform mean filtering on the accumulated different edge directions and calculate the variance.

[0172] S 401: Calculate the mean values of the edge angles of the two edge types, denoted as avg_direction_AT and avg_direction_TF.

[0173] S 402: Calculate the variances of the two edge types and perform mapping according to the calculation results, denoted as var_direction_AT and var_direction_TF respectively.

[0174] S5: Determine the final edge direction according to the calculation results.

[0175] S501: The first step is to determine whether there is an edge. The judgment condition is:

[0176] sum_type_no_edg = max(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge,

[0177] sum_type_h_edge, sum_type_no_edge

[0178] Or

[0179] sum_type_at_edge + sum_type_tf_edge + sum_typ□_v_edge + sum_type_h_edge < edge_th

[0180] where edge_th is the edge base threshold calculated in S202.

[0181] When one of the above two conditions is met, it is determined that this pixel point is a non-edge point at this time.

[0182] S502: When the condition of S501 is not satisfied, go to the second step to determine whether it is a vertical edge. The judgment condition is:

[0183] sum_type_v_edge

[0184] = max(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge)

[0185] And

[0186] sum_type_h_edge

[0187] = min(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge)

[0188] When this condition is met, it is determined that the edge direction of this pixel point is a vertical edge, and the edge judgment result is output.

[0189] S503: On the premise of meeting S502, further optimize the vertical edge confidence according to the gradient information of the central pixel point. Taking in S202 as an example, take out P 22The vertical gradient magnitude grad_y and the horizontal gradient magnitude grad_x. According to the proportional relationship between grad_y and grad_x, further map sum_type_v_edge to obtain and output the vertical edge confidence edge_confidence.

[0190] S504: When the condition of S502 is not satisfied, proceed to determine whether it is a horizontal edge. The determination condition is:

[0191] sum_type_h_edge

[0192] =max(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge)

[0193] and

[0194] sum_type_v_edge

[0195] =min(sum_type_at_edge, sum_type_tf_edge, sum_type_v_edge, sum_type_h_edge)

[0196] When this condition is satisfied, determine that the edge direction of this pixel point is a horizontal edge, and output the edge determination result.

[0197] S505: On the premise of satisfying S504, further optimize the vertical edge confidence according to the gradient information of the central pixel point. Taking in S202 as an example, take out the vertical gradient magnitude grad_y and the horizontal gradient magnitude grad_x of P 22 According to the proportional relationship between grad_y and grad_x, further map sum_type_h_edge to obtain and output the horizontal edge confidence edge_confidence.

[0198] S506: When the condition of S504 is not satisfied, proceed to the fourth step to determine whether it is a first and third quadrant edge (AT_Edge). The determination condition is as follows:

[0199] sum_type_at_edge≥sum_type_tf_edge && var_direction_AT < var_direction_TF

[0200] When this condition is satisfied, determine that the edge direction of this pixel point is a first and third quadrant edge (AT_Edge), output the edge type, and at the same time output the edge angle. The edge angle is calculated as follows:

[0201] Edge_angle = avg_direction_AT

[0202] S507: On the premise of satisfying S506, further calculate the edge confidence using the variance var_direction_AT calculated in S402 and the difference between the AT_Edge confidence and the TF_Edge confidence. The specific calculation is as follows:

[0203] edge_confidence = var_direction_AT * (sum_type_at_edge - sum_type_tf_edge)

[0204] S508: When the condition of S506 is not satisfied, go to the fifth step to determine whether it is a second and fourth quadrant edge (AT_Edge). The determination conditions are as follows:

[0205] sum_type_tf_edge ≥ sum_type_at_edge && var_direction_TF < var_direction_AT

[0206] When this condition is satisfied, it is determined that the edge direction of this pixel point is a second and fourth quadrant edge (AT_Edge), output the edge type, and at the same time output the edge angle. The edge angle calculation is as follows:

[0207] Edge_angle = avg_direction_TF

[0208] S509: On the premise of satisfying S508, further calculate the edge confidence using the variance var_direction_TF calculated in S402 and the difference between the TF_Ede confidence and the AT_Edge confidence. The specific calculation is as follows:

[0209] edge_confidence = var_direction_TF * (sum_type_tf_edge - sum_type_at_edge)

[0210] S6: Traverse point by point and repeat the calculation steps of S2 to S5.

[0211] In summary, through different types of edge filtering processing, the present disclosure effectively avoids the interference of noise on edge detection and greatly improves the accuracy of edge detection; at the same time, it outputs the edge type, edge angle, and edge confidence, calculates multiple effective information, and provides multiple effective reference information for subsequent image processing operations.

[0212] Figure 5The following is a schematic structural diagram of an image edge detection device 500 according to an embodiment of the present disclosure. As Figure 5 shown, the device includes:

[0213] A determination module 510, configured to determine initial edge information of each pixel point in the image to be detected.

[0214] A processing module 520, configured to determine target edge information of a first pixel point based on the initial edge information of the neighboring pixel points corresponding to the first pixel point in the image to be detected, where the target edge information includes a target edge direction, a target edge angle, and a target edge confidence level.

[0215] In some embodiments, the determination module is further configured to: for each pixel point in the image to be processed, convert the image to be processed into an image to be detected through a transformation matrix; for a second pixel point in the image to be detected, perform gradient detection within a first neighborhood to obtain the initial edge information of the second pixel point.

[0216] In some embodiments, the determination module is further configured to: through gradient detection, determine the initial gradient magnitude and the initial gradient direction of the second pixel point; based on the initial gradient magnitude and the initial gradient direction, determine the initial edge type of the second pixel point; based on the initial edge type and the initial gradient magnitude, determine the initial edge angle and the initial edge confidence level of the second pixel point, where the initial edge information includes at least one of the initial gradient magnitude, the initial edge type, the initial edge angle, and the initial edge confidence level.

[0217] In some embodiments, the determination module is further configured to: determine the difference between the maximum pixel value and the minimum pixel value among the pixel values corresponding to multiple pixel points within the first neighborhood; based on a first preset mapping relationship, determine a first threshold corresponding to the difference, where the first threshold is a classification parameter for determining the target edge type.

[0218] In some embodiments, the processing module is further configured to: respectively determine at least one fourth pixel point with an initial edge type of a first type and at least one fifth pixel point with an initial edge type of a second type according to multiple third pixel points within a second neighborhood corresponding to the first pixel point; based on the initial edge angles of each pixel point among at least one fourth pixel point, determine the mean and variance corresponding to the first type, and based on the initial edge angles of each pixel point among at least one fifth pixel point, determine the mean and variance corresponding to the second type; based on at least one of the initial edge confidence levels, the initial edge types, and the initial gradient magnitudes of each third pixel point among the multiple third pixel points, the mean and variance corresponding to the first type, the mean and variance corresponding to the second type, and the first threshold, through filtering processing, determine the target edge direction, the target edge angle, and the target edge confidence level of the first pixel point.

[0219] In some embodiments, the processing module is further configured to: among multiple third pixel points, respectively determine the initial edge confidence and value of the pixel points corresponding to the first type, second type, third type, fourth type, and fifth type of the initial edge type, and use the initial edge confidence and value corresponding to each type as a first set; in the case where the initial edge confidence and value corresponding to the fifth type is the maximum value in the first set, or the sum of the initial edge confidence and value corresponding to the first type, the initial edge confidence and value corresponding to the second type, the initial edge confidence and value corresponding to the third type, and the initial edge confidence and value corresponding to the fourth type is less than a first threshold, determine the target edge type of the first pixel point as the fifth type, where the target edge direction of the first pixel point is the edge direction corresponding to the target edge type.

[0220] In some embodiments, the processing module is further configured to: in the case where the initial edge confidence and value corresponding to the third type is the maximum value in the first set and the initial edge confidence and value corresponding to the fourth type is the minimum value in the first set, determine the target edge type of the first pixel point as the third type; determine the angle corresponding to the third type as the target edge angle of the first pixel point; and determine the target edge confidence of the first pixel point based on the initial gradient magnitude of the central pixel point of the third neighborhood pixel points corresponding to the first pixel point.

[0221] In some embodiments, the processing module is further configured to: in the case where the initial edge confidence and value corresponding to the first type is greater than the initial edge confidence and value corresponding to the second type and the variance corresponding to the first type is less than the variance corresponding to the second type, determine the target edge type of the first pixel point as the first type; determine the target edge angle of the first pixel point based on the mean value corresponding to the first type; and determine the target edge confidence of the first pixel point based on the variance corresponding to the first type, the initial edge confidence and value corresponding to the first type, and the initial edge confidence and value corresponding to the second type.

[0222] In some embodiments, the determination module is further configured to: respectively determine the number of pixel points with the initial edge type being the first type and the second type according to multiple sixth pixel points in the fourth neighborhood corresponding to the second pixel point; and perform a correction process on the initial edge type of the second pixel point based on the number of pixel points of the first type and the number of pixel points of the second type.

[0223] In summary, the image edge detection device proposed by the present disclosure corrects the initial edge information of each pixel point by considering the initial edge information of each pixel point and the initial edge information of the neighboring pixel points to obtain the target edge information, improving the accuracy of image edge detection; and simultaneously outputs the edge angle and edge confidence, providing effective reference information for subsequent image processing operations.

[0224] Regarding the image edge detection device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated herein.

[0225] Figure 6 FIG. 4 is a schematic structural diagram of an electronic device 600 for implementing the above image edge detection method according to an exemplary embodiment.

[0226] Referring to Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602, a memory 604, a power supply component 606, an input / output (I / O) interface 608, a sensor component 610, and a communication component 612.

[0227] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, telephone calls, data communication, battery management, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a balancing module to facilitate the interaction between the power supply component 606 and the processing component 602.

[0228] The memory 604 is configured to store various types of data to support the operation of the electronic device 600. Examples of these data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.

[0229] The power supply component 606 provides power to various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 600.

[0230] The I / O interface 608 provides an interface between the processing component 602 and a peripheral interface module, and the peripheral interface module may be a keyboard, a click wheel, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.

[0231] The sensor assembly 610 includes one or more sensors for providing status assessment of various aspects for the electronic device 600. For example, the sensor assembly 610 can detect the on / off state of the electronic device 600, the relative positioning of components, such as the display and keypad of the electronic device 600. The sensor assembly 610 can also detect a change in the position of the electronic device 600 or a component of the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 610 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 610 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications.

[0232] In some embodiments, the sensor assembly 610 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0233] The communication component 612 is configured to facilitate communication between the electronic device 600 and other devices in a wired or wireless manner. The electronic device 600 can access a wireless network based on communication standards, such as WiFi, 2G or 3G, 4G LTE, 5G NR (New Radio), or a combination thereof. In an exemplary embodiment, the communication component 612 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 612 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0234] In an exemplary embodiment, the electronic device 600 can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.

[0235] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the above instructions can be executed by a processor 620 of the electronic device 600 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0236] The present disclosure also provides a computer-readable storage medium, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of the image edge detection method provided by the present disclosure are implemented.

[0237] An embodiment of the present disclosure further provides a computer program product, including a computer program, and the computer program implements the image edge detection method described in the foregoing embodiments of the present disclosure when executed by a processor.

[0238] Figure 7 It is a schematic structural diagram of a chip 700 for implementing the above image edge detection method shown according to an exemplary embodiment. Refer to Figure 7 , the chip 700 includes at least one communication interface 701 and a processor 702. The communication interface 701 is used to receive signals input to the chip 700 or signals output from the above chip 700. The processor 702 communicates with the communication interface 701 and implements the image edge detection method described in the foregoing embodiments of the present disclosure through logic circuits or by executing code instructions.

[0239] In addition, the word "exemplary" is used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as "exemplary" is not necessarily understood to be advantageous compared to other aspects or designs. Instead, the use of the word exemplary is intended to present concepts in a concrete manner. As used herein, the term "or" is intended to mean an inclusive "or" rather than an exclusive "or". That is, unless otherwise specified or clear from the context, "X applies A or B" is intended to represent any arrangement in a natural inclusive arrangement. That is, if X applies A; X applies B; or X applies both A and B, then "X applies A or B" is satisfied in any of the foregoing instances. Additionally, unless otherwise specified or clear from the context referring to the singular form, the articles "a" and "an" as used in this application and the appended claims are generally understood to mean "one or more".

[0240] Similarly, although the present disclosure has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art upon reading and understanding this specification and the drawings. The present disclosure includes all such modifications and variations and is limited only by the scope of the claims. Specifically with respect to the various functions performed by the components described above (e.g., elements, resources, etc.), unless otherwise indicated, the terms used to describe such components are intended to correspond to any component (functionally equivalent) that performs the specific function of the described component, even if not structurally equivalent to the disclosed structure. Additionally, although certain features of the present disclosure may have been disclosed with respect to only one of several implementations, such features may, as may be desired and advantageous for any given or particular application, be combined with one or more other features of other implementations. Further, with respect to the use of "comprising", "having", "including", "with", or variations thereof in the detailed description or claims, such terms are intended to be inclusive in a manner similar to the term "including".

[0241] Other embodiments of the present disclosure will readily occur to those of ordinary skill in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are pointed out by the following claims.

[0242] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes may be made without departing from its scope. The scope of the present disclosure is limited only by the appended claims.

[0243] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data may be interchanged where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0244] In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples", etc. means that the specific features, structures, materials, or characteristics described in connection with the embodiments or examples are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0245] Any process or method description represented in a flowchart or described in other ways herein can be understood to represent a module, segment, or portion of code including one or more executable instructions for implementing a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations, where the functions can be executed in a manner that is not in the order shown or discussed, including in a substantially simultaneous manner according to the functions involved or in a reverse order, which should be understood by those skilled in the art to which the embodiments of the present disclosure pertain.

[0246] The logic and / or steps represented in a flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing a logical function, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processing module, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in connection with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection portion having one or more wirings (control method), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which a program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other appropriate processing as necessary, and then stored in a computer memory.

[0247] It should be understood that each part of the embodiments of the present disclosure can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one of the following techniques known in the art or a combination thereof can be used: discrete logic circuits with logic gate circuits for implementing logical functions on data signals, application specific integrated circuits with suitable combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.

[0248] Those of ordinary skill in the art can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0249] In addition, each functional unit in the various embodiments of the present disclosure can be integrated into a processing module, or each unit can exist physically alone, or two or more units can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disk, etc.

[0250] Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limitations of the present disclosure. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.

Claims

1. An image edge detection method, characterized in that, The method includes: Determining initial edge information of each pixel point in the image to be detected; Based on the initial edge information of the neighboring pixel points corresponding to the first pixel point in the image to be detected, determining the target edge information of the first pixel point, where the target edge information includes a target edge direction, a target edge angle, and a target edge confidence level.

2. The method according to claim 1, wherein The determining of the initial edge information of each pixel point in the image to be detected includes: For each pixel point in the image to be processed, converting the image to be processed into the image to be detected through a transformation matrix; Performing gradient detection on a second pixel point in the image to be detected within a first neighborhood to obtain the initial edge information of the second pixel point.

3. The method according to claim 2, characterized in that The performing of gradient detection on the second pixel point in the image to be detected within the first neighborhood to obtain the initial edge information of the second pixel point includes: Determining an initial gradient magnitude and an initial gradient direction of the second pixel point through the gradient detection; Based on the initial gradient magnitude and the initial gradient direction, determining an initial edge type of the second pixel point; Based on the initial edge type and the initial gradient magnitude, determining an initial edge angle and an initial edge confidence level of the second pixel point, where the initial edge information includes at least one of the initial gradient magnitude, the initial edge type, the initial edge angle, and the initial edge confidence level.

4. The method according to claim 3, characterized in that, The method further includes: Determining a difference between a maximum pixel value and a minimum pixel value among the pixel values corresponding to multiple pixel points within the first neighborhood; Based on a first preset mapping relationship, determining a first threshold corresponding to the difference, where the first threshold is a classification parameter for determining a target edge type.

5. The method according to claim 4, wherein The determining of the target edge information of the first pixel point based on the initial edge information of the neighboring pixel points corresponding to the first pixel point in the image to be detected includes: According to multiple third pixel points within a second neighborhood corresponding to the first pixel point, respectively determining at least one fourth pixel point with an initial edge type of a first type and at least one fifth pixel point with an initial edge type of a second type; Based on the initial edge angles of each pixel point among the at least one fourth pixel point, determining a mean and a variance corresponding to the first type, and based on the initial edge angles of each pixel point among the at least one fifth pixel point, determining a mean and a variance corresponding to the second type; Based on at least one of the initial edge confidence levels, initial edge types, and initial gradient magnitudes of each third pixel point among the multiple third pixel points, the mean and variance corresponding to the first type, the mean and variance corresponding to the second type, and the first threshold, determining the target edge direction, target edge angle, and target edge confidence level of the first pixel point through filtering processing.

6. The method according to claim 5, characterized in that, Based on the initial edge confidence levels, initial edge types, and the first threshold of each third pixel point among the multiple third pixel points, determining the target edge direction and target edge confidence level of the first pixel point through filtering processing includes: Among the multiple third pixel points, respectively determine the initial edge confidence and value of the pixel points corresponding to the first type, the second type, the third type, the fourth type, and the fifth type of the initial edge type, and use the initial edge confidence and value corresponding to each type as the first set; In the case where the initial edge confidence and value corresponding to the fifth type is the maximum value in the first set, or the sum of the initial edge confidence and value corresponding to the first type, the initial edge confidence and value corresponding to the second type, the initial edge confidence and value corresponding to the third type, and the initial edge confidence and value corresponding to the fourth type is less than the first threshold, determine the target edge type of the first pixel point as the fifth type, where the target edge direction of the first pixel point is the edge direction corresponding to the target edge type.

7. The method according to claim 6, characterized in that, The method further includes: In the case where the initial edge confidence and value corresponding to the third type is the maximum value in the first set, and the initial edge confidence and value corresponding to the fourth type is the minimum value in the first set, determine the target edge type of the first pixel point as the third type; Determine the angle corresponding to the third type as the target edge angle of the first pixel point; Based on the initial gradient magnitude of the central pixel point of the third neighborhood pixel points corresponding to the first pixel point, determine the target edge confidence of the first pixel point.

8. The method according to claim 7, characterized in that, The method further includes: In the case where the initial edge confidence and value corresponding to the first type is greater than the initial edge confidence and value corresponding to the second type, and the variance corresponding to the first type is less than the variance corresponding to the second type, determine the target edge type of the first pixel point as the first type; Based on the mean value corresponding to the first type, determine the target edge angle of the first pixel point; Based on the variance corresponding to the first type, the initial edge confidence and value corresponding to the first type, and the initial edge confidence and value corresponding to the second type, determine the target edge confidence of the first pixel point.

9. The method according to claim 4, characterized in that, The method further includes: According to the multiple sixth pixel points in the fourth neighborhood corresponding to the second pixel point, respectively determine the number of pixel points with the initial edge type being the first type and the second type; Based on the number of pixel points of the first type and the number of pixel points of the second type, perform correction processing on the initial edge type of the second pixel point.

10. An image edge detection device, comprising: A determination module, configured to determine the initial edge information of each pixel point in the image to be detected; A processing module, configured to determine the target edge information of the first pixel point based on the initial edge information of the neighborhood pixel points corresponding to the first pixel point in the image to be detected, where the target edge information includes a target edge direction, a target edge angle, and a target edge confidence.

11. An electronic device, characterized in that, Comprising: A processor and a memory for storing a computer program that can run on the processor, where the processor is configured to execute the method according to any one of claims 1-9 when running the computer program.

12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-9.

13. A computer program product, characterized in that, When the computer program product runs on a computer, it causes the computer to execute the method according to any one of claims 1-9.

14. A chip, characterized in that, Comprising at least one processor and a communication interface; the communication interface is used to receive signals input to the chip or signals output from the chip, and the processor communicates with the communication interface and implements the method according to any one of claims 1-9 through logic circuits or by executing code instructions.