Self-adaptive contour extraction method

CN119027442AActive Publication Date: 2024-11-26BEIJING FOCUSIGHT TECH

Patent Information

Application Number
CN202411061723.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-11-26
Estimated Expiration
2044-08-05

AI Technical Summary

Technical Problem

[0006]但是,此类自适应轮廓提取算法,对每张图像都要执行自适应的评估操作,额外引入时间成本陈本,且算法执行逻辑一般都比较复杂,会降低执行效率

Benefits of technology

[0030] The beneficial effect of the present invention is to solve the defects existing in the background technology,

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119027442A_ABST
    Figure CN119027442A_ABST
Patent Text Reader

Abstract

The invention relates to a self-adaptive contour extraction method. The method comprises the following steps: S1, selecting a representative image; s2, constructing a quality evaluation function; s3, smoothing the quality function; s4, determining a low-contrast threshold value; s5, calculating a reference contrast ratio; s6, determining a high-contrast threshold based on the reference contrast; and S7, batch contour extraction. According to the method, the representative image is selected, and detailed algorithm analysis is carried out on the representative image, so that contour extraction algorithm parameters with high quality and good robustness are obtained and are used for all images needing contour extraction, and a high-quality contour extraction effect is obtained; and when the high-quality effect is obtained, no extra consumed time is introduced during batch processing, and the whole process is automatically executed without manual intervention, so that the execution efficiency is not influenced while the effect is improved, and the labor cost is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of visual detection, in particular to an adaptive contour extraction method. Background Art

[0002] In the process of processing batches of product images to be inspected in computer vision projects, contours need to be extracted. Currently, there are methods that use manually designed algorithms and parameters and adaptive contour extraction algorithms.

[0003] Among them, the algorithm and parameters are designed manually, that is, the algorithm personnel select one or more images, design the algorithm according to the images, adjust the algorithm parameters, and use the designed algorithm and debugged parameters for the product images of the batch;

[0004] However, algorithms and parameters are designed manually, and each different project and different products require algorithm personnel to design algorithms specifically for specific situations. This cannot be universal, and due to the differences in the levels of specific algorithm personnel, the algorithm results may be unstable.

[0005] The adaptive contour extraction algorithm in the prior art automatically determines the logic and parameters of the contour extraction algorithm based on the analysis of the current image to be processed;

[0006] However, this type of adaptive contour extraction algorithm must perform an adaptive evaluation operation on each image, which introduces additional time costs, and the algorithm execution logic is generally complex, which will reduce execution efficiency. Summary of the invention

[0007] The technical problem to be solved by the present invention is to provide an adaptive contour extraction method, which can meet the demand for automatic high-quality contour extraction when contour extraction is required in the process of processing batch images of products to be inspected in a computer vision project.

[0008] The technical solution adopted by the present invention to solve the technical problem is: an adaptive contour extraction method, comprising the following steps:

[0009] S1. Select representative image: select a representative image from the collected images as a template image;

[0010] S2, constructing a quality evaluation function: after edge extraction on the template image, deburring the boundary area; then calculating the quality function value and constructing a quality evaluation function;

[0011] S3, quality function smoothing: use the smoothing factor to perform a series of Gaussian smoothing with parameters σ on the original quality function to obtain n_σ quality functions;

[0012] S4. Determine the low contrast threshold: obtain the coordinate points of all local minima in the n_σ functions as candidate points; use the screening criteria to screen out all candidate points that meet the criteria; select the point with the smallest horizontal coordinate and use the horizontal coordinate of the point as the low contrast threshold contrast_l;

[0013] S5, calculating the reference contrast;

[0014] S6. determining a high contrast threshold based on a reference contrast;

[0015] S7. Batch contour extraction: Substitute the high and low contrast thresholds into the canny contour extraction algorithm to extract contours of the images in need.

[0016] Furthermore, in step S2 described in the present invention, the method of performing edge extraction on the template image is to calculate the gradient of the template image to obtain a gradient map, use the current grayscale value g as the threshold, binarize the gradient amplitude map, and perform local maximum suppression in the gradient direction to obtain a boundary area.

