A method for detecting defects in industrial parts

By extracting and segmenting burr defect features, generating and enhancing verification code images, the difficult problem of converting complex burr defect images into concise verification codes is solved, and the detection accuracy and security of the verification codes are improved.

CN119515770BActive Publication Date: 2025-09-16IFLYTEK SOUTH CHINA ARTIFICIAL INTELLIGENCE RES INST GUANGZHOU CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411373889.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-09-16
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

Existing technologies make it difficult to effectively convert complex and changeable burr defect images into concise and clear verification code forms, while retaining key feature information and ensuring that the converted verification code has good recognition and anti-interference capabilities.

Method used

By extracting the shape, size, and distribution location features of the burr, a binary burr defect mask is generated, morphological operations and segmentation are performed, geometric features are calculated, a burr defect feature vector is constructed, a mapping relationship with the verification code characters is established, a verification code image is generated and enhanced, and finally compression and format conversion are performed.

Benefits of technology

The burr defect characteristics of industrial parts are converted into verification codes, which not only improves the accuracy of defect detection but also enhances the security of verification codes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119515770B_ABST
    Figure CN119515770B_ABST
Patent Text Reader

Abstract

The present application provides an industrial parts defect detection method, comprising: obtaining an input industrial parts burr defect image, extracting the shape, size, and distribution position features of the burrs in the image to obtain a burr feature map, segmenting the burr defect area according to the edge roughness and color difference in the burr feature map, and generating a binary burr defect mask; performing morphological operations on the binary burr defect mask, eliminating isolated noise points through dilation and corrosion, and connecting adjacent burr areas, segmenting the processed burr mask, and extracting independent burr defect areas according to the three-dimensional contour and surface texture features of the burrs; performing image enhancement processing on a preliminary verification code character matrix, adjusting the color contrast of the characters to highlight the thickness of the character strokes, and generating a verification code image; compressing and format converting the generated verification code image to obtain a final industrial parts burr defect verification code for use in defect detection of workpiece parts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and in particular to an industrial parts defect detection method. Background Art

[0002] The field of burr defect detection for industrial parts presents a pressing technical challenge. Currently, burr defect images are highly complex and diverse, posing a significant challenge to accurate identification. To improve detection accuracy and reliability, researchers have proposed a new method based on verification code recognition. However, effectively converting complex and diverse burr defect images into verification code form while preserving key feature information presents a thorny challenge. These defects vary significantly in size, shape, and distribution. Extracting these complex image features and converting them into concise and clear verification codes presents a significant challenge. Furthermore, the conversion process must ensure that critical defect information is not lost. This requires an algorithm that simplifies the image while retaining sufficient detail to support subsequent accurate identification and classification. Another challenge lies in ensuring that the converted verification code is sufficiently recognizable and resistant to interference. The verification code generation process requires enhancing the prominence of key features while suppressing interference from irrelevant information. In short, the core challenge facing this technology is how to efficiently convert complex and changeable burr defect images into concise and clear verification code forms while retaining key features, while ensuring that the converted verification code has good recognition and anti-interference capabilities. Summary of the Invention

[0003] The present invention provides an industrial parts defect detection method, which mainly includes:

[0004] The system obtains an input image of a burr defect on an industrial part, extracts the shape, size, and distribution location features of the burrs in the image, and obtains a burr feature map. Based on the edge roughness and color differences in the burr feature map, the burr defect area is segmented and a binary burr defect mask is generated.

[0005] Perform morphological operations on the binary burr defect mask, eliminate isolated noise points through dilation and erosion, connect adjacent burr areas, segment the processed burr mask, and extract independent burr defect areas based on the 3D contour and surface texture features of the burr.

[0006] For each independent burr defect area, its geometric features are calculated, a burr defect feature vector is constructed, and the semantic features of the burr defect feature vector are extracted to obtain the feature representation of the burr defect. Different types of burr defects are grouped based on their feature similarity, and the shape and size features of the most representative samples in each group of burr defects are selected as the representative features of the burr defects in that group.

[0007] Establishing a mapping relationship between each group of burr defect representatives and verification code characters, including mapping the shape and size attributes of the burrs to the shape and size characteristics of the characters, dividing the original burr defect image into several grids, and generating a preliminary verification code character matrix based on the grid positions and verification code character mapping results;

[0008] Perform image enhancement processing on the preliminary verification code character matrix, adjust the color contrast of the characters to highlight the thickness of the character strokes, and generate a verification code image;

[0009] The generated verification code image is compressed and format converted to obtain the final industrial part burr defect verification code, which is used for defect detection of workpiece parts.

[0010] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:

[0011] The present invention discloses a method for detecting defects in industrial parts. The method extracts features such as the shape, size, and distribution position of the burrs, segments the burr defect area, and generates a binary mask. After morphological processing and segmentation, the geometric features and semantic features of the independent burr defect area are extracted to construct a feature vector. The burr defects are grouped based on feature similarity, and representative samples are selected to establish a mapping relationship with verification code characters. The original image is divided into a grid, and a preliminary character matrix is ​​generated based on the mapping results. The final verification code is obtained after image enhancement processing. The present invention realizes the conversion of burr defect features of industrial parts into verification codes, which can be used for defect detection and improves the security of the verification code, and has important practical value. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 The figure is a flow chart of an industrial parts defect detection method of the present invention.

[0013] Figure 2 Schematic diagram of an industrial parts defect detection method of the present invention.

[0014] Figure 3 This is another schematic diagram of an industrial parts defect detection method according to the present invention. DETAILED DESCRIPTION

[0015] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0016] like Figure 1 -3. In this embodiment, a method for detecting defects in industrial parts may specifically include:

[0017] Step S101: Obtain an input image of a burr defect on an industrial part and extract the shape, size, and distribution characteristics of the burrs in the image to generate a burr feature map. Based on the edge roughness and color differences in the burr feature map, the burr defect area is segmented and a binary burr defect mask is generated.

