Flange surface defect detection algorithm based on traditional image processing

Through the traditional image processing algorithm -based flange defect detection algorithm, the existing flange surface defect detection relying on the problem of defects caused by artificial vision to be ignored, and the accurate positioning and classification of various defects on the flange surface, improved The detection accuracy and accuracy.

CN119379609APending Publication Date: 2025-01-28GONGJI INTELLIGENT TECH (SUZHOU) CO LTD
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202411351943.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-28

Smart Images

  • Figure CN119379609A_ABST
    Figure CN119379609A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of flange defect detection, in particular to a flange surface defect detection algorithm based on traditional image processing, which comprises the following steps: S1, image preprocessing, S2, image adaptive binarization, S3, image interference information suppression, S4, defect detection algorithm and S5, detection result output. According to the image adaptive threshold segmentation algorithm provided by the invention, the image segmentation threshold can be adaptively adjusted according to the overall brightness of the image, and the robustness and scratch detection performance of the detection algorithm are enhanced; different detection algorithms are provided for the three different defects on the surface of the flange, the number of the defects of different types can be accurately and efficiently recognized and positioned, the detection algorithms are excellent in accuracy and high in efficiency, and the requirements for accuracy and real-time performance in the actual production process can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of flange defect detection, and in particular to a flange surface defect detection algorithm based on traditional image processing. Background Art

[0002] Flange is an important component of the air conditioner outdoor unit, and the quality of the flange directly affects the service life of the air conditioner outdoor unit. At present, the defect detection of flange surface on the production line still mainly relies on the traditional manual visual method, which requires workers to inspect each flange surface. The human eye is prone to visual fatigue after long-term work, which leads to some defects that will significantly reduce the performance of the flange being ignored, seriously affecting the product quality. With the development of non-contact detection technologies such as machine vision, a lot of research has been done on the technology of realizing online quality detection in the production process. The research on industrial defect detection technology plays a very important role in promoting the intelligent development of the manufacturing industry. As one of the thousands of industrial products, the research on surface defect detection of flanges is conducive to promoting the application of technologies such as artificial intelligence and information science in the industrial field and accelerating the intelligent process of industrial manufacturing.

[0003] In the field of surface defect detection, surface defect detection methods based on traditional image processing usually do not need to rely on a large amount of data. They can be customized according to the characteristics of the image and have strong interpretability. When the algorithm fails, the cause of the failure can be quickly analyzed. Surface defect detection methods based on traditional image processing can better utilize prior knowledge in the scene to achieve defect detection. Due to its characteristics of not relying on a large amount of data, it is still widely used in actual industrial applications. Summary of the invention

[0004] The object of the present invention is to provide a flange surface defect detection algorithm based on traditional image processing that can detect and identify various types of defects on the flange surface.

[0005] Based on the above purpose, the present invention adopts the following technical solution:

[0006] A flange surface defect detection algorithm based on traditional image processing includes the following steps:

[0007] S1. Image preprocessing: grayscale and filter the collected flange images in turn, then remove the background of the flange target image based on the circle detection algorithm to extract the image region of interest;

[0008] S2, image adaptive binarization: segment the image region of interest extracted in step S1 by an adaptive threshold segmentation algorithm, identify defective images, and convert the image region of interest into a binary image;

[0009] S3, image interference information suppression: retain the defective image area identified in step S2 by segmentation, and design an interference information suppression algorithm to suppress background interference information based on the characteristic that the gradient of surface interference information changes smoothly;

[0010] S4, defect detection algorithm: analyzing the defect binary image obtained in step S3, and locating and classifying different types of defects by using different detection algorithms;

[0011] S5. Output the detection result: generate a defect mark on the original flange image according to the defect type and positioning information detected in step S4, and finally output the detection result.

[0012] Preferably, the specific process of image preprocessing in step S1 includes:

[0013] A threshold is selected to binarize the original image, and the maximum connected domain in the image is found to achieve preliminary positioning of the flange surface; the pixels in the area outside the maximum connected domain are suppressed to 0, the maximum connected domain is retained, and mapped back to the original image to obtain an image with suppressed background; then the image is detected using the EDCircles circle detection algorithm to extract the flange area from the image.

[0014] Preferably, the specific process of step S2 of image adaptive binarization includes:

[0015] A brightness description factor is introduced to describe the brightness of the entire image. The brightness description factor describes the overall brightness by calculating the pixel weighted average of the image grayscale histogram. The calculation formula of the brightness description factor is:

[0016]

[0017] In the formula, θ b represents the brightness description factor, K represents the highest gray level when summing pixels, i represents the i-th gray level, num i represents the number of pixels of the i-th gray level, t n Represents the sum of all pixels of K gray levels;

[0018] The image segmentation threshold can be dynamically adjusted through different brightness factors, and a most suitable global segmentation threshold can be assigned to each image; when the overall appearance of the image is relatively dark, the brightness description factor takes a smaller value, and when the overall appearance of the image is relatively bright, the brightness description factor takes a larger value.

[0019] Preferably, the specific process of suppressing image interference information in step S3 includes:

[0020] Calculate the pixel mean p in the pixel 8 neighborhood μ and variance pδ :

[0021]

[0022] Use the Lapacian operator to calculate the gradient corresponding to the pixel:

[0023]

[0024] Calculate the retention threshold of pixels:

[0025]

[0026] After calculation, T r Points smaller than the set threshold are filtered out as interference information, and T is retained. r Pixels that are greater than the set threshold and meet the grayscale threshold condition are used to suppress interference information.

[0027] Preferably, the detection algorithm in step S4 includes an unpolished defect detection algorithm, a sand hole defect detection algorithm and a scratch defect detection algorithm.

[0028] Preferably, the process of the unpolished defect detection algorithm includes:

[0029] The image obtained in step S3 is transformed from the spatial domain to the frequency domain through discrete Fourier transform, and then the transformed spectrum is filtered and arc detected; if there is an arc in the spectrum, the image is identified as a sample with unpolished defects, and the sample image with unpolished defects is binarized by adaptive threshold to obtain a binary image, and then the small holes in the binary image are filled by the expansion algorithm, and then the unpolished defects are located based on the connected domain extraction.

[0030] Preferably, the process of the sand hole defect detection algorithm includes:

[0031] Connected domain analysis is performed on the binary image obtained in step S3 to locate the defect. According to the characteristics of the sand hole defect, rules are designed from three aspects: area, aspect ratio and area proportion to determine whether the defect is a sand hole defect. Assume that the area of ​​each connected domain is A c , the length and width of the minimum bounding rectangle of the connected domain are H c and W c , then the aspect ratio r hw and area ratio r a The calculation formulas are

[0032]

[0033] Different thresholds are selected for the three rules of area, aspect ratio and area proportion respectively. When a connected domain satisfies these three rules at the same time, the area corresponding to the connected domain will be judged as a sand hole defect.

[0034] Preferably, the process of the scratch defect detection algorithm includes:

[0035] For the binary image processed by the unpolished defect detection algorithm and the sand hole defect detection algorithm, the Hough line detection algorithm is used to perform line segment detection on the image; then the results of the different detected line segments are fused. If the distance between the center points of two line segments is less than a certain threshold, the two line segments are considered to belong to the same scratch area; for the line segments belonging to the same scratch area, they are connected by a smooth curve to generate the scratch defect detection result.

[0036] The beneficial effects of the present invention include:

[0037] The present invention proposes an adaptive threshold-interference information suppression algorithm, which can segment the flange surface defects from the ROI image; the segmented ROI image is converted from a grayscale image to a binary image, so that the appearance information such as the outline and shape of the defect is retained in the binary image, and the defect position on the binary image is consistent with the defect position on the ROI image, thereby realizing the precise positioning of the flange surface defect position.

[0038] In order to solve the two problems of large difference in surface brightness of flange images collected in the scene and small difference in grayscale characteristics between scratch defects and background, the present invention introduces a brightness description factor to dynamically adjust the image segmentation threshold, so that the image segmentation threshold can be adaptively adjusted according to the brightness of the scene image, thereby improving the precision and accuracy of defect recognition and enhancing the robustness of the detection algorithm and the scratch detection performance.

[0039] The present invention designs different detection algorithms according to the different characteristics of flange surface defects. It can locate and classify defects of different categories based on the identified defect binary images, so as to accurately identify the number, type and position of unpolished defects, sand hole defects and scratch defects on the flange surface, and generate the final detection results. The defect detection algorithm used in this application has excellent accuracy and high efficiency, and can meet the accuracy and real-time requirements in the actual production process. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is the algorithm framework diagram of the present invention;

