Part processing surface defect visual detection method and system based on image enhancement and binarization algorithm

Through image enhancement and binarization algorithms, combined with morphological cores and Sobel gradients, the efficient and low error detection problems in the detection of surface defects of parts processing are solved, and high-precision real-time detection is achieved, which is suitable for a variety of surface defects of processing.

CN120563479APending Publication Date: 2025-08-29HARBIN NAISHI INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202510729111.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-03
Publication Date
2025-08-29

AI Technical Summary

Technical Problem

In the detection of surface defects of parts processing in the field of mechanical manufacturing, the prior art has low efficiency and high missed detection rate, and it is difficult to achieve high-precision and low-error detection without relying on big data training, while meeting the requirements of real-time and deployment costs in industrial scenarios.

Method used

Using image enhancement and binarization algorithms, the bottom cap transformation of vertical and horizontal morphological cores and the multi-directional Sobel gradient fusion, combined with dynamic threshold segmentation and contour screening, a multi-directional gradient feature map is generated to screen out real surface defects.

Benefits of technology

A high detection rate (≥95%) for small and multi-directional scratches is achieved, and the error detection rate is reduced to below 5%, and the processing time is ≤200ms. It meets the real-time inspection requirements of industrial production lines and adapts to a variety of process defect types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120563479A_ABST
    Figure CN120563479A_ABST
Patent Text Reader

Abstract

The invention discloses a part machining surface defect visual detection method and system based on image enhancement and a binarization algorithm, and belongs to the field of machine manufacturing. The problem of how to realize high-precision and low-false-detection defect detection by optimizing an image processing flow without relying on big data training is solved, and meanwhile, the requirements of an industrial scene on real-time performance and deployment cost are met. The method comprises the following steps: inputting a part surface image and a mask image, and carrying out corrosion operation to generate a safety detection area; carrying out bottom cap transformation by adopting longitudinal and transverse morphological nucleuses, and separating scratches and noise; extracting transverse and longitudinal gradients by using a Sobel operator, and generating a multidirectional gradient feature map; performing dynamic threshold segmentation to generate a binary image, and connecting fracture scratches through closed operation; and screening longitudinal and transverse scratch contours according to the length-width ratio, carrying out distance transformation and minimum inscribed circle radius calculation, and judging the region with the radius smaller than a threshold value as a real defect. The method is mainly applied to the defect detection field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of mechanical manufacturing, and in particular relates to a method for visually detecting surface defects of machined parts based on image enhancement and binarization algorithms. Background Art

[0002] In the field of mechanical manufacturing, the surface quality of machined parts directly impacts equipment assembly accuracy and operational reliability. Surface defects such as scratches and pits can cause stress concentration and accelerated corrosion, making defect detection a core requirement of production quality inspection. Traditional manual visual inspection methods rely on empirical judgment, resulting in low efficiency and a high missed detection rate (approximately 15%-20%). They also struggle to adapt to the real-time inspection requirements of automated production lines.

[0003] To improve inspection efficiency, existing technologies have proposed automated inspection solutions based on machine vision. Among them, existing Chinese patent CN115393594A discloses a product surface inspection method. This deep learning-based inspection method extracts defect features through convolutional neural networks. However, it faces significant bottlenecks in actual industrial scenarios: First, model training requires a large amount of labeled data, while industrial defect samples are sparse and labeling is expensive. Second, lighting changes and background interference in complex working conditions can easily lead to reduced model generalization, resulting in false detection rates generally exceeding 10%. Furthermore, deep learning algorithms require high hardware computing power, making real-time processing difficult in embedded devices.

[0004] To address the above issues, some research has turned to traditional image processing algorithms, directly extracting defect features through techniques such as edge detection and morphological operations. For example, Chinese patent CN116309277A discloses a steel inspection method and system based on deep learning. This is a defect detection method based on morphological filtering, but this method has two limitations: first, a single morphological kernel is difficult to adapt to the feature enhancement requirements of multi-directional scratches, resulting in missed detection of small scratches; second, background noise interference outside the inspection area (such as water stains and oil stains) is not considered, and texture changes in non-inspection areas are mistakenly identified as defects. In summary, the existing technology urgently needs to resolve the following technical contradictions: how to achieve high-precision, low-false-detection defect detection by optimizing the image processing process without relying on big data training, while meeting the real-time and deployment cost requirements of industrial scenarios. Summary of the Invention

