Image segmentation method and system suitable for defect detection of complex industrial parts

By adopting image quality optimization and combining threshold segmentation and morphological operation methods in the detection of complex industrial parts defects, the problem of insufficient image segmentation accuracy and robustness in the detection of complex industrial parts defects is solved, and high-precision target area extraction and detection efficiency are improved.

CN119887819APending Publication Date: 2025-04-25XI'AN UNIVERSITY OF ARCHITECTURE AND TECHNOLOGY
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411991490.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The prior art is difficult to achieve high-precision and high-rootability detection in the detection of defects of complex industrial parts. Especially in complex geometric feature environments, traditional image segmentation algorithms are difficult to distinguish between target areas and backgrounds, and are greatly affected by light changes and noise interference.

Method used

An image segmentation method is proposed. Through four stages: image quality optimization, preliminary target area extraction, target area screening and target area extraction, linear transformation method is used to adjust the brightness and contrast of the grayscale map, combined with the threshold segmentation method based on binarization and closed operation, the image is initially segmented, and the target outline of the specified perimeter and area range is obtained, and the target outline is used to generate a mask to extract the target area.

Benefits of technology

The precise segmentation of images of complex industrial parts is achieved, the accuracy and detection efficiency of target area extraction is significantly improved, the risks of false detection and missed detection are reduced, and high-quality segmentation results can be obtained under different lighting conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119887819A_ABST
    Figure CN119887819A_ABST
Patent Text Reader

Abstract

The invention provides an image segmentation method and system suitable for complex industrial part defect detection, and the method comprises the following specific steps: obtaining a gray-scale map of an industrial part, adjusting the brightness and contrast of the gray-scale map through a linear transformation method, and obtaining an adjusted map; performing preliminary segmentation on the adjustment graph by using a threshold segmentation method based on binaryzation and closed operation to obtain a segmented graph; obtaining a target contour of a specified perimeter and area range on the segmented image; and generating a mask by using the target contour, and extracting a corresponding target region in the grey-scale map of the industrial part. The method serves as a preposed step of defect detection, and accurate segmentation of the image is achieved through four stages of image quality optimization, preliminary target area extraction, target area screening and target area extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to image processing technology, and specifically relates to an image segmentation method and system suitable for complex industrial parts defect detection, which can realize high-precision target area extraction in a complex geometric feature environment. Background Art

[0002] In the field of industrial manufacturing, with the continuous advancement of production technology, the requirements for the surface quality of parts are getting higher and higher. Defect detection of industrial parts has become an important link in ensuring product quality. The main task of this link is to accurately identify and locate possible defects on the surface of parts, such as cracks, pores, scratches and pits, etc. These defects will directly affect the performance and service life of the parts, and even cause the function of the entire product to fail. Therefore, how to complete defect detection efficiently and accurately is an urgent problem to be solved in industrial production.

[0003] Traditional industrial parts defect detection methods mainly rely on manual work, that is, visual inspection or using magnifying equipment to observe the surface of the parts to determine whether there are defects. However, there are many shortcomings in manual inspection. First, manual inspection is inefficient and it is difficult to meet the needs of large-scale and high-efficiency production in modern industry; second, the reliability of the inspection results depends on the operator's experience and subjective judgment, which easily leads to poor consistency; in addition, manual inspection costs are high, especially in the inspection of complex parts, which requires a lot of manpower investment; finally, in the face of complex backgrounds and small defects, manual methods are difficult to achieve high-precision and high-robustness inspection.

[0004] With the development of automation technology, automated inspection methods based on image processing have gradually become mainstream. This type of method collects two-dimensional images of the surface of parts and uses computer vision technology to process the images, thereby realizing automatic identification and positioning of defects. Although image-based automated inspection methods have overcome many defects of manual inspection, they still face some technical difficulties in practical applications: first, the surface of industrial parts usually has complex textures or patterns, and traditional image segmentation algorithms are difficult to effectively distinguish the target area from the background; second, due to changes in lighting conditions, uneven brightness often occurs in the captured images, affecting the extraction of the target area; in addition, the defects of industrial parts have various forms, including differences in size, shape and position, and existing segmentation methods often perform poorly in dealing with such diversity; finally, noise interference in the shooting environment (such as surface stains, light spots, etc.) will further reduce the accuracy of image segmentation. Summary of the invention

