A common rail pipe surface defect detection method based on machine vision
Patent Information
- Application Number
- CN202610742479.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-27
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2046-05-27
AI Technical Summary
当前共轨管表面缺陷检测仍以人工目视为主,存在效率低、主观性强、易漏检微小缺陷等问题,无法满足批量生产需求
[0030] Compared with existing technologies, the advantages and positive effects of this invention are as follows: by correcting the uniformity of illumination on cylindrical curved surfaces, diffuse reflection and specular reflection components are accurately separated, completely eliminating interference from uneven illumination; multi-scale feature extraction is used to comprehensively depict defect texture information and improve feature representation capabilities; the initial cluster centers are determined by relying on Gaussian mixture models to avoid local optima caused by random initialization; the three-axis angular function fusion spatial neighborhood constraints and cluster center anchoring significantly enhance noise resistance and segmentation accuracy; and by combining defect probability calculation, adaptive segmentation, and morphological processing, accurate defect extraction, classification, and grading are achieved, meeting the high-precision, automated batch inspection requirements of common rail pipes.
Smart Images

Figure CN122368042B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of defect detection technology, and in particular relates to a method for detecting surface defects in common rail pipes based on machine vision. Background Technology
[0002] The high-pressure common rail is a core precision component of the high-pressure fuel supply system in diesel engines. Its surface quality directly determines fuel injection accuracy, system sealing, and overall engine reliability. During forging, machining, and heat treatment processes, the common rail surface is prone to defects such as scratches, pits, protrusions, and corrosion. Micron-level defects can cause fuel leaks and fatigue fractures under high-pressure conditions, making surface defect detection a crucial step in common rail quality control before shipment. Currently, common rail surface defect detection relies primarily on manual inspection, which suffers from low efficiency, high subjectivity, and a tendency to miss minute defects, failing to meet the demands of mass production. Existing machine vision inspection technologies have poor adaptability to cylindrical curved common rails, inadequate illumination uniformity correction, and difficulty in effectively separating diffuse and specular reflection components. Feature extraction often uses a single scale, failing to comprehensively characterize defect texture information. Gray-level clustering relies on random initial centers, easily getting trapped in local optima, and lacks spatial neighborhood consistency constraints, making defect segmentation susceptible to noise interference. Meanwhile, traditional methods have limited defect classification rules, making it difficult to accurately determine the type and severity of defects, and thus hindering the achievement of high-precision, automated surface defect detection for common rail pipes. Summary of the Invention
[0003] To address the technical problems existing in the background art described above, this invention proposes a machine vision-based method for detecting surface defects in common rail pipes.
[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0005] S1. Use a visual inspection device to collect grayscale images of the common rail pipe surface, and perform illumination uniformity correction on the collected grayscale images to obtain the preprocessed target grayscale image.
[0006] S2. Using each pixel in the target grayscale image as the feature extraction center, a multi-scale sliding window strategy is adopted to calculate the local grayscale mean, local grayscale variance and grayscale gradient magnitude in the neighborhood windows at different scales respectively, and the feature values at each scale are concatenated to form a multi-dimensional grayscale feature vector for each pixel.
[0007] S3. Perform global grayscale histogram statistics on the target grayscale image, use Gaussian mixture model to perform probability fitting on the grayscale histogram, determine the initial cluster center by the mean of each Gaussian component obtained by fitting, determine the search range constraint of each cluster in the feature space by the standard deviation of each Gaussian component, and record the number of Gaussian components as the number of clusters.
[0008] S4. Using the determined number of clusters, initial cluster centers, and search range constraints as prior information, construct a three-item objective function containing a data fitting term, a spatial neighborhood consistency constraint term, and a cluster center anchoring regularization term. Solve the membership degree of each pixel to each cluster and the cluster center through iterative optimization. The cluster center anchoring regularization term constrains the cluster centers within the search range constraints of the initial cluster centers.
[0009] S5. Calculate the defect probability of each pixel based on the membership degree, extract the defect candidate region through adaptive threshold segmentation, perform connected component analysis and morphological post-processing on the defect candidate region, extract the area parameter and grayscale feature parameter of the defect region for defect classification, and output the defect information.
[0010] Preferably, the specific implementation of the illumination uniformity correction in step S1 is as follows:
[0011] Acquire grayscale images of common rail pipes Based on the Hough transform, the two edge lines of the common rail pipe are detected, and the axial direction of the common rail pipe in the image is determined. Central axis coordinates And radius R, for each pixel in the image Calculate its perpendicular distance to the central axis. Calculate the angle between the normal vector on the cylindrical surface and the incident direction of the light source: Construct ideal illumination basis functions for cylindrical surfaces ,in, Let A be the direct light intensity coefficient and B be the ambient light constant. The optimal values of A and B are obtained by fitting the standard common rail tube image using the least squares method.
[0012] Based on the two-color reflection model, the image of the common rail tube to be detected is... The diffuse reflectance is modeled as the sum of the diffuse and specular reflectance components. The original image is normalized using the illumination basis function to obtain the initial diffuse reflectance. ,in, To prevent the division by zero by a minimum constant, a local minimum filtering method is applied to the initial diffuse reflectance to obtain a diffuse reflectance estimate. Reconstructing diffuse components: And specular reflection component: ;
[0013] The diffuse reflection component is smoothed by mean filtering: Calculate the illumination residual: ;
[0014] The corrected target grayscale image is obtained based on the illumination residual: .
[0015] Preferably, in step S2, the multi-scale sliding window strategy includes windows of at least three scales; for each pixel, in a window of scale k... The features calculated internally include: local gray-level mean, local gray-level variance, and gray-level gradient magnitude; the feature values of the scale are concatenated to form a multidimensional gray-level feature vector.
[0016] Preferably, the specific implementation process of using a Gaussian mixture model to perform probability fitting on the gray-level histogram in step S3 is as follows:
[0017] Calculate the normalized gray-level histogram of the target gray-level image. , ;
[0018] Set the search range for the number of components in the Gaussian mixture model. For each candidate component number The Gaussian mixture model is fitted using the Expectation-Maximization (EM) algorithm. ,in, The mixing weights for the j-th Gaussian component are... Let be the mean and standard deviation of the j-th Gaussian component, respectively. Let g be the Gaussian probability density function, and g be the gray value.
[0019] The optimal number of components is selected using the Bayesian Information Criterion (BIC). : The optimal number of clusters is selected as c that minimizes the BIC value. ;
[0020] The mean of each Gaussian component in the optimal model is used as the initial cluster center, and the standard deviation of each Gaussian component is used to determine the feature search radius of each cluster. ,in This is the search range expansion coefficient.
[0021] Preferably, the three-item objective function comprising a data fitting term, a spatial neighborhood consistency constraint term, and a cluster center anchoring regularization term in step S4 is specifically constructed as follows: The first item The second term is the data fitting term. The third term is a spatial neighborhood consistency constraint. The regularization term is used to anchor the cluster centers; N is the total number of pixels. For the number of cluster categories, Let be the membership degree of pixel i to cluster j. Let i be the multidimensional grayscale feature vector of pixel i. Let j be the center vector of cluster j. For spatial constraint weighting coefficients, Let i be the set of spatial neighbors of pixel i. The number of pixels in the neighborhood. To anchor the regularization weight coefficients, As the initial cluster centers, The cluster center represents the current iteration's cluster center, and it is updated with each generation.
[0022] As a preferred approach, with the objective function as a constraint, the cluster centers are first fixed and the membership degrees are updated, then the membership degrees are fixed and the cluster centers are updated again. This process is repeated iteratively to update the membership degrees and cluster centers until the objective function converges.
[0023] As a preferred embodiment, the implementation of the search range constraint in step S4 is as follows: after each iteration of updating the cluster center, the Euclidean distance between each cluster center and its corresponding initial cluster center is checked. When the Euclidean distance is greater than or equal to the feature search radius, the cluster center is projected to the search range boundary.
[0024] Preferably, the spatial neighborhood set The construction adopts an edge-aware strategy. A 5×5 candidate neighborhood window is taken with pixel i as the center. The consistency of gray-level gradient direction between pixel i and each pixel in the candidate neighborhood is calculated. If the consistency of gray-level gradient direction is greater than the preset consistency threshold, the neighboring pixels are included in the spatial neighborhood set, and pixels with excessively large gradient direction differences are excluded.
[0025] Preferably, the defect probability calculation method in step S5 is as follows: First, the clusters are sorted from low to high according to the gray value of the cluster center. The cluster with the lowest gray value is determined as the dark defect class, the cluster with the highest gray value is determined as the bright defect class, and the remaining clusters are normal surface classes, thus obtaining the index set of defect clusters. For pixel i, its membership value to each defect cluster in the membership matrix is queried, and the maximum value is taken as the defect probability of the pixel.
[0026] Preferably, the specific implementation of step S5, which involves performing connected component analysis and morphological post-processing on the defect candidate region, extracting the area parameter and grayscale feature parameter of the defect region for defect classification, and outputting the defect information, is as follows:
[0027] The Otsu method is used to binarize the defect probability map to obtain a binary mask of the defect candidate region.
[0028] Connected component labeling is performed on candidate defect regions, the area of each connected component is calculated, a minimum defect area threshold is set, connected components with an area less than the threshold are filtered out, and morphological closing operation is performed on the retained defect regions.
[0029] The pixel area of the defect is extracted as an area parameter, and the difference between the average gray level in the defect area and the average gray level in the adjacent normal surface area is extracted as a gray level feature parameter. The above parameters are matched with a preset defect classification rule library to output the severity category and actual area of the defect.
[0030] Compared with existing technologies, the advantages and positive effects of this invention are as follows: by correcting the uniformity of illumination on cylindrical curved surfaces, diffuse reflection and specular reflection components are accurately separated, completely eliminating interference from uneven illumination; multi-scale feature extraction is used to comprehensively depict defect texture information and improve feature representation capabilities; the initial cluster centers are determined by relying on Gaussian mixture models to avoid local optima caused by random initialization; the three-axis angular function fusion spatial neighborhood constraints and cluster center anchoring significantly enhance noise resistance and segmentation accuracy; and by combining defect probability calculation, adaptive segmentation, and morphological processing, accurate defect extraction, classification, and grading are achieved, meeting the high-precision, automated batch inspection requirements of common rail pipes. Attached Figure Description
[0031] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0032] Figure 1 This is a flowchart illustrating a machine vision-based method for detecting surface defects in common rail pipes. Detailed Implementation
[0033] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0034] Numerous specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways than those described herein, and therefore the invention is not limited to the specific embodiments disclosed in the following specification.
[0035] In this embodiment, the surface quality of the high-pressure common rail pipe directly determines the fuel injection accuracy, system sealing, and overall operational reliability. During forging, machining, and heat treatment processes, defects such as scratches, pits, protrusions, and corrosion are easily generated on the surface of the common rail pipe. Micron-level defects can cause safety hazards such as fuel leakage and fatigue fracture under high-pressure conditions. Therefore, surface defect detection is a crucial step in the quality control of common rail pipes before they leave the factory. Currently, surface defect detection of common rail pipes still relies mainly on manual visual inspection, which suffers from low efficiency, strong subjectivity, and the tendency to miss minute defects, failing to meet the needs of mass production. Therefore, this invention proposes a machine vision-based method for detecting surface defects in common rail pipes, specifically implemented as follows: Figure 1 As shown.
[0036] First, a grayscale image of the common rail pipe surface is acquired using a visual inspection device. The acquired grayscale image is then corrected for illumination uniformity to obtain a preprocessed target grayscale image.
[0037] Furthermore, the visual inspection device includes a linear CCD camera, a line laser light source, and a rotating fixture; the rotating fixture holds the common rail tube and drives it to rotate uniformly around its axis; the linear CCD camera is arranged along the axial direction of the common rail tube and, in conjunction with the line laser light source, scans the outer surface of the common rail tube line by line to acquire a 360-degree unfolded surface grayscale image.
[0038] Furthermore, the specific implementation of illumination uniformity correction is as follows: acquiring the grayscale image of the common rail tube. Based on the Hough transform, the two edge lines of the common rail pipe are detected, and the axial direction of the common rail pipe in the image is determined. Central axis coordinates And radius R, for each pixel in the image Calculate its perpendicular distance to the central axis. Calculate the angle between the normal vector on the cylindrical surface and the incident direction of the light source: Construct ideal illumination basis functions for cylindrical surfaces ,in, Let A be the direct light intensity coefficient and B be the ambient light constant. The optimal values of A and B are obtained by fitting the image of a standard common rail tube using the least squares method. Based on a two-color reflectance model, the image of the common rail tube to be tested is... The diffuse reflectance is modeled as the sum of the diffuse and specular reflectance components. The original image is normalized using the illumination basis function to obtain the initial diffuse reflectance. ,in, To prevent the division by zero by a minimum constant, a local minimum filtering method is applied to the initial diffuse reflectance to obtain a diffuse reflectance estimate. Reconstructing diffuse components: And specular reflection component: For diffuse reflection components Mean filtering is performed to obtain the smoothed diffuse reflection component: Calculate the illumination residual: The corrected target grayscale image is obtained based on the illumination residual. .
[0039] Then, using each pixel in the target grayscale image as the feature extraction center, a multi-scale sliding window strategy is employed to calculate the local grayscale mean, local grayscale variance, and grayscale gradient magnitude within neighborhood windows of different scales. The feature values from each scale are then concatenated to form a multi-dimensional grayscale feature vector for each pixel. Specifically, the multi-scale sliding window strategy includes windows of at least three scales; for each pixel, within a window of scale k... The features calculated internally include: local gray-level mean, local gray-level variance, and gray-level gradient magnitude; the feature values of the scale are concatenated to form a multidimensional gray-level feature vector.
[0040] Next, a global grayscale histogram is statistically analyzed on the target grayscale image. A Gaussian mixture model is used to probabilistically fit the grayscale histogram. The mean of each Gaussian component is used to determine the initial cluster centers, and the standard deviation of each Gaussian component is used to determine the search range constraint of each cluster in the feature space. The number of Gaussian components is denoted as the number of clusters. Specifically, the specific implementation process of using a Gaussian mixture model to probabilistically fit the grayscale histogram is as follows: calculate the normalized grayscale histogram of the target grayscale image. , Set the search range for the number of components in the Gaussian mixture model. For each candidate component number The Gaussian mixture model is fitted using the Expectation-Maximization (EM) algorithm. ,in, The mixing weights for the j-th Gaussian component are... Let be the mean and standard deviation of the j-th Gaussian component, respectively. Let g be the Gaussian probability density function and g be the gray value; the optimal number of components is selected using the Bayesian Information Criterion (BIC). : The optimal number of clusters is selected as c that minimizes the BIC value. The mean of each Gaussian component in the optimal model is used as the initial cluster center, and the standard deviation of each Gaussian component is used to determine the feature search radius of each cluster. ,in This is the search range expansion factor, with a value ranging from 1.5 to 3.0.
[0041] Using the predetermined number of clusters, initial cluster centers, and search range constraints as prior information, a three-item objective function is constructed, comprising a data fitting term, a spatial neighborhood consistency constraint term, and a cluster center anchoring regularization term. The membership degree of each pixel to each cluster and the cluster center are solved through iterative optimization. The cluster center anchoring regularization term constrains the cluster centers within the search range constraints of the initial cluster centers. Specifically, the construction of the three-item objective function comprising the data fitting term, spatial neighborhood consistency constraint term, and cluster center anchoring regularization term is as follows: The first item The second term is the data fitting term. The third term is a spatial neighborhood consistency constraint. The regularization term is used to anchor the cluster centers; N is the total number of pixels. For the number of cluster categories, Let be the membership degree of pixel i to cluster j. Let i be the multidimensional grayscale feature vector of pixel i. Let j be the center vector of cluster j. For spatial constraint weighting coefficients, Let i be the set of spatial neighbors of pixel i. The number of pixels in the neighborhood. To anchor the regularization weight coefficients, As the initial cluster centers, The cluster center represents the current iteration's cluster center, and it is updated with each generation.
[0042] Furthermore, using the objective function as a constraint, the membership degrees are first updated while the cluster centers are fixed, and then the cluster centers are updated while the membership degrees are fixed. This process of iteratively updating the membership degrees and cluster centers continues until the objective function converges. The formula for updating the membership degrees is: ,in, Let be the membership degree of pixel i to cluster j, with a value ranging from [0,1]. Let the squared Euclidean distance from pixel i to the center of cluster j be . Let be the squared average distance from all pixels in the neighborhood of pixel i to the center of cluster j. is the spatial constraint weight coefficient, ranging from 0.1 to 1.0, and m is the fuzzy index, ranging from 1.5 to 2.5. The update formula for the cluster centers is: ,in, The updated center of cluster j. To anchor the regularization weight coefficients, values range from 0.5 to 2.0. This is the initial cluster center. This position is initially updated to the initial cluster center, and after each update, it is replaced by the cluster center of the previous iteration.
[0043] Furthermore, the implementation of the search range constraint is as follows: after each iteration of updating the cluster centers, the Euclidean distance between each cluster center and its corresponding initial cluster center is checked. When the Euclidean distance is greater than or equal to the feature search radius, the cluster centers are projected to the search range boundary.
[0044] Furthermore, the spatial neighborhood set The construction adopts an edge-aware strategy. A 5×5 candidate neighborhood window is taken with pixel i as the center. The consistency of gray-level gradient direction between pixel i and each pixel in the candidate neighborhood is calculated. If the consistency of gray-level gradient direction is greater than the preset consistency threshold, the neighboring pixels are included in the spatial neighborhood set, and pixels with excessively large gradient direction differences are excluded.
[0045] Finally, the defect probability of each pixel is calculated based on the membership degree. Defect candidate regions are extracted through adaptive threshold segmentation. Connectivity analysis and morphological post-processing are performed on these candidate regions to extract area parameters and grayscale feature parameters for defect classification, outputting the defect information. Specifically, firstly, the clusters are sorted from low to high according to the grayscale value of their cluster centers. The cluster with the lowest grayscale value is identified as the dark defect class, the cluster with the highest grayscale value as the bright defect class, and the remaining clusters as the normal surface class, resulting in the index set D of the defect clusters. For pixel i, its membership degree value to each defect cluster in the membership matrix is queried, and the maximum value is taken as the defect probability of that pixel. Then, the Otsu method is used to binarize the defect probability map to obtain a binary mask of the defect candidate region. Connected components are labeled in the defect candidate region, the area of each connected component is calculated, a minimum defect area threshold is set, connected components with an area less than the threshold are filtered out, and morphological closing operations are performed on the retained defect regions. The pixel area of the defect is extracted as the area parameter, and the difference between the average gray level in the defect region and the average gray level of the adjacent normal surface region is extracted as the gray level feature parameter. The above parameters are matched with the preset defect classification rule library to output the severity category and actual area of the defect, thereby realizing the detection and identification of defects.
[0046] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments for application in other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A machine vision-based method for detecting surface defects in common rail pipes, characterized in that, Includes the following steps: S1. Use a visual inspection device to collect grayscale images of the common rail pipe surface, and perform illumination uniformity correction on the collected grayscale images to obtain the preprocessed target grayscale image. S2. Using each pixel in the target grayscale image as the feature extraction center, a multi-scale sliding window strategy is adopted to calculate the local grayscale mean, local grayscale variance and grayscale gradient magnitude in the neighborhood windows at different scales respectively, and the feature values at each scale are concatenated to form a multi-dimensional grayscale feature vector for each pixel. S3. Perform global grayscale histogram statistics on the target grayscale image, use Gaussian mixture model to perform probability fitting on the grayscale histogram, determine the initial cluster center by the mean of each Gaussian component obtained by fitting, determine the search range constraint of each cluster in the feature space by the standard deviation of each Gaussian component, and record the number of Gaussian components as the number of clusters. S4. Using the determined number of clusters, initial cluster centers, and search range constraints as prior information, construct a three-item objective function containing a data fitting term, a spatial neighborhood consistency constraint term, and a cluster center anchoring regularization term. Solve the membership degree of each pixel to each cluster and the cluster center through iterative optimization. The cluster center anchoring regularization term constrains the cluster centers within the search range constraints of the initial cluster centers. S5. Calculate the defect probability of each pixel based on the membership degree, extract the defect candidate region through adaptive threshold segmentation, perform connected component analysis and morphological post-processing on the defect candidate region, extract the area parameter and grayscale feature parameter of the defect region for defect classification, and output the defect information. The specific implementation of illumination uniformity correction in step S1 is as follows: Acquire grayscale images of common rail pipes Based on the Hough transform, the two edge lines of the common rail pipe are detected, and the axial direction of the common rail pipe in the image is determined. Central axis coordinates And radius R, for each pixel in the image Calculate its perpendicular distance to the central axis. Calculate the angle between the normal vector of the light source on the cylindrical surface and the incident direction of the light source: Construct ideal illumination basis functions for cylindrical surfaces ,in, The values of A and B are the direct light intensity coefficient and the ambient light constant, respectively. The optimal values of A and B are obtained by fitting the standard common rail tube image using the least squares method. Based on the two-color reflection model, the image of the common rail tube to be detected is... The diffuse reflectance is modeled as the sum of the diffuse and specular reflectance components. The original image is normalized using the illumination basis function to obtain the initial diffuse reflectance. ,in, To prevent the division by zero by a minimum constant, a local minimum filtering method is applied to the initial diffuse reflectance to obtain a diffuse reflectance estimate. Reconstructing the diffuse component: And specular reflection component: ; The diffuse reflection component is smoothed by mean filtering: Calculate the illumination residual: ; The corrected target grayscale image is obtained based on the illumination residual: ; The construction of the three-item metric function, which includes a data fitting term, a spatial neighborhood consistency constraint term, and a cluster center anchoring regularization term, in step S4 is as follows: The first item The second term is the data fitting term. The third term is a spatial neighborhood consistency constraint. The regularization term is used to anchor the cluster centers; N is the total number of pixels. For the number of cluster categories, Let be the membership degree of pixel i to cluster j. Let i be the multidimensional grayscale feature vector of pixel i. Let j be the center vector of cluster j. These are the spatial constraint weighting coefficients. Let i be the set of spatial neighbors of pixel i. The number of pixels in the neighborhood. To anchor the regularization weight coefficients, As the initial cluster centers, The cluster center represents the current iteration's cluster center, and it is updated with each generation.
2. The method for detecting surface defects of common rail pipes based on machine vision according to claim 1, characterized in that, In step S2, the multi-scale sliding window strategy includes windows of at least three scales; for each pixel, in a window of scale k... The features calculated internally include: local gray-level mean, local gray-level variance, and gray-level gradient magnitude; the feature values of the scale are concatenated to form a multidimensional gray-level feature vector.
3. The method for detecting surface defects of common rail pipes based on machine vision according to claim 1, characterized in that, The specific implementation process of using a Gaussian mixture model to perform probability fitting on the gray-level histogram in step S3 is as follows: Calculate the normalized gray-level histogram of the target gray-level image. , ; Set the search range for the number of components in the Gaussian mixture model. For each candidate component number The Gaussian mixture model is fitted using the Expectation-Maximization (EM) algorithm. ,in, The mixing weights for the j-th Gaussian component are... Let be the mean and standard deviation of the j-th Gaussian component, respectively. Let g be the Gaussian probability density function, and g be the gray value. The optimal number of components is selected using the Bayesian Information Criterion (BIC). : The optimal number of clusters is selected as c that minimizes the BIC value. ; The mean of each Gaussian component in the optimal model is used as the initial cluster center, and the standard deviation of each Gaussian component is used to determine the feature search radius of each cluster. ,in This is the search range expansion coefficient.
4. The method for detecting surface defects of common rail pipes based on machine vision according to claim 1, characterized in that, Using the objective function as a constraint, first fix the cluster centers and update the membership degrees, then fix the membership degrees and update the cluster centers again. Iterate the membership degrees and cluster centers in this way until the objective function converges.
5. The method for detecting surface defects of common rail pipes based on machine vision according to claim 1, characterized in that, The implementation method of the search range constraint in step S4 is as follows: after each iteration of updating the cluster center, the Euclidean distance between each cluster center and its corresponding initial cluster center is checked. When the Euclidean distance is greater than or equal to the feature search radius, the cluster center is projected to the search range boundary.
6. The method for detecting surface defects of common rail pipes based on machine vision according to claim 1, characterized in that, The spatial neighborhood set The construction adopts an edge-aware strategy. A 5×5 candidate neighborhood window is taken with pixel i as the center. The consistency of gray-level gradient direction between pixel i and each pixel in the candidate neighborhood is calculated. If the consistency of gray-level gradient direction is greater than the preset consistency threshold, the neighboring pixels are included in the spatial neighborhood set, and pixels with excessively large gradient direction differences are excluded.
7. The method for detecting surface defects of common rail pipes based on machine vision according to claim 1, characterized in that, The defect probability calculation method in step S5 is as follows: First, the clusters are sorted from low to high according to the gray value of the cluster center. The cluster with the lowest gray value is determined as the dark defect class, the cluster with the highest gray value is determined as the bright defect class, and the remaining clusters are normal surface classes, thus obtaining the index set of defect clusters. For pixel i, its membership value to each defect cluster in the membership matrix is queried, and the maximum value is taken as the defect probability of the pixel.
8. The method for detecting surface defects of common rail pipes based on machine vision according to claim 1, characterized in that, In step S5, the defect candidate region is subjected to connected component analysis and morphological post-processing. The area parameters and gray-level feature parameters of the defect region are extracted for defect classification, and the defect information is output. The specific implementation of this step is as follows: The Otsu method is used to binarize the defect probability map to obtain a binary mask of the defect candidate region. Connected component labeling is performed on candidate defect regions, the area of each connected component is calculated, a minimum defect area threshold is set, connected components with an area less than the threshold are filtered out, and morphological closing operation is performed on the retained defect regions. The pixel area of the defect is extracted as an area parameter, and the difference between the average gray level in the defect area and the average gray level in the adjacent normal surface area is extracted as a gray level feature parameter. The above parameters are matched with a preset defect classification rule library to output the severity category and actual area of the defect.
Citation Information
Patent Citations
Metal composite material surface defect intelligent detection method based on machine vision
CN121767364A
Fabric defect detection method based on deep convolutional neural network and visual saliency
WO2019104767A1