Optical machined part defect detection method based on image technology

The defect edges of optical machining parts are extracted through image acquisition and Canny edge detection algorithms, and combined with the support vector machine model, the problem of the reduction in accuracy of traditional detection methods in complex backgrounds is solved, and efficient and stable defect identification and distinction are achieved.

CN119205644APending Publication Date: 2024-12-27YANGZHOU HONGBOYING OPTOELECTRONICS TECHNOLOGY CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411221860.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Traditional optical machine defect detection methods are difficult to accurately extract defect edges under complex backgrounds or uneven lighting conditions, and it is difficult to distinguish different types of defects, and it is impossible to quickly adapt to new defect types, resulting in a decrease in detection accuracy.

Method used

Using image technology-based detection methods, including image acquisition, preprocessing, edge detection, feature extraction and machine learning model training, using Canny edge detection algorithm and support vector machine model, the model performance is evaluated through cross-validation to ensure that the model has a good generalization ability to transform.

Benefits of technology

It realizes accurate extraction of defect edges and distinction between different types of defects in complex contexts, improves the reliability and stability of detection, can adapt to various situations, and improves detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119205644A_ABST
    Figure CN119205644A_ABST
Patent Text Reader

Abstract

The invention discloses an optical machined part defect detection method based on an image technology, and belongs to the technical field of optical machined part detection, in the method, a defect edge in an image is extracted through a Canny edge detection algorithm, a defect area can be effectively separated from a background area, and a foundation is laid for subsequent feature extraction and defect recognition. The segmentation technology has the advantages that the contour of the defect can be accurately defined, and high detection precision can be kept even under the background of complex textures or uneven illumination. In addition, the non-maximum suppression and double-threshold detection mechanism of the Canny algorithm is helpful for reducing false detection and missing detection, and the detection reliability is improved. And extracting shape, texture and statistical features from the segmented defect region, wherein the features are keys for distinguishing different types of defects. Different types of defects can be effectively distinguished through feature extraction, and classification errors are reduced. The calculation amount of subsequent model training and recognition can be reduced, and the efficiency of the whole detection process is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of optical processed part detection, and in particular relates to an optical processed part defect detection method based on image technology. Background Art

[0002] Optical processed parts mainly include lenses, mirrors, prisms, windows, etc. Their processing technology is complex and has extremely high requirements for materials, shapes, sizes and surface quality. Optical processed parts are an important part of the field of precision manufacturing and are widely used in optical instruments, cameras, fiber optic communications and other fields. The quality of optical processed parts directly affects the performance of the final product. The production process of optical processed parts is roughly as follows: Material selection: Use high-purity optical glass or crystal to ensure optical performance. Cutting and rough grinding: Cut the material into the required shape and perform rough grinding to form a basic outline. Fine grinding and polishing: Through fine grinding and polishing, the surface of the optical processed parts reaches the specified smoothness and precision. Inspection: Strict quality inspection of optical processed parts to ensure that they meet the design requirements.

[0003] However, traditional edge detection methods may not be able to accurately extract defect edges under complex backgrounds or uneven lighting conditions, resulting in reduced accuracy in defect recognition. At the same time, the features extracted by some methods may not be sufficient to distinguish different types of defects, or may not be stable enough when the image changes. When new defect types appear, traditional detection methods may be difficult to adapt quickly and require the detection strategy to be redesigned. Summary of the invention

[0004] The purpose of the present invention is to provide an optical workpiece defect detection method based on image technology in order to solve the above-mentioned problems.

[0005] The technical solution adopted by the present invention is as follows: a method for detecting defects of optical processed parts based on image technology, the method comprising the following steps:

[0006] S1: First, perform image acquisition and build an image acquisition system to ensure that hardware equipment such as cameras, lenses, and light sources work properly;

[0007] S2: Perform image preprocessing and grayscale conversion to convert the collected color image into a grayscale image to reduce the computational complexity. Then perform image denoising: use the mean filter method to remove image noise. Finally, perform image binarization: by setting a suitable threshold, convert the grayscale image into a binary image for subsequent processing;