[0005] In order to solve the problems existing in the prior art, the present invention provides an image segmentation method and system suitable for defect detection of complex industrial parts. As a prerequisite for defect detection, accurate image segmentation is achieved through four stages: image quality optimization, preliminary target area extraction, target area screening, and target area extraction.

[0006] To achieve the above object, the present invention provides the following technical solution: an image segmentation method suitable for defect detection of complex industrial parts, the specific steps are as follows: Obtain a grayscale image of an industrial part, and use a linear transformation method to adjust the brightness and contrast of the grayscale image to obtain an adjusted image; The adjustment image is segmented initially using a threshold segmentation method based on binarization and a closing operation to obtain a segmentation image; Get the target contour with specified perimeter and area range on the segmentation map; The mask is generated using the target contour to extract the corresponding target area in the grayscale image of the industrial part.

[0007] Furthermore, the grayscale image of the industrial parts is captured by a high-precision 3D camera. When the grayscale image is linearly transformed, the brightness and contrast of the grayscale image are adjusted by the contrast gain coefficient and the brightness offset, as follows:

[0008] in, is the original grayscale image at position The pixel value at , ranges from [0,255], The adjusted image is at position The pixel value at is the contrast gain coefficient, is the brightness offset; if is less than 0, set it to 0; if If it is greater than 255, set it to 255; otherwise, leave it unchanged.

[0009] Furthermore, the adjustment image is preliminarily segmented using a threshold segmentation method based on binarization and a closing operation to obtain the segmentation image: The threshold segmentation method for binarization is to compare each pixel value of the adjustment image with the set threshold:

[0010] in, is the pixel value of the original image, is the set threshold, is the pixel value of the processed binary image.

[0011] Furthermore, the binary processed image is preliminarily segmented using a closing operation, which includes a dilation operation and an erosion operation; The dilation operation is used to expand the foreground of the image after threshold segmentation, specifically:

[0012] in, is the pixel value of the original input image; is a structural element, specifically a matrix with a neighborhood range of 3×3, Is a structural element Each element in represents the expansion operation, is the expanded image at position The pixel value at ; Use the erosion operation to shrink the foreground area, remove the expanded part after dilation, and repair the edge of the object. Specifically:

[0013] in, is the pixel value of the original input image, is a structural element, represents the corrosion operation, Represents the image after erosion.

[0014] Furthermore, in the step of obtaining the target contour of the specified perimeter and area range on the segmentation map: the boundary of the foreground object in the segmentation map is extracted by a contour extraction algorithm, and the perimeter and area of ​​the extracted contour are calculated in sequence. The contour that meets the following conditions is a valid target contour:

[0015] in, is the perimeter of the contour, is the minimum perimeter set, is the maximum perimeter; is the area of ​​the contour, is the minimum area set, is the maximum area.

[0016] Furthermore, the contour extraction algorithm uses the 8-connectivity type to determine the connectivity between pixels; The perimeter of a contour is the sum of the distances between all pixels on the contour boundary. It can be expressed as:

[0017] in, Represents the Euclidean distance between two pixels; The area of ​​the contour is obtained by calculating the number of pixels within the area enclosed by the contour. It is expressed as:

[0018] in, Indicates that the area of ​​each contour pixel is a unit area.

[0019] The present invention also provides an image segmentation system suitable for complex industrial parts defect detection, comprising: An image adjustment module is used to obtain a grayscale image of an industrial part and use a linear transformation method to adjust the brightness and contrast of the grayscale image to obtain an adjusted image; The image segmentation module uses a threshold segmentation method based on binarization and a closing operation to perform preliminary segmentation on the adjustment image to obtain a segmentation image; Contour acquisition module, used to obtain the target contour of the specified perimeter and area range on the segmentation map; The target region recognition module is used to generate a mask using the target contour and extract the corresponding target region in the grayscale image of the industrial part.

[0020] The present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the above-mentioned image segmentation method applicable to defect detection of complex industrial parts are implemented.

[0021] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned image segmentation method suitable for complex industrial parts defect detection are implemented.

[0022] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the above-mentioned image segmentation method suitable for complex industrial part defect detection.