[0018] The obtained industrial part burr defect image is preprocessed by linear grayscale transformation and adaptive histogram equalization to obtain a preprocessed image with enhanced contrast and prominent burr features; the shape, size, and distribution position of the burrs are extracted from the preprocessed image to generate a burr feature map including the burr contour, area, and coordinates; the burr feature map is edge detected using the Canny operator to obtain edge information in the burr feature map, and the gradient amplitude and direction of the edge pixel points are calculated; if the edge information meets the high and low thresholds automatically determined by the OTSU algorithm, the edge is binarized to obtain a preliminary burr contour; the preliminary burr contour is segmented using a region growing algorithm based on edges and grayscale gradients, starting with the seed point obtained by the edge detection, and the segmented region is gradually expanded; if the grayscale value difference and gradient direction difference of adjacent pixels are both less than a set threshold, they are included in the same region until further expansion is impossible; the segmented regions are evaluated and optimized, and the rationality of the segmented regions is evaluated using shape features and texture features; if the segmented regions are unreasonable, they are merged or split.

[0019] Exemplarily, an image of industrial part burr defects is preprocessed using linear grayscale transformation and adaptive histogram equalization to enhance image contrast and highlight burr features. The burr shape, size, and distribution location are extracted from the preprocessed image, generating a burr feature map containing the burr outline, area, and coordinates. The Canny operator is used to perform edge detection on the burr feature map to obtain edge information from the image. The gradient amplitude and direction of edge pixels are calculated, and the edges are binarized based on high and low thresholds automatically determined by the OTSU algorithm to obtain a preliminary burr outline. The preliminary burr outline is then segmented using a region growing algorithm based on edges and grayscale gradients. Starting with a seed point obtained by edge detection, the segmented region is gradually expanded. When the grayscale value and gradient direction differences between adjacent pixels are both less than a set threshold, they are included in the same region until further expansion is impossible. The segmentation results are evaluated and optimized, using shape and texture features to assess the rationality of the segmented regions, and merging or splitting unreasonable regions. Morphological operations are performed on the optimized region. A 3x3 rectangular structuring element is used to perform one opening operation to remove small noise and two closing operations to fill internal holes. This completes the burr defect region. The defective region is marked as foreground, and the non-defective region is marked as background, generating a binary burr defect mask image. The acquired industrial part burr defect image undergoes a linear grayscale transformation, mapping pixel values ​​from 0-255 to 0-1 to enhance image contrast. Adaptive histogram equalization is then applied to divide the image into 8x8 local blocks. Histogram equalization is then performed within each block to highlight local details. The preprocessed image is then subjected to morphological gradient operations to extract the burr contour. Dilation and erosion operations are performed using a 3x3 structuring element to obtain the burr edge. The burr area and centroid coordinates are calculated, generating a burr feature map containing the contour, area, and coordinates. Canny edge detection was applied to the feature map, and image gradients were calculated. The x-direction gradient Gx and the y-direction gradient Gy were obtained using the Sobel operator. The edge strength M = sqrt(Gx^2 + Gy^2), and the edge direction θ = arctan(Gy / Gx). The OTSU algorithm was used to automatically determine the upper and lower thresholds, with the upper threshold set at 128 and the lower threshold set at 0.4 times the high threshold, i.e., 51.2. Edges were then binarized. A region growing algorithm based on edges and grayscale gradients used edge pixels as seed points. Adjacent pixels were included in the same region if the grayscale value difference between them was less than 20 and the gradient direction difference was less than 30 degrees. The segmentation results were evaluated by calculating the perimeter / area ratio and the energy signature of the grayscale co-occurrence matrix for each region. If the ratio was greater than 0.1 and the energy signature was less than 0.5, the segmentation was considered reasonable; otherwise, regions were merged or split.Finally, morphological operations are performed on the optimized area. A 3x3 rectangular structure element is used to perform one opening operation and two closing operations to obtain a complete burr defect area. The pixel value of the defect area is set to 255, and the pixel value of the non-defect area is set to 0 to generate a binary burr defect mask image.

[0020] In step S102 , morphological operations are performed on the binary burr defect mask to eliminate isolated noise points through dilation and erosion, and to connect adjacent burr areas. The processed burr mask is segmented to extract independent burr defect areas based on the three-dimensional contour and surface texture features of the burrs.

[0021] A dilation operation is applied to the binary burr defect mask, and a structural element is used for iteration to expand the boundary of the burr area. Subsequently, an erosion operation is performed to remove isolated noise points to obtain an optimized burr mask image; the contour information of the optimized burr mask is extracted using the Sobel operator, and the curvature change and direction consistency are calculated based on the contour information to determine the connectivity of adjacent burr areas; a rigid body transformation algorithm is used to align the two-dimensional burr mask image with the three-dimensional point cloud data collected by the depth camera, and the two-dimensional image coordinate system is converted to a three-dimensional point cloud coordinate system; bilateral filtering is performed on the point cloud data for denoising, and surface reconstruction and smoothing are performed using the moving least squares method. The depth value and normal vector information of each pixel are extracted, and a feature vector containing the depth value, the component of the normal vector and the grayscale value is constructed in combination with the grayscale value of the two-dimensional image; a region growing algorithm is used to segment the feature vector, and the edge points of the burr area are selected as seed points. The area is gradually expanded. When the Euclidean distance of the feature vectors of adjacent points is less than a preset threshold, they are included in the same area until further expansion is impossible, thereby obtaining an independent burr defect area.