[0041] Figure 2 The image of the flange to be detected of the present invention;

[0042] Figure 3It is the ROI image after image preprocessing of the present invention;

[0043] Figure 4 This is a comparison diagram of the image adaptive segmentation effect of the present invention;

[0044] Figure 5 Schematic diagram of three types of flange surface defects;

[0045] Figure 6 is a flow chart of the defect detection algorithm of the present invention;

[0046] Figure 7 This is a comparison diagram of the image Fourier transform results of the present invention;

[0047] Figure 8 This is a diagram showing the detection results of three flange surface defects according to the present invention. DETAILED DESCRIPTION

[0048] The following is a further explanation of the present invention in conjunction with specific embodiments. Figure 1 As shown, the present invention is a flange surface defect detection algorithm based on traditional image processing, comprising the following steps:

[0049] S1. Image preprocessing: The collected flange images are preprocessed in sequence, and then the background of the flange target image is removed based on the circle detection algorithm to extract the image region of interest (ROI).

[0050] The flange image to be processed is as follows Figure 2 As shown, after grayscale processing, median filtering and Gaussian filtering are performed respectively; the image after filtering is processed by a circle detection algorithm to remove other background images in the image except the flange surface; since the flange surfaces are all circular, the image is processed by the EDCircles circle detection algorithm to obtain a ROI image that only retains the flange surface image.

[0051] First, a suitable threshold is selected to binarize the original image, and then the maximum connected domain in the image is found to preliminarily locate the flange surface position; the pixels in the area outside the maximum connected domain are suppressed to 0, and the maximum connected domain is retained, and then it is mapped back to the original image to obtain an image with suppressed background; finally, the image is detected using the EDCircles algorithm to extract the flange area from the image, as shown in Figure 3 shown.

[0052] S2, image adaptive binarization: For the ROI image obtained in step S1, a brightness description factor is introduced to characterize the brightness of the entire image; the brightness description factor characterizes the overall brightness of the image by calculating the pixel weighted average of the image grayscale histogram, and its calculation formula is:

[0053]

[0054] In the formula, θ b represents the brightness description factor, K represents the highest gray level when summing pixels, i represents the i-th gray level, num i represents the number of pixels of the i-th gray level, t n Represents the sum of all pixels of K gray levels.

[0055] Through different brightness description factors, the image segmentation threshold can be dynamically adjusted to assign the most appropriate global segmentation threshold to each image; when the overall appearance of the image is relatively dark, θ b The value of is small, and when the overall appearance of the image is bright, θ b The value is large; thus, θ can be adaptively adjusted according to the different brightness changes in the scene image. b The size of the image can be more accurately identified and segmented into defective images; the processing effect of the image adaptive threshold segmentation algorithm is as follows Figure 4 As shown, Figure 4 (a) is the ROI image after processing in step S1. Figure 4 (b) is the binary image processed by the adaptive threshold segmentation algorithm.

[0056] S3. Suppression of image interference information: Since there is a lot of background information similar to scratches on the flange surface, if the straight line detection algorithm is used directly on the original image to detect scratches, it will be impossible to distinguish whether the identified features are defects due to the introduction of too much interference information; since scratches also show certain grayscale characteristics in the image, scratches can also be retained by segmentation first; segmentation can minimize the interference of other surface information while retaining scratches; according to the characteristic that the gradient of surface interference information changes slowly, an interference information suppression algorithm can be designed to suppress it to reduce the impact of background interference information; the specific process of interference information suppression includes:

[0057] Calculate the pixel mean p in the pixel 8 neighborhood μ and variance p δ :

[0058]

[0059] Use the Lapacian operator to calculate the gradient corresponding to the pixel:

[0060]

[0061] Calculate the retention threshold of pixels:

[0062]

[0063] After calculation, T r Points smaller than the set threshold are filtered out as interference information, and T is retained. r Pixels that are greater than the set threshold and meet the grayscale threshold condition are used to suppress interference information.

[0064] S4. Defect detection algorithm: In actual detection scenarios, there are usually three types of defects on the flange surface, such as Figure 5 Shown, including Figure 5 (a) The unpolished defect shown, Figure 5 (b) The sand hole defect and Figure 5 (c) Scratch defect shown; for the above three different defect types, different defect detection algorithms are set to identify and classify the defects in a targeted manner. The design flange defect detection algorithm process is as follows: Figure 6 shown.