[0005] In view of this, the present invention aims to propose a method and system for visual inspection of surface defects of component processing based on image enhancement and binarization algorithms, so as to solve the problem of how to achieve high-precision and low-false-detection defect detection by optimizing the image processing process without relying on big data training, while meeting the requirements of industrial scenarios for real-time performance and deployment costs.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a method for visual detection of surface defects of machined parts based on image enhancement and binarization algorithm, the method comprising: Image preprocessing and safe area generation steps: Input the surface image of the component to be inspected and its corresponding mask image, perform an erosion operation on the mask image to generate a safe inspection area, and retain the edge buffer area; Scratch feature enhancement step: Use the longitudinal morphological kernel and the transverse morphological kernel to perform bottom-hat transformation on the surface image to separate the scratch area from the background noise. Use the Sobel operator to extract the transverse and longitudinal edge gradients of the surface image to generate a multi-directional gradient feature map. Multi-threshold binarization and morphological optimization steps: dynamic threshold segmentation is performed on the gradient feature map to generate an initial binarized image, and a closing operation is performed on the binarized image to connect the broken scratch edges; Contour screening and verification steps: Extract the contour of the image after the closing operation, and screen longitudinal scratches and transverse scratches according to the preset aspect ratio conditions; perform distance transformation on the screened contour, calculate the minimum inscribed circle radius, and determine that the area with a radius less than or equal to the set threshold is a real surface defect.

[0007] Furthermore, a preferred method is proposed, in which the corrosion operation in the image preprocessing and safe area generation steps adopts an elliptical structure kernel with a size of 11×11 pixels, and the edge buffer area width retained after corrosion is ≥5 pixels.

[0008] Furthermore, a preferred embodiment is proposed, in which the longitudinal morphological kernel is a rectangular kernel of 30×200 pixels, and the transverse morphological kernel is a rectangular kernel of 200×30 pixels.

[0009] Furthermore, a preferred method is proposed, in which the threshold of the dynamic threshold segmentation in the multi-threshold binarization and morphological optimization step is 180, and the closing operation uses an ellipse kernel of 5×5 pixels for morphological operation.

[0010] Furthermore, a preferred embodiment is proposed, wherein the preset aspect ratio condition in the contour screening and verification step includes: Longitudinal scratch judgment conditions: contour height > 40 pixels and height > width; Horizontal scratch determination criteria: outline width > 40 pixels and width > height.

[0011] Furthermore, a preferred method is proposed, in which the threshold value of the minimum inscribed circle radius in the contour screening and verification step is set to 3 pixels, and when the radius of the inscribed circle corresponding to the contour is ≤3 pixels, it is determined to be a real surface defect.

[0012] Furthermore, a preferred embodiment is proposed, wherein the method further comprises: marking the position of the verified defective area, and outputting a detection report including defect coordinate information and a visual result image.

[0013] Based on the same inventive concept, the present invention also proposes a visual inspection system for surface defects of parts processing based on image enhancement and binarization algorithm, the system comprising: Image preprocessing and safe area generation unit: used to input the surface image of the component to be inspected and its corresponding mask image, perform an erosion operation on the mask image to generate a safe inspection area, and retain the edge buffer area; Scratch feature enhancement unit: It is used to perform bottom-hat transformation on the surface image using longitudinal morphological kernel and transverse morphological kernel respectively, separate the scratch area from the background noise, extract the transverse edge gradient and longitudinal edge gradient of the surface image using the Sobel operator, and generate a multi-directional gradient feature map; Multi-threshold binarization and morphological optimization unit: used to perform dynamic threshold segmentation on the gradient feature map to generate an initial binarized image, perform closing operation on the binarized image, and connect the broken scratch edges; Contour screening and verification unit: used to extract the contour of the image after the closing operation, and screen longitudinal scratches and transverse scratches according to the preset aspect ratio conditions; perform distance transformation on the screened contour, calculate the minimum inscribed circle radius, and determine that the area with a radius less than or equal to the set threshold is a real surface defect.