[0022] For example, a dilation operation is applied to the binary burr defect mask, using a 3x3 structuring element for three iterations to expand the burr region boundaries and fill small voids and gaps. An erosion operation is then performed, using the same structuring element for two iterations to remove isolated noise points and retain the main burr structure, resulting in an optimized burr mask image. The Sobel operator is used to extract the contour information of the optimized burr mask, and the contour curvature and direction are calculated. The connectivity of adjacent burr regions is determined based on the curvature change and directional consistency. If the curvature change is less than 0.1 and the directional angle is less than 15 degrees, the adjacent regions are merged into a complete burr defect region. A rigid body transformation algorithm is used to align the two-dimensional burr mask image with the three-dimensional point cloud data collected by the depth camera, converting the two-dimensional image coordinate system to the three-dimensional point cloud coordinate system. The point cloud data was subjected to bilateral filtering for denoising, followed by surface reconstruction and smoothing using the moving least squares method. The depth and normal vector information for each pixel was extracted and, combined with the grayscale values ​​of the 2D image, a 6-dimensional feature vector was constructed, containing the depth value, the x, y, and z components of the normal vector, and the grayscale value. A region growing algorithm was used to segment the constructed feature vector. Edge points in the burr region were selected as seed points, and the region was gradually expanded. When the Euclidean distance between the feature vectors of adjacent points was less than 0.5, they were included in the same region until further expansion became impossible, ultimately resulting in independent burr defect regions. For the binary burr defect mask, a 3x3 structuring element was first applied, performing three dilation operations. This expanded regions with an original pixel value of 1 by 3 pixels, filling holes with a diameter of less than 6 pixels. The same structuring element was then used for two erosion operations to remove protrusions smaller than 4 pixels and isolated noise points at the edge. The optimized mask image was then subjected to edge detection using the Sobel operator, and the gradients in the x and y directions were calculated to determine the edge strength and direction. Curvature was calculated along the edge, sampling every 10 pixels. Curvature was calculated by fitting a circle around three adjacent points. Adjacent regions were merged if the curvature variation was less than 0.1 and the included angle was less than 15 degrees. The 2D mask image and the 3D point cloud data captured by the depth camera were registered using an iterative closest point algorithm, with a maximum number of iterations of 50 and a convergence threshold of 0.001 mm. The aligned point cloud data was denoised using a bilateral filter with a radius of 5 mm, a spatial standard deviation of 2.5 mm, and a range standard deviation of 10 mm. The surface was then reconstructed using the moving least squares method, selecting the 20 nearest neighbor points and fitting the local surface using a quadratic polynomial. For each point in the reconstructed surface, the depth and normal vector were extracted and combined with the grayscale values ​​of the original 2D image to construct a 6-dimensional feature vector. Finally, segmentation was performed using a region growing algorithm, selecting edge points as seed points. Adjacent points with a Euclidean distance of less than 0.5 between their 6-dimensional feature vectors were included in the same region. Continue to expand until no adjacent points that meet the conditions can be found, and finally an independent burr defect area is obtained.

[0023] In step S103, for each independent burr defect area, its geometric features are calculated to construct a burr defect feature vector; the semantic features of the burr defect feature vector are extracted to obtain a feature representation of the burr defect; different types of burr defects are grouped based on the feature similarity of the burr defects, and the shape and size features of the most representative samples in each group of burr defects are selected as the representative features of the burr defects in that group.

[0024] The geometric and texture features of the burr defect area are obtained to construct a multidimensional burr defect feature vector; wherein, the geometric features include area, perimeter, circularity, rectangularity, aspect ratio, and orientation angle. An autoencoder with three layers of encoders and three layers of decoders is used to reduce the dimensionality of the multidimensional burr defect feature vector; if the number of nodes in the middle layer is 1 / 4 of the dimension of the original feature vector, a low-dimensional burr defect feature representation is obtained through a compression and reconstruction process. The feature vector output by the autoencoder is Z-score normalized, and the cosine similarity between different burr defect samples is calculated. A similarity matrix is ​​constructed based on the cosine similarity, and the similarity matrix is ​​analyzed using a density-based clustering algorithm; if the neighborhood radius is 0.5 and the minimum number of samples is 4, burr defects with similar features are automatically grouped. For each group of burr defects, the average eigenvector and variance of the samples in the group are calculated; if the Euclidean distance weight between the sample and the average eigenvector in the group is 0.7 and the variance weight of each dimension of the sample feature is 0.3, the sample with the smallest weighted sum is selected as the representative sample of the group.

[0025] For example, for each individual burr defect region, its area, perimeter, circularity (4π*area / perimeter^2), rectangularity (area / area of ​​the minimum bounding rectangle), aspect ratio, and orientation angle are calculated. A multidimensional burr defect feature vector is constructed by combining the grayscale distribution and texture features of the defect region. An autoencoder with a three-layer encoder and a three-layer decoder is used to reduce the dimensionality of the burr defect feature vector. The number of nodes in the middle layer is set to 1 / 4 the dimensionality of the original feature vector. Mean squared error is used as the loss function, and the Adam optimizer is used for training to extract key semantic features. A low-dimensional burr defect feature representation is obtained through compression and reconstruction, preserving the key information of the original features. The feature vector output by the autoencoder is Z-score normalized to ensure that all dimensional features have the same scale. Based on this normalized burr defect feature representation, the cosine similarity between different burr defect samples is calculated to construct a similarity matrix. This similarity matrix is ​​analyzed using a density-based clustering algorithm with a neighborhood radius of 0.5 and a minimum sample size of 4 to automatically group burrs with similar characteristics. For each burr defect group, the average eigenvector and variance of the samples within the group are calculated. The Euclidean distance between each sample and the average eigenvector within the group is calculated, and the variance of each dimension of the sample's features is also calculated. These two metrics are weighted and summed, with weights of 0.7 and 0.3, respectively. The sample with the smallest weighted sum is selected as the representative sample for the group. The shape, contour, and size parameters of this sample are then extracted as the representative features of the burr defect group. Geometric features are calculated for each individual burr defect region. The area is first determined by pixel counting, and the perimeter is then obtained using a boundary tracing algorithm. Circularity is calculated using 4π area / perimeter^2, yielding a value between 0.8 and 0.95. Rectangularity is calculated by dividing the area by the area of ​​the minimum enclosing rectangle, typically ranging from 0.6 to 0.9. The aspect ratio is calculated by dividing the length along the main axis by the width along the perpendicular direction, and ranges from 1.2 to 3. The orientation angle is determined by the angle between the main axis and the horizontal, ranging from 0 to 180 degrees. Grayscale distribution features were described using mean, standard deviation, skewness, and kurtosis, while texture features were represented using the energy, contrast, and correlation of the gray-level co-occurrence matrix. The constructed feature vector had a dimension of 20. The autoencoder used a 20-10-5-10-20 architecture, a ReLU activation function, a learning rate of 0.001, a batch size of 32, and 1000 epochs of training. Dimensionality reduction resulted in a 5-dimensional feature vector. Z-score normalization subtracted the mean from each feature and divided it by the standard deviation, resulting in a mean of 0 and a variance of 1. The cosine similarity between the normalized feature vectors was calculated to generate a similarity matrix. The DBSCAN algorithm was used with a neighborhood radius of ε = 0.5 and a minimum number of samples, MinPts = 4, to cluster similar samples into one cluster. For each group, the mean feature vector μ and the covariance matrix Σ were calculated. The Mahalanobis distance d = (x - μ) ^TΣ ^ -1(x - μ) from each sample x to μ was calculated. The variance v of each dimension of x was also calculated.Let s = 0.7d + 0.3v, select the sample with the smallest s as the representative, and extract its contour coordinate sequence and length, width, and area size parameters as the representative features of the group.

