Image edge denoising and edge preservation method, device, equipment and storage medium
By calculating the gradient point of the edge point of the image and combined with the gradient template to verify and remove the noise and pseudo -edges in the edge of the image, solve the problem of low noise reduction and low margin accuracy in existing technologies, and achieve more efficient image edge processing.
Patent Information
- Application Number
- CN202411043208.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-07-31
AI Technical Summary
The accuracy of the prior art in image edge noise reduction and edge preservation still needs to be improved, and it is difficult to effectively remove pseudo-edges and reduce noise.
By calculating the first gradient of each edge point, the Boolean first -step and two -step degree is obtained, combining the gradient templates of noise and pseudo -edges, searching for suspected targets, and combining the characteristic curve of the polynomial equation. Verify noise and pseudo -edges.
The accurate noise reduction and edge of the edge of the image can be achieved, which can effectively remove the pseudo -edges and reduce noise, and improve the accuracy of the image edge detection.
Smart Images

Figure CN118822892B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to an image edge denoising and edge preserving method, device, equipment and storage medium. Background Art
[0002] Edges are the most basic features of objects in images and are an important basis for image segmentation, target recognition, and visual detection. Due to the influence of image quality and detection parameters (such as intensity threshold), edge detection results sometimes produce non-real edges, such as noise and pseudo edges, which interfere with subsequent image processing and analysis and affect the accuracy of computer decision-making. Therefore, it is necessary to verify the authenticity of image edges, a process also called noise reduction and edge preservation.
[0003] Currently, methods such as neighborhood edge intensity non-maximum suppression, double threshold segmentation, and morphological processing are mostly used for denoising and edge preservation. Although they can remove noise and complete edge extraction to a certain extent, the accuracy of denoising and edge preservation still needs to be improved. Summary of the invention
[0004] The object of the present invention is to provide an image edge denoising and edge preserving method and device, equipment and storage medium, which can accurately remove pseudo edges and reduce noise.
[0005] The first aspect of the present invention discloses a method for reducing image edge noise and preserving edge, comprising:
[0006] According to the image edge data, the first-order gradient of each edge point is calculated;
[0007] Obtaining gradient data of each edge point according to the first-order gradient and the first-order gradient threshold, wherein the gradient data includes a Boolean first-order gradient and a Boolean second-order gradient, and the Boolean first-order gradient and the Boolean second-order gradient are Boolean values;
[0008] Search all the gradient data according to the gradient template of noise and the gradient template of pseudo edge to obtain a plurality of suspected targets, wherein the suspected targets include suspected noise and suspected pseudo edge;
[0009] Traversing the suspected target, fitting the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target using a polynomial equation to obtain a characteristic curve, and when the current suspected target is verified as a noise point according to the noise deviation based on the characteristic curve or the current suspected target is verified as a false edge according to the correlation coefficient, deleting the current suspected target in the image edge data;
[0010] Output the image edge data after removing noise points and false edges.
[0011] In some embodiments, obtaining the gradient data of the target edge point according to the first-order gradient and the first-order gradient threshold includes:
[0012] Compare the first-order gradient of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the target edge point;
[0013] Compare the first-order gradient of the next edge point of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the next edge point;
[0014] An XOR operation is performed on the Boolean first-order gradient of the target edge point and the Boolean first-order gradient of the next edge point to obtain the Boolean second-order gradient of the target edge point.
[0015] In some embodiments, the step of determining the first-order gradient threshold comprises:
[0016] Performing linear regression on the image edge data, removing singular edge points whose deviation is greater than the fitting residual from the image edge data, and obtaining filtered edge data;
[0017] Calculating the first-order gradient of the edge data after screening, arranging all the first-order gradients in ascending order and calculating the second-order gradient to obtain a first-order gradient sequence and a second-order gradient sequence;
[0018] Calculating the mean and standard deviation of the second-order gradient sequence;
[0019] Obtaining the index value of the first second-order gradient in the second-order gradient sequence that is not less than the sum of the mean and the standard deviation;
[0020] The first-order gradient corresponding to the index value in the first-order gradient sequence is set as the first-order gradient threshold.
[0021] In some embodiments, before calculating the first-order gradient of each edge point, the method further includes:
[0022] dividing the image edge corresponding to the image edge data into a plurality of edge segments;
[0023] Perform linear regression on each edge segment to obtain several regression lines;
[0024] Performing coordinate transformation on the edge segment corresponding to the regression line according to the direction angle of the regression line to obtain the transformed edge segment;
[0025] All transformed edge segments are concatenated, and the image edge data is updated.
[0026] In some embodiments, the gradient template of the noise includes a first gradient feature, a second gradient feature, and a third gradient feature arranged in sequence, the gradient template of the pseudo edge includes a group gradient feature and an intermediate gradient feature, and searching all the gradient data according to the gradient template of the noise and the gradient template of the pseudo edge to obtain a number of suspected targets includes:
[0027] Traversing all the gradient data, taking the index position of the gradient data that meets the third gradient feature as the end point, and the index position of the gradient data that meets the first gradient feature as the starting point, and when the starting point and the end point include the gradient data that meets the second gradient feature, setting the edge point between the starting point and the end point as suspected noise;
[0028] Traversing all the gradient data, taking the index position of the gradient data that meets the group gradient feature as the starting point, searching backward from the starting point, taking the index position of the gradient data that meets the group gradient feature as the end point, and when the starting point and the end point include gradient data that meets the intermediate gradient feature, setting the edge point between the starting point and the end point as a suspected pseudo edge;
[0029] The suspected noise and the suspected false edge constitute the suspected target.
[0030] In some embodiments, a polynomial equation is used to fit the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target to obtain a characteristic curve, and based on the characteristic curve, whether the current suspected target is a noise point is verified according to the noise deviation or whether the current suspected target is a false edge is verified according to the correlation coefficient, including:
[0031] If the current suspected target is suspected noise:
[0032] Selecting a number of data points in the confidence margin of the front neighborhood of the current suspected target and in the confidence margin of the back neighborhood to obtain first selected data;
[0033] Using a third-order polynomial equation to perform least squares fitting on the first selected data to obtain the characteristic curve;
[0034] Calculating the deviation of the current suspected target according to the characteristic curve, and determining that the current suspected target is a noise point when the deviation exceeds a deviation threshold;
[0035] If the current suspected target is a suspected false edge:
[0036] Selecting a number of data points in the confidence margin of the front neighborhood of the current suspected target and in the confidence margin of the back neighborhood to obtain second selected data;
[0037] Using a first-order polynomial equation or a second-order polynomial equation to perform least squares fitting on the second selected data to obtain the characteristic curve;
[0038] According to the characteristic curve, the correlation between the actual value and the fitted value of the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target is calculated to obtain a correlation coefficient;
[0039] When the correlation coefficient is greater than a preset threshold, the current suspected target is determined to be a false edge.
[0040] In some embodiments, calculating the first-order gradient of each edge point according to the image edge data includes:
[0041] Performing linear regression on the image edge data to obtain a fitting curve;
[0042] Calculating the deviation of the image edge data according to the fitting curve;
[0043] The edge point corresponding to the minimum deviation is taken as the initial point, and the first-order gradient of each edge point is calculated in turn.
[0044] A second aspect of the present invention discloses an image edge denoising and edge preserving device, comprising:
[0045] A first-order gradient unit, used to calculate the first-order gradient of each edge point according to the image edge data;
[0046] A gradient data unit, used to obtain gradient data of each edge point according to the first-order gradient and the first-order gradient threshold, wherein the gradient data includes a Boolean first-order gradient and a Boolean second-order gradient, and the Boolean first-order gradient and the Boolean second-order gradient are Boolean values;
[0047] A suspected target unit, used for searching all the gradient data according to a gradient template of noise and a gradient template of pseudo edge to obtain a plurality of suspected targets, wherein the suspected targets include suspected noise and suspected pseudo edge;
[0048] A verification unit, used to traverse the suspected target, fit the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target using a polynomial equation to obtain a characteristic curve, and when the current suspected target is verified as a noise point based on the noise deviation or the current suspected target is verified as a pseudo edge based on the correlation coefficient based on the characteristic curve, the current suspected target is deleted from the image edge data;
[0049] The output unit is used to output the image edge data after the noise points and false edges are deleted.
[0050] The third aspect of the present invention discloses an electronic device, comprising a memory storing executable program code and a processor coupled to the memory; the processor calls the executable program code stored in the memory to execute the image edge denoising and edge preservation method disclosed in the first aspect.
[0051] A fourth aspect of the present invention discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the image edge denoising and edge preservation method disclosed in the first aspect.
[0052] The beneficial effect of the present invention is that the Boolean first-order gradient is used to characterize the size of edge fluctuations, and the Boolean second-order gradient is used to characterize the size of the intensified or weakened edge fluctuations in the neighborhood, and the gradient data of the edge is obtained. The gradient data of the edge is matched with the pre-established gradient template of the noise and the gradient template of the pseudo-edge, and the suspected noise and suspected false edges are retrieved. Finally, by selecting the confidence data of the neighborhood before and after the suspected noise for polynomial fitting, the noise distribution is evaluated using the deviation value, the confidence data of the neighborhood before and after the suspected false edge is selected for polynomial fitting, and the edge characteristics are evaluated using the correlation coefficient, the verification of noise and pseudo-edges is completed. Pseudo-edges can be accurately removed and noise can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings herein show specific examples of the technical solutions described in the present invention, and together with the specific implementation methods constitute a part of the specification, and are used to explain the technical solutions, principles and effects of the present invention.
[0054] Unless otherwise specified or defined, the same reference numerals in different drawings represent the same or similar technical features, and the same or similar technical features may also be represented by different reference numerals.
[0055] Figure 1 It is a flow chart of an image edge denoising and edge preservation method disclosed in an embodiment of the present invention;
[0056] Figure 2 is a schematic diagram of an edge profile disclosed in an embodiment of the present invention;
[0057] Figure 3 is a flow chart of calculating gradient data disclosed in an embodiment of the present invention;
[0058] Figure 4 is a flow chart of determining a first-order gradient threshold value disclosed in an embodiment of the present invention;
[0059] Figure 5 is a schematic diagram of an ideal model of isolated noise disclosed in an embodiment of the present invention;
[0060] Figure 6is a schematic diagram of an ideal model of continuous noise disclosed in an embodiment of the present invention;
[0061] Figure 7 is a schematic diagram of an ideal pseudo edge model disclosed in an embodiment of the present invention;
[0062] Figure 8 It is a flow chart for extracting suspected noise and suspected false edges disclosed in an embodiment of the present invention;
[0063] Fig. 9 This is a flow chart of an image edge denoising and edge preservation process disclosed in an embodiment of the present invention;
[0064] Fig.10 is a suspected noise verification flow chart disclosed in an embodiment of the present invention;
[0065] Fig.11 is a suspected pseudo edge verification flow chart disclosed in an embodiment of the present invention;
[0066] Fig.12 It is a structural schematic diagram of an image edge denoising and edge preservation device disclosed in an embodiment of the present invention;
[0067] Fig.13 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0068] Unless otherwise specified or defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art. In the case of combining the technical solution of the present invention with realistic scenarios, all technical and scientific terms used herein may also have meanings corresponding to the purpose of implementing the technical solution of the present invention. The "first, second..." used herein is only used to distinguish the names and does not represent a specific quantity or order. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0069] It should be noted that when a component is considered to be "fixed to" another component, it can be directly fixed to the other component or there can be a central component; when an component is considered to be "connected to" another component, it can be directly connected to the other component or there can be a central component at the same time; when an component is considered to be "installed on" another component, it can be directly installed on the other component or there can be a central component at the same time. When an component is considered to be "set on" another component, it can be directly set on the other component or there can be a central component at the same time.
[0070] Unless otherwise specified or defined, the "said" and "the" used in this document refer to the technical features or technical contents mentioned or described before the corresponding position, and the technical features or technical contents may be the same as or similar to the technical features or technical contents mentioned therein. In addition, the terms "including" and "having" and any variations thereof used in this document are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.
[0071] In order to improve the accuracy of image edge denoising, the present invention uses mathematical statistics analysis to perform edge filtering denoising and edge preservation based on the assumptions of edge physical continuity and randomness of noise distribution. Physical models of isolated noise, continuous noise and pseudo-edge of discrete edges are established in advance, and the first-order gradient is used to characterize the edge fluctuation size, and the second-order gradient is used to characterize the neighborhood edge fluctuation trend, and the noise template and pseudo-edge template are constructed by gradient combination. Then, the gradient threshold is obtained by mathematical statistics analysis, and the gradient data of the edge is matched with the noise template and the pseudo-edge template to retrieve suspected noise and suspected false edges. Finally, by selecting the confidence data of the neighborhood before and after the suspected noise for polynomial fitting, using the deviation value to evaluate the noise distribution, selecting the confidence data of the neighborhood before and after the suspected false edge for polynomial fitting, and using the correlation coefficient to evaluate the edge characteristics, the verification of noise and pseudo-edges is completed, and pseudo-edges can be accurately removed and noise can be reduced, that is, non-real edges can be removed.
[0072] The embodiment of the present invention discloses an image edge denoising and edge preserving method, which is used to remove the non-real edges generated in the image edge detection. The method can be implemented by computer programming. The execution subject of the method can be an electronic device such as a computer, a laptop computer, a tablet computer, or an image edge denoising and edge preserving device embedded in the electronic device, and the present invention is not limited to this. In order to facilitate the understanding of the present invention, the specific embodiments of the present invention will be described in more detail below with reference to the drawings of the specification.
[0073] like Figure 1 As shown, the method comprises the following steps:
[0074] Step S100: Calculate the first-order gradient of each edge point according to the image edge data;
[0075] The edge points obtained by edge detection on smooth continuous contours form a data sequence, and the data in the data sequence is distributed along the detection step direction. This data sequence is called image edge data. The first-order gradient is used to characterize the degree of edge fluctuation. Edge point P i Can be relative to the neighboring point Pi+1 Calculate the first-order gradient, or relative to the neighboring point P i-1 Calculate the first-order gradient and also use P i-1 and P i+1 Calculate the first-order gradient. Edge point P i Relative to neighboring point P i+1 The first-order gradient calculation formula is:
[0076]
[0077] Edge point P i Relative to neighboring point P i-1 The first-order gradient calculation formula is:
[0078]
[0079] Edge point P i Relative to neighboring point P i-1 , P i+1 The first-order gradient calculation formula is:
[0080]
[0081] in, Represents the edge point P i The first-order gradient of; x, y are the pixel coordinates of the edge point. From equations (1) and (2), we can see that the edge point P i The first-order gradient is only related to the neighboring point P i±1 Its size directly reflects the degree of fluctuation of the neighborhood edge.
[0082] The specific calculation process of this embodiment is as follows: first, linear regression is performed on the image edge data to form a fitting curve, then the deviation of each edge point in the image edge data relative to the fitting curve is calculated, the edge point with the smallest deviation has the best confidence, the edge point corresponding to the smallest deviation is used as the initial point, and the first-order gradient of each edge point is calculated in sequence from the initial point. By linearly regressing the image edge data, taking the point with the smallest deviation as the best confidence point, taking it as the initial point, and calculating the first-order gradient of all edge points in sequence, the accuracy of the first-order gradient calculation can be improved.
[0083] In some examples, the edge contour corresponding to the image edge data is more complex. In order to meet the assumption of smoothness and continuity, it is necessary to pre-process the image edge data according to the actual shape of the target edge, that is, to normalize the target edge trend line to the coordinate axis through piecewise coordinate transformation. Figure 2As shown in the figure, the edge contour is a closed curve with large undulations. If the image edge data obtained by edge detection is directly processed, the accuracy of noise reduction and edge preservation will be low due to data distribution. Therefore, it is necessary to segment the edge contour into several smooth and monotonous edge segments for further processing, which can not only effectively improve the accuracy of noise reduction and edge preservation when the edge contour is more complex, but also uniformly process all edge segment data.
[0084] Specifically, before calculating the first-order gradient of the edge point, the image edge corresponding to the image edge data is first divided into several edge segments by judging the turning point of the curve through the slope change information of the curve; since each edge segment is smooth and monotonous, each edge segment can be regressed using a linear trend line, such as Figure 2 As shown by the arrows in the middle, several regression lines are obtained. The regression equation is expressed as: y = tanθ·x+b, where x and y represent the horizontal and vertical coordinates of the image coordinate system, respectively, b is the intercept, and θ is the direction angle, that is, the angle of the regression line relative to the horizontal axis. Then, according to the direction angle of each regression line, the edge segment corresponding to the regression line is transformed so that the linear trend line coincides with the horizontal axis to obtain the transformed edge segment; then the transformed edge segments are spliced one by one, and the image edge data is replaced with the spliced data, which can facilitate the unified processing of all edge segment data. Through the above processing, the originally complex edge contour is converted into a smooth and monotonous multi-segment edge arranged along the horizontal axis, thereby improving the accuracy of denoising and edge preservation when the edge contour is more complex. Among them, the coordinate transformation can be a composite coordinate transformation, such as translation, rotation, splicing, etc. The specific formula for coordinate transformation is:
[0085]
[0086] Among them, x i,j ,y i,j and x' i,j ,y' i,j are the horizontal and vertical coordinates of the data of the jth point in the i-th edge segment in the original image coordinate system and the new coordinate system, respectively, i is the direction angle of the i-th edge segment, δ i-1 is the length of the i-1th edge segment in the x-axis direction, x i,s ,y i,s Is the starting point of the trend line segment of the i-th edge segment, which can be obtained by the vertical point of the first point of the edge segment on the trend line. The specific formula is:
[0087]
[0088] Among them, x i,0 ,y i,0 are the horizontal and vertical coordinates of the starting point in the i-th edge segment.
[0089] Through segmentation processing, several smooth and continuous edge segments are divided, and then through coordinate composite transformation, the edge segments are spliced on the horizontal axis, which can easily process all edge segment data uniformly. It is worth noting that after segmentation preprocessing, the detection step length s of each edge segment is i Can be unequal.
[0090] Step S200: Obtaining gradient data of each edge point according to the first-order gradient and the first-order gradient threshold, wherein the gradient data includes a Boolean first-order gradient and a Boolean second-order gradient, and the Boolean first-order gradient and the Boolean second-order gradient are Boolean values;
[0091] The gradient data is composed of a Boolean first-order gradient and a Boolean second-order gradient, expressed as: [B i ',B i ”], where the Boolean first-order gradient B i ' is a Boolean value, which is used to reflect whether there is fluctuation at the edge of the neighborhood; Boolean second-order gradient B i " is a Boolean value, which is used to reflect whether the fluctuation trend of the neighborhood edge has changed. By comparing the first-order gradient and the first-order gradient threshold, the Boolean first-order gradient of the edge point can be obtained. By comparing the Boolean first-order gradient of the edge point with the Boolean first-order gradient of the neighborhood edge point, the Boolean second-order gradient of the edge point can be determined.
[0092] Specifically, Figure 3 As shown, the steps of calculating the gradient data of a target edge point include:
[0093] Step S210: comparing the first-order gradient of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the target edge point;
[0094] The discreteness of edge noise is evaluated by comparing the sample deviation from the overall or local gradient level. Therefore, the probability statistics tool can be used to obtain the first-order gradient threshold. i When the first-order gradient of is greater than the first-order gradient threshold, it is judged as discrete, and the Boolean first-order gradient B i 'Mark TRUE(T), otherwise it is judged as continuous and the Boolean first-order gradient B i 'Mark FALSE (F). That is:
[0095]
[0096] Among them, B i ' is the target edge point P i The Boolean first-order gradient of τ0 is the first-order gradient threshold, which can be obtained using probability statistics tools.
[0097] Step S220: Compare the first-order gradient of the next edge point of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the next edge point;
[0098] Step S230: performing an XOR operation on the Boolean first-order gradient of the target edge point and the Boolean first-order gradient of the next edge point to obtain the Boolean second-order gradient of the target edge point.
[0099] Use the Boolean operation of the Boolean first-order gradient to get the target edge point P i The Boolean second-order gradient of is:
[0100]
[0101] Among them, B i ' is the target edge point P i The Boolean first-order gradient of i+1 ' is the target edge point P i The next edge point P i+1 The Boolean first-order gradient of i ” is the target edge point P i The Boolean second-order gradient of is the exclusive OR operator.
[0102] Obviously, no matter whether the edge gradient is from the current smaller (B i '=F) changes to a larger neighborhood (B i+1 '=T), or from the current larger (B i '=T) changes to a smaller neighborhood (B i+1 '=F), then the Boolean second-order gradient B i " are all equal to T, which to some extent reflects the trend of significant fluctuations in the local edge.
[0103] The key to the accuracy of edge noise and pseudo-edge recognition lies in the setting of the first-order gradient threshold. In this embodiment, the first-order gradient threshold is an adaptively set threshold, such as Figure 4 As shown, the steps of determining the first-order gradient threshold include:
[0104] Step S211: performing linear regression on the image edge data, removing singular edge points whose deviation is greater than the fitting residual from the image edge data, and obtaining filtered edge data;
[0105] Step S212: calculating the first-order gradient of the edge data after screening, arranging all the first-order gradients in ascending order and calculating the second-order gradient to obtain a first-order gradient sequence and a second-order gradient sequence;
[0106] Step S213: Calculate the mean and standard deviation of the second-order gradient sequence;
[0107] Step S214: obtaining the index value of the first second-order gradient in the second-order gradient sequence that is not less than the sum of the mean and the standard deviation;
[0108] Step S215: setting the first-order gradient corresponding to the index value in the first-order gradient sequence as the first-order gradient threshold.
[0109] First, perform linear regression on the edge data of the image to screen out singular edge points whose deviation (the error between the predicted value of the linear regression model and the actual observed value) exceeds the fitting residual (such as the root mean square error RMSE). The screened singular edge points do not enter the subsequent calculation of the first-order gradient threshold. Then, calculate the first-order gradient of the screened edge data, arrange them in ascending order, and calculate the second-order gradient, as well as the mean and standard deviation of the second-order gradient. Find the first index value in the second-order gradient sequence that is not less than the mean and standard deviation. Finally, extract the corresponding value from the first-order gradient sequence according to the index value and set it as the first-order gradient threshold.
[0110] Among them, the second-order gradient is obtained by the difference of the first-order gradient. The specific formula is:
[0111]
[0112] in, Represents the edge point P i The second-order gradient of the edge point P; x, y are the pixel coordinates of the edge point. From formula (5), we can see that the second-order gradient is not only related to the neighboring point P i±1 Also related to the neighboring point P i±2 Therefore, it is possible to effectively predict the fluctuation trend of the local edge, such as aggravating or slowing down the fluctuation.
[0113] Since the real edge is smooth and continuous, the first-order gradient of the real edge is also smooth and continuous. Through the above processing, the discontinuous point in the first-order gradient can be indexed, and the confidence level pointing to the false edge reaches more than 68%.
[0114] Step S300: searching all gradient data according to the gradient template of noise and the gradient template of pseudo-edge to obtain a number of suspected targets, wherein the suspected targets include suspected noise and suspected pseudo-edge;
[0115] Based on the objective law of material continuity and the basic assumption of random distribution of noise, the edge physical characteristics and mathematical statistics are integrated, and discrete physical models of false edges such as isolated noise, continuous noise and pseudo-edges and gradient templates based on Boolean first-order gradients and Boolean second-order gradients are established in advance. The gradient data is traversed and retrieved through the template matching method to extract suspected targets such as suspected noise and suspected pseudo-edges.
[0116] Specifically, noise includes isolated noise and continuous noise. The ideal model of isolated noise is as follows: Figure 5As shown in the figure, in a segment of edge outlined by the point sequence [A, B, C, D, E], point C is significantly outlier, with a larger gradient than the adjacent edges before and after, which obviously exceeds the overall or local gradient level, showing bilateral discreteness, and consistent with the structural characteristics of the adjacent local edges before and after point C (...AB and DE...). Such point C is called isolated noise. The ideal model of continuous noise is as follows Figure 6 As shown in , when several noise points with bilateral discreteness appear continuously in the point sequence, they are random in spatial distribution, and the edges of the front and back neighborhoods are similar in structural characteristics. In this case, these noise points are called continuous noise, such as Figure 6 C1, ..., C n .
[0117] The ideal model of pseudo edge is as follows Figure 7 As shown, if the point sequence C1, C2, ..., C n-1 , C n Continuous smoothing, only at the endpoints C1 and C n The gradient at the edge of the neighborhood significantly exceeds the overall or local level, so that [C1,…,C n ] shows bilateral discreteness as a whole. At this time, the structural similarity of the edges of the previous and next neighborhoods is used to determine [C1,…,C n ] is a pseudo edge. When the front local edge and the back local edge have the same structural features, [C1,…,C n ] is a pseudo edge; otherwise, it is a real edge. Figure 7 In the model shown, the front edge "...AB" is linearly related to the back edge "DE...", so [C1,...,C n ] is a pseudo edge.
[0118] According to the Boolean first-order gradient calculation formula (3) and the Boolean second-order gradient calculation formula (4), pre-calculate Figure 5 The isolated noise model shown, Figure 6 The continuous noise model shown, Figure 7 The Boolean first-order gradient and Boolean second-order gradient of the pseudo-edge model shown. The obtained gradient data are shown in the following table:
[0119]
[0120] By combining gradient data in an orderly manner [B i ',B i ”], can be generated separately Figure 5 The gradient template of the isolated noise model, Figure 6 The gradient template of the continuous noise model, Figure 7The gradient template of the pseudo-edge model. Among them, the gradient template of isolated noise is [F,T]-[T,F]-[T,T], the gradient template of continuous noise is [F,T]-n[T,F]-[T,T], and the gradient template of pseudo-edge is [F,T]-[T,T]-n[F,F]-[F,T]-[T,T]. Based on the gradient template of isolated noise, the gradient template of continuous noise, and the gradient template of pseudo-edge, through the traversal search method, the suspected noise and suspected pseudo-edge parts can be extracted and identified from the gradient data of all edge points.
[0121] In this embodiment, Figure 8 As shown, the specific steps include:
[0122] Step S310: traverse all gradient data, take the index position of the gradient data that meets the third gradient feature as the end point, take the index position of the gradient data that meets the first gradient feature as the starting point, and when the starting point and the end point include gradient data that meets the second gradient feature, set the edge point between the starting point and the end point as suspected noise;
[0123] Step S320: traverse all the gradient data, take the index position of the gradient data that meets the group gradient feature as the starting point, search backward from the starting point, take the index position of the gradient data that meets the group gradient feature as the end point, and when the starting point and the end point include gradient data that meets the intermediate gradient feature, set the edge point between the starting point and the end point as a suspected pseudo edge;
[0124] In the gradient template of noise (including the gradient template of isolated noise and continuous noise), the gradient data [F, T] is called the first gradient feature, the gradient data [T, F] is called the second gradient feature, and the gradient data [T, T] is called the third gradient feature.
[0125] In the gradient template of the pseudo edge, the gradient data group [F,T]-[T,T] is called the group gradient feature, and the gradient data [F,F] is called the intermediate gradient feature.
[0126] Fig. 9 The dotted line frame in the middle is a computer implementation scheme for searching for suspected noise and suspected false edges in this embodiment. The specific process is: searching for the first feature point B from front to back m = [T, T], m is the index of the feature point in the point sequence. Check the adjacent point B in front of the first feature point m-1Is the gradient data equal to [T,F]. When it is equal to [T,F]: continue to check whether the gradient data is equal to [T,F] point by point until it is equal to [F,T] and stop searching (note that there is no [F,F]), and take the point [F,T] as the second feature point, assuming the index number is n. At this time, take the points with index numbers from n+2 to m between the first feature point and the second feature point as suspected edge noise. Otherwise: continue to search for the second feature point from the first feature point. Assuming that the index number of the second feature point in the point sequence is n, then B n-1 =[F,T] and B n =[T,T]. In the process of searching for the second feature point, determine whether the middle point (if any) satisfies B i =[F,F]. If satisfied, continue searching; otherwise, interrupt the searching process and restart. The points with index numbers from n+2 to m between the first feature point and the second feature point are regarded as suspected false edges.
[0127] The obtained suspected noise and suspected pseudo edge constitute the suspected target.
[0128] Since the present invention is based on the following basic assumptions: (1) the real edge has a smooth and continuous curve shape in a contour structural feature; (2) the minimum structural feature on the edge contains at least 2 pixels; (3) the noise distribution is random and has structural similarity with the local edges before and after the noise and pseudo-edges. According to the basic assumptions, the noise distribution should be random, and the local edges before and after the noise and pseudo-edges satisfy the similarity of structural features. To this end, after extracting the suspected noise and suspected pseudo-edges through the above template, it is still necessary to further verify the suspected noise and suspected pseudo-edges by using the deviation value to evaluate the distribution of the noise and the correlation coefficient to evaluate the characteristics of the structure. Specifically, several confidence points at the front and back ends of the suspected edges such as suspected noise and suspected pseudo-edges are selected to fit the characteristic curve, and the noise is verified according to the deviation value between the suspected noise and the characteristic curve, and the pseudo-edge is verified according to the correlation between the suspected pseudo-edge and the characteristic curve.
[0129] In this embodiment, Fig.10 As shown, if the current suspected target is suspected noise, the specific verification steps include:
[0130] Step A410: Selecting a number of data points in the confidence margin of the front neighborhood and the confidence margin of the back neighborhood of the current suspected target respectively to obtain first selected data;
[0131] Step A420: using a third-order polynomial equation to perform least squares fitting on the first selected data to obtain a characteristic curve;
[0132] Step A430: Calculate the deviation of the current suspected target according to the characteristic curve, and when the deviation exceeds the deviation threshold, determine that the current suspected target is a noise point;
[0133] For suspected noise, select at least 2 points (such as A and B) from the confidence edge of the front neighborhood of the suspected noise (for example, the first-order gradient F is used as the confidence edge) and at least 2 points (such as D and E) from the confidence edge of the back neighborhood to obtain the first selected data. Use the third-order polynomial equation to perform the least squares fitting on the first selected data (such as A, B, D, E) to obtain the characteristic curve. The characteristic curve can be expressed as:
[0134] f(x)=ax 3 +bx 2 +cx+d, (6)
[0135] Calculate the deviation of the suspected noise from the characteristic curve respectively. When the deviation exceeds the threshold (which can be calculated by the first-order gradient threshold), the noise is confirmed and the current suspected target is determined to be a noise point and should be removed; otherwise, the current suspected target is considered to be a point with a larger gradient on the real edge and should be retained. The deviation calculation formula is:
[0136] ε=|f(x)-y|, (7)
[0137] Where y is the true value of the suspected noise, f(x) is the fitted value of the characteristic curve of the suspected noise, and ε is the deviation.
[0138] like Fig.11 As shown, if the current suspected target is a suspected false edge, the specific verification steps include:
[0139] Step B410: Selecting a number of data points in the confidence margin of the front neighborhood of the current suspected target and the confidence margin of the back neighborhood to obtain second selected data;
[0140] Step B420: using a first-order polynomial equation or a second-order polynomial equation to perform least squares fitting on the second selected data to obtain a characteristic curve;
[0141] Step B430: Calculate the correlation between the actual value and the fitted value of the confidence margin of the front neighborhood and the confidence margin of the back neighborhood of the current suspected target according to the characteristic curve to obtain the correlation coefficient;
[0142] Step B440: When the correlation coefficient is greater than a preset threshold, the current suspected target is determined to be a false edge.
[0143] Select several points in the confidence edge of the front neighborhood of the suspected pseudo-edge and several points in the confidence edge of the back neighborhood to obtain the second selected data. Use the first-order and / or second-order polynomial equation to perform least squares fitting on the second selected data to obtain a characteristic curve. Then, based on the characteristic curve, evaluate the correlation between the actual value and the fitted value of the selected confidence edge to obtain the correlation coefficient. When the correlation coefficient is greater than the threshold (such as 0.9), it means that the curve fitting is effective, the confidence edge of the front neighborhood and the confidence edge of the back neighborhood have consistent function characteristics, and meet the conditions of similar structural characteristics. Therefore, the current suspected target is determined to be a pseudo edge and should be eliminated; otherwise, the pseudo edge is considered invalid and should be retained. The correlation coefficient calculation formula is:
[0144]
[0145] Among them, in the formula, x i ,y i is the actual value of the edge point, f(x i ) is x i The fitted value of
[0146] and They are y i and f(x i )’s average value.
[0147] For example, for suspected noise, edge points with index numbers n, n+1, m+F1, and m+F2 are selected (m+F1 and m+F2 represent the first and second points after index m that satisfy B'=F, respectively), and the characteristic curve fitting formula (6) is used for fitting, and the deviation ε of each suspected noise is calculated using the deviation calculation formula (7). i If ε i ≥τ0(x i -x i-1 ), then determine the edge point (x i ,y i ) is a noise point, otherwise it is not a noise point. For suspected pseudo-edges, select no less than the following confidence edges: n-3, n-2, n-1, n, n+1, m+F1, m+F2, m+F3, and use f(x)=bx+c and / or f(x)=ax 2 +bx+c is fitted, and the correlation coefficient r is calculated using the correlation coefficient calculation formula (8). If r ≥ 0.9, the pseudo edge is determined to be established, otherwise it is not established.
[0148] If the current suspected target is determined to be a noise point or a false edge, the current suspected target is deleted from the image edge data. The suspected targets are traversed, and the next suspected target is used as the current suspected target for re-verification until all suspected targets are traversed.
[0149] In some examples, when the image edge data includes multiple smooth continuous contours, steps S200 to S400 may be performed on each edge segment in sequence until no suspected noise or suspected false edge is found.
[0150] Step S500: outputting the image edge data after deleting the noise points and the false edges.
[0151] After deleting the noise points and false edges, it is equivalent to removing the non-real edges generated during edge detection, improving the accuracy of the image edge. Then the processed image edge data is output for the next processing flow such as image segmentation, target recognition, and visual detection.
[0152] If the image edge data is segmented and coordinate transformed in step S100, after the non-real edges are removed, the coordinates of the image edge data can be restored to the original coordinates by using the inverse transformation of the coordinate transformation.
[0153] In this embodiment, the original edge contains 196 data points. After processing, 45 noises (red points) and 11 pseudo edges (green points) are removed. The accuracy of noise and pseudo edge recognition and removal is 100%, and the edge preservation accuracy is 94.6% (8 data points of the real edge are lost).
[0154] Through three examples of testing, the image edge denoising and edge preservation method of the present invention has the effect of filtering denoising and edge preservation for edges with different signal-to-noise ratios. The test found that for edge information with obvious noise interference (signal-to-noise ratio less than 15dB), the processing denoising accuracy and edge preservation accuracy are both above 80%. When the signal-to-noise ratio is 1.85dB, the denoising accuracy reaches 82%. It shows that the image edge denoising and edge preservation method of the present invention also has a good effect on low signal-to-noise ratio filtering.
[0155] In summary, the present invention pre-establishes the physical models of isolated noise, continuous noise, and pseudo-edge of discrete edges, and uses Boolean first-order gradients to characterize the changes in edge fluctuations, uses Boolean second-order gradients to characterize the changes in the trend of neighborhood edge fluctuations, and combines Boolean first-order gradients and Boolean second-order gradients to construct noise templates and pseudo-edge templates. Then, mathematical statistics are used to analyze the gradient threshold, and the gradient data of the edge is matched with the noise template and the pseudo-edge template to retrieve suspected noise and suspected false edges. Finally, by selecting the confidence data of the neighborhood before and after the suspected noise for polynomial fitting, using the deviation value to evaluate the noise distribution, selecting the confidence data of the neighborhood before and after the suspected false edge for polynomial fitting, and using the correlation coefficient to evaluate the edge characteristics, the verification of noise and pseudo-edges is completed, and pseudo-edges can be accurately removed and noise can be reduced, that is, non-real edges can be removed.
[0156] like Fig.12As shown, an embodiment of the present invention discloses an image edge denoising and edge preservation device, comprising:
[0157] A first-order gradient unit 610, used to calculate the first-order gradient of each edge point according to the image edge data;
[0158] A gradient data unit 620, configured to obtain gradient data of each edge point according to the first-order gradient and the first-order gradient threshold, wherein the gradient data includes a Boolean first-order gradient and a Boolean second-order gradient, and the Boolean first-order gradient and the Boolean second-order gradient are Boolean values;
[0159] A suspected target unit 630 is used to search all the gradient data according to the gradient template of noise and the gradient template of pseudo edge to obtain a number of suspected targets, wherein the suspected targets include suspected noise and suspected pseudo edge;
[0160] A verification unit 640 is used to traverse the suspected target, fit the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target using a polynomial equation to obtain a characteristic curve, and when the current suspected target is verified as a noise point based on the noise deviation or the current suspected target is verified as a pseudo edge based on the correlation coefficient based on the characteristic curve, the current suspected target is deleted from the image edge data;
[0161] The output unit 650 is used to output the image edge data after the noise points and false edges are deleted.
[0162] like Fig.13 As shown, an embodiment of the present invention discloses an electronic device, including a memory 401 storing executable program codes and a processor 402 coupled to the memory 401;
[0163] The processor 402 calls the executable program code stored in the memory 401 to execute the image edge denoising and edge preservation method described in the above embodiments.
[0164] The embodiment of the present invention further discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the image edge denoising and edge preservation method described in the above embodiments.
[0165] The purpose of the above embodiments is to exemplarily reproduce and deduce the technical solution of the present invention, and to fully describe the technical solution, purpose and effect of the present invention. Its purpose is to make the public understand the disclosed content of the present invention more thoroughly and comprehensively, and it does not limit the scope of protection of the present invention.
[0166] The above embodiments are not exhaustive enumerations of the present invention, and there may be multiple other implementations not listed. Any replacement and improvement made without violating the concept of the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for reducing image edge noise and preserving edge, characterized in that: include: According to the image edge data, the first-order gradient of each edge point is calculated; Obtaining gradient data of each edge point according to the first-order gradient and the first-order gradient threshold, wherein the gradient data includes a Boolean first-order gradient and a Boolean second-order gradient, and the Boolean first-order gradient and the Boolean second-order gradient are Boolean values; Search all the gradient data according to the gradient template of noise and the gradient template of pseudo edge to obtain a plurality of suspected targets, wherein the suspected targets include suspected noise and suspected pseudo edge; Traversing the suspected target, fitting the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target using a polynomial equation to obtain a characteristic curve, and when the current suspected target is verified as a noise point according to the noise deviation based on the characteristic curve or the current suspected target is verified as a false edge according to the correlation coefficient, deleting the current suspected target in the image edge data; Output the image edge data after removing noise points and false edges; Obtaining gradient data of a target edge point according to the first-order gradient and the first-order gradient threshold includes: Compare the first-order gradient of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the target edge point; Compare the first-order gradient of the next edge point of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the next edge point; Perform an XOR operation on the Boolean first-order gradient of the target edge point and the Boolean first-order gradient of the next edge point to obtain the Boolean second-order gradient of the target edge point; The gradient template of the noise includes a first gradient feature, a second gradient feature and a third gradient feature arranged in sequence, the gradient template of the pseudo edge includes a group gradient feature and an intermediate gradient feature, and all the gradient data are searched according to the gradient template of the noise and the gradient template of the pseudo edge to obtain a plurality of suspected targets, including: Traversing all the gradient data, taking the index position of the gradient data that meets the third gradient feature as the end point, and the index position of the gradient data that meets the first gradient feature as the starting point, and when the starting point and the end point include the gradient data that meets the second gradient feature, setting the edge point between the starting point and the end point as suspected noise; Traversing all the gradient data, taking the index position of the gradient data that meets the group gradient feature as the starting point, searching backward from the starting point, taking the index position of the gradient data that meets the group gradient feature as the end point, and when the starting point and the end point include gradient data that meets the intermediate gradient feature, setting the edge point between the starting point and the end point as a suspected pseudo edge; The suspected noise and the suspected false edge constitute the suspected target.
2. The image edge denoising and edge preservation method according to claim 1, characterized in that: The step of determining the first-order gradient threshold comprises: Performing linear regression on the image edge data, removing singular edge points whose deviation is greater than the fitting residual from the image edge data, and obtaining filtered edge data; Calculating the first-order gradient of the edge data after screening, arranging all the first-order gradients in ascending order and calculating the second-order gradient to obtain a first-order gradient sequence and a second-order gradient sequence; Calculating the mean and standard deviation of the second-order gradient sequence; Obtaining the index value of the first second-order gradient in the second-order gradient sequence that is not less than the sum of the mean and the standard deviation; The first-order gradient corresponding to the index value in the first-order gradient sequence is set as the first-order gradient threshold.
3. The image edge denoising and edge preservation method according to claim 1, characterized in that: Before calculating the first-order gradient of each edge point, it also includes: dividing the image edge corresponding to the image edge data into a plurality of edge segments; Perform linear regression on each edge segment to obtain several regression lines; Performing coordinate transformation on the edge segment corresponding to the regression line according to the direction angle of the regression line to obtain the transformed edge segment; All transformed edge segments are concatenated, and the image edge data is updated.
4. The image edge denoising and edge preservation method according to claim 1, characterized in that: A polynomial equation is used to fit the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target to obtain a characteristic curve, and based on the characteristic curve, whether the current suspected target is a noise point is verified according to the noise deviation or whether the current suspected target is a false edge is verified according to the correlation coefficient, including: If the current suspected target is suspected noise: Selecting a number of data points in the confidence margin of the front neighborhood of the current suspected target and in the confidence margin of the back neighborhood to obtain first selected data; Using a third-order polynomial equation to perform least squares fitting on the first selected data to obtain the characteristic curve; Calculating the deviation of the current suspected target according to the characteristic curve, and determining that the current suspected target is a noise point when the deviation exceeds a deviation threshold; If the current suspected target is a suspected false edge: Selecting a number of data points in the confidence margin of the front neighborhood of the current suspected target and in the confidence margin of the back neighborhood to obtain second selected data; Using a first-order polynomial equation or a second-order polynomial equation to perform least squares fitting on the second selected data to obtain the characteristic curve; According to the characteristic curve, the correlation between the actual value and the fitted value of the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target is calculated to obtain a correlation coefficient; When the correlation coefficient is greater than a preset threshold, the current suspected target is determined to be a false edge.
5. The image edge denoising and edge preservation method according to claim 1, characterized in that: The step of calculating the first-order gradient of each edge point according to the image edge data includes: Performing linear regression on the image edge data to obtain a fitting curve; Calculating the deviation of the image edge data according to the fitting curve; The edge point corresponding to the minimum deviation is taken as the initial point, and the first-order gradient of each edge point is calculated in turn.
6. An image edge denoising and edge preservation device, characterized in that: include: A first-order gradient unit, used to calculate the first-order gradient of each edge point according to the image edge data; A gradient data unit, used to obtain gradient data of each edge point according to the first-order gradient and the first-order gradient threshold, wherein the gradient data includes a Boolean first-order gradient and a Boolean second-order gradient, and the Boolean first-order gradient and the Boolean second-order gradient are Boolean values; A suspected target unit, used for searching all the gradient data according to a gradient template of noise and a gradient template of pseudo edge to obtain a plurality of suspected targets, wherein the suspected targets include suspected noise and suspected pseudo edge; A verification unit, used to traverse the suspected target, fit the confidence edge of the front neighborhood and the confidence edge of the back neighborhood of the current suspected target using a polynomial equation to obtain a characteristic curve, and when the current suspected target is verified as a noise point based on the noise deviation or the current suspected target is verified as a pseudo edge based on the correlation coefficient based on the characteristic curve, the current suspected target is deleted from the image edge data; An output unit, used for outputting image edge data after noise points and false edges are deleted; Obtaining gradient data of a target edge point according to the first-order gradient and the first-order gradient threshold includes: Compare the first-order gradient of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the target edge point; Compare the first-order gradient of the next edge point of the target edge point with the first-order gradient threshold to obtain the Boolean first-order gradient of the next edge point; Perform an XOR operation on the Boolean first-order gradient of the target edge point and the Boolean first-order gradient of the next edge point to obtain the Boolean second-order gradient of the target edge point; The gradient template of the noise includes a first gradient feature, a second gradient feature and a third gradient feature arranged in sequence, the gradient template of the pseudo edge includes a group gradient feature and an intermediate gradient feature, and all the gradient data are searched according to the gradient template of the noise and the gradient template of the pseudo edge to obtain a plurality of suspected targets, including: Traversing all the gradient data, taking the index position of the gradient data that meets the third gradient feature as the end point, and the index position of the gradient data that meets the first gradient feature as the starting point, and when the starting point and the end point include the gradient data that meets the second gradient feature, setting the edge point between the starting point and the end point as suspected noise; Traversing all the gradient data, taking the index position of the gradient data that meets the group gradient feature as the starting point, searching backward from the starting point, taking the index position of the gradient data that meets the group gradient feature as the end point, and when the starting point and the end point include gradient data that meets the intermediate gradient feature, setting the edge point between the starting point and the end point as a suspected pseudo edge; The suspected noise and the suspected false edge constitute the suspected target.
7. An electronic device, characterized in that: It comprises a memory storing executable program code and a processor coupled to the memory; the processor calls the executable program code stored in the memory to execute the image edge denoising and edge preservation method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program enables a computer to execute the image edge denoising and edge preserving method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Intelligent multifunctional belt surface patch edge detection method
CN103208117A
Edge detection method, device, computer storage medium and terminal
CN108389215A