[0014] Based on the same inventive concept, the present invention also proposes a computer device, including a memory and a processor, wherein a computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes a visual detection method for surface defects of component processing based on image enhancement and binarization algorithm as described in any one of the above items.

[0015] Based on the same inventive concept, the present invention also proposes a computer-readable storage medium, which stores a computer program. When the computer program is run by a processor, it executes the steps of a method for visual detection of surface defects of component processing based on image enhancement and binarization algorithm as described above.

[0016] Compared with the prior art, the present invention has the following beneficial effects: The proposed method uses a bottom-hat transform of longitudinal and transverse morphological kernels (30×200 and 200×30 pixels) combined with multi-directional Sobel gradient fusion to effectively enhance the texture features of scratches with different orientations, addressing the problem of traditional algorithms under-detecting small / multi-directional scratches. Experimental results show that this method has a detection rate of ≥95% for scratches ≥0.5 mm in length, reducing the missed detection rate to below 5% (compared to the approximately 15%-20% missed detection rate for traditional algorithms).

[0017] The proposed method uses mask etching to create a safe detection area (edge ​​buffer width ≥ 5 pixels). Combined with dynamic threshold segmentation (threshold = 180) and a contour screening strategy (aspect ratio + inscribed circle radius ≤ 3 pixels), it effectively filters out background noise interference such as water stains and oil contamination. The measured false detection rate in industrial scenarios remains stable at less than 8%, over 40% lower than the traditional fixed threshold method (false detection rate of approximately 12%-18%).

[0018] The entire process of the method proposed in this invention is implemented based on traditional image processing algorithms, without relying on GPU acceleration. The processing time of a single image (640×640 resolution) is ≤200ms, meeting the real-time detection requirement of the production line of ≤500ms, and the efficiency is improved by 60% compared with the deep learning solution (average processing time ≥500ms).

[0019] The method proposed in the present invention can adapt to the surface inspection needs of parts of different sizes by dynamically adjusting the morphological kernel size (such as the range of 30×200 to 50×300 pixels) and the aspect ratio threshold (such as the range of height>40 to height>60 pixels), covering various process defect types such as metal stamping parts and castings.

[0020] The present invention is mainly used in the field of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which constitute part of the present invention, are provided to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are provided to explain the present invention and do not constitute an undue limitation of the present invention. In the accompanying drawings: Figure 1 This is a flow chart of a method for visually detecting surface defects of machined parts based on image enhancement and binarization algorithms according to the present invention; Figure 2 This is a comparison chart of the effects of the traditional defect detection method described in the present invention and this method. DETAILED DESCRIPTION

[0022] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely explain the technical solutions in the embodiments of the present invention. It should be noted that the embodiments of the present invention and the features therein can be combined with each other in the absence of conflict, and the embodiments described are only part of the embodiments of the present invention, not all of the embodiments.

[0023] Implementation method 1, see Figure 1 This embodiment describes a method for visually detecting surface defects of machined parts based on image enhancement and binarization algorithms, the method comprising: Image preprocessing and safe area generation steps: Input the surface image of the component to be inspected and its corresponding mask image, perform an erosion operation on the mask image to generate a safe inspection area, and retain the edge buffer area; Scratch feature enhancement step: Use the longitudinal morphological kernel and the transverse morphological kernel to perform bottom-hat transformation on the surface image to separate the scratch area from the background noise. Use the Sobel operator to extract the transverse and longitudinal edge gradients of the surface image to generate a multi-directional gradient feature map. Multi-threshold binarization and morphological optimization steps: dynamic threshold segmentation is performed on the gradient feature map to generate an initial binarized image, and a closing operation is performed on the binarized image to connect the broken scratch edges; Contour screening and verification steps: Extract the contour of the image after the closing operation, and screen longitudinal scratches and transverse scratches according to the preset aspect ratio conditions; perform distance transformation on the screened contour, calculate the minimum inscribed circle radius, and determine that the area with a radius less than or equal to the set threshold is a real surface defect.