[0023] Compared with the prior art, the present invention has at least the following beneficial effects: The present invention proposes an image segmentation method suitable for defect detection of complex industrial parts. Through four detailed stages of image quality optimization, preliminary target area extraction, target area screening and target area extraction, accurate segmentation of complex industrial parts images is achieved. This method not only significantly improves the accuracy of target area extraction, but also greatly improves the detection efficiency. The use of linear transformation technology optimizes the brightness and contrast of the image, making the boundary between the target area and the background clearer, thereby reducing the risk of false detection and missed detection. In addition, combined with threshold segmentation and morphological operations, the present invention can cope with complex industrial parts surfaces and variable lighting conditions, ensuring that high-quality segmentation results can be obtained in different environments.

[0024] The image segmentation system of the present invention has high adaptability and reliability. The system's built-in image adjustment module, image segmentation module, contour acquisition module and target area recognition module work together to form a complete processing flow. This process not only achieves effective image segmentation, but also ensures that the extracted target area meets the detection requirements through strict contour screening and mask generation technology. This high adaptability and reliability enables the present invention to be widely used in defect detection of various complex industrial parts, providing a strong guarantee for quality control in the production process.

[0025] The image segmentation method of the present invention not only improves the accuracy and efficiency of defect detection of complex industrial parts, but also promotes the development of industrial automation and intelligence. By introducing advanced image processing technology and algorithms, the present invention realizes the rapid and accurate segmentation of industrial part images, providing high-quality image input for subsequent defect detection and classification. The successful application of this technology not only reduces the cost and time of manual detection, but also improves the accuracy and reliability of detection, providing strong support for the automation and intelligent transformation of industrial production. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 This is an overall flow chart of an image segmentation method suitable for complex industrial parts defect detection according to the present invention; Figure 2 This is a comparison chart of the image effects before and after adjusting the image brightness and contrast through linear transformation; Figure 3 This is the preliminary segmentation effect of combining threshold segmentation with morphological operations; Figure 4 To count all the outline diagrams; Figure 5 To filter the desired target area according to the threshold rule; Figure 6 The generated mask is applied to the original grayscale image.

[0027] Figure 7This is an image processed by the adaptive threshold method and the Canny edge detection algorithm. DETAILED DESCRIPTION

[0028] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0029] See also Figure 1 The present invention provides an image segmentation method suitable for defect detection of complex industrial parts. First, the brightness and contrast of the grayscale image taken by a high-precision 3D camera are adjusted by a linear transformation method, so as to balance the grayscale distribution of the image and improve the overall image quality; the image is subjected to a threshold segmentation combined with a morphological operation to extract the target area and form a preliminary segmentation result; the segmented image is further screened to retain only the target contours that meet the specified range to ensure the accuracy of the target area; a mask is generated using the screened contours to extract the corresponding target area in the original grayscale image for subsequent defect detection, which specifically includes the following steps: S1. For the grayscale image taken by the high-precision 3D camera, the brightness and contrast of the image are adjusted by linear transformation method. The image effects before and after adjustment are as follows: Figure 2 shown.

[0030] In step S1, the brightness and contrast of the grayscale image captured by the high-precision 3D camera are adjusted by a linear transformation method as follows: In the preprocessing stage of image processing, the brightness and contrast of the grayscale image taken by the high-precision 3D camera are first adjusted. Since the original image may have uneven brightness or insufficient contrast due to factors such as shooting angle and lighting changes, the brightness and contrast adjustment can enhance the details of the image, making the target area more prominent and clear in the subsequent processing. The specific method uses the linear transformation method:

[0031] in, is the original grayscale image at position The pixel value at , ranges from [0,255], The adjusted image is at position The pixel value at is the contrast gain coefficient, Brightness offset. According to the image and workpiece characteristics, select Highlight details in the image and increase Boosts the brightness of all pixels to improve low-light performance.

[0032] In order to prevent the image brightness or contrast from being over-adjusted, which may cause image distortion or information loss, saturation processing is performed on the adjusted pixel values.

[0033] Specifically, if is less than 0, set it to 0; if If it is greater than 255, set it to 255; otherwise, leave it unchanged.

[0034] S2. Use the threshold segmentation method based on binarization combined with the closing operation to perform preliminary segmentation on the image. The preliminary segmentation effect is as follows: Figure 3 shown.