[0008] S3: Perform image segmentation and use the Canny edge detection algorithm to extract the defect edges in the image. According to the edge information, perform regional segmentation on the image to separate the defect area and the background area;

[0009] S4: performing feature extraction, extracting features from the segmented defect area;

[0010] S5: Use the extracted features to train a machine learning model;

[0011] S6: Evaluate model performance through methods such as cross-validation to ensure that the model has good generalization ability;

[0012] S7: perform defect recognition: input the preprocessed image into the trained model to identify defects in the image;

[0013] S8: Output the inspection results in the form of images or reports, marking the defect location and type;

[0014] S9: According to the detection results, the optical parts are classified, and new defect samples are continuously collected to expand the training set and improve the detection accuracy of the model. After that, the entire optical parts defect detection process based on image technology can be completed.

[0015] In a preferred embodiment, in step S1, during the image acquisition process, the light source angle and intensity are adjusted to make the defect characteristics on the surface of the optical workpiece as obvious as possible. The camera parameters, including exposure time, resolution, etc., are set to obtain high-quality images.

[0016] In a preferred embodiment, in step S2, graying the image specifically includes:

[0017] Reading color images: First, read the color image from the image acquisition system. The image is usually stored in the form of RGB (red, green and blue) three channels;

[0018] Color space conversion: Then, perform color space conversion on each pixel. Common conversion methods include average method, weighted method, etc. In the average method, the gray value II can be calculated by the following formula:

[0019] Use the following formula:

[0020] I=0.2989R+0.5870G+0.1140BI=0.2989R+0.5870G+0.1140B.

[0021] Among them, R, G, and B represent the pixel values ​​of the red, green, and blue channels respectively.

[0022] Generate grayscale image: Finally, the calculated grayscale value I is assigned to each pixel to generate a grayscale image.

[0023] In a preferred embodiment, in step S2, the specific steps of removing image noise by using the mean filtering method are as follows:

[0024] a. Determine the size of the filter window.

[0025] b. For each pixel in the image, calculate the average value of all pixels in its neighborhood.

[0026] c. Assign the calculated average value to the current pixel to complete the filtering operation;

[0027] The specific processing flow for image binarization is as follows:

[0028] a. Select threshold: Determine a suitable threshold T and use the Otsu algorithm to automatically calculate a threshold that maximizes the inter-class variance.

[0029] b. Apply threshold: For each pixel in the grayscale image, perform binarization based on the comparison between its grayscale value and the threshold value TT. If the pixel value is greater than or equal to the threshold value T, set it to white 255

[0030] ; If the pixel value is less than the threshold T, set it to black or 0.

[0031] c. Generate a binary image: Through the above steps, a binary image containing only two colors is finally generated, where white represents the foreground which is the defect area, and black represents the background.

[0032] In a preferred embodiment, in step S4, the detailed processing flow using the Canny algorithm is as follows:

[0033] a. First, use a Gaussian filter to smooth the image to reduce the impact of image noise on edge detection. Determine the Gaussian kernel size: Select an appropriate Gaussian kernel size. The Gaussian kernel size calculation formula is: (2k+1)×(2k+1), where k is the standard deviation.

[0034] b. Apply Gaussian filtering: Convolve the image with the Gaussian kernel, calculate the weighted average of each pixel and its neighborhood, and obtain a smoothed image. Then convolve the image with the Gaussian kernel, calculate the weighted average of each pixel and its neighborhood, and obtain a smoothed image.

[0035] c. Use the Sobel operator or other differential operators to calculate the gradient of the image in the horizontal (Gx) and vertical (Gy) directions; calculate the gradient magnitude and direction of each pixel in the smoothed image, which will be used for edge positioning;

[0036] d. Use non-maximum suppression to refine the edges and ensure that each edge pixel is a local gradient maximum. Compare gradient directions: For each pixel, compare its gradient magnitude with that of its neighboring pixels in the positive and negative gradient directions according to its gradient direction. Suppress non-maximum: If the gradient magnitude of the current pixel is not a local maximum, set it to 0, otherwise keep its gradient magnitude.