[0065] For the unpolished defect detection algorithm, the unpolished defects show certain regularity in the image, which is usually an area composed of some arc segments. It is found through experiments that the image of the unpolished defects also has obvious regularity in the frequency domain, so the unpolished defects can be detected by the Fourier transform method. In this embodiment, the discrete Fourier transform is used to transform the image of the unpolished defects from the spatial domain to the frequency domain. The images before and after the transformation are as follows: Figure 7 As shown; then the transformed spectrum graph is filtered and arc detection operations are performed. If there is an arc in the spectrum graph, the image is identified as a sample with unpolished defects; when the image sample is identified as an unpolished defect sample, the image is binarized with an adaptive threshold to obtain a binary image, and then the small holes in the binary image are filled through the expansion algorithm, and then the unpolished defects are located based on the connected domain extraction.

[0066] For the sand hole defect detection algorithm, a binary image containing defects such as sand holes can be obtained after segmentation through the adaptive threshold segmentation algorithm. The defects can be located by performing connected domain analysis on the image; the binary image not only contains sand hole defect information, but also contains defect information such as unpolished and scratches. Corresponding rules can be designed to filter out sand hole defects; according to the rules of sand hole characteristics, rules can be designed from three aspects: area, aspect ratio and area proportion to determine whether the defect is a sand hole defect.

[0067] Assume that the area of ​​each connected domain is A c , the length and width of the minimum bounding rectangle of the connected domain are H c and W c , then the aspect ratio r hw and area ratio r a The calculation formulas are

[0068]

[0069] Different thresholds are selected for the three rules of area, aspect ratio and area proportion respectively. When a connected domain satisfies these three rules at the same time, the area corresponding to the connected domain will be judged as a sand hole defect.

[0070] For the scratch defect detection algorithm, after the adaptive threshold-interference information suppression process and the detection of the above two types of defects, a binary segmentation image of the scratch can be obtained; when the scratch defect detection algorithm processes the binary image, it first uses the Hough line detection algorithm to perform line segment detection on the segmented image, and detects the scratch area where the pixels are closely arranged and approximately distributed in a straight line as a line segment; then the results of the different detected line segments are fused, and each line segment is analyzed. If there are two line segments whose center point distance is less than a certain threshold, it is considered that the two line segments belong to the same scratch area; for the line segments in the same scratch area, they are connected by a smooth curve as the final detection result.

[0071] S5, output the detection result: according to the defect type and location information detected in step S4, a defect mark is generated on the original flange image, and the detection result is finally output. The detection result image is as follows: Figure 8 As shown, Figure 8 (a) The marked area is an unpolished defect. Figure 8 The marked area in (b) is a sand hole defect. Figure 8 The marked area in (c) is a scratch defect.

[0072] After experimental testing, the defect detection algorithm proposed in this embodiment achieved an average recognition accuracy of 93.82% on the collected defect data set. In the actual detection process, the average detection time for each image was 500ms. Its detection accuracy and detection time meet the production use requirements.

[0073] The above description is only a further explanation of the present invention in combination with specific embodiments. All descriptions do not limit the scope of protection of the present invention. Any changes or replacement schemes that can be easily thought of by any technician in this field within the technical scope disclosed by the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.

Claims

1. A flange surface defect detection algorithm based on traditional image processing, comprising the following steps: S1. Image preprocessing: grayscale and filter the collected flange images in turn, then remove the background of the flange target image based on the circle detection algorithm to extract the image region of interest; S2, image adaptive binarization: segment the image region of interest extracted in step S1 by an adaptive threshold segmentation algorithm, identify defective images, and convert the image region of interest into a binary image; S3, image interference information suppression: retain the defective image area identified in step S2 by segmentation, and design an interference information suppression algorithm to suppress background interference information based on the characteristic that the gradient of surface interference information changes smoothly; S4, defect detection algorithm: analyzing the defect binary image obtained in step S3, and locating and classifying different types of defects by using different detection algorithms; S5. Output the detection result: Generate a defect mark on the original flange image according to the defect type and positioning information detected in step S4, and finally output the detection result.