[0035] In step S2, a threshold segmentation method based on binarization is combined with a closing operation to perform preliminary segmentation of the image as follows: S201, in the preliminary processing stage of image segmentation, a binarization process is applied to compare each pixel value of the image with a set threshold value:

[0036] in, is the pixel value of the original image, is the set threshold, is the pixel value of the processed binary image.

[0037] S202, using dilation operation to expand the foreground (white pixels) of the image after threshold segmentation, and fill small holes or defects. Specifically:

[0038] in, is the pixel value of the original input image; is the structural element, which is a 3×3 matrix that defines the neighborhood range. Is a structural element Each element in represents the expansion operation, is the expanded image at position For each pixel in the image, check the pixel values ​​of the pixel and its surrounding neighborhood. If the current pixel in the image is the foreground (white pixel, value 1), the neighboring pixels around the pixel (according to the definition of the structure element) will also be assigned the foreground value. The structure element determines the extension range of the dilation operation.

[0039] S203, using corrosion operation to reduce the foreground area, remove the part expanded after dilation, and repair the edge of the object:

[0040] in, is the pixel value of the original input image, is a structural element, represents the corrosion operation, Represents the image after erosion.

[0041] The closing operation is achieved by first performing the expansion in step S202 and then performing the erosion in step S203. This combined operation can remove small black holes or cracks in the image and close the holes inside the foreground object.

[0042] S3. Further filter the segmented image to retain only the target contours that meet the specified perimeter and area range. All the contours counted are as follows: Figure 4 As shown; In step S3, the segmented image is further screened to retain only the target contours that meet the specified perimeter and area range. Specifically: S301: Based on the segmented image in step S2, the boundary of the foreground object in the image is extracted by using a contour extraction algorithm. First, the starting point of the contour is found, and a foreground pixel in the image is extracted. To begin, select an adjacent foreground pixel , and check if the pixel is a neighbor of a background pixel. If it is a neighbor of a background pixel, the pixel is considered the starting point of the contour.

[0043] From the starting point Start by selecting the next adjacent foreground pixel , the pixel must also be a foreground pixel and adjacent to the background pixel. By sequential tracking until you return to the starting point , forming a closed path:

[0044] in, is the number of contour points, is the distance between adjacent contour points. Once a closed path of the contour is found, the image will continue to be scanned to find the next foreground pixel , and recursively extract all possible contours from this pixel.

[0045] Connectivity is used in contour extraction algorithms to determine which pixels belong to the contour of the same object. Specifically, the 8-connectivity type is used:

[0046] Among them, two pixels are considered to be connected if they are adjacent in the horizontal, vertical or diagonal direction. Represents pixels The set of 8 neighbor pixels of is with Pixels with connectivity.

[0047] S302, calculate the perimeter and area of ​​the extracted contours in turn. The perimeter of the contour is the sum of the distances between all pixels on the contour boundary. Assume that the contour is composed of pixels, the perimeter It can be expressed as:

[0048] in, represents the Euclidean distance between two pixels. The area of ​​a contour can be obtained by counting the number of pixels within the area enclosed by the contour. Assume that the contour contains pixels, then the area It can be expressed as:

[0049] in, Indicates that the area of ​​each contour pixel is a unit area. According to the set perimeter and area range, the contours that meet the conditions are filtered out. Only contours that meet the following two conditions will be retained:

[0050] in, is the minimum perimeter set, is the maximum perimeter; is the minimum area set, is the maximum area; these eligible contours are considered valid target contours.

[0051] S4. Generate a mask using the filtered contour to extract the corresponding target area in the original grayscale image.

[0052] In the above scheme, in step S4, a mask is generated using the filtered contour to extract the corresponding target area in the original grayscale image. Specifically: Create a grayscale image based on the filtered contours For images of the same size, the initial value of the mask image is zero:

[0053] Among them, the mask image Only used to mark the target area, a value of 1 indicates the target area, and a value of 0 indicates the background area.

[0054] For each filtered contour , fill the area surrounded by the contour with 1 in the mask image, that is:

[0055] here, It is the outline The filling operation is implemented by contour region marking. Specifically, a breadth-first search (BFS) identifies all connected regions. By traversing each connected region, it is determined whether it is inside the target contour and a unique label value is assigned to these regions. In this process, all pixels belonging to the contour are marked as the target region. Figure 5 shown.