[0037] e. Perform dual threshold detection and edge connection. By setting two high and low thresholds, edge pixels can be further screened and edge connections can be performed.

[0038] f. Finally, all pixels marked as edges are combined to form the final edge detection result.

[0039] In a preferred embodiment, in step S4, the extracted features include:

[0040] Shape characteristics: such as area, perimeter, roundness, and rectangularity.

[0041] Texture features: such as gray-level co-occurrence matrix and local binary pattern.

[0042] Statistical characteristics: such as mean, variance, skewness, kurtosis, etc.

[0043] In a preferred embodiment, in step S5, a support vector machine model is used for training, and the formula is: Find the optimal hyperplane w T x+b=0, which maximizes the interval between positive and negative samples, where w is the normal vector and b is the intercept;

[0044] The optimization problem calculation formula is:

[0045]

[0046] The model training steps are:

[0047] a. Divide into training set and validation set.

[0048] b. Initialize model parameters.

[0049] c. Iterative training:

[0050] d. Forward propagation: calculate the predicted value and loss function.

[0051] e. Back propagation: Calculate the gradient of the loss function with respect to the model parameters.

[0052] f. Update parameters: Update model parameters according to the gradient descent algorithm.

[0053] In a preferred embodiment, in step S6, first, the data set is divided into a training set, a validation set and a test set, wherein the validation set is used to adjust the model parameters, and the test set is used to finally evaluate the model performance. Next, a cross-validation method, such as k-fold cross-validation, is used to repeatedly use different subsets of the data for training and validation to obtain a more stable evaluation result. In each iteration, the model is trained on the training set and tested on the validation set, and various performance indicators, such as accuracy, precision, recall and F1 score, are recorded. The accuracy reflects the proportion of samples correctly classified by the model, the precision measures the accuracy of the model prediction as a positive example, the recall rate indicates the ability of the model to correctly identify positive examples, and the F1 score is the harmonic mean of the precision and recall rate, which comprehensively reflects the performance of the model. By comparing the performance indicators of different models, the one with the best performance is selected as the final model. Finally, the final model is independently tested using the test set to obtain the performance expectations of the model in practical applications, ensuring that the prediction effect of the model on unknown data meets the expected standards.

[0054] In a preferred embodiment, in step S7, during the defect recognition phase, the image must be processed strictly according to the preprocessing process of the training phase, including the parameter settings of grayscale, denoising and binarization, and the threshold selection in the Canny edge detection algorithm.

[0055] In a preferred embodiment, in step S8, the output image or report should clearly mark the location and type of the defect to facilitate the operator or subsequent automated system to perform corresponding processing. To achieve this goal, it is necessary to ensure that the results output by the defect recognition model have good confidence, that is, the model has sufficient confidence in the reliability of its prediction results. For low-confidence prediction results, further verification or manual review should be carried out. At the same time, the output format should be easy for operators to understand. For example, different colors or shapes of marks can be used on the image to distinguish different types of defects, and detailed defect statistics and analysis can be provided in the report, thereby improving the transparency of the detection process and the practicality of the detection results.

[0056] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:

[0057] 1. In the present invention, the defect edge in the image is extracted by the Canny edge detection algorithm, which can effectively separate the defect area from the background area, laying the foundation for subsequent feature extraction and defect recognition. The advantage of this segmentation technology is that it can accurately define the outline of the defect and maintain a high detection accuracy even in the background of complex texture or uneven illumination. In addition, the non-maximum suppression and dual threshold detection mechanism of the Canny algorithm help reduce false detection and missed detection, and improve the reliability of detection.

[0058] 2. In the present invention, shape, texture and statistical features are extracted from the segmented defect area. These features are the key to distinguishing different types of defects. Through these feature extractions, different types of defects can be effectively distinguished and classification errors can be reduced. At the same time, the selected features have a certain robustness to image rotation, scaling and illumination changes, ensuring the stability of the detection system. By selecting representative features, the amount of calculation for subsequent model training and recognition can be reduced, and the efficiency of the entire detection process can be improved.