[0024] The method proposed in this embodiment uses image enhancement and a multi-threshold binarization algorithm to effectively separate surface defects from background noise and accurately extract defect features such as scratches, thereby achieving high-precision detection and reducing false positives without relying on big data training. The method also generates safe areas and edge buffers through an erosion operation, adapting to the differences in surface images of different components. It is highly versatile and robust, suitable for detecting a variety of surface defects.

[0025] The method proposed in this embodiment does not rely on complex big data training or expensive hardware, resulting in low deployment costs. It can be implemented on existing industrial inspection equipment, making it suitable for large-scale industrial applications. Through contour screening, verification, and minimum inscribed circle radius determination, it can accurately identify true surface defects, reduce the risk of misidentification, and improve overall inspection reliability.

[0026] Implementation method 2. This implementation method further limits the visual detection method for surface defects of component processing based on image enhancement and binarization algorithm described in implementation method 1. The corrosion operation in the image preprocessing and safety area generation steps adopts an elliptical structure kernel with a size of 11×11 pixels. After corrosion, the edge buffer area width retained is ≥5 pixels.

[0027] This implementation uses an elliptical structure kernel to more accurately simulate the actual component surface morphology and defect characteristics. Compared to traditional rectangular structure kernels, the elliptical structure kernel can better match the curvature of the component surface, reducing false detections. The width of the edge buffer area retained after corrosion is set to ≥ 5 pixels to ensure the integrity of the edge area and prevent excessive processing of details, thereby avoiding erroneous defect judgments due to insufficient edge information during actual inspection.

[0028] Implementation method three. This implementation method further limits the visual detection method for surface defects of component processing based on image enhancement and binarization algorithm described in implementation method one. The longitudinal morphological kernel is a rectangular kernel of 30×200 pixels, and the transverse morphological kernel is a rectangular kernel of 200×30 pixels.

[0029] In this implementation, different longitudinal and transverse morphological kernels are used to enhance the morphological features of surface defects on machined parts. The longitudinal morphological kernel (30×200 pixels) focuses on highlighting features in the longitudinal direction, while the transverse morphological kernel (200×30 pixels) focuses on features in the transverse direction. This allows for better adaptation to the varying directionality of surface defects and improves defect detection accuracy.

[0030] Implementation method 4. This implementation method further limits the visual detection method for surface defects of component processing based on image enhancement and binarization algorithm described in implementation method 1. The threshold of dynamic threshold segmentation in the multi-threshold binarization and morphological optimization steps is 180, and the closing operation uses an elliptical kernel of 5×5 pixels for morphological operations.

[0031] In this embodiment, the dynamic threshold segmentation algorithm adaptively adjusts the segmentation threshold according to the grayscale features of the image. Setting the threshold to 180 optimizes the segmentation of the background and defect area in the grayscale image, so that surface defects can be distinguished from normal areas more accurately. By using a 5×5 elliptical kernel, small area defects caused by image noise or irregular shapes can be effectively removed while retaining the structure of the real defect to avoid false detection. Compared with square or circular kernels, elliptical kernels can better fit defects of certain specific shapes, especially when dealing with surface defects with linear or curvilinear features, they can better retain the overall outline of the defect and improve the accuracy of detection. The combination of dynamic threshold and morphological operations can more accurately handle complex situations on the surface of parts, effectively improve the accuracy of defect detection, and reduce false detection and missed detection.

[0032] Implementation 5. This implementation further limits the visual detection method for component surface defects based on image enhancement and binarization algorithm described in Implementation 1. The preset aspect ratio conditions in the contour screening and verification steps include: Longitudinal scratch judgment conditions: contour height > 40 pixels and height > width; Horizontal scratch determination criteria: outline width > 40 pixels and width > height.