[0056] like Figure 6 As shown, using the generated mask From the original grayscale image The target area is extracted by performing a bitwise product operation on the mask image and the original grayscale image. :

[0057] Among them, when the mask When , the corresponding pixel value in the original image is retained ; When the mask When the target area image The corresponding pixel value in is set to 0, that is, the background part is not retained. In this way, the target area is successfully extracted from the original grayscale image.

[0058] The method proposed in the present invention uses a multi-stage image processing process and a linear transformation method to optimize the brightness and contrast of the image, thereby enhancing the image details, making the target area easier to separate, and effectively improving the precision and accuracy of target area extraction. The morphological operation is combined with threshold segmentation to extract the preliminary target area, which can effectively cope with the complex surface of industrial parts and changing lighting conditions. The screening algorithm based on perimeter and area strictly screens out irrelevant contours, and finally uses masking technology to accurately map the target area back to the original image. Through step-by-step optimization and precise extraction, the present invention finally achieves high-precision image segmentation of target areas in complex scenes, and can efficiently extract target areas that meet the requirements, ensuring the accuracy and reliability of subsequent defect detection.

[0059] The following are device embodiments of the present invention, which can be used to perform method embodiments of the present invention. For details not disclosed in the device embodiments, please refer to the method embodiments of the present invention.

[0060] In one embodiment of the present invention, an image segmentation system suitable for complex industrial parts defect detection is also provided. The system can implement the steps of an image segmentation method suitable for complex industrial parts defect detection. The system includes: an image adjustment module, an image segmentation module, a contour acquisition module and a target area recognition module. Specifically: An image adjustment module is used to obtain a grayscale image of an industrial part and use a linear transformation method to adjust the brightness and contrast of the grayscale image to obtain an adjusted image; The image segmentation module uses a threshold segmentation method based on binarization and a closing operation to perform preliminary segmentation on the adjustment image to obtain a segmentation image; Contour acquisition module, used to obtain the target contour of the specified perimeter and area range on the segmentation map; The target region recognition module is used to generate a mask using the target contour and extract the corresponding target region in the grayscale image of the industrial part.

[0061] In another embodiment of the present invention, a terminal device is provided, the terminal device includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc., which are the computing core and control core of the terminal, which are suitable for implementing one or more instructions, and are specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding functions; the processor described in the embodiment of the present invention can be a method for image segmentation suitable for defect detection of complex industrial parts.

[0062] In another embodiment of the present invention, the present invention further provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It is understandable that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and the extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the above-mentioned embodiment related to an image segmentation method suitable for complex industrial parts defect detection.

[0063] The adaptive threshold method refers to dynamically calculating the threshold of each pixel based on the local features of different areas of the image, rather than using a global fixed threshold. For industrial parts with rough surfaces and complex geometric shapes, dynamically calculating the threshold based on local features often leads to blurred boundaries between different parts, misjudgment in grayscale transition areas, and some parts that should have regular shapes become irregular, making it impossible to accurately segment the target area.

[0064] The Canny edge detection algorithm includes Gaussian filtering, gradient calculation, non-maximum suppression and dual threshold detection, and can detect real edges. This traditional edge detection method is only applicable to images with smooth surfaces, uniform lighting, and a very large difference between the target area and the background. It is not applicable to metal industrial parts with rough surfaces. It will detect the rough surface as an edge, but the actual edge cannot be detected, and the detected edge is easily disconnected due to the difference in pixel values.

[0065] The two commonly used segmentation methods mentioned above are Figure 7 As shown, the method of the present invention Figure 3 and Figure 4 By comparison, it can be clearly seen that the target area after the initial segmentation by the method of the present invention is not affected by the surface roughness. The target area after segmentation is smooth and noise-free, and the edge contour is clear and smooth and not adhered to other parts. For workpieces with complex shapes, the segmentation target area can also be accurately extracted for subsequent image defect detection tasks.

[0066] In terms of computational efficiency, the method of the present invention uses a unified threshold method, which reduces the threshold calculation time compared to the dynamic threshold. At the same time, the subsequent closed operation reduces the impact of image illumination changes. On the basis of reducing time costs, the segmentation accuracy is improved and is suitable for actual industrial image processing.