[0059] 3. In the present invention, the extracted features are used to train the machine learning model to automatically identify defects in the image without manual intervention, which greatly improves the detection efficiency. At the same time, through training, the model can learn the complex patterns of defects, thereby achieving a higher accuracy rate in the recognition stage. Through evaluation methods such as cross-validation, it is ensured that the model has good generalization ability and can adapt to various situations encountered in the actual production environment. With the collection of new defect samples, the model can be continuously updated and optimized to improve the adaptability and accuracy of the detection system. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 It is a schematic diagram of the process principle of the present invention. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0062] Reference Figure 1 ,

[0063] Example:

[0064] A method for detecting defects in optical processed parts based on image technology, the method comprising the following steps:

[0065] S1: First, perform image acquisition and build an image acquisition system to ensure that hardware equipment such as cameras, lenses, and light sources work properly;

[0066] S2: Perform image preprocessing and grayscale conversion to convert the collected color image into a grayscale image to reduce the computational complexity. Then perform image denoising: use the mean filter method to remove image noise. Finally, perform image binarization: by setting a suitable threshold, convert the grayscale image into a binary image for subsequent processing;

[0067] S3: Perform image segmentation and use the Canny edge detection algorithm to extract the defect edges in the image. According to the edge information, perform regional segmentation on the image to separate the defect area and the background area;

[0068] S4: performing feature extraction, extracting features from the segmented defect area;

[0069] S5: Use the extracted features to train a machine learning model;

[0070] S6: Evaluate model performance through methods such as cross-validation to ensure that the model has good generalization ability;

[0071] S7: perform defect recognition: input the preprocessed image into the trained model to identify defects in the image;

[0072] S8: Output the inspection results in the form of images or reports, marking the defect location and type;

[0073] S9: According to the detection results, the optical processed parts are classified, and new defect samples are continuously collected to expand the training set and improve the detection accuracy of the model. After that, the entire optical processed parts defect detection process based on image technology can be completed.

[0074] In step S1, during the image acquisition process, the light source angle and intensity are adjusted to make the defect features on the surface of the optical workpiece as obvious as possible. The camera parameters, including exposure time, resolution, etc., are set to obtain high-quality images.

[0075] In step S2, the image grayscale conversion specifically includes:

[0076] Reading color images: First, read the color image from the image acquisition system. The image is usually stored in the form of RGB (red, green and blue) three channels;

[0077] Color space conversion: Then, perform color space conversion on each pixel. Common conversion methods include average method, weighted method, etc. In the average method, the gray value II can be calculated by the following formula:

[0078] Use the following formula:

[0079] I=0.2989R+0.5870G+0.1140BI=0.2989R+0.5870G+0.1140B.

[0080] Among them, R, G, and B represent the pixel values ​​of the red, green, and blue channels respectively.

[0081] Generate grayscale image: Finally, assign the calculated grayscale value I to each pixel to generate a grayscale image

[0082] In step S2, the specific steps of using the mean filtering method to remove image noise are as follows:

[0083] a. Determine the size of the filter window.

[0084] b. For each pixel in the image, calculate the average value of all pixels in its neighborhood.

[0085] c. Assign the calculated average value to the current pixel to complete the filtering operation;

[0086] The specific processing flow for image binarization is as follows:

[0087] a. Select threshold: Determine a suitable threshold T and use the Otsu algorithm to automatically calculate a threshold that maximizes the inter-class variance.

[0088] b. Apply threshold: For each pixel in the grayscale image, perform binarization based on the comparison between its grayscale value and the threshold value TT. If the pixel value is greater than or equal to the threshold value T, it is set to white 255; if the pixel value is less than the threshold value T, it is set to black or 0.

[0089] c. Generate a binary image: Through the above steps, a binary image containing only two colors is finally generated, where white represents the foreground which is the defect area, and black represents the background.

[0090] In step S4, the detailed processing flow using the Canny algorithm is as follows:

[0091] a. First, use a Gaussian filter to smooth the image to reduce the impact of image noise on edge detection. Determine the Gaussian kernel size: Select an appropriate Gaussian kernel size. The Gaussian kernel size calculation formula is: (2k+1)×(2k+1), where k is the standard deviation.

[0092] b. Apply Gaussian filtering: Convolve the image with the Gaussian kernel, calculate the weighted average of each pixel and its neighborhood, and obtain a smoothed image. Then convolve the image with the Gaussian kernel, calculate the weighted average of each pixel and its neighborhood, and obtain a smoothed image.

[0093] c. Use the Sobel operator or other differential operators to calculate the gradient of the image in the horizontal (Gx) and vertical (Gy) directions; calculate the gradient magnitude and direction of each pixel in the smoothed image, which will be used for edge positioning;

[0094] d. Use non-maximum suppression to refine the edges and ensure that each edge pixel is a local gradient maximum. Compare gradient directions: For each pixel, compare its gradient magnitude with that of its neighboring pixels in the positive and negative gradient directions according to its gradient direction. Suppress non-maximum: If the gradient magnitude of the current pixel is not a local maximum, set it to 0, otherwise keep its gradient magnitude.

[0095] e. Perform dual threshold detection and edge connection. By setting two high and low thresholds, edge pixels can be further screened and edge connections can be performed.

[0096] f. Finally, all pixels marked as edges are combined to form the final edge detection result.

[0097] In step S4, the extracted features include:

[0098] Shape characteristics: such as area, perimeter, roundness, and rectangularity.

[0099] Texture features: such as gray-level co-occurrence matrix and local binary pattern.

[0100] Statistical characteristics: such as mean, variance, skewness, kurtosis, etc.

[0101] In step S5, the support vector machine model is used for training. The formula is: Find the optimal hyperplane w T x+b=0, which maximizes the interval between positive and negative samples, where w is the normal vector and b is the intercept;

[0102] The optimization problem calculation formula is:

[0103]

[0104] The model training steps are:

[0105] a. Divide into training set and validation set.

[0106] b. Initialize model parameters.

[0107] c. Iterative training:

[0108] d. Forward propagation: calculate the predicted value and loss function.

[0109] e. Back propagation: Calculate the gradient of the loss function with respect to the model parameters.

[0110] f. Update parameters: Update model parameters according to the gradient descent algorithm.

[0111] In step S6, first, the data set is divided into a training set, a validation set, and a test set, wherein the validation set is used to adjust the model parameters, and the test set is used to finally evaluate the model performance. Next, a cross-validation method, such as k-fold cross-validation, is used to repeatedly use different subsets of the data for training and validation to obtain a more stable evaluation result. In each iteration, the model is trained on the training set and tested on the validation set, and various performance indicators, such as accuracy, precision, recall, and F1 score, are recorded. The accuracy reflects the proportion of samples correctly classified by the model, the precision measures the accuracy of the model's prediction as a positive example, the recall indicates the model's ability to correctly identify positive examples, and the F1 score is the harmonic mean of the precision and recall, which comprehensively reflects the performance of the model. By comparing the performance indicators of different models, the one with the best performance is selected as the final model. Finally, the final model is independently tested using the test set to obtain the performance expectations of the model in practical applications, ensuring that the prediction effect of the model on unknown data meets the expected standards.

[0112] In step S7, during the defect recognition phase, the image must be processed strictly according to the preprocessing process of the training phase, including the parameter settings of grayscale, denoising and binarization, and the threshold selection in the Canny edge detection algorithm.

[0113] In step S8, the output image or report should clearly mark the location and type of the defect to facilitate the operator or subsequent automated system to perform corresponding processing. To achieve this goal, it is necessary to ensure that the results output by the defect recognition model have good confidence, that is, the model has sufficient confidence in the reliability of its prediction results. For low-confidence prediction results, further verification or manual review should be carried out. At the same time, the output format should be easy for operators to understand. For example, different colors or shapes of marks can be used on the image to distinguish different types of defects, and detailed defect statistics and analysis can be provided in the report, thereby improving the transparency of the detection process and the practicality of the detection results.