[0026] Step S104, establishing a mapping relationship between each group of burr defect representatives and verification code characters, including mapping the burr shape and size attributes to the shape and size characteristics of the characters; dividing the original burr defect image into several grids, and generating a preliminary verification code character matrix based on the grid positions and the verification code character mapping results.

[0027] Obtain representative features of burr defects and features of verification code characters, and establish a correspondence database between the representative features of burr defects and the features of verification code characters; apply the Otsu algorithm to the original burr defect image according to the correspondence database, and perform adaptive threshold segmentation to extract independent burr areas in the burr defect image; for the independent burr areas, query the correspondence database to obtain characters that match the independent burr areas, fill the characters into preset grid positions, and obtain a preliminary character matrix; use a binary grammar model to calculate the probability of adjacent character combinations in the preliminary character matrix, and determine whether the probability is lower than a preset threshold; if the probability is lower than the preset threshold, recalculate the matching degree of the burr feature at that position with other candidate characters, select the suboptimal matching result to replace the corresponding character in the preliminary character matrix, and obtain an optimized character matrix.

[0028] For example, a database of correspondences between representative features of burr defects and verification code character features is constructed. A Fourier descriptor-based contour matching method is used to calculate the similarity between the burr contour and the standard character contour. The area ratio of the burr to the character is compared, with a threshold range of 0.8-1.2, to establish a preliminary mapping relationship between burrs and characters. The Otsu algorithm is applied to the original burr defect image for adaptive threshold segmentation. Individual burr regions are extracted, and the centroid coordinates and principal direction of each burr region are calculated. Based on these features, the image is divided into M×N grids, each grid size corresponding to the average burr size, and the grid boundaries are determined by the distribution of the burr centroid coordinates. Each grid is traversed. If a burr defect exists within the grid, the mapping database is searched based on the representative features of the burr to obtain the corresponding character. The character identifier is then filled into the corresponding grid position. For large burrs that span multiple grids, the grid with the largest coverage area is selected for the character. If multiple burrs exist within a grid, the burr with the largest area is selected as the representative grid, forming a preliminary character matrix. The character matrix is ​​checked for local consistency. A bigram model is used to calculate the probability of adjacent character combinations, with a threshold of 0.01. If the probability falls below the threshold, the combination is considered invalid. The matching degree of the burr feature at that location with other candidate characters is recalculated, and the suboptimal match is selected for replacement to optimize the overall consistency of the character matrix. To construct a mapping between the burr defect and the verification code character, a 64-point Fourier transform descriptor of the burr outline is first extracted. The Euclidean distance is calculated with a pre-stored standard character outline descriptor. A match is considered if the distance is less than 0.2. The ratio of the burr area to the standard character area is also calculated. If it is within the range of 0.8-1.2, the match is further confirmed. The Otsu algorithm is applied to the original image, and the optimal threshold is selected for binarization to obtain the burr area. The centroid coordinates and main direction of each burr are calculated. Based on this information, the 800×600 pixel image is divided into a 10×8 grid. The grid is traversed. If a burr exists within a grid, its area, perimeter ratio, and direction features are extracted, and the corresponding character is retrieved from the mapping database. For glitches that span multiple grids, meaning their area exceeds 150% of the average, characters are added to the grid with the largest coverage area. If multiple glitches fall within a grid, the one with the largest area is selected as the representative. This results in a 10×8 character matrix. A binary grammar model trained on 100,000 common words is used to calculate the probability of adjacent character pairs. If the probability is less than 0.01, the combination is considered unreasonable. The similarity between the glitches at that location and the suboptimal matching character is then recalculated. If the similarity difference is less than 20%, the suboptimal character is replaced to improve overall consistency.

[0029] According to the representative characteristics of the burr defects in the grid, the corresponding characters are found in the verification code character set, the characters corresponding to the grid are arranged according to the grid positions, a character matrix is ​​generated, the edge contours of the character matrix are analyzed, the missing parts are identified and completed, and the completed character matrix is ​​obtained.

[0030] A feature vector is constructed based on the area, perimeter ratio, and direction angle of the burr defects in the grid. The support vector machine classifier is used to search for the character with the highest matching degree in the pre-established verification code character feature library to obtain an initial character matrix. The Canny edge detection algorithm is applied to the initial character matrix to calculate the image gradient amplitude and direction. The edge contour of the character matrix is ​​obtained through the double threshold method and edge connection, and the area with discontinuous or missing edges is identified. For the identified missing area, the morphological reconstruction algorithm is used to preliminarily fill the missing part in combination with the shape features and semantic information of adjacent characters, and a structure close to the character stroke width is selected. elements, reconstructing the character outline through iterative expansion and intersection operations to obtain a repaired character outline; using a convolutional neural network with a U-Net structure to perform fine processing on the repaired character outline, the network input is the repaired character image, and the output is the complete character image. By learning the local structural features of the characters, character details that conform to the context are generated to obtain a completed character matrix; applying an optical character recognition algorithm to the completed character matrix for verification, and calculating the recognition confidence. If the recognition confidence is lower than a preset threshold, the convolutional neural network is fine-tuned until a high-confidence completed character matrix is ​​obtained.

[0031] For example, a feature vector is constructed based on the area, perimeter ratio, and direction angle of the burr defects in the grid, and the support vector machine classifier is used to search for the character with the highest matching degree in the pre-established verification code character feature library. The feature library expands the samples by multi-angle rotation, scaling, and noise addition, and arranges the matching results according to the grid position to generate an initial character matrix. The Canny edge detection algorithm is applied to the initial character matrix to calculate the image gradient amplitude and direction. The edge contour of the character matrix is ​​obtained by the double threshold method and edge connection, and the area with discontinuous or missing edges is identified. For the identified missing areas, the morphological reconstruction algorithm is used to preliminarily fill the missing parts in combination with the shape features and semantic information of adjacent characters. Structural elements with a width close to the character strokes are selected, and the character contour is reconstructed through iterative expansion and intersection operations to obtain the repaired character contour. Based on the restored character outlines, a convolutional neural network with a U-Net architecture refines the completed region. The network takes the restored character image as input and outputs the complete character image. Training is performed using a pixel-level cross-entropy loss function and the Adam optimizer. By learning the local structural features of the characters, it generates contextually appropriate character details, ultimately producing a completed character matrix. The completed results are verified using an optical character recognition algorithm, and the recognition confidence is calculated. If the confidence falls below a preset threshold, the convolutional neural network is returned to the previous step for fine-tuning until a highly confident completed character matrix is ​​obtained. When addressing burr defects within the mesh, feature vectors are first extracted, including area, perimeter ratio, and orientation angle, typically resulting in 10-15 dimensional vectors. A CAPTCHA character feature library contains 3,000 samples from common fonts, each expanded to 9,000 by rotating them by ±15°, scaling them by 0.8-1.2 times, and adding 5% Gaussian noise. Characters are matched against this library using a support vector machine with an RBF kernel, C = 1.0, and gamma = 'scale'. Canny edge detection uses a Gaussian kernel size of 5x5, a low threshold of 50, and a high threshold of 150. Morphological reconstruction uses a 3x3 rectangular structuring element, with a typical number of 5-10 iterations. The U-Net network incorporates four rounds of downsampling and upsampling, starting with 64 convolution kernels, which double with each layer, to a maximum of 512. The training set consists of 100,000 defective-intact character image pairs, with a batch size of 32 and a learning rate of 0.001, trained for 100 epochs. A pixel-wise cross-entropy loss is used with the Adam optimizer. After completion, verification is performed using the Tesseract OCR engine, with a confidence threshold of 0.8. If the confidence threshold is below, the U-Net is fine-tuned for 5 epochs at a learning rate of 0.0001. The entire process, from feature extraction to final verification, typically takes 0.5-1 seconds per character on a quad-core CPU.