[0033] In this implementation, by setting criteria for longitudinal and transverse scratches, the system can accurately identify scratch defects on component surfaces in different directions. Longitudinal scratches require that the outline's height be greater than its width and exceed 40 pixels, while transverse scratches require that the outline's width be greater than its height and exceed 40 pixels. This classification allows the system to classify defects based on their shape and direction, avoiding misidentification or missed detections.

[0034] By using preset aspect ratio conditions, contours that do not meet these conditions can be filtered out during image processing, thereby preventing irrelevant noise or meaningless details from affecting the detection results. This method improves the accuracy of defect detection, especially when processing workpiece images with complex backgrounds or noise.

[0035] In practical applications, preset aspect ratio conditions can effectively exclude non-defective image areas and avoid false detections. For example, if the height and width ratio of certain areas do not match the characteristics of a scratch, they will be filtered out, reducing the risk of the system mistakenly identifying other objects or noise as defects. By setting different longitudinal and transverse scratch determination conditions, it can be flexibly adapted to the actual workpiece and defect type. This conditional screening method can adjust the detection accuracy according to the actual characteristics of the component, making the method more practical and efficient in different production environments.

[0036] Implementation method six. This implementation method further limits the visual detection method for surface defects of component processing based on image enhancement and binarization algorithm described in implementation method one. The set threshold value of the minimum inscribed circle radius in the contour screening and verification step is 3 pixels. When the radius of the inscribed circle corresponding to the contour is ≤3 pixels, it is judged as a real surface defect.

[0037] In image processing, noise or interference may lead to false detection and misidentification. By setting the minimum inscribed circle radius to 3 pixels, pseudo contours caused by noise or small image defects can be effectively removed. These small pseudo contours often do not represent real surface defects, so using this threshold to exclude these irrelevant details helps to focus on identifying real defects. An inscribed circle radius of less than 3 pixels usually corresponds to very small defects, which are likely to have little impact on performance and quality in actual processing, so they can be excluded. This ensures that the inspection system focuses on defects that actually affect the function and quality of the parts. Limiting the threshold to 3 pixels can also effectively reduce the amount of calculation, because there is no need for complex subsequent processing of these tiny and potentially unimportant defects, thereby improving the efficiency of the overall inspection.

[0038] Implementation method seven. This implementation method further limits the method for visual detection of surface defects of component processing based on image enhancement and binarization algorithm described in implementation method one. The method also includes: marking the position of the verified defect area, and outputting a detection report containing defect coordinate information and a visual result image.

[0039] Embodiment 8: This embodiment describes a visual inspection system for surface defects of machined parts based on image enhancement and binarization algorithms, the system comprising: Image preprocessing and safe area generation unit: used to input the surface image of the component to be inspected and its corresponding mask image, perform an erosion operation on the mask image to generate a safe inspection area, and retain the edge buffer area; Scratch feature enhancement unit: It is used to perform bottom-hat transformation on the surface image using longitudinal morphological kernel and transverse morphological kernel respectively, separate the scratch area from the background noise, extract the transverse edge gradient and longitudinal edge gradient of the surface image using the Sobel operator, and generate a multi-directional gradient feature map; Multi-threshold binarization and morphological optimization unit: used to perform dynamic threshold segmentation on the gradient feature map to generate an initial binarized image, perform closing operation on the binarized image, and connect the broken scratch edges; Contour screening and verification unit: used to extract the contour of the image after the closing operation, and screen longitudinal scratches and transverse scratches according to the preset aspect ratio conditions; perform distance transformation on the screened contour, calculate the minimum inscribed circle radius, and determine that the area with a radius less than or equal to the set threshold is a real surface defect.

[0040] Implementation method nine: A computer device described in this implementation method includes a memory and a processor, wherein a computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes a visual detection method for surface defects of component processing based on image enhancement and binarization algorithm according to any one of implementation methods one to seven.

[0041] Implementation method ten, a computer-readable storage medium described in this implementation method is characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is run by the processor, the steps of a method for visual detection of surface defects of component processing based on image enhancement and binarization algorithm as described in any one of implementation methods one to seven are executed.