[0067] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods and systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0068] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, 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 generate 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 flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0069] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0070] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0071] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. An image segmentation method suitable for defect detection of complex industrial parts, characterized in that: The specific steps are as follows: Obtain a grayscale image of an industrial part, and use a linear transformation method to adjust the brightness and contrast of the grayscale image to obtain an adjusted image; The adjustment image is segmented initially using a threshold segmentation method based on binarization and a closing operation to obtain a segmentation image; Get the target contour with specified perimeter and area range on the segmentation map; The mask is generated using the target contour to extract the corresponding target area in the grayscale image of the industrial part.

2. The image segmentation method for complex industrial parts defect detection according to claim 1, characterized in that: The grayscale image of the industrial parts is taken with a high-precision 3D camera. When the grayscale image is linearly transformed, the brightness and contrast of the grayscale image are adjusted by the contrast gain coefficient and the brightness offset, as follows: in, is the original grayscale image at position The pixel value at , ranges from [0,255], The adjusted image is at position The pixel value at is the contrast gain coefficient, is the brightness offset; if is less than 0, set it to 0; if If it is greater than 255, set it to 255; otherwise, leave it unchanged.

3. The image segmentation method suitable for complex industrial parts defect detection according to claim 1, characterized in that: The adjustment image is segmented initially using a threshold segmentation method based on binarization and a closing operation to obtain the segmentation image: The threshold segmentation method for binarization is to compare each pixel value of the adjustment image with the set threshold: in, is the pixel value of the original image, is the set threshold, is the pixel value of the processed binary image.

4. The image segmentation method suitable for complex industrial parts defect detection according to claim 3 is characterized in that: The binary processed image is preliminarily segmented using a closing operation, which includes a dilation operation and an erosion operation; The dilation operation is used to expand the foreground of the image after threshold segmentation, specifically: in, is the pixel value of the original input image; is a structural element, specifically a matrix with a neighborhood range of 3×3, Is a structural element Each element in represents the expansion operation, is the expanded image at position The pixel value at ; Use the erosion operation to shrink the foreground area, remove the expanded part after dilation, and repair the edge of the object. Specifically: in, is the pixel value of the original input image, is a structural element, represents the corrosion operation, Represents the image after erosion.

5. The image segmentation method suitable for complex industrial parts defect detection according to claim 1, characterized in that: In the step of obtaining the target contour with the specified perimeter and area range on the segmentation map: the boundary of the foreground object in the segmentation map is extracted by the contour extraction algorithm, and the perimeter and area of ​​the extracted contour are calculated in sequence. The contour that meets the following conditions is a valid target contour: in, is the perimeter of the contour, is the minimum perimeter set, is the maximum perimeter; is the area of ​​the contour, is the minimum area set, is the maximum area.

6. The image segmentation method suitable for complex industrial parts defect detection according to claim 5, characterized in that: The contour extraction algorithm uses the 8-connectivity type to determine the connectivity between pixels; The perimeter of a contour is the sum of the distances between all pixels on the contour boundary. It can be expressed as: in, Represents the Euclidean distance between two pixels; The area of ​​the contour is obtained by calculating the number of pixels within the area enclosed by the contour. It is expressed as: in, Indicates that the area of ​​each contour pixel is a unit area.

7. An image segmentation system suitable for complex industrial parts defect detection, characterized in that: include: An image adjustment module is used to obtain a grayscale image of an industrial part and use a linear transformation method to adjust the brightness and contrast of the grayscale image to obtain an adjusted image; The image segmentation module uses a threshold segmentation method based on binarization and a closing operation to perform preliminary segmentation on the adjustment image to obtain a segmentation image; Contour acquisition module, used to obtain the target contour of the specified perimeter and area range on the segmentation map; The target region recognition module is used to generate a mask using the target contour and extract the corresponding target region in the grayscale image of the industrial part.

8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of an image segmentation method suitable for complex industrial parts defect detection as described in any one of claims 1 to 7 are implemented.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of an image segmentation method suitable for complex industrial parts defect detection as described in any one of claims 1 to 7 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of an image segmentation method suitable for complex industrial parts defect detection as described in any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Appearance defect detection method and device and application thereof

    CN120747061A

  • Cutting positioning method and system for semiconductor slicing machine

    CN120782865A

  • Star map stray light processing method based on multidirectional gradient

    CN121074076A