[0032] Analyze the spacing and size relationship between characters in the completed character matrix, segment the overlapping characters that exceed the overlap requirement, and obtain optimized characters; splice the feature image of each character according to the matrix position to obtain a preliminary verification code character matrix.

[0033] Apply the connected domain analysis algorithm to the completed character matrix, identify independent character areas through 8-neighborhood connectivity judgment, and obtain the position and size information of the characters. Calculate the ratio of the overlapping area of ​​adjacent character boundary boxes to the character area. If the ratio exceeds the preset threshold, use the contour analysis-based segmentation method to separate the overlapping characters. Perform morphological processing on the separated character image, use rectangular structural elements for opening operations to remove noise, and close operations to fill internal holes to obtain a character image with complete shape. Analyze the spacing and size relationship between characters, calculate the Euclidean distance of adjacent character center points and the character aspect ratio, and if the spacing is less than the preset ratio of the average character width or the aspect ratio difference exceeds the preset threshold, scale and adjust the position of the characters. According to the adjusted character matrix position information, splice the optimized character feature images in the original arrangement order, apply Gaussian kernel to the transition area between characters for fuzzy processing, and obtain a preliminary verification code character matrix.

[0034] Exemplarily, a connected domain analysis algorithm is applied to the completed character matrix. Through 8-neighborhood connectivity judgment, each independent character area is identified, the position and size information of each character is obtained, and the bounding box coordinates of the character are calculated. The ratio of the overlapping area of ​​the adjacent character bounding boxes to the character area is calculated. If the ratio exceeds the preset threshold of 0.2, the overlapping characters are separated by a segmentation method based on contour analysis. The character contours are extracted, the concave points are found, and the characters are segmented along the lines connecting the concave points to obtain the separated character images. The segmented character images are morphologically processed. A 3x3 rectangular structural element is used to perform an open operation once to remove small noise points and a closed operation twice to fill the internal holes to ensure the integrity and consistency of the character shape, while preserving the bounding box information of each character. The spacing and size relationship between characters are analyzed, and the Euclidean distance of the center points of adjacent characters and the character aspect ratio are calculated. If the spacing is less than 1 / 4 of the average character width or the aspect ratio difference exceeds 20%, the characters are scaled and adjusted in position. Based on the adjusted character matrix position information, the optimized character feature images are spliced ​​back to their original order. A 3x3 Gaussian kernel is applied to the transition regions between characters to smooth character edges, resulting in a preliminary CAPTCHA character matrix. When processing the completed character matrix, an 8-neighborhood connected component analysis algorithm is first applied, with a pixel brightness threshold of 128, to identify each individual character region. For a 100x30 pixel CAPTCHA image, 4-6 connected regions are typically obtained. The bounding box of each region is calculated, recording the upper left corner coordinates (x, y) and width and height (w, h). The overlap of the bounding boxes of adjacent characters is then calculated. Segmentation is triggered if the ratio of the overlapping area to the character area exceeds 0.2. During segmentation, character outlines are extracted, simplified using the Douglas-Peucker algorithm, and concave points are detected. Characters are segmented along the lines connecting the concave points, resulting in separated sub-images. Morphological processing is performed on each character image, using a 3x3 rectangular structuring element to first remove noise points smaller than 9 pixels and then fill holes smaller than 9 pixels. Character spacing is analyzed, and the distance between adjacent character centers is calculated. If the distance is less than 1 / 4 of the average character width, the position is adjusted. Character aspect ratios are calculated, and if the difference in aspect ratios between adjacent characters exceeds 20%, the abnormal characters are scaled. Finally, the character images are concatenated in their original order, and a 3x3 Gaussian kernel is applied to blur the spaces between characters. This yields the final CAPTCHA character matrix, typically 100x30 pixels in size and containing 4-6 characters.

[0035] Step S105 , performing image enhancement processing on the preliminary verification code character matrix, adjusting the color contrast of the characters to highlight the thickness of the character strokes, and generating a verification code image.

[0036] A contrast-limited adaptive histogram equalization process is applied to the verification code character matrix, wherein the process divides the image into local areas, performs histogram equalization on each area, and merges the processing results through an interpolation method; based on the equalization processing results, an Otsu algorithm is used to perform adaptive threshold segmentation, an optimal threshold is determined, and the character area is separated from the background to obtain a binary character image; morphological operations are performed on the binary character image, a skeleton extraction algorithm based on distance transformation is used to retain the main structure of the character, and a dilation operation is performed using a structural element; the processed character image is fused with a background layer generated using a Perlin noise algorithm, and the degree of fusion between the character and the background is controlled by an alpha blending algorithm; Gaussian noise is added to the fused image, wherein the mean of the Gaussian noise is a preset value, and the standard deviation is a preset value, and a bilinear interpolation method is used to randomly distort the local area, and the distortion amplitude is controlled within a preset range to generate a final verification code image.

