A contour extraction method based on monocular digital image
By constructing a Gaussian pyramid and using Gaussian difference operators in digital images, combined with brightness and chrominance information, and using a flow-based Gaussian difference algorithm, the problem of edge discontinuity and noise in digital image contour extraction is solved, achieving clearer and more Accurate contour extraction effect.
Patent Information
- Application Number
- CN202210674544.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-15
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
There are problems such as discontinuity of lines and area boundaries, complex shapes and a large amount of noise in digital image contour extraction, resulting in poor edge detection results.
Using a contour extraction method based on monocular digital images, through smoothing and filter iteration of the image scale space, a Gaussian pyramid is constructed and the Gaussian difference operator is used for edge detection. Combining the brightness and chromaticity information, the flow-based Gaussian difference algorithm is used to extract Contour edge lines to reduce noise interference.
The clarity and coherence of edge contours are improved, more accurate and clearer image contour extraction results are generated, and the problems of noise and interference in traditional methods are overcome.
Smart Images

Figure CN115100226B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field related to image processing, and in particular to a contour extraction method based on a monocular digital image. Background Art
[0002] Image contours refer to the lines and boundaries of areas of interest in digital images, including object boundaries and area boundaries defined by sudden changes in brightness, color, or texture. Human vision usually distinguishes target objects by their edges and contours. In digital images, edge contours are important features for distinguishing different areas. Edge detection is a basic task in digital image processing and is crucial for analyzing image content. Therefore, it is widely used in many computer vision, target recognition, and automatic detection.
[0003] Generally speaking, there are two main types of edge detection technology. The first region-based technology classifies pixels with high similarity into a region by identifying and analyzing the color, brightness and texture attributes in digital images, and extracts edge information of the image by detecting the boundaries between regions. The second line-based extraction technology uses high contrast in brightness, color or texture to find lines or boundaries. There are three types of region-based contour extraction technologies: region growing, region segmentation and region merging. Line-based technologies include active contour technology, edge detection-based technology and edge grouping-based technology.
[0004] In digital image processing, there are several edge detection methods available, which can be divided into first-order and second-order difference detection. In the first-order difference detection, the input digital image is convolved with a suitable mask to generate a gradient image. The edges in the image are detected by thresholding, and the edge information is converted to white and the non-edge information is converted to black to obtain the edge information. Common first-order differential operators include Roberts operator (cross differential algorithm), Prewitt operator, Sobel operator, and Canny operator. In the second-order difference detection, the digital image is first smoothed by an adaptive filter. Since the second-order derivative is very sensitive to noise, the filtering function is very important. Second-order differential operators include Laplace operator, Zuniga-Haralick localization operator, LOG operator (Laplacian of Gaussian operator) and DOG operator (Gaussian difference operator).
[0005] In the process of digital image contour extraction, there are problems such as discontinuity of lines and region boundaries, complex shapes, textures and a lot of noise. Summary of the invention
[0006] The present invention aims to overcome the above-mentioned deficiencies in the prior art and provides a contour extraction method based on a monocular digital image, which reduces noise interference and improves edge contour clarity.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] A contour extraction method based on a monocular digital image specifically comprises the following steps:
[0009] (1) Image scale space: Under the premise of keeping the image size unchanged, the structural information of the digital image at each scale is obtained through smoothing and filter iteration. On this basis, the image at each scale is studied and processed using a preset experimental window to achieve the effect of image preprocessing.
[0010] (2) Gaussian difference operator edge detection: The window for observing the image is set to a fixed value. The pixel size of the image observed under this window changes, which generates an image pyramid. Based on the image pyramid, the image is operated by Gaussian smoothing and downsampling. The obtained set of processed images are arranged in a set to obtain a Gaussian pyramid. The prediction residual is calculated between each group of upper and lower images of the Gaussian pyramid to form a Gaussian difference pyramid and obtain the Gaussian difference operator DOG.
[0011] (3) Flow-based Gaussian difference edge detection: The image is preprocessed by Gaussian smoothing and image grayscale to obtain a gradient image, and then the extracted contour lines are processed using a bilateral filter operation to construct an edge tangent flow and harmonize the image at the same time. Finally, the Gaussian difference algorithm based on the edge tangent flow is used to extract the contour edge lines of the digital image.
[0012] In the scale space of the image, the Gaussian difference pyramid is used to combine the brightness and color information of the digital image, and the image's color information gradient image and brightness information gradient image are fused together. The edge direction of each point is calculated to form an edge tangent flow. The flow-based Gaussian difference algorithm is used to detect and extract the contour edge line of the digital image, overcoming the poor coherence problem caused by the isotropy of the traditional Gaussian difference kernel, and generating a digital image contour map that retains significant edge features and removes noise and interference information. The method is compared with several commonly used contour extraction methods, and it can be seen that the contour extraction results obtained by this method are more coherent and clear. That is, this method proposes a simple edge detection method based on computational geometry technology, which organically combines brightness information and color information, fully considers the edge tangent flow information of the image, reduces noise interference, and extracts a clearer and more accurate edge contour of the image.
[0013] As a preference, in step (1), taking image I(x, y) as an example, the scale space T tIt is generated by using an image smoothing operator with a scale parameter of t. The scale parameter t reflects the degree of smoothing of the digital image. t} t∈R It is called the image of the two-dimensional image I(x,y) under the scale parameter t. R refers to the set of real numbers. The larger the parameter t is, the simpler the content of the image is.
[0014] Preferably, in step (1), the scale space operator T t Visual invariance needs to be met, including the following:
[0015] Grayscale invariance: Yes T t (I+h)=T t (I) + h, where h is an arbitrary constant;
[0016] Contrast invariance: Yes T t (f(I)) = f(T t (I)), where f is an arbitrary non-decreasing real function;
[0017] Translation invariance: T t (τ a (I)) = τ a (T t (I)), where τ a (I) = I (x + a), where a is an arbitrary constant;
[0018] Scalability invariance: satisfying t'(t,δ)>0, which can make H δ T t =T t H δ Established, and H δ I = I(δx), where δ is any positive real number and t is the scale parameter;
[0019] Euclidean invariance: For any orthogonal matrix R, there exists T t (R·I)=R·T t (I), where (R·I)(x)=I(R·x);
[0020] Affine invariance: For any affine transformation A and any scale parameter t, t'(δ,A)>0, and AT t =T t A is established;
[0021] Among them, T t (I) refers to the scale space operator function, and I refers to the input image I(x,y).
[0022] Preferably, in step (2), the image pyramid is used for image compression and computer vision, and multiple resolution images from the same original image are arranged in a pyramid shape from large to small, which are obtained by stepwise down sampling until a certain termination condition is reached. In the image pyramid, the higher the level of the pyramid, the smaller the size and resolution of the image. The pixel size of the base level J is 2 J ×2 J Or N×N, where J=log2N, the size of the 0th level vertex is 1×1, that is, one pixel, and the pixel size of the jth level is 2 j ×2 j , where 0≤j≤J; considering the image distortion problem, the image pyramid will be shortened to P+1 level, where 1≤P≤J, and j=JP,…,J-2,J-1,J; limiting the level to P to reduce the resolution of the original digital image, where the total number of pixels in the P+1 level pyramid (P>0) is:
[0023]
[0024] Preferably, in step (2), each image resolution size is a group, and there are several layers in the Gaussian pyramid. Each layer is constructed by Gaussian smoothing and downsampling on the basis of the previous layer of image. The specific construction process is as follows:
[0025] (21) The first layer of the first group of the image pyramid is the original digital image, which is convolved with a Gaussian kernel, with σ as the standard deviation, and the calculated new image is placed in the second layer of the first group, where the Gaussian convolution formula is:
[0026]
[0027]
[0028] Where D(x,y) is the distance between the midpoint (x,y) in the frequency domain and the midpoint of the frequency rectangle;
[0029] (22) Use the new standard deviation σ' to perform Gaussian kernel convolution on the image of the second layer of the first group, and place the resulting image in the third layer of the first group of the image pyramid;
[0030] (23) Repeat step (22) to finally obtain the first group of N layers of images. In each group of results of the Gaussian pyramid, each layer of images is obtained by convolving the same image with different standard deviations.
[0031] (24) Down-sampling the original image, placing the resulting image in the first layer of the second group of the image pyramid, and performing the same three steps on it to obtain an N-layer image;
[0032] (25) Repeat step (24) to obtain M groups of N-layer images and finally construct a Gaussian pyramid.
[0033] Preferably, in step (2), the Gaussian difference operator DOG is obtained as follows:
[0034] In the scale space constructed by the Gaussian pyramid, σ is the coordinate of the scale space, M is the number of groups in the Gaussian pyramid structure, and N is the number of layers of each group in the Gaussian pyramid;
[0035]
[0036] Among them, σ0 is the reference scale, m is the group number in the Gaussian pyramid, and n is the number of the layer within the group; in the Gaussian pyramid, there are M groups and N layers of images. The images in the Gaussian pyramid use the symbol (m, n) for positioning and one-to-one correspondence;
[0037] In the Gaussian pyramid, the Gaussian filter of the image is expressed as:
[0038]
[0039] Substituting different parameter values of σ, we get another Gaussian filtered image:
[0040]
[0041] The Gaussian filter function is:
[0042]
[0043] Then, the difference between the two Gaussian filtered images is calculated to obtain:
[0044]
[0045] Among them, G σ1 -G σ2 For the Gaussian difference operator DOG, we get:
[0046]
[0047] Preferably, in step (3), the gradient image is obtained as follows:
[0048] At the (x,y) pixel of image f, the intensity and direction of the surrounding pixel set are determined. The tool used is the gradient. To represent it, and define it in vector form:
[0049]
[0050] The gradient vector indicates that the image f changes fastest and at the largest rate along the gradient direction at the pixel point (x, y). This is a significant geometric feature of the gradient vector. The length of is represented by M(x,y):
[0051]
[0052] M(x,y) represents the value of the rate of change of the gradient vector direction, where g x , g y M(x,y) is the same as the original image in pixel size and is obtained by taking the derivative of x and y at all pixel positions in image f. M(x,y) is called the gradient image.
[0053] The angle of the gradient vector relative to the x-axis is:
[0054]
[0055] The edge direction of a pixel is perpendicular to the gradient vector of that point, so the gradient is used to determine the edge strength and direction of a point;
[0056] Only brightness information can be obtained in grayscale images, so the image is converted from RGB space to YUV color space for processing, and the brightness and chromaticity information of the image is obtained in YUV space. The conversion matrix is:
[0057]
[0058] Among them, Y is the pixel brightness value in the image, and the three letters R, G, and B represent the three base colors of red, green, and blue respectively. Therefore, the brightness information of the image is:
[0059] Y=0.299R+0.587G+0.144B
[0060] In the process of taking the first-order or second-order derivative of the image pixels, the influence of noise on the derivative result cannot be ignored. The Sobel operator, as a discrete differential operator, is effective in suppressing noise. Therefore, the Sobel operator is used to calculate the gradient of the image brightness information:
[0061]
[0062] The gradient length of the brightness of the image is:
[0063]
[0064] Because solving the square and square root takes a lot of time in the calculation process, in order to improve the calculation efficiency, the approximate value without square root is taken:
[0065] |ΔY|=|ΔY x |+|ΔY y |
[0066] When calculating the gradient value of chromaticity information, the internationally accepted color measurement standard CIE-L * a * b * This standard can be applied to the calculation of the light source color and object color of the image, and is used to convert the RGB image to CIE-L * a * b * Color space, first convert RGB to XYZ color space:
[0067]
[0068] Where XYZ is the tristimulus value of the object, CIE-L * a * b * The conversion formula of space is:
[0069]
[0070] X0Y0Z0 represents the tristimulus values of the CIE standard illuminant, L * is the psychological brightness, a * 、b * It is psychological chromaticity;
[0071] Therefore, the gradient containing the image chromaticity information is expressed as:
[0072]
[0073] Then the gradient length of the image chromaticity information is:
[0074]
[0075] in, CIE-L * a * b * Distance in color space:
[0076]
[0077] For the convenience of calculation, the approximate values of the two are:
[0078]
[0079] Similarly, take the approximate value of the gradient length of the image chromaticity information:
[0080]
[0081] The obtained brightness gradient approximation and the obtained chromaticity gradient approximation are unified into a roughly the same numerical range and normalized:
[0082] ΔY'=(ΔY-min)(max-min)
[0083] ΔC'=(ΔC-min)(max-min)
[0084] From this, the brightness gradient and chromaticity gradient are obtained, and both satisfy a linear relationship. The fusion gradient is calculated as:
[0085]
[0086] Preferably, in step (3), the specific method of constructing the edge tangent flow is as follows:
[0087] In order to retain enough detail information in the contour extraction of the image, the edge tangent flow ETF is used for smoothing;
[0088] The ETF construction filter is defined as:
[0089]
[0090] In the formula, Ω μ It is represented as the neighborhood of x, whose radius is μ, k is the normalization factor of the vector, t cur (y) represents the normalized tangent vector of y, and Φ(x,y) represents the vector t cur (y) direction;
[0091] Detailed description of ω in the formula s (x, y) is the spatial weight function, which is essentially a rectangular filter with a radius of μ, and its expression is:
[0092]
[0093] ω m (x, y) is the amplitude weight function, and its expression is:
[0094]
[0095] Where e(x) represents the normalized gradient value at point x, and η represents the rate of descent;
[0096] ω d (x, y) is the direction weight function, and its expression is:
[0097] ω d (x,y)=|t cur (x)·t cur (y)|
[0098] Amplitude weight function ω m (x,y) and direction weight function ω d (x,y) plays an important role in maintaining image features. d The value of (x, y) will decrease as the two normalized tangent vectors are perpendicular, and increase as the two vectors are parallel; in this case, the symbol function Φ(x, y)∈{1, -1} is used to represent t cur (y) direction:
[0099]
[0100] Through the obtained initial fusion gradient M0(x), the edge tangent flow t is obtained according to the vertical relationship of the gradient field. 0 (x), by using the formula t i (x)→t i+1 Iterate (x) 2-3 times to obtain the edge tangent flow ETF with good effect.
[0101] Preferably, in step (3), a one-dimensional Gaussian blur is calculated along the edge tangent orthogonal to the edge tangent by DOG, and edge alignment smoothing is performed by line integral convolution along the edge tangent flow. The two-channel flow guidance method is called the Gaussian difference algorithm based on the edge tangent flow FDOG. The FDOG filter is defined as:
[0102]
[0103] Among them l s (t) represents the line l at parameter t S The point on l S Expressed as perpendicular to curve C x , and with C x Compared to point x, it is used to indicate the width of the curve; C x represents the flow curve at point x, s represents the arc length parameter, and its value range is [-S, S]; therefore I(l s (t)) represents the input image I at l s The value represented by point (t) is the DOG edge model for function f:
[0104]
[0105]
[0106] Among them, G σ (x) is a Gaussian function of a single variable with variance 1; σ c and σ sThey respectively control the center edge interval and the interval size with the peripheral edge of the filtering result, and the values of both are σ s =1.6σ c , which can make the function f closer to the Gaussian Laplace operator; ρ controls the level and sensitivity of the noise, and its value is between [0.79, 1.0];
[0107] The FDOG filter is located along the C x The cumulative response formula is:
[0108]
[0109] After obtaining the Gaussian difference filtering result based on the edge tangent flow, FDOG obtains the binary image of the edge by thresholding:
[0110]
[0111] Among them, τ controls the size of the center-surround difference and takes values in [0, 1].
[0112] The beneficial effects of the present invention are: organically combining brightness information and color information, fully considering the edge tangent flow information of the image, reducing the interference of noise, and extracting a clearer and more accurate edge contour of the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0113] Figure 1 It is a schematic diagram of multi-scale expression of images;
[0114] Figure 2 is a schematic diagram of an image pyramid;
[0115] Figure 3 This is a demonstration diagram of the image pyramid;
[0116] Figure 4 is a system model diagram of the approximation and residual pyramid;
[0117] Figure 5 It is a schematic diagram of the Gaussian pyramid structure;
[0118] Figure 6 It is a schematic diagram of the Gaussian difference pyramid structure;
[0119] Figure 7 is a flow chart of the contour extraction method;
[0120] Figure 8 It is the principle diagram of gradient confirmation of edge direction;
[0121] Fig. 9 This is the effect diagram of edge tangent flow construction;
[0122] Fig.10 This is the FDOG filter structure diagram;
[0123] Fig.11 It is a schematic diagram of multi-scale expression of images.
[0124] Fig.12 It is a schematic diagram of multi-scale expression of images. DETAILED DESCRIPTION
[0125] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments.
[0126] A contour extraction method based on a monocular digital image specifically comprises the following steps:
[0127] (1) Image scale space: Under the premise of keeping the image size unchanged, the structural information of the digital image at each scale is obtained through smoothing and filter iteration. On this basis, the image at each scale is studied and processed using a preset experimental window to achieve the effect of image preprocessing.
[0128] In computer vision, digital images show different degrees of smoothness in different application contexts. The change in grayscale value corresponds to the spatial phenomenon of the object and can be identified in areas of different sizes, ranging from a few pixels to large areas. Identifying the change in grayscale value is essential for decoding the inherent information in the image. The scale space of an image is an abstract framework formed in the process of combining the same image for observation and study by obtaining multiple images with different blur levels after various smoothing processes and filter iterations.
[0129] Under different scale parameters, the scale structure in the digital image is different. As the scale parameter increases, the subtle scale structure can be minimized, thereby achieving the purpose of separating the digital image structure. Therefore, by processing the digital image at a sufficiently coarse scale, the subtle scale structure that is irrelevant or not within the scope of the study can be removed as much as possible. Such an operation will greatly reduce the difficulty of processing digital images, and experiments have shown that image processing guided by such an idea is meaningful.
[0130] Taking image I(x,y) as an example, the scale space T t It is generated by using an image smoothing operator with a scale parameter of t. The scale parameter t reflects the degree of smoothing of the digital image. t} t∈R It is called the image of the two-dimensional image I(x,y) under the scale parameter t. R refers to the set of real numbers. The larger the parameter t is, the simpler the image content is. The multi-scale expression of the image is as follows: Figure 1 shown.
[0131] Scale space operator T tVisual invariance needs to be met, including the following:
[0132] Satisfy grayscale invariance and contrast invariance: When the brightness and angle of light received by a three-dimensional object in a real scene change, the grayscale and contrast of the image perceived by the human eye will also change accordingly. Therefore, the scale space operator T t It is necessary to keep the grayscale and contrast unchanged during analysis.
[0133] Grayscale invariance: Yes T t (I+h)=T t (I) + h, where h is an arbitrary constant;
[0134] Contrast invariance: Yes T t (f(I)) = f(T t (I)), where f is an arbitrary non-decreasing real function.
[0135] Satisfies translation invariance, scaling invariance, Euclidean invariance, and affine invariance: When the relative direction and angle between the real three-dimensional object and the observer change, the position, angle, size, and shape of the image perceived by the human eye will also change accordingly. Therefore, the scale space operator T t It is necessary to be independent of relative position, relative angle, size and affine transformation when performing analysis.
[0136] Translation invariance: T t (τ a (I)) = τ a (T t (I)), where τ a (I) = I (x + a), where a is an arbitrary constant;
[0137] Scalability invariance: satisfying t'(t,δ)>0, which can make H δ T t =T t H δ Established, and H δ I = I(δx), where δ is any positive real number and t is the scale parameter;
[0138] Euclidean invariance: For any orthogonal matrix R, there exists T t (R·I)=R·T t (I), where (R·I)(x)=I(R·x);
[0139] Affine invariance: For any affine transformation A and any scale parameter t, t'(δ,A)>0, and AT t =T t A is established;
[0140] Among them, T t (I) refers to the scale space operator function, and I refers to the input image I(x,y).
[0141] (2) Gaussian difference operator edge detection: The window for observing the image is set to a fixed value. The pixel size of the image observed under this window changes, which generates an image pyramid. Based on the image pyramid, the image is operated by Gaussian smoothing and downsampling. The obtained set of processed images are arranged in a set to obtain a Gaussian pyramid. The prediction residual is calculated between each group of upper and lower images of the Gaussian pyramid to form a Gaussian difference pyramid and obtain the Gaussian difference operator DOG.
[0142] In scale space, the number of pixels of digital images observed at different scales is different. From another perspective, the window for observing the image is set to a fixed value, and the pixel size of the image observed under this window changes, which produces an image pyramid. The purpose of constructing an image pyramid is to obtain the expression of the image at different scales, and this scale is usually the resolution of the image. Digital images are obtained through continuous smoothing and sampling to obtain digital images of various pixel sizes.
[0143] The Gaussian difference operator DOG (Different of Gaussian) used in this method is established based on the image pyramid. Its edge extraction algorithm has a small convolution kernel, a fast algorithm speed, and can well retain the detail information of the original image. Therefore, the Gaussian difference operator has a significant effect in image edge detection.
[0144] In the multi-scale expression of images, one of the structures that views image information from the perspective of resolution is the image pyramid, which is efficient, clear and easy to understand. Image pyramid is used for image compression and computer vision. It arranges multiple resolution images from the same original image in a pyramid shape from large to small. It is obtained by downsampling in stages until a certain termination condition is reached. Figure 2 As shown, the base of the pyramid is a multi-pixel representation of the original image, mostly the original image itself, while the top has only a small number of pixels or even only one pixel.
[0145] In the image pyramid, the higher the level of the pyramid, the smaller the image size and resolution. The pixel size of the base level J is 2 J ×2 J Or N×N, where J=log2N, the size of the 0th level vertex is 1×1, that is, one pixel, and the pixel size of the jth level is 2 j ×2 j, where 0≤j≤J; considering the image distortion problem, the image pyramid will be shortened to P+1 level, where 1≤P≤J, and j=JP,…,J-2,J-1,J; limiting the level to P to reduce the resolution of the original digital image, where the total number of pixels in the P+1 level pyramid (P>0) is:
[0146]
[0147] Taking an original digital image of size 1024×1024 as the experimental object, the relationship between the image size and the number of levels at each level of the image pyramid is shown in the following table:
[0148]
[0149] In the image pyramid, the higher the level of the digital image used in the experiment, the less information it contains, and of course the smaller its pixel size is. Figure 3 Shown is a demonstration diagram of an image pyramid.
[0150] A system model of an approximate and prediction residual pyramid is constructed based on the image pyramid. Taking the J-th level image as input, the image required by the J-1-th level approximate pyramid is output through the approximate filter and the downsampler, and the image required by the J-th level supplementary prediction residual pyramid is output through the upsampler and the interpolation filter, as shown in Figure 4 shown.
[0151] Both the approximate pyramid and the prediction residual pyramid are implemented in an iterative manner. In the first iteration, the original digital image is placed in the Jth level of the pyramid, and then the following three steps are performed P times, where j = J-P+1,…,J-2,J-1,J:
[0152] (1) Calculate an approximate image with reduced resolution of the input image at level j through an approximate filter and a downsampler, and place it at level j-1 of the approximate pyramid;
[0153] (2) the approximate image generated in step (1) is passed through an upsampler and an interpolation filter to generate an estimate of the j-th level image, where the dimension of the predicted image is the same as that of the j-th level image;
[0154] (3) The j-th level input image of step 1 and the predicted image of step 2 are subtracted to obtain the j-th level prediction residual, which is placed at the j-th level of the prediction residual pyramid.
[0155] The interpolation filter and approximate filter in the system model for constructing the approximate and prediction residual pyramid can adopt a variety of filtering techniques. Interpolation filters include nearest neighbor interpolation, bilinear interpolation, spline and wavelet techniques. In approximate filtering: using neighborhood averaging can get an average pyramid; without filtering, a sub-sampling pyramid can be obtained; using low-pass Gaussian filtering can get a Gaussian pyramid, which is also the pyramid structure used in this method.
[0156] The image is operated by Gaussian smoothing and subsampling, and a group of processed images are arranged in a set to obtain a Gaussian pyramid. Each image resolution size is a group, and there are several layers in the Gaussian pyramid. Each layer is constructed on the basis of the previous layer of image by means of Gaussian smoothing and downsampling. The specific construction process is as follows:
[0157] (21) The first layer of the first group of the image pyramid is the original digital image, which is convolved with a Gaussian kernel, with σ as the standard deviation, and the calculated new image is placed in the second layer of the first group, where the Gaussian convolution formula is:
[0158]
[0159]
[0160] Where D(x,y) is the distance between the midpoint (x,y) in the frequency domain and the midpoint of the frequency rectangle;
[0161] (22) Use the new standard deviation σ' to perform Gaussian kernel convolution on the image of the second layer of the first group, and place the resulting image in the third layer of the first group of the image pyramid;
[0162] (23) Repeat step (22) to finally obtain the first group of N layers of images. In each group of results of the Gaussian pyramid, each layer of images is obtained by convolving the same image with different standard deviations.
[0163] (24) Down-sampling the original image, placing the resulting image in the first layer of the second group of the image pyramid, and performing the same three steps on it to obtain an N-layer image;
[0164] (25) Repeat step (24) to obtain M groups of N-layer images, and finally construct a Gaussian pyramid, whose structure is as follows: Figure 5 shown.
[0165] The Gaussian difference operator DOG is a further improvement on the Gaussian pyramid. The main pyramid structure is to calculate the prediction residual of each group of upper and lower images of the Gaussian pyramid to form a new Gaussian difference pyramid. Its structure is as follows: Figure 6 The Gaussian difference operator DOG is obtained as follows:
[0166] In the scale space constructed by the Gaussian pyramid, σ is the coordinate of the scale space, M is the number of groups in the Gaussian pyramid structure, and N is the number of layers of each group in the Gaussian pyramid;
[0167]
[0168] Among them, σ0 is the reference scale, m is the group number in the Gaussian pyramid, and n is the number of the layer within the group; in the Gaussian pyramid, there are M groups and N layers of images. The images in the Gaussian pyramid use the symbol (m, n) for positioning and one-to-one correspondence;
[0169] In the Gaussian pyramid, the Gaussian filter of the image is expressed as:
[0170]
[0171] Substituting different parameter values of σ, we get another Gaussian filtered image:
[0172]
[0173] The Gaussian filter function is:
[0174]
[0175] Then, the difference between the two Gaussian filter images in equation (5) and equation (6) is calculated to obtain:
[0176]
[0177] Among them, G σ1 -G σ2 For the Gaussian difference operator DOG, we get:
[0178]
[0179] (3) Flow-based Gaussian difference edge detection: The image is preprocessed by Gaussian smoothing and image grayscale to obtain a gradient image, and then the extracted contour lines are processed using a bilateral filter operation to construct an edge tangent flow and harmonize the image at the same time. Finally, the Gaussian difference algorithm based on the edge tangent flow is used to extract the contour edge lines of the digital image.
[0180] In the grayscale value of a digital image, the edge pixels and background pixels of the image contour have a large difference in most areas of the contour, but it is not ruled out that there are some areas with similar grayscale values. Therefore, in order to make the digital image contour extracted by edge detection have better edge information characteristics, this method uses a flow-based Gaussian difference algorithm to detect and extract the contour edge line of the digital image, pre-processes the image with Gaussian smoothing and image graying, and then uses filtering operations to process the extracted contour line. The contour extraction algorithm used in this method is as follows: Figure 7 shown.
[0181] In order to achieve the purpose of edge detection, the first-order derivative or second-order derivative of the image pixels is often used to find the intensity and direction of the edge pixel set. In this way, the part of the image pixel grayscale value that changes rapidly is identified and image segmentation is performed on it. However, the traditional method of using grayscale changes only considers the brightness information in the grayscale image, and the results of edge detection may have a certain error with the results perceived by the human eye. Therefore, on the basis of brightness information, this method adds the chromaticity information of the image to improve the accuracy of edge detection. The acquisition of gradient image is as follows:
[0182] At the (x,y) pixel of image f, the intensity and direction of the surrounding pixel set are determined. The tool used is the gradient. To represent it, and define it in vector form:
[0183]
[0184] The gradient vector indicates that the image f changes fastest and at the largest rate along the gradient direction at the pixel point (x, y). This is a significant geometric feature of the gradient vector. The length of is represented by M(x,y):
[0185]
[0186] M(x,y) represents the value of the rate of change of the gradient vector direction, where g x , g y M(x,y) is the same as the original image in pixel size and is obtained by taking the derivative of x and y at all pixel positions in image f. M(x,y) is called the gradient image.
[0187] The angle of the gradient vector relative to the x-axis is:
[0188]
[0189] The edge direction of a pixel is perpendicular to the gradient vector of that point, so the gradient is used to determine the edge strength and direction of a point, such as Figure 8 The schematic diagram of how the gradient determines the edge direction, where one square represents one pixel;
[0190] Only brightness information can be obtained in grayscale images, so the image is converted from RGB space to YUV color space for processing, and the brightness and chromaticity information of the image is obtained in YUV space. The conversion matrix is:
[0191]
[0192] Among them, Y is the pixel brightness value in the image, and the three letters R, G, and B represent the three base colors of red, green, and blue respectively. Therefore, the brightness information of the image is:
[0193] Y=0.299R+0.587G+0.144B (14)
[0194] In the process of taking the first-order or second-order derivative of the image pixels, the influence of noise on the derivative result cannot be ignored. The Sobel operator, as a discrete differential operator, is effective in suppressing noise. Therefore, the Sobel operator is used to calculate the gradient of the image brightness information:
[0195]
[0196] According to formula (11), the gradient length of the brightness of the image is:
[0197]
[0198] Because solving the square and square root takes a lot of time in the calculation process, in order to improve the calculation efficiency, the approximate value without square root is taken:
[0199] |ΔY|=|ΔY x |+|ΔY y | (17)
[0200] When calculating the gradient value of chromaticity information, the internationally accepted color measurement standard CIE-L * a * b * This standard can be applied to the calculation of the light source color and object color of the image, and is used to convert the RGB image to CIE-L * a * b * Color space, first convert RGB to XYZ color space:
[0201]
[0202] Where XYZ is the tristimulus value of the object, CIE-L * a * b * The conversion formula of space is:
[0203]
[0204] X0Y0Z0 represents the tristimulus values of the CIE standard illuminant, L * is the psychological brightness, a * 、b * It is psychological chromaticity;
[0205] Therefore, the gradient containing the image chromaticity information is expressed as:
[0206]
[0207] Then the gradient length of the image chromaticity information is:
[0208]
[0209] in, CIE-L * a * b * Distance in color space:
[0210]
[0211] For the convenience of calculation, the approximate values of the two are:
[0212]
[0213] Similarly, take the approximate value of the gradient length of the image chromaticity information in equation (21):
[0214]
[0215] The brightness gradient approximation obtained by equation (17) and the chromaticity gradient approximation obtained by equation (24) are unified into a roughly the same numerical range and normalized:
[0216] ΔY'=(ΔY-min)(max-min) (25)
[0217] ΔC'=(ΔC-min)(max-min) (26)
[0218] From this, the brightness gradient and chromaticity gradient are obtained, and both satisfy a linear relationship. The fusion gradient is calculated as:
[0219]
[0220] Images with random noise or textures may produce many disconnected and small edges. Some studies have adopted a better solution, which is to adjust the filter according to the approximate edge direction. The idea behind these methods is to first respond to brightness changes that occur at the edges, and then use edge-aligned blur to smooth these responses. The edge direction calculated at each point forms an edge tangent flow (ETF). The one-dimensional Gaussian blur along the edge tangent orthogonal to the edge tangent is calculated by DOG, and edge-aligned smoothing is performed by line integral convolution along the edge tangent flow. The two-channel flow guidance method is called the flow-based difference of Gaussians (FDOG) algorithm. The specific method of constructing the edge tangent flow is as follows:
[0221] In order to retain enough detail information in the contour extraction of the image, the edge tangent flow ETF is used for smoothing;
[0222] The ETF construction filter is defined as:
[0223]
[0224] In the formula, Ω μ It is represented as the neighborhood of x, whose radius is μ, k is the normalization factor of the vector, t cur (y) represents the normalized tangent vector of y, and Φ(x,y) represents the vector t cur (y) direction;
[0225] Detailed description of ω in equation (28) s (x, y) is the spatial weight function, which is essentially a rectangular filter with a radius of μ, and its expression is:
[0226]
[0227] ω m (x, y) is the amplitude weight function, and its expression is:
[0228]
[0229] Where e(x) represents the normalized gradient value at point x, and η represents the rate of descent;
[0230] ω d (x, y) is the direction weight function, and its expression is:
[0231] ω d (x,y)=|t cur (x)·t cur (y)| (31)
[0232] Amplitude weight function ω m (x,y) and direction weight function ω d (x,y) plays an important role in maintaining image features. d The value of (x, y) will decrease as the two normalized tangent vectors are perpendicular, and increase as the two vectors are parallel; in this case, the symbol function Φ(x, y)∈{1, -1} is used to represent t cur (y) direction:
[0233]
[0234] The initial fusion gradient M0(x) is obtained by equation (27), and then the edge tangent flow t is obtained according to the vertical relationship of the gradient field 0 (x), by using the formula t i (x)→t i+1 (x) is iterated 2-3 times to obtain the edge tangent flow ETF with good effect. Fig. 9 Construct the effect graph for edge tangent flow with ETF kernel size 5.
[0235] In contour extraction, the traditional Gaussian difference filter has the problems of poor coherence and unclear directionality, which is caused by the isotropic structure of its kernel. This method adopts the flow-based Gaussian difference algorithm to overcome some of the previous problems. Fig.10 The Gaussian difference method based on edge tangent flow is illustrated. Figure (a) is taken from Fig. 9 , C in Figure (b) x represents the flow curve at point x, s represents the arc length parameter, and its value range is [-S, S], l S Expressed as perpendicular to curve C x , and with C x Indicates the width of the curve compared to point x.
[0236] The FDOG filter is defined as:
[0237]
[0238] Among them l s (t) represents the line l at parameter t S The point on l S Expressed as perpendicular to curve C x , and with C x Compared to point x, it is used to indicate the width of the curve; C x represents the flow curve at point x, s represents the arc length parameter, and its value range is [-S, S]; therefore I(l s (t)) represents the input image I at l sThe value represented by point (t) is the DOG edge model for function f:
[0239]
[0240]
[0241] Among them, G σ (x) is a Gaussian function of a single variable with variance 1; σ c and σ s They respectively control the center edge interval and the interval size with the peripheral edge of the filtering result, and the values of both are σ s =1.6σ c , which can make the function f closer to the Gaussian Laplace operator; ρ controls the level and sensitivity of the noise, and its value is between [0.79, 1.0];
[0242] The FDOG filter is located along the C x The cumulative response formula is:
[0243]
[0244] After obtaining the Gaussian difference filtering result based on the edge tangent flow, FDOG obtains the binary image of the edge by thresholding:
[0245]
[0246] Among them, τ controls the size of the center-surround difference and takes a value in [0, 1], and is 0.5 most of the time.
[0247] like Fig.11 ,This method selects two monocular digital images to test the contour extraction algorithm, where (a) is a simple calligraphy image with obvious edge features and clear background, and (b) is a complex cartoon image with more contours and background color interference.
[0248] The edge detection algorithms using several different operators and filters are used to extract the contours of these two images with great differences, and the results of contour edge detection are compared. Fig.12 The following is a comparison chart of the results.
[0249] In each contour extraction procedure, the two hysteresis thresholds used by the Canny algorithm are 150 and 100, and the Gaussian radius of the operator is 3; the Gaussian radius used in the Sobel algorithm is 3, and the differential order in the x and y directions is 1; the differential order in the x and y directions in the Scharr filter is 1, and the scaling factor when calculating the derivative is 1; the kernel size in the ETF algorithm is 5, and the threshold is 0.8; the parameters selected in this method are σ c=0.3,σ m =3, τ=0.8, ρ=0.998.
[0250] Through Fig.11 The comparison shows the differences between several algorithms. Among them, the contours extracted by the Canny algorithm have less noise and interference, and the thinner contours will have a sense of breakage, and it is easy to identify image noise as edges; the Sobel algorithm and the Scharr filter have the same problem, the edges are not clear enough in simple calligraphy contours without background, and the Scharr filter is particularly obvious. The anti-interference ability of the background in the cartoon image contours with complex backgrounds is poor, and a lot of noise will be generated; the image contour information extracted by the ETF algorithm will be broken when there is interference, and the contour is somewhat distorted; from the results, this algorithm can better retain the image contour when extracting text contours and graphic image contours, and has strong anti-interference ability, and the generated pictures are clearer.
[0251] In summary, in the scale space of the image, the Gaussian difference pyramid is used to combine the brightness and color information of the digital image, and the image's color information gradient image and brightness information gradient image are fused together. The edge direction of each point is calculated to form an edge tangent flow, and the flow-based Gaussian difference algorithm is used to detect and extract the contour edge line of the digital image, overcoming the poor coherence problem caused by the isotropy of the traditional Gaussian difference kernel. A digital image contour map is generated that retains significant edge features and removes noise and interference information, and is compared with several commonly used contour extraction methods. It can be seen that the contour extraction results obtained by this method are more coherent and clear.
Claims
1. A contour extraction method based on a monocular digital image, characterized in that: The specific steps include: (1) Image scale space: Under the premise of keeping the image size unchanged, the structural information of the digital image at each scale is obtained through smoothing and filter iteration. On this basis, the image at each scale is studied and processed using a preset experimental window to achieve the effect of image preprocessing. (2) Gaussian difference operator edge detection: The window for observing the image is set to a fixed value. The pixel size of the image observed under this window changes, which generates an image pyramid. Based on the image pyramid, the image is operated by Gaussian smoothing and downsampling. The obtained set of processed images are arranged in a set to obtain a Gaussian pyramid. The prediction residual is calculated between each group of upper and lower images of the Gaussian pyramid to form a Gaussian difference pyramid and obtain the Gaussian difference operator DOG. (3) Flow-based Gaussian difference edge detection: The image is preprocessed by Gaussian smoothing and image graying to obtain a gradient image, and then the extracted contour lines are processed using a bilateral filter operation to construct an edge tangent flow and blend the image at the same time. After that, the Gaussian difference algorithm based on the edge tangent flow is used to extract the contour edge lines of the digital image. In step (3), the gradient image is obtained as follows: At the (x,y) pixel of image f, the intensity and direction of the surrounding pixel set are determined. The tool used is the gradient. To represent it, and define it in vector form: The gradient vector indicates that the image f changes fastest and at the largest rate along the gradient direction at the pixel point (x, y). This is a significant geometric feature of the gradient vector. The length of is represented by M(x,y): M(x,y) represents the value of the rate of change of the gradient vector direction, where g x , g y M(x,y) is the same as the original image in pixel size and is obtained by taking the derivative of x and y at all pixel positions in image f. M(x,y) is called the gradient image. The angle of the gradient vector relative to the x-axis is: The edge direction of a pixel is perpendicular to the gradient vector of that point, so the gradient is used to determine the edge strength and direction of a point; Only brightness information can be obtained in grayscale images, so the image is converted from RGB space to YUV color space for processing, and the brightness and chromaticity information of the image is obtained in YUV space. The conversion matrix is: Among them, Y is the pixel brightness value in the image, and the three letters R, G, and B represent the three base colors of red, green, and blue respectively. Therefore, the brightness information of the image is: Y=0.299R+0.587G+0.144B In the process of taking the first-order or second-order derivative of the image pixels, the influence of noise on the derivative result cannot be ignored. The Sobel operator, as a discrete differential operator, is effective in suppressing noise. Therefore, the Sobel operator is used to calculate the gradient of the image brightness information: The gradient length of the brightness of the image is: Because solving the square and square root takes a lot of time in the calculation process, in order to improve the calculation efficiency, the approximate value without square root is taken: |ΔY|=|ΔY x |+|D Y | When calculating the gradient value of chromaticity information, the internationally accepted color measurement standard CIE-L * a * b * This standard can be applied to the calculation of the light source color and object color of the image, and is used to convert the RGB image to CIE-L * a * b * Color space, first convert RGB to XYZ color space: Where XYZ is the tristimulus value of the object, CIE-L * a * b * The conversion formula of space is: Where Y / Y0>0.01 X0Y0Z0 represents the tristimulus values of the CIE standard illuminant, L * is the psychological brightness, a * 、b * is the psychological chromaticity; therefore, the gradient containing the image chromaticity information is expressed as: Then the gradient length of the image chromaticity information is: in, CIE-L * a * b * Distance in color space: For the convenience of calculation, the approximate values of the two are: Similarly, take the approximate value of the gradient length of the image chromaticity information: The obtained brightness gradient approximation and chromaticity gradient approximation are unified into the same numerical range and normalized: ΔY'=(ΔY-min)(max-min) ΔC'=(ΔC-min)(max-min) From this, the brightness gradient and chromaticity gradient are obtained, and both satisfy a linear relationship. The fusion gradient is calculated as:
2. The method for extracting contours based on a monocular digital image according to claim 1, wherein In step (1), taking image I(x,y) as an example, the scale space T t It is generated by using an image smoothing operator with a scale parameter of t. The scale parameter t reflects the degree of smoothing of the digital image. t } t∈R It is called the image of the two-dimensional image I(x,y) under the scale parameter t. R refers to the set of real numbers. The larger the parameter t is, the simpler the content of the image is.
3. The method for extracting contours based on a monocular digital image according to claim 2, wherein In step (1), the scale space operator T t Visual invariance needs to be met, including the following: Grayscale invariance: Yes T t (I+h)=T t (I) + h, where h is an arbitrary constant; Contrast invariance: Yes T t (f(I)) = f(T t (I)), where f is an arbitrary non-decreasing real function; Translation invariance: T t (τ a (I)) = τ a (T t (I)), where τ a (I) = I (x + a), where a is an arbitrary constant; Scalability invariance: satisfying t'(t,δ)>0, which can make H δ T t =T t H δ Established, and H δ I = I(δx), where δ is any positive real number and t is the scale parameter; Euclidean invariance: For any orthogonal matrix R, there exists T t (R·I)=R·T t (I), where (R·I)(x)=I(R·x); Affine invariance: For any affine transformation A and any scale parameter t, t'(δ,A)>0, and AT t =T t A is established; Among them, T t (I) refers to the scale space operator function, and I refers to the input image I(x,y).
4. The method for extracting contours based on a monocular digital image according to claim 1, characterized in that: In step (2), the image pyramid is used for image compression and computer vision. Multiple resolution images from the same original image are arranged in a pyramid shape from large to small. The images are obtained by downsampling in stages until a certain termination condition is reached. In the image pyramid, the higher the level of the pyramid, the smaller the image size and resolution. The pixel size of the base level J is 2 J ×2 J Or N×N, where J=log2N, the size of the 0th level vertex is 1×1, that is, one pixel, and the pixel size of the jth level is 2 j ×2 j , where 0≤j≤J; considering the image distortion problem, the image pyramid will be shortened to P+1 level, where 1≤P≤J, and j=JP,···,J-2,J-1,J; limiting the level to P to reduce the resolution of the original digital image, where the total number of pixels in the P+1 level pyramid (P>0) is:
5. The method for extracting contours based on a monocular digital image according to claim 4, characterized in that: In step (2), each image resolution size is a group, and there are several layers in the Gaussian pyramid. Each layer is constructed based on the previous layer of image by means of Gaussian smoothing and downsampling. The specific construction process is as follows: (21) The first layer of the first group of the image pyramid is the original digital image, which is convolved with a Gaussian kernel, with σ as the standard deviation, and the calculated new image is placed in the second layer of the first group, where the Gaussian convolution formula is: D(x,y)=[(x-x0) 2 +(y-y0) 2 ] 1 / 2 Where D(x,y) is the distance between the midpoint (x,y) in the frequency domain and the midpoint of the frequency rectangle; (22) Use the new standard deviation σ' to perform Gaussian kernel convolution on the image of the second layer of the first group, and place the resulting image in the third layer of the first group of the image pyramid; (23) Repeat step (22) to finally obtain the first group of N layers of images. In each group of results of the Gaussian pyramid, each layer of images is obtained by convolving the same image with different standard deviations. (24) Down-sampling the original image, placing the resulting image in the first layer of the second group of the image pyramid, and performing the same three steps on it to obtain an N-layer image; (25) Repeat step (24) to obtain M groups of N-layer images and finally construct a Gaussian pyramid.
6. The method for extracting contours based on a monocular digital image according to claim 5, characterized in that: In step (2), the Gaussian difference operator DOG is obtained as follows: In the scale space constructed by the Gaussian pyramid, σ is the coordinate of the scale space, M is the number of groups in the Gaussian pyramid structure, and N is the number of layers of each group in the Gaussian pyramid; Among them, σ0 is the reference scale, m is the group number in the Gaussian pyramid, and n is the number of the layer within the group; in the Gaussian pyramid, there are M groups and N layers of images. The images in the Gaussian pyramid use the symbol (m, n) for positioning and one-to-one correspondence; In the Gaussian pyramid, the Gaussian filter of the image is expressed as: Substituting different parameter values of σ, we get another Gaussian filtered image: The Gaussian filter function is: Then, the difference between the two Gaussian filtered images is calculated to obtain: Among them, G σ1 -G σ2 For the Gaussian difference operator DOG, we get:
7. The method for extracting contours based on a monocular digital image according to claim 1, characterized in that: In step (3), the specific method of constructing the edge tangent flow is as follows: In order to retain enough detail information in the contour extraction of the image, the edge tangent flow ETF is used for smoothing; The ETF construction filter is defined as: In the formula, Ω μ It is represented as the neighborhood of x, whose radius is μ, k is the normalization factor of the vector, t cur (y) represents the normalized tangent vector of y, and Φ(x,y) represents the vector t cur (y) direction; Detailed description of ω in the formula s (x, y) is the spatial weight function, which is essentially a rectangular filter with a radius of μ, and its expression is: ω m (x, y) is the amplitude weight function, and its expression is: Where e(x) represents the normalized gradient value at point x, and η represents the rate of descent; ω d (x, y) is the direction weight function, and its expression is: ω d (x,y)=|t cur (x)·t cur (y)| Amplitude weight function ω m (x,y) and direction weight function ω d (x,y) plays an important role in maintaining image features. d The value of (x, y) will decrease as the two normalized tangent vectors are perpendicular, and increase as the two vectors are parallel; in this case, the symbol function Φ(x, y)∈{1, -1} is used to represent t cur (y) direction: Through the obtained initial fusion gradient M0(x), the edge tangent flow t is obtained according to the vertical relationship of the gradient field. 0 (x), by using the formula t i (x)→t i+1 Iterate (x) 2-3 times to obtain the edge tangent flow ETF with good effect.
8. The method for extracting contours based on a monocular digital image according to claim 7, characterized in that: In step (3), a one-dimensional Gaussian blur is calculated along the edge tangent orthogonal to the edge tangent by DOG, and edge alignment smoothing is performed by line integral convolution along the edge tangent flow. The two-channel flow guidance method is called the Gaussian difference algorithm based on edge tangent flow FDOG. The FDOG filter is defined as: Among them l s (t) represents the line l at parameter t S The point on l S Expressed as perpendicular to curve C x , and with C x Compared to point x, it is used to indicate the width of the curve; C x represents the flow curve at point x, s represents the arc length parameter, and its value range is [-S, S]; Therefore I(l s (t)) represents the input image I at l s The value represented by point (t) is the DOG edge model for function f: Among them, G σ (x) is a Gaussian function of a single variable with variance 1; σ c and σ s They respectively control the center edge interval and the interval size with the peripheral edge of the filtering result, and the values of both are σ s =1.6σ c , which can make the function f closer to the Gaussian Laplace operator; ρ controls the level and sensitivity of the noise, and its value is between [0.79, 1.0]; The FDOG filter is along the C x The cumulative response formula is: After obtaining the Gaussian difference filtering result based on the edge tangent flow, FDOG obtains the binary image of the edge by thresholding: Among them, τ controls the size of the center-surround difference and takes values in [0, 1].