[0042] Implementation method 11, see Figure 2This embodiment provides a specific example of the method for visually inspecting surface defects of machined parts based on image enhancement and binarization algorithms described in Embodiment 1, and is also used to explain Embodiments 2 to 8. Specifically: S1. Image input and preprocessing: Acquire the surface image of the metal stamping part to be inspected (original resolution 1920×1080 pixels) and simultaneously read the pre-annotated mask image (white area is the inspection area, black is the background); The image and mask are uniformly scaled to 640×640 pixels, and bilinear interpolation is used to preserve edge details; S2. Generation of safety detection area: Create an elliptical structure kernel with a size of 11×11 pixels, perform an erosion operation on the mask image (iteration number = 1), and generate a safe detection area with an edge buffer area width of 5 pixels; Perform bitwise AND operation on the eroded mask and the original image to eliminate background interference in non-detection areas; S3, Multi-directional scratch feature enhancement The longitudinal morphological kernel (30 pixels wide × 200 pixels high) and the transverse morphological kernel (200 pixels wide × 30 pixels high) were defined respectively; Perform a vertical bottom-hat transform on the safe area image: Use the vertical kernel to perform a morphological closing operation (dilation followed by erosion), perform a difference operation between the closing operation result and the original image, and extract the vertical scratch features; Perform a horizontal bottom-hat transform on the safe area image: Repeat the above operation using the horizontal kernel to extract horizontal scratch features; The vertical and horizontal bottom-hat transformation results are superimposed at the pixel level to generate a preliminary enhanced image; S4. Gradient feature fusion and binarization processing Apply the Sobel operator to the enhanced image separately: X-direction gradient calculation (kernel size = 3, dx = 1, dy = 0) to extract horizontal edges; Y-direction gradient calculation (kernel size = 3, dx = 0, dy = 1) to extract the longitudinal edge; The X / Y direction gradient images are converted to absolute values ​​and then superimposed, normalized to the grayscale range of 0-255, to generate a multi-directional gradient fusion image; Perform dynamic threshold segmentation on the fused image: set a fixed threshold T = 180, set the area with pixel value ≥ T to 255 (white), and set the rest to 0 (black) to obtain the initial binary image; S5. Morphological optimization and contour screening Perform a closing operation on the binary image: use a 5×5 pixel ellipse kernel, first dilate (iteration number = 1) and then erode (iteration number = 1) to connect the broken scratch edges; Extract all contours in the image after the closing operation and filter them according to the following rules: Vertical scratches: The height of the outline's circumscribed rectangle is greater than 40 pixels, and the height is greater than the width. Horizontal scratch: The width of the outline rectangle is greater than 40 pixels, and the width is greater than the height; Perform distance transformation on contours that meet the aspect ratio and calculate the minimum inscribed circle radius of each contour: If the radius is ≤3 pixels, it is determined to be a real scratch defect; If the radius is greater than 3 pixels, it is considered as noise interference and removed; S6. Result output and visualization Draw a red rectangle on the original image to mark the defect location and generate a detection result map; Outputs a JSON format inspection report containing the number of defects, location coordinates, and size parameters.

[0043] The comparison between the traditional defect detection method and this method is shown in the figure below. Figure 2 As shown, it can be seen that this method is more effective.

[0044] Those skilled in the art will appreciate that embodiments of the present disclosure may be provided as methods, systems, or computer program products. Thus, the present disclosure may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code. The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including the instruction device, which implements the function specified in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes. These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes. Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure and are not intended to limit its scope of protection. Although the present disclosure has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that after reading the present disclosure, those skilled in the art can still make various changes, modifications or equivalent substitutions to the specific implementation methods of the invention, but these changes, modifications or equivalent substitutions are all within the scope of protection of the disclosed claims.

Claims