[0037] For example, contrast-limited adaptive histogram equalization is applied to a preliminary verification code character matrix. The image is segmented into 8x8 local regions. Histogram equalization is performed on each region, and the contrast limit threshold is set to 0.01. The results are combined through interpolation to enhance the local contrast of the image and highlight the outline features of the characters. Adaptive threshold segmentation is performed using the Otsu algorithm. The optimal threshold is determined based on the principle of maximizing the inter-class variance of the image grayscale histogram. The character region is separated from the background to obtain a binary character image while retaining the edge information map. Morphological operations are performed on the binarized character image. A skeleton extraction algorithm based on distance transformation is used to retain the main structure of the character. Then, a 3x3 cross-shaped structuring element is used for dilation. The number of iterations is adjusted according to the required stroke thickness to achieve thickening or thinning of the character strokes. The processed character image is fused with a background layer generated using the Perlin noise algorithm. The degree of fusion between the character and the background is controlled by an alpha blending algorithm. The alpha value is set between 0.6 and 0.8 to adjust the color and transparency of the character. Finally, Gaussian noise with a mean of 0 and a standard deviation of 10 is added, and bilinear interpolation is used to randomly warp local regions within a range of 1-3 pixels to generate the final CAPTCHA image. When processing a 100x30 pixel CAPTCHA character matrix, contrast-limited adaptive histogram equalization is first applied to divide the image into 5x2 bins, each 20x15 pixels in size. A histogram is calculated for each bin, with a contrast threshold of 0.01. Pixels exceeding the threshold are reassigned to other bins. The results are then merged using bilinear interpolation to produce the enhanced image. The Otsu algorithm is then used for adaptive threshold segmentation. The grayscale histogram is calculated, and thresholds are iterated from 0 to 255. The optimal threshold is selected, typically between 100 and 150, to maximize the inter-class variance. Pixels below the threshold are set to 0, and those above the threshold are set to 255, resulting in a binary image. A distance transform is then applied to the binary image, calculating the distance from each foreground pixel to the nearest background pixel. The local maximum point is used as the skeleton. Using a 3x3 cross-shaped structuring element [[(0, 1, 0), (1, 1, 1), (0, 1, 0)]], two or three dilation operations were performed to thicken the character strokes. To generate the background, the Perlin noise algorithm was used, with an 8x8 grid and smooth noise generated through cosine interpolation. To blend the character image with the background, the alpha value was set to 0.7, i.e., I_result = 0.7I_char + 0.3I_background. Gaussian noise was added, and random numbers with a mean of 0 and a standard deviation of 10 were generated using the Box-Muller transform. Finally, bilinear interpolation was applied to 20% of randomly selected regions for local distortion, with a distortion amplitude between 1 and 3 pixels, to produce the final verification code image.

[0038] Step S106 , compressing and formatting the generated verification code image to obtain a final industrial part burr defect verification code for use in defect detection of workpiece parts.

[0039] The verification code image is grayscale converted, and the grayscale conversion converts the RGB value into a single-channel grayscale value through a weighted average method; the grayscale image is subjected to frequency domain analysis according to the single-channel grayscale value, and the frequency domain analysis includes dividing the grayscale image into 8x8 small blocks, performing a two-dimensional discrete cosine transform on the small blocks, and obtaining a frequency domain coefficient matrix; the frequency domain coefficient matrix is ​​subjected to zigzag scanning, and the zigzag scanning converts the frequency domain coefficient matrix into a one-dimensional sequence; the one-dimensional sequence is compressed using arithmetic coding, and the compression encodes the symbols through a probability model to obtain a compressed bit stream; the compressed bit stream is encapsulated into a JPEG format, and the encapsulation includes adding file header information, and the file header information includes an SOI marker, an APP0 segment, a DQT segment, a SOF0 segment, a DHT segment, and an SOS segment; wherein the DQT segment stores a quantization table, the SOF0 segment records the image size and sampling factor, and the DHT segment contains a Huffman table.

[0040] For example, the generated verification code image undergoes grayscale conversion, using a weighted average method to convert RGB values ​​into single-channel grayscale values, reducing the image data volume. A discrete cosine transform is applied to the grayscale image for frequency domain analysis, segmenting the image into 8x8 blocks. Each block undergoes a two-dimensional DCT transform to obtain a frequency domain coefficient matrix. High-frequency coefficients are quantized using the JPEG standard quantization table. The quantization table is scaled based on the target compression ratio, discarding high-frequency information that is insensitive to the human eye. The quantized coefficient matrix undergoes a zigzag scan to convert the two-dimensional matrix into a one-dimensional sequence. The sequence is then compressed using arithmetic coding, and symbols are encoded using a probabilistic model to generate a compressed bitstream. The compressed bitstream is then encapsulated in JPEG format, with file header information added, including an SOI marker, an APP0 segment, a DQT segment, a SOF0 segment, a DHT segment, and a SOS segment. The DQT segment stores the quantization table, the SOF0 segment records the image size and sampling factor, and the DHT segment contains the Huffman table. Finally, a JPEG file of the industrial part burr defect verification code is generated. The generated CAPTCHA image is integrated with a workpiece defect detection system. A CAPTCHA decoding step is incorporated into the preprocessing phase of the image recognition algorithm. CAPTCHA information is extracted through inverse JPEG decompression and character recognition algorithms, serving as a reference for subsequent defect detection. When processing a 100x30 pixel CAPTCHA image, grayscale conversion is first performed using a weighted average method, with weight coefficients R: 0.299, G: 0.587, and B: 0.114. The converted grayscale image is then segmented into 4x4 blocks of 8x8 pixels. A two-dimensional DCT transform is applied to each block, yielding 64 frequency coefficients. Quantization is performed using the JPEG standard luminance quantization table, which is scaled according to the target compression ratio. The quantized coefficient matrix is ​​converted to a one-dimensional sequence using a zigzag scan. The sequence is compressed using adaptive arithmetic coding. The initial probability model assumes equal probability for all symbols, and the probabilities are dynamically updated during the encoding process. The compressed bitstream is encapsulated in JPEG format. The file header contains an SOI marker, an APP0 segment, a DQT segment storing the quantization table, a SOF0 segment recording the image size and sampling factor, a DHT segment storing the Huffman table, and an SOS segment marking the start of the image data. The resulting JPEG file is approximately 30-40% the size of the original image. In the defect detection system, the verification code image is first decoded using JPEG to restore it to a grayscale image. An adaptive threshold segmentation algorithm is then applied to separate the characters from the background, generating a binary image. Connected component analysis is used to extract each character, and its area, perimeter ratio, and orientation are calculated. Finally, a pre-trained support vector machine classifier is used to recognize the characters. The recognition results serve as auxiliary information for defect detection and verify the reliability of the detection results.