[0017] Furthermore, in step S2 of the present invention, four set elements are used to perform corrosion operations on the boundary area to obtain four burr areas, and then the four burr areas are subtracted from the boundary area in turn to remove the burrs in the boundary area and obtain a burr-free boundary area.

[0018] Furthermore, in step S4 of the present invention, the screening criteria are:

[0019] f(min_x) / min(f(max_r),f(max_l))<0.9;

[0020] Among them: min_x is the horizontal coordinate of the local minimum, f(min_x) is the vertical coordinate of the corresponding local minimum, max_r and (max_l) are the horizontal coordinates of the local maxima on the left and right sides of the local minimum, and f(max_r) and f(max_l) are their corresponding vertical coordinates.

[0021] Furthermore, in step S5 of the present invention, the method for calculating the reference contrast is:

[0022] (1) Obtain the reference area, use contrast_l to binarize the gradient amplitude map, and use the set element to perform an erosion operation on the binarization result to obtain the reference area;

[0023] (2) Contrast traversal: the starting and ending values ​​of the contrast traversal are contrast_l and min(contrast_l+60,255) respectively, and the step length is 3;

[0024] (3) Similarity calculation: The contrast of each traversal is used as the threshold to binarize the gradient amplitude map, and the similarity between the binarized result and the reference area is calculated. The similarity calculation formula is:

[0025] 2- area(diff(region,region_ref))

[0026] max(area,area_ref)

[0027] Where: region is the current binarization result, region_ref is the reference region, area(diff(region, regin_ref)) refers to the area of ​​the absolute subtraction result of region and region_ref, area, area_ref are the areas of region and region_ref respectively;

[0028] (4) Determine the reference similarity and traverse to obtain the point with the maximum similarity. The horizontal coordinate of this point is the reference contrast, denoted as contrast_ref.

[0029] Furthermore, in step S6 of the present invention, the high contrast threshold is determined by finding the coordinates of the minimum point of the quality function, recorded as (c_min, m_min), and finding the point whose ordinate is closest to 1.15*m_min, and the abscissa value of the point is the high contrast threshold.

[0030] The beneficial effects of the present invention are that the defects existing in the background technology are solved.

[0031] The present invention extracts contours by obtaining optimal parameters, achieves high-quality results, does not introduce additional time consumption during batch processing, and is fully automatically executed without human intervention, which improves the results without affecting execution efficiency and saves labor costs.

[0032] For artificially designed algorithms and parameters, the present invention can be fully automatically executed, and is a universal algorithm, which solves the problem of non-universality, and has fixed logic, which solves the problem of unstable effect;

[0033] For the adaptive contour extraction algorithm, the present invention only performs one adaptive evaluation operation on the representative image to determine the optimal parameters. There is no adaptive evaluation operation during the execution of the algorithm, and the algorithm logic is simple, which is a conventional Canny algorithm, thereby solving the problem of externally introduced time costs and reduced efficiency due to complex logic. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0035] The present invention will now be described in further detail in conjunction with the accompanying drawings and preferred embodiments. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.

[0036] like Figure 1 An adaptive contour extraction method is shown, which selects representative images and performs detailed algorithm analysis on the representative images to obtain high-quality and robust contour extraction algorithm parameters, which are used for all images that require contour extraction, thereby obtaining high-quality contour extraction effects.

[0037] The specific steps are as follows:

[0038] 1. Select representative images

[0039] Select a representative image from the images of the same type of products and the same batch to be processed in the current project. This image is called a template image. All subsequent algorithm design operations will be based on the template image.

[0040] 2. Construct quality assessment function

[0041] Traverse the grayscale values ​​from 0 to 255 with a step size of 2, and perform the following operations on each grayscale value traversed:

[0042] (1) Edge extraction on the template image