1. A method for visual inspection of surface defects of parts processing based on image enhancement and binarization algorithm, characterized in that: The method comprises: Image preprocessing and safe area generation steps: Input the surface image of the component to be inspected and its corresponding mask image, perform an erosion operation on the mask image to generate a safe inspection area, and retain the edge buffer area; Scratch feature enhancement step: Use the longitudinal morphological kernel and the transverse morphological kernel to perform bottom-hat transformation on the surface image to separate the scratch area from the background noise. Use the Sobel operator to extract the transverse and longitudinal edge gradients of the surface image to generate a multi-directional gradient feature map. Multi-threshold binarization and morphological optimization steps: dynamic threshold segmentation is performed on the gradient feature map to generate an initial binarized image, and a closing operation is performed on the binarized image to connect the broken scratch edges; Contour screening and verification steps: Extract the contour of the image after the closing operation, and screen longitudinal scratches and transverse scratches according to the preset aspect ratio conditions; perform distance transformation on the screened contour, calculate the minimum inscribed circle radius, and determine that the area with a radius less than or equal to the set threshold is a real surface defect.

2. The method for visual inspection of surface defects of parts processing based on image enhancement and binarization algorithm according to claim 1, characterized in that: In the image preprocessing and safe area generation steps, the erosion operation adopts an elliptical structure kernel with a size of 11×11 pixels, and the width of the edge buffer area retained after the erosion is ≥5 pixels.

3. The method for visual inspection of surface defects of parts processing based on image enhancement and binarization algorithm according to claim 1, characterized in that: The longitudinal morphological kernel is a rectangular kernel of 30×200 pixels, and the transverse morphological kernel is a rectangular kernel of 200×30 pixels.

4. The method for visual inspection of surface defects of parts processing based on image enhancement and binarization algorithm according to claim 1, characterized in that: The threshold value of the dynamic threshold segmentation in the multi-threshold binarization and morphological optimization step is 180, and the closing operation uses an ellipse kernel of 5×5 pixels for morphological operation.

5. The method for visual inspection of surface defects of parts processing based on image enhancement and binarization algorithm according to claim 1, characterized in that: The preset aspect ratio conditions in the outline screening and verification steps include: Longitudinal scratch judgment conditions: contour height > 40 pixels and height > width; Horizontal scratch determination criteria: outline width > 40 pixels and width > height.

6. The method for visual inspection of surface defects of parts processing based on image enhancement and binarization algorithm according to claim 1, characterized in that: The threshold value of the minimum inscribed circle radius in the contour screening and verification step is set to 3 pixels. When the radius of the inscribed circle corresponding to the contour is ≤3 pixels, it is determined to be a real surface defect.

7. The method for visual inspection of surface defects of parts processing based on image enhancement and binarization algorithm according to claim 1, characterized in that: The method further includes: marking the position of the verified defect area, and outputting a detection report containing defect coordinate information and a visual result image.

8. A visual inspection system for surface defects of parts processing based on image enhancement and binarization algorithm, characterized in that: The system comprises: Image preprocessing and safe area generation unit: used to input the surface image of the component to be inspected and its corresponding mask image, perform an erosion operation on the mask image to generate a safe inspection area, and retain the edge buffer area; Scratch feature enhancement unit: It is used to perform bottom-hat transformation on the surface image using longitudinal morphological kernel and transverse morphological kernel respectively, separate the scratch area from the background noise, extract the transverse edge gradient and longitudinal edge gradient of the surface image using the Sobel operator, and generate a multi-directional gradient feature map; Multi-threshold binarization and morphological optimization unit: used to perform dynamic threshold segmentation on the gradient feature map to generate an initial binarized image, perform closing operation on the binarized image, and connect the broken scratch edges; Contour screening and verification unit: used to extract the contour of the image after the closing operation, and screen longitudinal scratches and transverse scratches according to the preset aspect ratio conditions; perform distance transformation on the screened contour, calculate the minimum inscribed circle radius, and determine that the area with a radius less than or equal to the set threshold is a real surface defect.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes a method for visual detection of surface defects of component processing based on image enhancement and binarization algorithm according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of a method for visually detecting surface defects of component processing based on image enhancement and binarization algorithms as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Product surface detection method

    CN115393594A

  • Steel detection method and system based on deep learning

    CN116309277A

Cited By

  • PHEMT defect detection method and system

    CN120852411A

  • A method and system for defect detection of phemts

    CN120852411B