[0041] The above embodiment is only one of the preferred implementation methods of the present invention and should not be used to limit the scope of protection of the present invention. Any changes or modifications that have no substantive meaning made to the main design concept and spirit of the present invention, as long as the technical problems they solve are still consistent with the present invention, should be included in the scope of protection of the present invention.

Claims

1. A method for detecting defects in industrial parts, characterized in that: The method comprises: The system obtains an input image of a burr defect on an industrial part, extracts the shape, size, and distribution location features of the burrs in the image, and obtains a burr feature map. Based on the edge roughness and color differences in the burr feature map, the burr defect area is segmented and a binary burr defect mask is generated. Perform morphological operations on the binary burr defect mask, eliminate isolated noise points through dilation and erosion, connect adjacent burr areas, segment the processed burr mask, and extract independent burr defect areas based on the 3D contour and surface texture features of the burr. For each independent burr defect area, its geometric features are calculated, a burr defect feature vector is constructed, and the semantic features of the burr defect feature vector are extracted to obtain the feature representation of the burr defect. Different types of burr defects are grouped based on their feature similarity, and the shape and size features of the most representative samples in each group of burr defects are selected as the representative features of the burr defects in that group. Establishing a mapping relationship between each group of burr defect representatives and verification code characters, including mapping the shape and size attributes of the burrs to the shape and size characteristics of the characters, dividing the original burr defect image into several grids, and generating a preliminary verification code character matrix based on the grid positions and verification code character mapping results; Perform image enhancement processing on the preliminary verification code character matrix, adjust the color contrast of the characters to highlight the thickness of the character strokes, and generate a verification code image; The generated verification code image is compressed and format converted to obtain the final industrial part burr defect verification code, which is used for defect detection of workpiece parts.

2. The method according to claim 1, wherein The method comprises: obtaining an input burr defect image of an industrial part, extracting the shape, size, and distribution position features of the burrs in the image, obtaining a burr feature map, segmenting the burr defect area according to the edge roughness and color difference in the burr feature map, and generating a binary burr defect mask, including: The acquired industrial parts burr defect image is preprocessed by linear grayscale transformation and adaptive histogram equalization to obtain a preprocessed image with enhanced contrast and prominent burr features; Extracting the shape, size and distribution position of the burr according to the preprocessed image, and generating a burr feature map including the burr outline, area and coordinates; Perform edge detection on the burr feature map using a Canny operator to obtain edge information in the burr feature map, and calculate the gradient amplitude and direction of edge pixels; If the edge information meets the high and low thresholds automatically determined by the OTSU algorithm, the edge is binarized to obtain a preliminary burr outline; Performing regional segmentation on the preliminary burr contour using a region growing algorithm based on edge and grayscale gradient, starting with a seed point obtained by edge detection and gradually expanding the segmented region; If the grayscale value difference and gradient direction difference of adjacent pixels are both less than the set threshold, they will be included in the same area until they can no longer be expanded; Evaluating and optimizing the segmented regions, and evaluating the rationality of the segmented regions using shape features and texture features; If the segmented regions are unreasonable, they are merged or split.

3. The method according to claim 1, wherein The morphological operation is performed on the binary burr defect mask to eliminate isolated noise points by dilation and corrosion, and adjacent burr areas are connected. The processed burr mask is segmented, and independent burr defect areas are extracted according to the three-dimensional contour and surface texture characteristics of the burr, including: Apply a dilation operation to the binary burr defect mask, iterate using the structural element to expand the burr area boundary, and then perform an erosion operation to remove isolated noise points to obtain the optimized burr mask image; Extracting contour information of the optimized burr mask using a Sobel operator, calculating curvature change and direction consistency based on the contour information, and determining connectivity of adjacent burr regions; A rigid body transformation algorithm is used to align the two-dimensional burr mask image with the three-dimensional point cloud data collected by the depth camera, and the two-dimensional image coordinate system is converted to the three-dimensional point cloud coordinate system; Performing bilateral filtering to reduce noise on the point cloud data, performing surface reconstruction and smoothing using the moving least squares method, extracting the depth value and normal vector information of each pixel, and constructing a feature vector containing the depth value, the components of the normal vector, and the grayscale value in combination with the grayscale value of the two-dimensional image; The feature vector is segmented using a region growing algorithm, and the edge points of the burr area are selected as seed points. The area is gradually expanded. When the Euclidean distance between the feature vectors of adjacent points is less than a preset threshold, they are included in the same area until further expansion is impossible, resulting in an independent burr defect area.

4. The method according to claim 1, wherein The method comprises the following steps: calculating the geometric features of each independent burr defect area, constructing a burr defect feature vector, extracting the semantic features of the burr defect feature vector, obtaining a feature representation of the burr defect, grouping different types of burr defects based on feature similarity of the burr defects, and selecting the shape and size features of the most representative samples in each group of burr defects as representative features of the group of burr defects. Obtain the geometric features and texture features of the burr defect area and construct a multi-dimensional burr defect feature vector; The geometric features include area, perimeter, circularity, rectangularity, aspect ratio and orientation angle; Performing dimensionality reduction processing on the multi-dimensional burr defect feature vector using an autoencoder comprising a three-layer encoder and a three-layer decoder; If the number of nodes in the middle layer is 1 / 4 of the dimension of the original feature vector, a low-dimensional burr defect feature representation is obtained through the compression and reconstruction process; Performing Z-score normalization on the feature vector output by the autoencoder, and calculating the cosine similarity between different burr defect samples; Constructing a similarity matrix based on the cosine similarity, and analyzing the similarity matrix using a density-based clustering algorithm; If the neighborhood radius is 0.5 and the minimum number of samples is 4, burr defects with similar characteristics are automatically grouped; For each group of burr defects, calculate the average eigenvector and variance of the samples in the group; If the Euclidean distance weight between the sample and the average feature vector in the group is 0.7 and the variance weight of each dimension of the sample feature is 0.3, the sample with the smallest weighted sum is selected as the representative sample of the group.