[0043] Assume that the current gray value is g, calculate the gradient of the template image, and obtain the gradient map (including amplitude and direction). Take g as the threshold, binarize the gradient amplitude map, and perform local maximum suppression in the gradient direction. The method of local maximum suppression is the same as the canny contour extraction algorithm, so as to obtain the boundary area.

[0044] (2) Deburring the Boundary Area

[0045] Use "-|", "|-", The four elements are used to corrode the boundary area to obtain four burr areas, and then the four burr areas are subtracted from the boundary area in turn to remove the burrs in the boundary area. The boundary area mentioned below refers to the boundary area with the burrs removed.

[0046] (3) Calculate the quality function value

[0047] The calculation formula of the quality function value v is:

[0048]

[0049] in: It means taking the average of the 5 / 4 power values ​​of the areas of all connected domains in the boundary area;

[0050] (4) Quality function construction

[0051] Calculate the v obtained by performing the above operation on the template image using all g used in the traversal process with grayscale ranging from 0 to 255 and a step length of 2. With g as the independent variable and v as the dependent variable, the constructed function is the quality assessment function;

[0052] 3. Quality function smoothing

[0053] The smoothing factor σ starts from 17.0, and decreases by 0.9 each time, ending at 3.0. A series of Gaussian smoothing with parameters σ is performed on the original mass function to obtain multiple mass functions. Let the number of mass functions obtained be n_σ;

[0054] 4. Determine the low contrast threshold

[0055] (1) Obtaining candidate points

[0056] Obtain the coordinates of all local minima in n_σ functions as candidate points;

[0057] (2) Screening candidate points

[0058] The screening criteria are:

[0059] f(min_x) / min(f(max_r),f(max_l))<0.9;

[0060] Where: min_x is the abscissa of the local minimum, f(min_x) is the ordinate of the corresponding local minimum, max_r and (max_l) are the abscissas of the local maxima on the left and right sides of the local minimum, and f(max_r) and f(max_l) are their corresponding ordinates;

[0061] Filter out all candidate points that meet the criteria;

[0062] (3) Determination of low contrast threshold

[0063] Among all the points screened out, the point with the smallest horizontal coordinate is the point to be selected, and its horizontal coordinate is the low contrast threshold, recorded as contrast_l;

[0064] 5. Calculate the reference contrast

[0065] (1) Obtaining the reference area

[0066] Use contrast_l to binarize the gradient magnitude map, and use a circular element with a diameter of 3 to erode the binarized result. The result is called the reference area.

[0067] (2) Contrast traversal

[0068] The starting and ending values ​​of contrast traversal are contrast_l and min(contrast_l+60,255) respectively, and the step length is 3;

[0069] (3) Similarity calculation

[0070] The contrast of each traversal is used as the threshold to binarize the gradient amplitude map, and the similarity between the binarized result and the reference area is calculated. The similarity calculation formula is:

[0071]

[0072] Where: region is the current binarization result, region_ref is the reference region, area(diff(region, regin_ref)) refers to the area of ​​the absolute subtraction result of region and region_ref (i.e., union minus intersection), area, area_ref are the areas of region and region_ref respectively;

[0073] (4) Reference similarity determination

[0074] Traverse to get the point with the greatest similarity, set the coordinates of this point to (contrast_max, sim_max), the horizontal coordinate of this point is to the left, find the point whose vertical coordinate is closest to 0.95im_max, the horizontal coordinate of this point is the reference contrast, recorded as contrast_ref;

[0075] 6. Determine the high contrast threshold based on the reference contrast

[0076] (1) Constructing quality function

[0077] The starting and ending values ​​of the contrast traversal are contrast_ref and 2*contrast_ref respectively, and the step length is 3. As in step 2, construct the quality function;

[0078] (2) Determination of high contrast threshold

[0079] Find the coordinates of the minimum point of the quality function, recorded as (c_min, m_min), and look to the left for the point whose ordinate is closest to 1.15*m_min. The abscissa value of this point is the high contrast threshold.

[0080] 7. Batch contour extraction