[0114] In the present invention, the defect edge in the image is extracted by the Canny edge detection algorithm, which can effectively separate the defect area from the background area, laying the foundation for subsequent feature extraction and defect recognition. The advantage of this segmentation technology is that it can accurately define the outline of the defect and maintain a high detection accuracy even in the background of complex texture or uneven illumination. In addition, the non-maximum suppression and dual threshold detection mechanism of the Canny algorithm help reduce false detection and missed detection, and improve the reliability of detection.

[0115] In the present invention, shape, texture and statistical features are extracted from the segmented defect area. These features are the key to distinguishing different types of defects. Through these feature extractions, different types of defects can be effectively distinguished, reducing classification errors. At the same time, the selected features have a certain robustness to image rotation, scaling and illumination changes, ensuring the stability of the detection system. By selecting representative features, the amount of calculation for subsequent model training and recognition can be reduced, and the efficiency of the entire detection process can be improved.

[0116] In the present invention, the extracted features are used to train the machine learning model to automatically identify defects in the image without manual intervention, which greatly improves the detection efficiency. At the same time, through training, the model can learn the complex patterns of defects, thereby achieving a higher accuracy rate in the recognition stage. Through evaluation methods such as cross-validation, it is ensured that the model has good generalization ability and can adapt to various situations encountered in the actual production environment. With the collection of new defect samples, the model can be continuously updated and optimized to improve the adaptability and accuracy of the detection system.

[0117] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0118] The above description enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting defects in optical workpieces based on image technology, characterized in that: The method comprises the following steps: S1: First, perform image acquisition and build an image acquisition system to ensure that the camera, lens, and light source hardware equipment work properly; S2: Perform image preprocessing and grayscale conversion to convert the collected color image into a grayscale image to reduce the computational complexity; then perform image denoising: use the mean filter method to remove image noise; finally perform image binarization: by setting a suitable threshold, convert the grayscale image into a binary image for subsequent processing; S3: Perform image segmentation and use the Canny edge detection algorithm to extract the defect edges in the image; perform regional segmentation on the image based on the edge information to separate the defect area and the background area; S4: performing feature extraction, extracting features from the segmented defect area; S5: Use the extracted features to train a machine learning model; S6: Evaluate model performance through cross-validation method to ensure that the model has good generalization ability; S7: perform defect recognition: input the preprocessed image into the trained model to identify defects in the image; S8: Output the inspection results in the form of images or reports, marking the defect location and type; S9: According to the detection results, the optical processed parts are classified, and new defect samples are continuously collected to expand the training set and improve the detection accuracy of the model. After that, the entire optical processed parts defect detection process based on image technology can be completed.

2. The optical workpiece defect detection method based on image technology according to claim 1, characterized in that: In the step S1, the angle and intensity of the light source are adjusted during the image acquisition process to make the defect features on the surface of the optical workpiece as obvious as possible; Set the camera parameters, including exposure time and resolution, to obtain high-quality images.

3. The optical workpiece defect detection method based on image technology as claimed in claim 1, characterized in that: In step S2, graying the image specifically includes: Reading color images: First, read the color image from the image acquisition system. The image is usually stored in the form of RGB (red, green and blue) three channels; Color space conversion: Then, each pixel is converted into a color space. Common conversion methods include the average method and the weighted method. In the average method, the gray value II is calculated by the following formula: Use the following formula: I=0.2989R+0.5870G+0.1140BI=0.2989R+0.5870G+0.1140B; Among them, R, G, and B represent the pixel values ​​of the red, green, and blue channels respectively; Generate grayscale image: Finally, the calculated grayscale value I is assigned to each pixel to generate a grayscale image.