5. The method according to claim 1, wherein The mapping relationship between each group of burr defect representatives and verification code characters is established, including mapping the burr shape and size attributes to the shape and size characteristics of the characters, dividing the original burr defect image into a plurality of grids, and generating a preliminary verification code character matrix based on the grid positions and the verification code character mapping results, including: Obtain representative features of burr defects and character features of verification codes, and establish a database of corresponding relationships between the representative features of burr defects and the character features of verification codes; Applying the Otsu algorithm to the original burr defect image according to the correspondence database, performing adaptive threshold segmentation to extract independent burr areas in the burr defect image; For the independent burr area, query the corresponding relationship database to obtain characters that match the independent burr area, and fill the characters into preset grid positions to obtain a preliminary character matrix; Calculating the probability of adjacent character combinations in the preliminary character matrix using a bigram model, and determining whether the probability is lower than a preset threshold; If the probability is lower than a preset threshold, recalculate the matching degree between the burr feature at the position and other candidate characters, select the suboptimal matching result to replace the corresponding character in the preliminary character matrix, and obtain an optimized character matrix; It also includes: finding corresponding characters in the verification code character set based on the representative characteristics of the burr defects in the grid, arranging the characters corresponding to the grid according to the grid position, generating a character matrix, analyzing the edge contours of the character matrix, identifying and completing the missing parts, and obtaining a completed character matrix; analyzing the spacing and size relationship between characters in the completed character matrix, segmenting overlapping characters that exceed the overlap requirement, and obtaining optimized characters; splicing the feature image of each character according to the matrix position to obtain a preliminary verification code character matrix.

6. The method according to claim 5, wherein: The method includes: finding corresponding characters in the verification code character set based on representative features of the burr defects in the grid, arranging the characters corresponding to the grid according to the grid positions, generating a character matrix, analyzing the edge contours of the character matrix, identifying and completing the missing parts, and obtaining a completed character matrix, including: A feature vector is constructed based on the area, perimeter ratio, and direction angle of the burr defect in the grid. The support vector machine classifier is used to search for the character with the highest matching degree in the pre-established verification code character feature library to obtain the initial character matrix. Applying the Canny edge detection algorithm to the initial character matrix, calculating the image gradient amplitude and direction, obtaining the edge contour of the character matrix through a double threshold method and edge connection, and identifying areas with discontinuous or missing edges; For the identified missing area, a morphological reconstruction algorithm is used to preliminarily fill the missing part in combination with the shape features and semantic information of adjacent characters, and structural elements with a width close to that of the character strokes are selected. The character contour is reconstructed through iterative dilation and intersection operations to obtain a repaired character contour; A convolutional neural network with a U-Net structure is used to refine the restored character outline. The network input is the restored character image and the output is the complete character image. By learning the local structural features of the character, the character details that conform to the context are generated to obtain the completed character matrix. An optical character recognition algorithm is applied to the completed character matrix for verification, and recognition confidence is calculated. If the recognition confidence is lower than a preset threshold, the convolutional neural network is fine-tuned until a completed character matrix with high confidence is obtained.

7. The method according to claim 5, wherein: The spacing and size relationship between characters in the completed character matrix are analyzed, and overlapping characters that exceed the overlap requirement are segmented to obtain optimized characters; The feature images of each character are spliced ​​according to the matrix position to obtain the preliminary verification code character matrix, including: Apply the connected component analysis algorithm to the completed character matrix, identify independent character regions through 8-neighborhood connectivity judgment, and obtain the character position and size information; Calculating the ratio of the overlapping area of ​​adjacent character bounding boxes to the character area, and if the ratio exceeds a preset threshold, separating the overlapping characters using a segmentation method based on contour analysis; Morphological processing is performed on the separated character images. The rectangular structure elements are used to perform opening operations to remove noise and closing operations to fill the internal holes to obtain a character image with a complete shape. Analyze the spacing and size relationship between characters, calculate the Euclidean distance between the center points of adjacent characters and the character aspect ratio, and if the spacing is less than a preset ratio of the average character width or the aspect ratio difference exceeds a preset threshold, scale and adjust the position of the characters; According to the adjusted character matrix position information, the optimized character feature images are spliced ​​in the original arrangement order, and the Gaussian kernel is applied to the transition area between characters for fuzzy processing to obtain the preliminary verification code character matrix.

8. The method according to claim 1, wherein The image enhancement process is performed on the preliminary verification code character matrix, the color contrast of the characters is adjusted to highlight the thickness of the character strokes, and the verification code image is generated, including: Applying contrast-limited adaptive histogram equalization to the verification code character matrix, wherein the process divides the image into local regions, performs histogram equalization on each region, and combines the results through interpolation; Based on the equalization processing result, the Otsu algorithm is used to perform adaptive threshold segmentation, determine the optimal threshold, separate the character area from the background, and obtain a binary character image; Performing morphological operations on the binary character image, using a skeleton extraction algorithm based on distance transformation to retain the main structure of the character, and performing an expansion operation using structural elements; Fusing the processed character image with a background layer generated using a Perlin noise algorithm, and controlling the degree of fusion between the character and the background using an alpha blending algorithm; Gaussian noise is added to the fused image, where the mean and standard deviation of the Gaussian noise are preset values, and a bilinear interpolation method is used to randomly distort the local area, where the distortion amplitude is controlled within a preset range, to generate a final verification code image.

9. The method according to claim 1, wherein The generated verification code image is compressed and format converted to obtain a final industrial part burr defect verification code for use in defect detection of workpiece parts, including: Performing grayscale conversion on the verification code image, wherein the grayscale conversion converts the RGB value into a single-channel grayscale value by a weighted average method; Performing frequency domain analysis on the grayscale image according to the single-channel grayscale value, wherein the frequency domain analysis includes dividing the grayscale image into 8x8 small blocks, performing a two-dimensional discrete cosine transform on the small blocks, and obtaining a frequency domain coefficient matrix; Performing a zigzag scan on the frequency domain coefficient matrix, wherein the zigzag scan converts the frequency domain coefficient matrix into a one-dimensional sequence; compressing the one-dimensional sequence using arithmetic coding, wherein the compression encodes symbols through a probability model to obtain a compressed bit stream; Encapsulating the compressed bit stream into a JPEG format, wherein the encapsulation includes adding file header information, wherein the file header information includes an SOI marker, an APP0 segment, a DQT segment, a SOF0 segment, a DHT segment, and an SOS segment; The DQT segment stores a quantization table, the SOF0 segment records image size and sampling factor, and the DHT segment contains a Huffman table.

Citation Information

Patent Citations

  • A defect detection device and method based on a motor copper bar burr growth area

    CN109447989A

  • Defect detection method for product

    JP2016004274A