2. The flange surface defect detection algorithm based on traditional image processing according to claim 1 is characterized in that: The specific process of the image preprocessing in step S1 includes: A threshold is selected to binarize the original image, and the maximum connected domain in the image is found to achieve preliminary positioning of the flange surface; the pixels in the area outside the maximum connected domain are suppressed to 0, the maximum connected domain is retained, and mapped back to the original image to obtain an image with suppressed background; then the image is detected using the EDCircles circle detection algorithm to extract the flange area from the image.

3. The flange surface defect detection algorithm based on traditional image processing according to claim 1 is characterized in that: The specific process of the step S2 image adaptive binarization includes: A brightness description factor is introduced to describe the brightness of the entire image. The brightness description factor describes the overall brightness by calculating the pixel weighted average of the image grayscale histogram. The calculation formula of the brightness description factor is: In the formula, θ b represents the brightness description factor, K represents the highest gray level when summing pixels, i represents the i-th gray level, num i represents the number of pixels of the i-th gray level, t n Represents the sum of all pixels of K gray levels; The image segmentation threshold can be dynamically adjusted through different brightness factors, and a most suitable global segmentation threshold can be assigned to each image; when the overall appearance of the image is relatively dark, the brightness description factor takes a smaller value, and when the overall appearance of the image is relatively bright, the brightness description factor takes a larger value.

4. The flange surface defect detection algorithm based on traditional image processing according to claim 1 is characterized in that: The specific process of suppressing image interference information in step S3 includes: Calculate the pixel mean p in the pixel 8 neighborhood μ and variance p δ : Use the Lapacian operator to calculate the gradient corresponding to the pixel: Calculate the retention threshold of pixels: After calculation, T r Points smaller than the set threshold are filtered out as interference information, and T is retained. r Pixels that are greater than the set threshold and meet the grayscale threshold condition are used to suppress interference information.

5. The flange surface defect detection algorithm based on traditional image processing according to claim 1 is characterized in that: The detection algorithms in step S4 include an unpolished defect detection algorithm, a sand hole defect detection algorithm and a scratch defect detection algorithm.

6. The flange surface defect detection algorithm based on traditional image processing according to claim 5 is characterized in that: The process of the unpolished defect detection algorithm includes: The image obtained in step S3 is transformed from the spatial domain to the frequency domain through discrete Fourier transform, and then the transformed spectrum is filtered and arc detected; if there is an arc in the spectrum, the image is identified as a sample with unpolished defects, and the sample image with unpolished defects is binarized by adaptive threshold to obtain a binary image, and then the small holes in the binary image are filled by the expansion algorithm, and then the unpolished defects are located based on the connected domain extraction.

7. The flange surface defect detection algorithm based on traditional image processing according to claim 5 is characterized in that: The process of the sand hole defect detection algorithm includes: Connected domain analysis is performed on the binary image obtained in step S3 to locate the defect. According to the characteristics of the sand hole defect, rules are designed from three aspects: area, aspect ratio and area proportion to determine whether the defect is a sand hole defect. Assume that the area of ​​each connected domain is A c , the length and width of the minimum bounding rectangle of the connected domain are H c and W c , then the aspect ratio r hw and area ratio r a The calculation formulas are: Different thresholds are selected for the three rules of area, aspect ratio and area proportion respectively. When a connected domain satisfies these three rules at the same time, the area corresponding to the connected domain will be judged as a sand hole defect.

8. The flange surface defect detection algorithm based on traditional image processing according to claim 5 is characterized in that: The process of the scratch defect detection algorithm includes: For the binary image processed by the unpolished defect detection algorithm and the sand hole defect detection algorithm, the Hough line detection algorithm is used to perform line segment detection on the image; then the results of the different detected line segments are fused. If the distance between the center points of two line segments is less than a certain threshold, the two line segments are considered to belong to the same scratch area; for the line segments belonging to the same scratch area, they are connected by a smooth curve to generate the scratch defect detection result.

Citation Information

Cited By

  • Part feature recognition method for vertical machining center

    CN119624954A

  • Coating surface defect grade image recognition and evaluation method

    CN120612470A

  • Flange and end face flatness detection method thereof

    CN120912558A

  • Battery surface defect detection method and system

    CN121095137A

  • Flange forge piece surface defect detection method and system based on image processing

    CN122023235A