4. The optical workpiece defect detection method based on image technology as claimed in claim 1, characterized in that: In step S2, the specific steps of using the mean filtering method to remove image noise are as follows: a. Determine the size of the filter window; b. For each pixel in the image, calculate the average value of all pixels in its neighborhood; c. Assign the calculated average value to the current pixel to complete the filtering operation; The specific processing flow for image binarization is as follows: a. Select threshold: determine a suitable threshold T and use the Otsu algorithm to automatically calculate a threshold that maximizes the inter-class variance; b. Apply threshold: For each pixel in the grayscale image, perform binarization based on the comparison between its grayscale value and the threshold value TT; if the pixel value is greater than or less than the threshold value T, set it to white 255; if the pixel value is less than the threshold value T, set it to black or 0; c. Generate a binary image: Through the above steps, a binary image containing only two colors is finally generated, where white represents the foreground which is the defect area, and black represents the background.

5. The optical workpiece defect detection method based on image technology as claimed in claim 1, characterized in that: In step S4, the detailed processing flow using the Canny algorithm is as follows: a. First, use a Gaussian filter to smooth the image to reduce the impact of image noise on edge detection; determine the Gaussian kernel size: select an appropriate Gaussian kernel size. The Gaussian kernel size calculation formula is: (2k+1)×(2k+1), where k is the standard deviation; b. Apply Gaussian filtering: Convolve the image with the Gaussian kernel, calculate the weighted average of each pixel and its neighborhood, and obtain a smoothed image. Then, convolve the image with the Gaussian kernel, calculate the weighted average of each pixel and its neighborhood, and obtain a smoothed image. c. Use the Sobel operator or other differential operators to calculate the gradient of the image in the horizontal (Gx) and vertical (Gy) directions; calculate the gradient magnitude and direction of each pixel in the smoothed image, which will be used for edge positioning; d. Use non-maximum suppression method to refine the edge and ensure that each edge pixel is a local gradient maximum; compare gradient directions: for each pixel, compare its gradient magnitude with that of adjacent pixels in the positive and negative gradient directions according to its gradient direction; suppress non-maximum: if the gradient magnitude of the current pixel is not a local maximum, set it to 0, otherwise keep its gradient magnitude; e. Perform dual threshold detection and edge connection. By setting two high and low thresholds, edge pixels can be further screened and edge connections can be performed. f. Finally, all pixels marked as edges are combined to form the final edge detection result.

6. The optical workpiece defect detection method based on image technology as claimed in claim 1, characterized in that: In step S4, the extracted features include: Shape characteristics: area, perimeter, roundness, rectangularity; Texture features: gray-level co-occurrence matrix, local binary pattern; Statistical characteristics: mean, variance, skewness, kurtosis.

7. The optical workpiece defect detection method based on image technology as claimed in claim 1, characterized in that: In step S5, the support vector machine model is used for training, and the formula is: find the optimal hyperplane w T x+b=0, which maximizes the interval between positive and negative samples, where w is the normal vector and b is the intercept; The optimization problem calculation formula is: The model training steps are: a. Divide the training set and the validation set; b. Initialize model parameters; c. Iterative training: d. Forward propagation: calculate the predicted value and loss function; e. Back propagation: calculate the gradient of the loss function with respect to the model parameters; f. Update parameters: Update model parameters according to the gradient descent algorithm.

8. The optical workpiece defect detection method based on image technology as claimed in claim 1, characterized in that: In step S6, first, the data set is divided into a training set, a validation set and a test set, wherein the validation set is used to adjust the model parameters, and the test set is used to finally evaluate the model performance; next, a cross-validation method is used to repeatedly use different subsets of the data for training and validation to obtain a more stable evaluation result; In each iteration, the model is trained on the training set and tested on the validation set, and various performance indicators are recorded.

9. The optical workpiece defect detection method based on image technology as claimed in claim 1, characterized in that: In step S7, during the defect recognition phase, the image must be processed strictly according to the preprocessing process of the training phase, including the parameter settings of grayscale, denoising and binarization, and the threshold selection in the Canny edge detection algorithm.

10. The optical workpiece defect detection method based on image technology according to claim 1, characterized in that: In step S8, the output image or report should clearly mark the location and type of the defect.

Citation Information

Cited By

  • Method for size measurement and appearance detection of O-shaped ring

    CN119919410A

  • Cutting workpiece defect detection method and system based on image feature feedback

    CN120747040A

  • Real-time image monitoring method and system for yucca extract separation process

    CN121095238A