[0081] Substitute the high and low contrast thresholds into the canny contour extraction algorithm to extract contours of the image in need.

[0082] The above description only describes the specific implementation mode of the present invention. Various examples do not limit the essential content of the present invention. After reading the description, ordinary technicians in the relevant technical field can modify or deform the specific implementation modes described above without departing from the essence and scope of the invention.

Claims

1. An adaptive contour extraction method, characterized in that: The following steps are included: S1. Select representative image: select a representative image from the collected images as a template image; S2, constructing a quality assessment function: after edge extraction on the template image, deburring the boundary area; Then the quality function value is calculated and the quality evaluation function is constructed; S3, quality function smoothing: use the smoothing factor to perform a series of Gaussian smoothing with parameters σ on the original quality function to obtain n_σ quality functions; S4. Determine the low contrast threshold: obtain the coordinate points of all local minima in the n_σ functions as candidate points; use the screening criteria to screen out all candidate points that meet the criteria; select the point with the smallest horizontal coordinate and use the horizontal coordinate of the point as the low contrast threshold contrast_l; S5, calculating the reference contrast; S6. determining a high contrast threshold based on a reference contrast; S7. Batch contour extraction: Substitute the high and low contrast thresholds into the canny contour extraction algorithm to extract contours of the images in need.

2. The method for extracting an adaptive contour according to claim 1, wherein: In the step S2, edge extraction is performed on the template image by calculating the gradient of the template image to obtain a gradient map, binarizing the gradient amplitude map with the current gray value g as the threshold, and performing local maximum suppression in the gradient direction to obtain a boundary area.

3. The method for extracting an adaptive contour according to claim 1, wherein: In the step S2, four set elements are used to perform an erosion operation on the boundary area to obtain four burr areas, and then the four burr areas are subtracted from the boundary area in turn to remove the burrs in the boundary area and obtain a burr-free boundary area.

4. The method for extracting an adaptive contour according to claim 1, wherein: In step S4, the screening criteria are: f(min_x) / min(f(max_r),f(max_l))<0.9; Among them: min_x is the horizontal coordinate of the local minimum, f(min_x) is the vertical coordinate of the corresponding local minimum, max_r and (max_l) are the horizontal coordinates of the local maxima on the left and right sides of the local minimum, and f(max_r) and f(max_l) are their corresponding vertical coordinates.

5. The method for extracting an adaptive contour according to claim 1, wherein: In step S5, the method for calculating the reference contrast is: (1) Obtain the reference area, use contrast_l to binarize the gradient amplitude map, and use the set element to perform an erosion operation on the binarization result to obtain the reference area; (2) Contrast traversal: the starting and ending values ​​of the contrast traversal are contrast_l and min(contrast_l+60,255) respectively, and the step length is 3; (3) Similarity calculation: The contrast of each traversal is used as the threshold to binarize the gradient amplitude map, and the similarity between the binarized result and the reference area is calculated. The similarity calculation formula is: 2- area(diff(region,region_ref)) max(area,area_ref) Where: region is the current binarization result, region_ref is the reference region, area(diff(region, regin_ref)) refers to the area of ​​the absolute subtraction result of region and region_ref, area, area_ref are the areas of region and region_ref respectively; (4) Determine the reference similarity and traverse to obtain the point with the maximum similarity. The horizontal coordinate of this point is the reference contrast, denoted as contrast_ref.

6. The method for extracting an adaptive contour according to claim 1, wherein: In step S6, the high contrast threshold is determined by finding the coordinates of the minimum point of the quality function, recorded as (c_min, m_min), and finding the point whose ordinate is closest to 1.15*m_min. The abscissa value of this point is the high contrast threshold.

Citation Information

Patent Citations

  • Image registration method based on improved structural similarity

    CN102509114A

  • Mobile phone multi-wavelength quantitative rapid detection method and device for immunochromatographic test strip

    CN111478998A

Cited By

  • Contour extraction method for dynamic sequence image

    CN122289719A