Mold quality detection method and system based on image processing
By constructing a model of periodic strength and periodic similarity, and screening suspected texture pixels, combined with iterative threshold segmentation, the problem of low crack recognition accuracy in mold quality inspection is solved, and high-precision crack detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies have low accuracy in crack identification during mold quality inspection, making it difficult to effectively distinguish cracks from normal textures, resulting in insufficient detection accuracy.
By constructing a model of period strength and period similarity, suspected texture pixels are screened out. Combined with iterative threshold segmentation, crack regions are accurately delineated. High-precision industrial cameras are used to acquire mold surface images, which are then grayscaled and smoothed to remove normal texture interference and improve the accuracy of crack recognition.
It improves the accuracy of crack identification in mold quality inspection, reduces missed and false detections, and ensures the accuracy and reliability of inspection results.
Smart Images

Figure CN121639593A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of mold quality detection, and particularly relates to a mold quality detection method and system based on image processing. BACKGROUND
[0002] The mold is a basic tool for industrial production, and its precision directly affects the size, shape and performance of products. Through mold quality detection, design or manufacturing defects can be found in advance to avoid the production of batch defective products.
[0003] At present, the method for mold quality detection is usually to use a visual iterative threshold segmentation method: an industrial camera is used to obtain a mold surface gray image, the obtained image is preprocessed, and then an iterative threshold segmentation is used to divide a target region, and then a quality is detected through a connected domain feature. A plastic mold production quality visual detection method is disclosed in a Chinese patent document with application number 202311528683.3. According to the periodic distribution of the gray image of the cylindrical device on the surface of the plastic mold cylindrical device in the axial direction, the periodic strength of each pixel point is obtained, and the suspected texture pixel points are screened out according to the periodic strength. Further, according to the neighborhood periodic distribution similarity between the suspected texture pixel points and the pixel points at the periodic position, the corresponding periodic similarity degree is obtained. After combining the periodic strength and the periodic similarity degree, the texture region pixel points are screened out, and finally the texture region is iteratively threshold segmented to obtain a more accurate segmentation result, so that the visual detection effect of the plastic mold production quality is better.
[0004] However, due to the irregular long strip shape of the crack, the gray difference is not significant; the normal texture is a periodic ring / linear structure, and the local gray is disordered after mixing, which is difficult to distinguish. Moreover, the iterative threshold segmentation is inaccurate due to the gray overlap in the mixed area, and the periodic analysis is disturbed by the randomness of the crack, which leads to threshold deviation and pixel point attribute misjudgment, and finally affects the detection accuracy. Therefore, we need to propose a mold quality detection method and system based on image processing to solve the above problems and effectively improve the crack recognition accuracy. SUMMARY
[0005] The purpose of the present application is to provide a mold quality detection method and system based on image processing, which can effectively improve the crack recognition accuracy to solve the problems raised in the background technology.
[0006] To achieve the above purpose, the technical scheme adopted by the present application is as follows:
[0007] A mold quality detection method based on image processing, comprising the following steps:
[0008] S1, a high-precision industrial camera is installed directly above the mold to obtain a mold surface gray image, and the obtained image is grayed and smoothed;
[0009] S2, constructing a distribution model according to the reference distance distribution condition of each pixel point in the image after the smoothing processing, calculating a periodicity strength degree, preliminarily screening the pixel points according to the periodicity strength degree, and distinguishing the possibility of texture pixel points and non-texture pixel points;
[0010] S3, taking the pixel points with the periodicity strength degree greater than a preset periodicity threshold value in the texture pixel points as suspected texture pixel points, and screening out the suspected texture pixel points;
[0011] S4, taking the suspected texture pixel points as targets, constructing a comprehensive model by using the circumferential edge pixel points and the periodic weight pixel points, and calculating a periodic similarity degree;
[0012] S5, multiplying the periodicity strength degree and the periodic similarity degree of the suspected texture pixel points, obtaining a texture region possibility, and comprehensively considering the probability that the pixel points belong to the texture region;
[0013] S6, taking the suspected texture pixel points with the texture region possibility greater than a preset threshold value as texture region pixel points, and determining the texture region to be screened out;
[0014] S7, performing iterative threshold segmentation after screening out the texture region pixel points, and accurately dividing out a target region with a crack region feature;
[0015] S8, obtaining a minimum circumscribed rectangle of a connected domain of the target region, and judging by a length-width ratio, if the length-width ratio is greater than a preset elongated threshold value, it is recorded as unqualified, otherwise, it is recorded as qualified.
[0016] Preferably, the periodicity strength degree calculation process is as follows:
[0017] A1, sequentially taking each pixel point in the image as a target pixel point;
[0018] A2, in the axial neighborhood, screening out the pixel points with the difference in the gray value from the target pixel point less than a preset gray threshold value as axial reference pixel points;
[0019] A3, calculating the gradient value of the axial reference pixel points, obtaining a gradient mean value, and defining the reference pixel points with the gradient value greater than the mean value as axial edge pixel points;
[0020] A4, arranging the edge pixel points along the axis to obtain a sequence, calculating the distance between the mth pixel and the previous pixel in the sequence, and taking this distance as a reference distance;
[0021] A5, substituting the reference distance into the distribution model to calculate the periodicity strength degree of the target pixel point.
[0022] Preferably, the preset periodicity threshold is determined based on the normalized distribution characteristics of periodic strength and statistical analysis of sample texture features, using empirical benchmarks and sample calibration. The preset periodicity threshold needs to balance the recall and precision of texture pixels. When the periodic strength of a texture pixel is not greater than the preset periodicity threshold, the texture pixel is directly excluded from the subsequent texture region analysis process and is not marked as a suspected texture pixel.
[0023] The preferred method for calculating periodic similarity is as follows:
[0024] B1. For the axial edge sequence of suspected texture pixels, calculate the distance between each edge pixel and the two previous edge pixels, and take the average value as the periodic reference distance.
[0025] B2. Within the axial neighborhood, select pixels that are an integer multiple of the period reference distance from the suspected texture pixels, and construct a period comparison pixel sequence by sorting them by distance.
[0026] B3. For each period comparison pixel, find the axial reference pixel with small gray level difference in the axial preset neighborhood, calculate the gradient mean to determine the axial edge pixel, and take the two closest pixels as the period weight pixel.
[0027] B4. Substitute the axial edge pixels into the comprehensive model to calculate the periodic similarity.
[0028] Preferably, the probability of the texture region is obtained by multiplying the product result close to 1 only when both the period strength and period similarity are high. If either parameter is low, the product result will be significantly reduced, thereby excluding non-texture pixels. When the probability of the texture region is determined, combined with a preset texture threshold, if the product of the period strength and period similarity is greater than the predicted texture threshold, then the pixel is highly likely to be a texture region and is initially confirmed as a texture region pixel. Otherwise, the texture region range is excluded and will not participate in texture filtering in the future.
[0029] The preferred method for determining the probability of belonging to a texture region is as follows:
[0030] By setting a preset texture threshold, cases where the product of period strength and period similarity is greater than the preset texture threshold are classified as high probability, and cases where the product of period strength and period similarity is less than or equal to the preset texture threshold are classified as low probability. When it is high probability, it is determined to be a pixel in a texture region and needs to be removed in subsequent iterations of threshold segmentation; when it is low probability, it is determined to be a pixel in a non-texture region.
[0031] Preferably, when determining the texture regions to be screened out, all suspected texture pixels are traversed, and the product of the period strength and period similarity is compared with a preset texture threshold. High-probability pixels are marked as texture, and low-probability pixels are marked as non-texture. The marked texture map is aligned with the original image to ensure that the resolution and pixel coordinates of the texture marking are completely consistent with the original image. Then, the original image is processed at the pixel level. Based on the marking results of the texture map, the gray values of the pixels in the texture region are set to specific invalid values. Then, the image after screening is visually inspected to confirm that the normal texture regions have been effectively masked and the gray-scale features of the background and potential crack regions have not been destroyed. If local textures are found to have not been screened out, the texture threshold needs to be fine-tuned and re-marked for screening.
[0032] Preferably, iterative threshold segmentation includes the following steps:
[0033] C1, grayscale image after texture removal;
[0034] C2. Traverse the image and extract all pixels whose grayscale value is not equal to an invalid value to form a set of valid pixels;
[0035] C3. Based on the grayscale distribution of the effective pixel set, set an initial threshold;
[0036] C4. Based on the current threshold, divide the set of valid pixels into foreground and background categories;
[0037] C5. Use the average grayscale value of foreground and background pixels as the new threshold;
[0038] C6. Repeat C4-C5 for iteration until the absolute value of the difference between the new threshold and the initial threshold is less than the iteration precision, then stop the iteration. The new threshold of the last iteration is the final segmentation threshold.
[0039] C7. Process the image after removing texture using the final segmentation threshold. Mark the pixels in the effective pixels whose gray values are less than or equal to the final segmentation threshold as crack candidate regions and set their gray values to the gray values corresponding to white. Mark the pixels in the effective pixels whose gray values are greater than the final segmentation threshold as background region pixels and set their gray values to the gray values corresponding to black. The resulting binary image is the target region segmentation map, where the white regions are suspected crack regions.
[0040] C8. First, perform an opening operation on the target region segmentation map using a 3*3 structuring element to remove tiny noise points in the target region segmentation map. Then, perform a closing operation using a 3*3 structuring element to fill the small voids in the crack region, making the crack outline more complete. Finally, output the optimized target region.
[0041] Preferably, when determining the aspect ratio, first perform connected component analysis on the target area, extract each connected component, then calculate the minimum bounding rectangle of each connected component to obtain the aspect ratio, and finally compare the aspect ratio with a preset slenderness threshold: if there is a connected component with an aspect ratio greater than the preset slenderness threshold, the mold is determined to be unqualified; otherwise, it is determined to be qualified.
[0042] Based on the above description of an image processing-based mold quality inspection method, the present invention also provides an image processing-based mold quality inspection system, including: an image acquisition module: using a high-precision industrial camera to take a picture from directly above the mold, acquiring an image of the mold surface and performing grayscale and smoothing processing;
[0043] Periodic analysis module: used to calculate the strength of pixel periodicity, filter suspected texture pixels, analyze the periodicity similarity of neighborhood periodic distribution, provide a basis for judging pixels in textured regions, and preliminarily process the image to distinguish the possibility of texture pixels from non-texture pixels.
[0044] Texture filtering module: Calculates the probability of texture regions based on the results of the periodic analysis module, filters out the pixels of texture regions, determines the normal texture regions that need to be removed, and reduces the interference of normal textures on subsequent detection;
[0045] Threshold segmentation module: After filtering out pixels in textured areas, iterative threshold segmentation is performed to obtain accurate target areas, highlighting defective areas such as cracks, which facilitates subsequent quality judgment;
[0046] Quality judgment module: Based on the target area obtained by the threshold segmentation module, calculate the aspect ratio of the minimum bounding rectangle of the connected region, compare it with the preset threshold to judge the quality of the mold, and output the detection result.
[0047] The mold quality inspection method and system based on image processing proposed in this invention have the following advantages compared with the prior art:
[0048] 1. This invention utilizes the difference between the periodicity of normal textures and the randomness of cracks. By calculating the strength of periodicity, filtering textured and non-texture pixels, filtering suspected textured pixels, calculating periodic similarity, and removing textured regions before iterative threshold segmentation, it solves the detection problem caused by the mixing of cracks and normal textures and improves detection accuracy.
[0049] 2. This invention uses the effective pixel set output after texture removal as the input data for iterative threshold segmentation, avoiding interference from the grayscale values of texture pixels in threshold calculation. After texture removal, the effective pixels only contain the background and defects. Iterative threshold segmentation can more accurately find the grayscale boundary between the background and defects, rather than a mixed boundary of background-texture-defect. Based on the precise labeling of the product of period strength and period similarity, the more thorough the texture removal, the purer the basis for calculating the iterative threshold, and the higher the distinction between the final segmented target area (crack) and the background, reducing missed detections and false detections.
[0050] 3. This invention utilizes the coordinated operation of an image acquisition module, a periodic analysis module, a texture filtering module, a threshold segmentation module, and a quality judgment module. The image acquisition module provides data, the periodic analysis module and the texture filtering module process the data to remove normal texture interference, the threshold segmentation module accurately divides the target area, and the quality judgment module draws a detection conclusion based on the segmentation results. This close cooperation effectively improves the accuracy of crack recognition. Attached Figure Description
[0051] Figure 1 A flowchart of a detection method according to an embodiment of the present invention is shown;
[0052] Figure 2 A flowchart illustrating the calculation of the strength of a period according to an embodiment of the present invention is shown;
[0053] Figure 3 A flowchart of the periodic similarity calculation process according to an embodiment of the present invention is shown;
[0054] Figure 4 A block diagram of a detection system according to an embodiment of the present invention is shown. Detailed Implementation
[0055] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The specific embodiments described herein are merely used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0056] This invention provides, for example Figures 1-3 The image processing-based mold quality inspection method shown includes the following steps:
[0057] S1. Install a high-precision industrial camera directly above the mold to acquire grayscale images of the mold surface, and perform grayscale conversion and smoothing on the acquired images to reduce the impact of noise;
[0058] In grayscale conversion, a weighted average method is used to convert a color image to a grayscale image. The conversion formula is as follows:
[0059] Gray = 0.299R + 0.587G + 0.114B
[0060] Where Gray is the gray value of the grayscale image, and R, G, and B are the intensity values of the original image in the red, green, and blue channels, respectively;
[0061] During smoothing, a Gaussian kernel is generated using a two-dimensional Gaussian function, which is then convolved with the grayscale image. The formula for the two-dimensional Gaussian function is as follows:
[0062] ,
[0063] in, The coordinates in the Gaussian kernel are The pixel weight values, x and y are the relative coordinates of the current pixel with the Gaussian kernel as the origin (0,0). The standard deviation of the Gaussian kernel. The normalization coefficient ensures that the sum of all weights in the Gaussian kernel is 1;
[0064] The formula for convolution is:
[0065] ,
[0066] in, The coordinates in the convolutional image are The new grayscale value of the pixel, In the original grayscale image, Within the neighborhood of the center, the coordinates are The original grayscale value of the pixel. The corresponding position in the Gaussian kernel The weight values, where k is the Gaussian kernel radius. Indicates to The weighted summation is performed on all pixels within the (2k+1)*(2k+1)-neighborhood of the center;
[0067] S2. Construct a distribution model based on the reference distance distribution of each pixel in the smoothed image, calculate the strength of the period, and preliminarily filter pixels based on the strength of the period to distinguish the possibility of texture pixels from non-texture pixels.
[0068] The formula for the distribution model is:
[0069] ,
[0070] in, For target pixel The strength of the periodicity, where M is the total number of pixels along the axial edge. This is the reference distance to the m-th edge pixel in the sequence. This is the reference distance for the (m-2)th edge pixel in the sequence. The preset first adjustment parameter is greater than 0. It is a linear normalization function;
[0071] The calculation process for the strength of a cycle is as follows:
[0072] A1. Take each pixel in the image as the target pixel in turn;
[0073] A2. Within the axial neighborhood (e.g., 30 pixels on each side of the target pixel), select pixels whose grayscale values differ from the target pixel's grayscale value by less than a preset grayscale threshold, and use them as axial reference pixels.
[0074] The preset grayscale threshold is set based on the grayscale distribution characteristics of the mold surface, the grayscale difference pattern between texture and defects, and the noise interference level. For example, by collecting multiple sets of grayscale images of the surface of defect-free molds, the distribution of grayscale difference values of adjacent pixels in the normal texture area is statistically analyzed (e.g., most differences are concentrated in 5~8). The preset grayscale threshold needs to cover this inherent fluctuation range to avoid mistakenly excluding normal texture pixels from the reference pixels. Usually, the preset grayscale threshold is set to 10, which is determined based on the inherent grayscale fluctuation upper limit of most defect-free samples, to ensure that pixels in the neighborhood of normal texture can be included in the axial reference pixel point.
[0075] A3. Calculate the gradient value of the axial reference pixel, find the average gradient, and define the reference pixel with a gradient value greater than the average value as the axial edge pixel. The gradient value of the axial reference pixel is calculated using the Sobel operator.
[0076] A4. Arrange the edge pixels along the axis to obtain a sequence, calculate the distance between the m-th pixel in the sequence and the previous pixel, and use this distance as a reference distance;
[0077] A5. Substitute the reference distance into the distribution model to calculate the periodic strength of the target pixel;
[0078] S3. Select suspected texture pixels whose period strength is greater than the preset periodicity threshold.
[0079] The preset periodic threshold is determined based on the normalized distribution characteristics of periodic strength and the statistical analysis of sample texture features, using empirical benchmarks and sample calibration. Since the normalized range of periodic strength is [0, 1], the preset periodic threshold needs to balance the recall and precision of texture pixels, and is usually set between 0.7 and 0.9.
[0080] The process for setting periodic thresholds is as follows:
[0081] 1) Collect multiple sets of grayscale images of the surface of defect-free cylindrical plastic mold components, and extract pixels from known normal texture areas;
[0082] 2) Calculate the periodic strength of all normal texture pixels in the sample to obtain their distribution range (e.g., most are concentrated in 0.75~0.95).
[0083] 3) Based on the distribution range, select a value near the lower limit of the range as the initial threshold (e.g., take 0.8 to ensure that more than 80% of the real texture pixels are covered).
[0084] 4) Test with sample images containing a small number of defects. If too many texture pixels are missed, lower the threshold. If too many non-texture pixels are misjudged, raise the threshold. Finally, determine the optimal threshold.
[0085] When the periodicity of a texture pixel is not greater than the preset periodicity threshold, the texture pixel is directly excluded from the subsequent texture region analysis process and is not marked as a suspected texture pixel. In the subsequent iterative threshold segmentation, these pixels will be retained in the image and participate in the segmentation calculation of the target region, avoiding the false exclusion of defective regions by normal texture screening.
[0086] S4. Using suspected texture pixels as targets, construct a comprehensive model using its circumferential edge pixels and periodic weight pixels, and calculate the periodic similarity.
[0087] The formula for the integrated model is as follows:
[0088] ,
[0089] in, For the target suspected texture pixel The degree of periodic similarity, where N is the number of elements in the periodically compared pixel sequence. This represents the number of axial reference pixels for the comparison pixels in the nth period. for The number of axial reference pixels, This represents the periodic strength of the two circumferential weighted pixels compared in the nth period, where n is the index value of the pixel being compared. This is the floor function, where b is a preset second adjustment parameter that is greater than 0. It is a linear normalization function;
[0090] The process for calculating periodic similarity is as follows:
[0091] B1. For the axial edge sequence of suspected texture pixels, calculate the distance between each edge pixel and the two previous edge pixels, and take the average value as the periodic reference distance.
[0092] B2. Within the axial neighborhood, select pixels that are an integer multiple of the period reference distance from the suspected texture pixels, and construct a period comparison pixel sequence by sorting them by distance.
[0093] B3. For each period comparison pixel, find the axial reference pixel with small gray level difference in the axial preset neighborhood, calculate the gradient mean to determine the axial edge pixel, and take the two closest pixels as the period weight pixel.
[0094] B4. Substitute the axial edge pixels into the comprehensive model to calculate the periodic similarity.
[0095] S5. Multiply the period strength and period similarity of suspected texture pixels to obtain the probability of texture regions, and comprehensively consider the probability that a pixel belongs to a texture region.
[0096] The probability of a texture region is obtained by multiplying the period strength and period similarity together until the product is close to 1. If either parameter is low, the product will be significantly reduced, thus excluding non-texture pixels. When the probability of a texture region is determined, a preset texture threshold is used. If the product of the period strength and period similarity is greater than the predicted texture threshold, then the pixel is highly likely to be a texture region and is initially identified as a texture region pixel. Otherwise, the texture region is excluded and will not participate in texture filtering in the future.
[0097] The predicted texture threshold is validated for its rationality by using multiple sets of known normal texture regions. If too many normal texture pixels are missed (e.g., the product of the period strength and period similarity of some real textures is lower than the threshold), the texture threshold is lowered. If too many non-texture points are texture points (e.g., the product of the period strength and period similarity of background pixels is higher than the threshold), the texture threshold is appropriately increased to ensure the accuracy of the confirmation results.
[0098] The specific method for confirming the probability of belonging to a texture region is as follows:
[0099] Since both the strength of the period and the similarity of the period are normalized, their product is in the range of [0,1]. This range directly corresponds to the probability. When the product of the strength of the period and the similarity of the period is close to 1, it means that the pixel satisfies both strong axial period and high neighborhood period consistency, and the probability of it belonging to the normal texture region is higher.
[0100] When the product of period strength and period similarity is close to 0, it indicates that the pixel lacks periodic features or has poor neighborhood consistency, and the probability of it belonging to a normal texture area is lower.
[0101] By setting a preset texture threshold, cases where the product of period strength and period similarity is greater than the preset texture threshold are classified as high probability, while cases where the product of period strength and period similarity is less than or equal to the preset texture threshold are classified as low probability. When the probability is high, it is determined to be a pixel in a texture region, which needs to be removed in subsequent iterations of threshold segmentation to avoid interfering with defect detection. When the probability is low, it is determined to be a pixel in a non-texture region, which is retained in the image to participate in the segmentation calculation of the defect region.
[0102] S6. Select suspected texture pixels with a texture region probability greater than a preset threshold as texture region pixels to determine the texture regions to be filtered out.
[0103] When identifying texture regions to be filtered, high-probability texture pixels are marked and removed based on their probability, ensuring that the remaining pixels focus on the background or defect areas. Specifically, all suspected texture pixels are traversed, and the product of period strength and period similarity is compared with a preset texture threshold. High-probability pixels are marked as texture, and low-probability pixels are marked as non-texture. The marked texture map is aligned with the original image to ensure that the resolution and pixel coordinates of the texture markings are completely consistent with the original image, avoiding erroneous or missed removals due to coordinate misalignment. Then, the original image is processed at the pixel level, and the grayscale values of the texture region pixels are set to specific invalid values based on the marking results of the texture map. The filtered image is then visually inspected to confirm that normal texture regions have been effectively masked and that the grayscale characteristics of the background and potential crack areas have not been destroyed. If local textures are found to have not been filtered out, the texture threshold needs to be fine-tuned for re-marking and filtering to ensure thorough filtering.
[0104] S7. After filtering out pixels in the textured region, perform iterative threshold segmentation to reduce the interference of normal textured regions on the iterative threshold calculation and accurately delineate the target region with crack region characteristics.
[0105] Iterative thresholding involves the following steps:
[0106] C1. Grayscale image after removing texture (texture areas are set to invalid values, so invalid value pixels need to be filtered out first, and only non-texture pixels are retained to participate in the threshold calculation).
[0107] C2. Traverse the image and extract all pixels whose gray values are not equal to invalid values (such as not equal to 0) to form a set of valid pixels, and denote its gray value range as (Gmin, Gmax).
[0108] C3. Based on the grayscale distribution of the effective pixel set, set an initial threshold. The formula for setting the initial threshold is:
[0109] ,
[0110] in, As the initial threshold is set, Gmin and Gmax are the minimum and maximum gray values in the set of valid pixels, respectively;
[0111] C4. Based on the current threshold, divide the set of valid pixels into foreground and background categories;
[0112] Among them, if the current gray value is less than or equal to the current threshold, it is determined to be a foreground type, i.e., a suspected defect area;
[0113] If the current grayscale value is greater than the current threshold, it is determined to be a background area, i.e., a normal area;
[0114] C5. Use the average grayscale value of foreground and background pixels as the new threshold;
[0115] C6. Repeat C4-C5 for iteration until the absolute value of the difference between the new threshold and the initial threshold is less than the iteration precision, then stop the iteration. The new threshold of the last iteration is the final segmentation threshold.
[0116] C7. Process the image after removing texture using the final segmentation threshold. Mark the pixels in the effective pixels whose gray values are less than or equal to the final segmentation threshold as crack candidate regions, and set their gray values to the gray values corresponding to white, i.e., 255. Mark the pixels in the effective pixels whose gray values are greater than the final segmentation threshold as background region pixels, and set their gray values to the gray values corresponding to black, i.e., 0. The resulting binary image is the target region segmentation map, where the white regions are suspected crack regions.
[0117] C8. First, perform an opening operation (erosion followed by dilation) on the target region segmentation map using a 3*3 structuring element to remove tiny noise points in the target region segmentation map. Then, perform a closing operation (dilation followed by erosion) on the target region segmentation map using a 3*3 structuring element to fill the small voids in the crack region, making the crack outline more complete. Finally, output the optimized target region for subsequent connected component analysis and quality judgment.
[0118] S8. Obtain the minimum bounding rectangle of the connected components of the target region. Determine the aspect ratio. If the aspect ratio is greater than the preset slenderness threshold, it is recorded as unqualified; otherwise, it is recorded as qualified.
[0119] When determining the aspect ratio, first perform connected component analysis on the target area, extract each connected component, then calculate the minimum bounding rectangle of each connected component to obtain the aspect ratio, and finally compare the aspect ratio with a preset elongation threshold (e.g., 10): if there is a connected component with an aspect ratio greater than the preset elongation threshold, the mold is deemed unqualified; otherwise, it is deemed qualified.
[0120] The preset slender threshold is based on the morphological differences between crack defects and normal interference areas. Combined with sample statistics and engineering experience, a dual approach of defect morphology analysis and sample calibration is adopted to ensure accurate differentiation between long strip cracks and non-crack connected regions, such as blocky areas formed by tiny impurities and noise.
[0121] By directly using the set of valid pixels output after texture removal as input data for iterative threshold segmentation, the grayscale values of texture pixels are avoided from interfering with threshold calculation. After texture removal, the valid pixels only contain background and defects. Iterative threshold segmentation can more accurately find the grayscale boundary between the background and defects, rather than a mixed boundary of background-texture-defect. Based on the precise labeling of the product of period strength and period similarity, the more thorough the texture removal, the purer the basis for iterative threshold calculation, and the higher the distinction between the final segmented target area (crack) and the background, reducing missed detections and false detections.
[0122] By utilizing the difference between the periodicity of normal textures and the randomness of cracks, and by calculating the strength of periodicity, filtering textured and non-textured pixels, filtering suspected textured pixels, calculating periodic similarity, and removing textured regions before iterative threshold segmentation, the detection problem caused by the mixing of cracks and normal textures is solved, and the detection accuracy is improved.
[0123] Based on the above-described image processing-based mold quality inspection method, this invention also provides an image processing-based mold quality inspection system, such as... Figure 4 As shown, it includes an image acquisition module, a periodic analysis module, a texture filtering module, a threshold segmentation module, and a quality judgment module. The image acquisition module uses a high-precision industrial camera to take pictures directly above the mold, acquire the mold surface image, and perform grayscale and smoothing processing.
[0124] The period analysis module is used to calculate the strength of the period of pixels, screen suspected texture pixels, analyze the period similarity of the period distribution in the neighborhood, provide a basis for judging the pixels in the texture region, and preliminarily process the image to distinguish the possibility of texture pixels from non-texture pixels.
[0125] The texture filtering module calculates the probability of texture regions based on the results of the periodic analysis module, filters out the pixels of texture regions, determines the normal texture regions that need to be removed, and reduces the interference of normal textures on subsequent detection.
[0126] The threshold segmentation module performs iterative threshold segmentation after filtering out pixels in the texture area to obtain an accurate target area, highlighting defect areas such as cracks, which facilitates subsequent quality judgment.
[0127] The quality judgment module calculates the aspect ratio of the minimum bounding rectangle of the connected region based on the target region obtained by the threshold segmentation module, compares it with the preset threshold to judge the quality of the mold, and outputs the detection result.
[0128] By working together with the image acquisition module, periodic analysis module, texture filtering module, threshold segmentation module, and quality judgment module, the image acquisition module provides data, the periodic analysis module and texture filtering module process the data to remove normal texture interference, the threshold segmentation module accurately divides the target area, and the quality judgment module draws a detection conclusion based on the segmentation results. This close cooperation effectively improves the accuracy of crack recognition.
[0129] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A mold quality detection method based on image processing, characterized by, The method comprises the following steps: S1, a high-precision industrial camera is installed directly above the mold to obtain a mold surface gray image, and the obtained image is grayed and smoothed; S2, a distribution model is constructed according to the reference distance distribution of each pixel point in the smoothed image, the periodicity strength is calculated, the pixel points are preliminarily screened according to the periodicity strength, and the possibility of distinguishing texture pixel points and non-texture pixel points is determined; S3, the pixel points with periodicity strength greater than a preset periodicity threshold in the texture pixel points are regarded as suspected texture pixel points, and the suspected texture pixel points are screened out; S4, taking the suspected texture pixel points as targets, a comprehensive model is constructed by using the circumferential edge pixel points and periodic weight pixel points, and the periodic similarity is calculated; S5, the periodicity strength and the periodic similarity of the suspected texture pixel points are multiplied to obtain the texture region possibility, and the probability that the pixel points belong to the texture region is comprehensively considered; S6, the suspected texture pixel points with texture region possibility greater than a preset threshold are regarded as texture region pixel points, and the texture region to be screened out is determined; S7, after the texture region pixel points are screened out, iterative threshold segmentation is performed to accurately divide the target region with crack region characteristics; S8, the minimum circumscribed rectangle of the connected domain of the target region is obtained, and the length-width ratio is judged. If the length-width ratio is greater than a preset elongated threshold, it is recorded as unqualified, otherwise, it is recorded as qualified.
2. The mold quality detection method based on image processing according to claim 1, characterized in that: The periodicity strength calculation process is as follows: A1, each pixel point in the image is taken as a target pixel point in turn; A2, in the axial neighborhood, the pixel points with a gray value difference less than a preset gray threshold from the target pixel point are selected as axial reference pixel points; A3, the gradient values of the axial reference pixel points are calculated, the gradient mean value is obtained, and the reference pixel points with gradient values greater than the mean value are determined as axial edge pixel points; A4, the edge pixel points are arranged along the axis to obtain a sequence, the distance between the mth pixel and the previous pixel in the sequence is calculated, and the distance is taken as the reference distance; A5, the reference distance is substituted into the distribution model to calculate the periodicity strength of the target pixel point.
3. The mold quality detection method based on image processing according to claim 2, characterized in that: The preset of the periodicity threshold is based on the normalized periodicity strength distribution characteristics and sample texture feature statistics, and is determined by using an experience benchmark and sample calibration. The preset periodicity threshold needs to balance the recall rate and precision rate of the texture pixel points. When the periodicity strength of the texture pixel point is not greater than the preset periodicity threshold, the texture pixel point is directly excluded from the subsequent texture region analysis process, and is not marked as a suspected texture pixel point.
4. The mold quality detection method based on image processing according to claim 3, characterized in that: The periodic similarity calculation process is as follows: B1, for the axial edge sequence of the suspected texture pixel point, the interval distance between each edge pixel point and the previous two edge pixel points is calculated, and the mean value is taken as the periodic reference distance; B2, in the axial neighborhood, the pixel points with a distance of an integer multiple of the periodic reference distance from the suspected texture pixel point are selected, and a periodic comparison pixel point sequence is constructed according to the distance; B3, for each periodic comparison pixel point, the axial reference pixel points with small gray difference are found in the axial preset neighborhood, the axial edge pixel points are determined by calculating the gradient mean value, and the two closest ones are taken as the periodic weight pixel points; B4, the axial edge pixel points are substituted into the comprehensive model to calculate the periodic similarity.
5. The mold quality detection method based on image processing according to claim 4, characterized in that: The texture region possibility is obtained in the following manner: only when the periodicity strength and the periodicity similarity are both high, the product result is close to 1, and if either parameter is low, the product result is significantly reduced, thereby excluding non-texture pixel points. In the determination of the texture region possibility, a preset texture threshold is combined, and if the product of the periodicity strength and the periodicity similarity is greater than the preset texture threshold, the pixel point is high in texture region possibility, and is preliminarily confirmed as a texture region pixel point, otherwise, the texture region range is excluded, and the pixel point is not involved in subsequent texture screening.
6. The mold quality detection method based on image processing according to claim 5, characterized in that: The specific confirmation manner of the probability of belonging to the texture region is as follows: The product of the periodicity strength and the periodicity similarity is greater than the preset texture threshold is divided into high probability, and the product of the periodicity strength and the periodicity similarity is less than or equal to the preset texture threshold is divided into low probability. When the probability is high, the pixel point is determined as a texture region pixel point, and is excluded in subsequent iterative threshold segmentation; when the probability is low, the pixel point is determined as a non-texture region pixel point.
7. The mold quality detection method based on image processing according to claim 6, characterized in that: In the determination of the texture region to be screened, all suspected texture pixel points are traversed, and the product of the periodicity strength and the periodicity similarity is compared with the preset texture threshold. The pixel points with high probability are marked as texture, and the pixel points with low probability are marked as non-texture. The marked texture map is aligned with the original image to ensure that the texture marking is completely consistent with the resolution and pixel coordinates of the original image. Then, the original image is processed at the pixel level. According to the marking result of the texture map, the gray value of the texture region pixel point is set to a specific invalid value. Then, the screened image is visually inspected to confirm that the normal texture region has been effectively shielded, and the gray scale features of the background and potential crack region have not been destroyed. If local texture is found to be not screened, the texture threshold needs to be fine-tuned for re-marking and screening.
8. The mold quality detection method based on image processing according to claim 7, characterized in that: The iterative threshold segmentation includes the following steps: C1, a gray scale image after screening of texture; C2, all pixel points with a gray scale value not equal to the invalid value are extracted to form an effective pixel set by traversing the image; C3, an initial threshold is set based on the gray scale distribution of the effective pixel set; C4, the effective pixel set is divided into a foreground class and a background class according to the current threshold; C5, the average gray scale mean values of the foreground class and the background class pixels are used as a new threshold; C6, C4-C5 are repeated for iteration until the absolute value of the difference between the new threshold and the initial threshold is less than the iteration accuracy, and the iteration is stopped. The new threshold of the last iteration is the final segmentation threshold; C7, the screened image after screening of texture is processed by using the final segmentation threshold. The pixels in the effective pixel set with a gray scale value less than or equal to the final segmentation threshold are marked as crack candidate regions, and the gray scale value is set to the gray scale value corresponding to white. The pixels in the effective pixel set with a gray scale value greater than the final segmentation threshold are marked as background region pixels, and the gray scale value is set to the gray scale value corresponding to black. At this time, the obtained binary image is the target region segmentation image, wherein the white region is a suspected crack region. C8, the target region segmentation map is first opened with a 3*3 structure element to remove the tiny noise points in the target region segmentation map, and then closed with a 3*3 structure element to fill the small holes in the crack region, making the crack profile more complete, and finally output the optimized target region.
9. The mold quality detection method based on image processing according to claim 8, characterized in that: In the aspect ratio judgment, first, the target region is subjected to connected component analysis, and each connected component is extracted, then the minimum bounding rectangle of each connected component is calculated to obtain the aspect ratio, and finally the aspect ratio is compared with the preset elongated threshold: if there is a connected component with an aspect ratio greater than the preset elongated threshold, the mold is determined to be unqualified; Otherwise, it is determined to be qualified.
10. A mold quality detection system based on image processing, implementing the mold quality detection method based on image processing of any one of claims 1-9, characterized in that: It includes: Image acquisition module: using a high-precision industrial camera to shoot directly above the mold, obtaining the mold surface image and gray scale and smoothing processing; Period analysis module: used to calculate the period strength of pixel points, screen suspected texture pixel points, analyze the neighborhood period distribution to obtain the period similarity, and provide a basis for judging texture region pixel points, and preliminarily process the image to distinguish the possibility of texture pixel points and non-texture pixel points; Texture screening module: calculate the texture region possibility according to the results of the period analysis module, screen out the texture region pixel points, determine the normal texture region to be removed, and reduce the interference of normal texture on subsequent detection; Threshold segmentation module: after screening out the texture region pixel points, iterative threshold segmentation is carried out to obtain the accurate target region, highlight the defect area such as crack, and facilitate subsequent quality judgment; Quality judgment module: according to the target region obtained by the threshold segmentation module, the aspect ratio of the minimum bounding rectangle of the connected component is calculated, compared with the preset threshold to judge the mold quality, and the detection result is output.
Citation Information
Patent Citations
Visual inspection method for production quality of plastic mold
CN117252874A
Cited By
An intelligent method and system for detecting cracks in an aero-engine blade
CN122156240A
A method for visual detection of thermal shock cracks in an industrial robot protective cover
CN122306826A
A visual inspection method for thermal shock cracks in industrial robot protective covers
CN122306826B