Machine Vision-Based Mold Precision Detection Method
Through the mold accuracy detection method based on machine vision, Hough linear detection and cluster analysis are used to solve the problem of false detection caused by image tilt in mold detection, and the accuracy and accuracy of mold detection are improved.
Patent Information
- Application Number
- CN202410967928.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2044-07-18
AI Technical Summary
The existing image matching algorithm fails to effectively deal with the error detection problem caused by image tilt in mold detection, which affects the mold accuracy detection results.
Through a machine vision-based method, the Hough linear detection algorithm is used to divide the mold surface area, and cluster analysis is used to determine the cluster cluster feature difference coefficient and corner point difference coefficient of each image block in the template image. Combined with the region matching degree, the point set is constructed for accuracy detection.
It improves the accuracy of mold detection, can accurately locate pixel coordinates under the image tilt, analyze the differences inside and outside the cluster cluster, clarify the defects on the surface of the mold, and improves the accuracy of detection.
Smart Images

Figure CN118898593B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image detection technology, and specifically relates to a method for detecting the precision of a mold based on machine vision. Background Art
[0002] With the rapid development of industries such as electronic products, automotive parts, and medical devices, the importance of precision plastic shell injection molding technology has become increasingly prominent. Injection molds are the core tools for injection molding, and their design and manufacturing directly affect the quality and production efficiency of products. During the continuous production process of injection molds, due to repeated injection and cooling cycles of high-temperature plastic melts, defects such as char marks, deformation, and pits are likely to appear on the mold surface. In order to ensure the surface smoothness and quality stability of injection molded parts, it is particularly important to accurately detect the surface condition of injection molds.
[0003] The surface of the mold can be quickly and efficiently detected through an image matching algorithm. It can achieve rapid and accurate detection of the surface condition of injection molds. However, in the process of point set matching of the same-sized image blocks in two images by the matching algorithm, the position characteristics of pixel points are not considered. If the objects in the two images are tilted, when point set matching is performed through the matching algorithm, it will lead to misdetection problems, thus affecting the detection results of mold precision. Summary of the Invention
[0004] In order to solve the above technical problems, a method for detecting the precision of a mold based on machine vision is provided to solve the existing problems.
[0005] The solution of this application to solve the technical problem is to provide a method for detecting the precision of a mold based on machine vision, including the following steps:
[0006] Obtain the template image and the image to be measured of the mold, determine the mold surface area of the template image, and obtain each image block of the template image;
[0007] Based on all pixel points in each image block of the template image, obtain each clustering cluster of each image block in the template image;
[0008] According to the feature differences and dispersion degrees between different pixel points within each clustering cluster of each image block in the template image, as well as the differences between different clustering clusters, determine the feature difference coefficients of each clustering cluster of each image block in the template image;
[0009] According to the positions of the pixel points corresponding to each clustering cluster in the template image, record the area formed by the positions of all pixel points as the pixel area of each clustering cluster; according to the gray-scale difference situation and texture feature difference degree between the connected domain where the clustering center of each clustering cluster is located and the pixel area of the corresponding clustering cluster, determine the corner point difference coefficients of each clustering cluster of each image block in the template image;
[0010] Determine the region matching degree of each clustering cluster of each image block in the template image according to the similarity degree of local features between the pixel region and the edge pixel points of the connected domain, as well as the feature difference coefficient and the corner point difference coefficient;
[0011] Based on the region matching degree of each clustering cluster of each image block in the template image, obtain the point set of each image block in the template image, and detect the accuracy of the image to be measured.
[0012] Preferably, the method for determining the mold surface region of the template image and obtaining each image block of the template image includes:
[0013] Adopt the Hough line detection algorithm for the template image, and calculate the slope and length of each detected line;
[0014] Denote the detected line with the absolute value of the slope less than or equal to the preset threshold as the horizontal line; denote the detected line with the absolute value of the reciprocal of the slope less than or equal to the preset threshold as the vertical line;
[0015] Select the first two detected lines from the horizontal lines in ascending order of length, and calculate the mean value of the ordinates of all pixel points on the two detected lines respectively. Denote the detected line with the larger mean value of the ordinates as the upper edge line, and denote the detected line with the smaller mean value of the ordinates as the lower edge line;
[0016] Select the first two detected lines from the vertical lines in ascending order of length, and calculate the mean value of the abscissas of all pixel points on the two detected lines respectively. Denote the detected line with the larger mean value of the abscissas as the right edge line, and denote the detected line with the smaller mean value of the abscissas as the left edge line;
[0017] Denote the region formed by the four edge lines of up, down, left, and right as the mold surface region of the template image;
[0018] Construct a rectangular coordinate system with the lower edge line as the x-axis and the left edge line as the y-axis;
[0019] Evenly divide the mold surface region of the template image to obtain each image block of the template image.
[0020] Preferably, the method for obtaining each clustering cluster of each image block in the template image is:
[0021] Through the edge detection algorithm, obtain the gradient direction and gradient amplitude of each pixel point in the template image;
[0022] Compose the gray value, gradient direction, and gradient amplitude of each pixel point in the template image into the feature vector of each pixel point in the template image;
[0023] Perform clustering analysis on the feature vectors of all pixel points within each image patch in the template image to obtain the clusters of each image patch in the template image.
[0024] Preferably, determining the feature difference coefficient of each cluster of each image patch in the template image includes:
[0025] Analyze the offset trend and dispersion degree of the feature vectors of different pixel points within each cluster of each image patch to determine the within-cluster difference degree of each cluster of each image patch;
[0026] Denote the distance between the feature vectors of the center points of any two clusters of each image patch as the cluster center difference;
[0027] Denote the difference between the within-cluster difference degrees of any two clusters of each image patch as the first difference;
[0028] Denote the sum of the cluster center difference and the first difference as the first sum value;
[0029] Take the mean value of all the first sum values in each image patch as the between-cluster difference degree of each image patch;
[0030] Denote the ratio of the within-cluster difference degree to the between-cluster difference degree of each cluster of each image patch as the first ratio;
[0031] If the between-cluster difference degree is 0, the feature difference coefficient of each cluster of each image patch in the template image is the within-cluster difference degree. Otherwise, the feature difference coefficient of each cluster of each image patch in the template image is the first ratio.
[0032] Preferably, determining the within-cluster difference degree of each cluster of each image patch includes:
[0033] Denote the similarity degree between the feature vectors of each pixel point within each cluster of each image patch and the remaining pixel points as the first similarity degree;
[0034] Denote the mean value of all the first similarity degrees of each pixel point within each cluster of each image patch as the first mean value of each pixel point;
[0035] Determine the dispersion degree of the first mean values of all pixel points within each cluster of each image patch as the within-cluster difference degree of each cluster of each image patch.
[0036] Preferably, determining the corner difference coefficient of each cluster of each image patch in the template image includes: Wherein, is the corner difference coefficient of the kth cluster of the mth image patch, is the number of corner points in the pixel region of the k-th clustering cluster of the m-th image block, is the first corner point difference of the k-th clustering cluster of the m-th image block, is the second corner point difference of the k-th clustering cluster of the m-th image block, and are respectively the connected domain of the k-th clustering cluster of the m-th image block and the average gray value of all pixel points in the pixel region.
[0037] Preferably, the determination method of the first corner point difference and the second corner point difference is as follows:
[0038] Denote the connected domain where the center of each clustering cluster of each image block is located as the connected domain of each clustering cluster;
[0039] Extract the corner points of the connected domain and the corner points of the pixel region of each clustering cluster respectively;
[0040] For each connected domain of each image block, calculate the distance between any two corner points in the connected domain, denoted as the first distance; take the average value of all the first distances in the connected domain of each clustering cluster as the corner point separation coefficient of the connected domain; set a local window with a preset size centered on any corner point; calculate the LBP value of the local window of each corner point in the connected domain;
[0041] Denote the product of the number of corner points in the local window of each corner point in the connected domain and the LBP value as the corner point texture value of each corner point;
[0042] Determine the corner point feature difference of the connected domain of each clustering cluster of each image block according to the dispersion degree of the corner point texture values of all corner points in the connected domain of each clustering cluster of each image block;
[0043] Fuse the corner point separation coefficient and the corner point feature difference to determine the first corner point difference of each clustering cluster of each image block;
[0044] For the corner points in the pixel region of each clustering cluster of each image block, use the same method as the first corner point difference to obtain the second corner point difference of each clustering cluster of each image block.
[0045] Preferably, determining the region matching degree of each clustering cluster of each image block in the template image includes: Wherein, is the region matching degree of the k-th clustering cluster of the m-th image block, is the dimensionality reduction matrix of the connected domain of the k-th clustering cluster of the m-th image block, is the dimensionality reduction matrix of the pixel region of the k-th clustering cluster of the m-th image block, w m is the number of all clustering clusters of the m-th image block, gm is the number of all connected components of the m-th image block, is the corner point difference coefficient of the k-th cluster of the m-th image block, is the feature difference coefficient of the k-th cluster of the m-th image block, ε is a tuning factor, exp() is the exponential function with the natural constant as the base, and R() represents calculating the similarity.
[0046] Preferably, the method for obtaining the dimensionality reduction matrix is as follows:
[0047] Obtain all edge pixels of the connected components and pixel regions of each cluster of each image block; with any edge pixel as the center, set a local window with a preset size;
[0048] Extract the corner point second moment, contrast, correlation, and entropy through the gray-level co-occurrence matrix of the local window of each edge pixel, and form the texture feature vector of each edge pixel;
[0049] Form the texture feature matrix of the connected component of each cluster by the texture feature vectors of all edge pixels within the connected component of each cluster;
[0050] Perform dimensionality reduction analysis on the texture feature matrix using a dimensionality reduction algorithm to obtain the dimensionality reduction matrix of the connected component of each cluster;
[0051] For all edge pixels within the pixel region of each cluster of each image block, use the same method as the dimensionality reduction matrix of the connected component of each cluster of each image block to obtain the dimensionality reduction matrix of the pixel region of each cluster.
[0052] Preferably, obtaining the point set of each image block in the template image and detecting the accuracy of the image to be measured includes:
[0053] Take the region matching degree of the cluster where each pixel in each image block is located as the matching value of each pixel in each image block;
[0054] Calculate the perpendicular distances from each pixel in each image block to the left edge line and the lower edge line respectively, and record them as the left distance and the lower distance of each pixel in each image block;
[0055] Form the position vector of each pixel in each image block by the left distance, lower distance, gray value, and matching value of each pixel in each image block;
[0056] Form the point set of each image block in the template image by the position vectors of all pixels in each image block;
[0057] Use the same method as the point set of each image block in the template image to obtain the point set of each image block in the image to be measured;
[0058] Using a matching algorithm, match the point sets of all image patches in the image to be measured with the point sets of the corresponding image patches in the template image to obtain the similarity of the image to be measured;
[0059] Perform normalization processing on the similarity. If the normalization result is less than the preset similarity threshold, there are defects in the image to be measured; otherwise, there are no defects in the image to be measured.
[0060] This application has at least the following beneficial effects:
[0061] This application determines the mold surface area through Hough line detection, divides it, and obtains each image patch in the template image. The beneficial effect is that when the mold is tilted in the image, it can more accurately locate the coordinates of each pixel point; cluster the feature vectors of all pixel points in each image patch in the template image; determine the feature difference coefficient of each clustering cluster in each image patch in the template image. The beneficial effect is that it considers the difference features of different pixel points within the clustering cluster and the differences between clusters to reflect the possibility of defects existing between the regions corresponding to different clustering clusters; determine the corner point difference coefficient of each clustering cluster in each image patch in the template image. The beneficial effect is that it considers the matching degree between the pixel region corresponding to the same clustering cluster and the connected domain where the clustering center is located, so as to more clearly identify the situation of defects on the mold surface; according to the similarity degree of the local features between the pixel region and the edge pixel points of the connected domain, as well as the feature difference coefficient and the corner point difference coefficient, determine the region matching degree of each clustering cluster in each image patch in the template image, obtain the point set of each image patch in the template image, and detect the accuracy of the image to be measured. The beneficial effect is that it analyzes the local features of the pixel region and the edge pixel points of the connected domain and the similarity degree of the edge pixel points between the pixel region and the connected domain, so as to reflect the similarity of the edge features. By constructing a point set, it considers the multi-dimensional features of pixel points, which is beneficial to improving the matching accuracy of each pixel point in the image and the accuracy of detecting the injection mold. Description of the Drawings
[0062] The following further elaborates in detail on the mold accuracy detection method based on machine vision of this application with reference to the drawings.
[0063] Figure 1 It is the flowchart of the steps of the mold accuracy detection method based on machine vision provided by the embodiment of this application;
[0064] Figure 2 It is the flowchart of the steps of the method for obtaining the feature difference coefficient of each clustering cluster in each image patch in the template image provided by the embodiment of this application;
[0065] Figure 3 It is the flowchart of the steps of the method for obtaining the first corner point difference of each clustering cluster in each image patch in the template image provided by the embodiment of this application. Detailed implementation manners
[0066] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the method for detecting the accuracy of a mold based on machine vision proposed in the present application will be further described in detail below with reference to the accompanying drawings and implementation examples. It should be understood that the specific implementation examples described herein are only used to explain the present application and are not used to limit the present application.
[0067] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs.
[0068] Please refer to Figure 1 , which shows a flowchart of the steps of the method for detecting the accuracy of a mold based on machine vision provided by an embodiment of the present application. The method includes the following steps:
[0069] Step 1: Obtain a template image and a to-be-tested image of the mold.
[0070] First, use a CCD camera to capture the surface of an injection mold with good accuracy and no defects. Secondly, capture the surface of the injection mold to be detected, perform noise reduction processing on the captured image, and then perform edge detection and grayscale processing to complete the preprocessing operation of the image, and obtain the template image and the to-be-tested image.
[0071] Preferably, in this embodiment, an injection mold for a mobile phone back shell is selected for detection. Median filtering is used to denoise the image, and the Canny edge detection algorithm is used to detect the edges of the image to complete the preprocessing operation of the image. Among them, median filtering and the Canny edge detection algorithm are well-known technologies and will not be elaborated here.
[0072] It can be understood that this embodiment uses median filtering and the Canny edge detection algorithm. As other implementation manners, implementers can use other methods in the prior art, such as mean filtering, Sobel edge detection, SIFT corner detection algorithm, etc. This embodiment does not limit this.
[0073] So far, the template image and the to-be-tested image of the mold are obtained.
[0074] Step 2: Determine the mold surface area of the template image according to the edge contour of the mold in the template image, and obtain each image block in the template image.
[0075] Since the overall edges of the mold are parallel and very regular, it is easy to detect the edge contour of the mold, obtain four edge straight lines of the mold, thereby determine the surface area of the mold, and segment the mold surface area to further determine the connected domain in the image. Specifically:
[0076] Apply the Hough line detection algorithm to the template image, and calculate the slope and length of each detected line;
[0077] The detected lines with the absolute value of the slope less than or equal to the preset threshold are denoted as horizontal lines;
[0078] Select the first two detected lines in ascending order of length from the horizontal lines, calculate the mean value of the vertical coordinates of all pixel points on the two detected lines respectively, denote the detected line with the larger mean value of the vertical coordinates as the upper edge line, and denote the detected line with the smaller mean value of the vertical coordinates as the lower edge line;
[0079] The detected lines with the absolute value of the reciprocal of the slope less than or equal to the preset threshold are denoted as vertical lines;
[0080] Select the first two detected lines in ascending order of length from the vertical lines, and calculate the mean value of the horizontal coordinates of all pixel points on the two detected lines respectively, denote the detected line with the larger mean value of the horizontal coordinates as the right edge line, and denote the detected line with the smaller mean value of the horizontal coordinates as the left edge line;
[0081] Preferably, in this embodiment, the preset threshold is set to 0.5. As other implementation manners, the implementer can set it according to the actual situation; it should be noted that the Hough line detection algorithm is a well-known technology and will not be elaborated here.
[0082] Extend the upper, lower, left, and right four edge lines to both ends until four intersection points appear when the four lines intersect. The area connected by the four intersection points is denoted as the mold surface area of the template image;
[0083] Construct a rectangular coordinate system with the lower edge line as the x-axis and the left edge line as the y-axis;
[0084] Evenly divide the mold surface area of the template image into multiple image blocks;
[0085] Preferably, in this embodiment, the mold surface area is evenly divided into 64 image blocks. It should be noted that as other implementation manners, the implementer can set it according to the actual situation; use the region growing algorithm to segment each image block to obtain each connected domain. The specific process is as follows: Select the 10 pixel points with the largest gray values in each image block as the initial seeds. During the growth process, calculate the absolute value of the difference in gray values between each growth point and its adjacent pixel points, which is denoted as the relative difference of each growth point. If the normalized result of the reciprocal of the relative difference is less than the similarity threshold of 0.9, stop growing, and finally obtain each connected domain in each image block; among them, the region growing algorithm is a well-known technology and will not be elaborated here.
[0086] It should be noted that when dividing the surface area of the mold, it is only necessary to ensure that the four dividing edges of each image block are parallel to the lower edge line and the left edge line during the dividing process.
[0087] Thus, each image block of the template image is obtained.
[0088] Step 3: Based on all the pixel points within each image block in the template image, obtain each clustering cluster of each image block in the template image; according to the feature differences and dispersion degrees between different pixel points within each clustering cluster of each image block in the template image, as well as the differences between different clustering clusters, determine the feature difference coefficients of each clustering cluster of each image block in the template image.
[0089] Through the analysis of features such as the color, texture, and gradient value of the pixel points on the surface of the injection mold for the mobile phone back shell, it is found that in different regions on the mold surface, such as the lens, logo, font, background, etc., the degree of consistency of features within the region is very high, but the differences between different regions are very large, with obvious edge contours and feature differences. Therefore, the pixel points can be clustered through a clustering algorithm to preliminarily verify whether a defect has occurred.
[0090] Based on the above analysis, perform a clustering analysis on each image block to reflect the differences of each cluster, specifically:
[0091] Through the edge detection algorithm, obtain the gradient direction and gradient value of each pixel point in the template image, and convert the gradient direction into a radian value;
[0092] Form the feature vector of each pixel point in the template image from the gray value, radian value, and gradient value of each pixel point in the template image;
[0093] Preferably, in this embodiment, the Sobel operator is used to obtain the gradient direction and gradient value of each pixel point. As other implementation manners, the implementer can use other methods in the prior art, such as the Scharr operator, etc. This embodiment does not make special restrictions on this.
[0094] Perform a clustering analysis on the feature vectors of all the pixel points within each image block in the template image to obtain multiple clusters;
[0095] Record the similarity degree between the feature vectors of each pixel point within each clustering cluster of each image block in the template image and the remaining pixel points as the first similarity;
[0096] Record the mean value of all the first similarities of each pixel point within each clustering cluster of each image block in the template image as the first mean value of each pixel point;
[0097] Preferably, in this embodiment, the K-means clustering algorithm is used for clustering analysis, and the number of clustering clusters is obtained by the elbow method. Secondly, the cosine similarity between the feature vectors of each pixel point within each clustering cluster of each image patch and the remaining pixel points is used as the first similarity. The K-means clustering algorithm and the elbow method are well-known technologies and will not be elaborated here.
[0098] It can be understood that in this embodiment, the K-means clustering algorithm is used for clustering analysis, and the cosine similarity is used to measure the similarity degree of vectors. As other implementation manners, those skilled in the art can adopt other methods in the prior art. For example, the hierarchical clustering algorithm can be used for clustering analysis, and the DTW distance can be used for similarity analysis, etc. This embodiment does not make special restrictions on this.
[0099] Further, the consistency degree of the feature vectors of all pixel points within each cluster is analyzed to obtain the intra-cluster difference degree of each cluster, specifically:
[0100] The dispersion degree of the first means of all pixel points within each clustering cluster of each image patch in the template image is determined as the intra-cluster difference degree of each clustering cluster of each image patch.
[0101] Preferably, in this embodiment, the standard deviation of the first means of all pixel points within each clustering cluster of each image patch in the template image is calculated as the intra-cluster difference degree of each clustering cluster of each image patch. As other implementation manners, those skilled in the art can adopt other methods to calculate the dispersion degree, such as variance, coefficient of variation, information entropy, etc. This embodiment does not make special restrictions on this.
[0102] It should be noted that if there are no defects on the mold surface corresponding to each pixel point within each clustering cluster of each image patch in the template image, the feature vectors of all pixel points within the cluster are relatively consistent, and the intra-cluster difference degree is smaller; if there are defective pixel points within the clustering cluster, the inconsistency of the feature vectors of the pixel points is larger, and the intra-cluster difference degree is larger.
[0103] Further, the difference situation between clusters in each image patch of the template image is analyzed to construct a feature difference coefficient, specifically:
[0104] The distance between the feature vectors of the center points of any two clustering clusters of each image patch is denoted as the clustering center difference.
[0105] The difference between the intra-cluster difference degrees of any two clustering clusters of each image patch is denoted as the first difference.
[0106] The sum of the clustering center difference and the first difference is denoted as the first sum value.
[0107] Take the mean of all the first sums in each image block as the between-cluster difference degree of each cluster in each image block;
[0108] Denote the ratio of the within-cluster difference degree to the between-cluster difference degree of each cluster in each image block as the first ratio;
[0109] If the between-cluster difference degree is 0, the feature difference coefficient of each cluster in each image block is the within-cluster difference degree; if the between-cluster difference degree is not 0, the feature difference coefficient of each cluster in each image block is the first ratio;
[0110] Preferably, in this embodiment, take the Euclidean distance between the feature vectors of the cluster centers within any two clusters in each image block as the cluster center difference; take the absolute value of the difference between the within-cluster difference degrees of any two clusters in each image block as the first difference.
[0111] It can be understood that in this embodiment, by calculating the Euclidean distance between the feature vectors of the cluster centers of two clusters, as other implementation manners, implementers can adopt other methods in the prior art, for example, DTW distance, etc., and this embodiment does not make special restrictions on this.
[0112] It should be noted that if the distance between the cluster centers of two clusters is larger, the cluster center difference is larger, the pixel points within the two clusters are more different, and the larger the between-cluster difference degree indicates the better the clustering effect; if the between-cluster difference degree is 0, it means that there is only one cluster in the corresponding image block; secondly, if the feature difference coefficient is smaller, it indicates that the effects of each cluster are better and the feature vectors in the corresponding cluster are more consistent, and if the feature difference coefficient is larger, it may indicate that there is a large inconsistency within the corresponding cluster or the distinction from other clusters is not obvious, indicating that there may be defects or abnormalities.
[0113] Further, the step flowchart of the method for obtaining the feature difference coefficient of each cluster in each image block of the template image provided in this application is as Figure 2 shown.
[0114] Thus, the feature difference coefficient of each cluster in each image block of the template image is obtained.
[0115] Step 4, according to the positions of the pixel points within each cluster corresponding in the template image, denote the region formed by the positions of all pixel points as the pixel region of each cluster; determine the corner point difference coefficient of each cluster in each image block of the template image according to the gray level difference situation and the texture feature difference degree between the connected domain where the cluster center of each cluster is located and the pixel region of the corresponding cluster.
[0116] Further, since the feature differences between different regions on the mold surface are very large, but the features within each region are relatively consistent, if there are no defects on the mold surface, within each image block, by clustering the pixel points, the internal elements of the clusters obtained by clustering should be relatively consistent; at the same time, the number of clusters in each image block should be the same as the number of connected components. Based on the above analysis, analyze the matching degree between the pixel regions where each pixel point in each cluster is located in the image and each connected component.
[0117] First, by analyzing the corner points within each connected component in each image block, construct a corner point difference coefficient, specifically:
[0118] Denote the connected component where the center of each cluster in each image block is located as the connected component of each cluster;
[0119] According to the positions of all pixel points in each cluster within each image block on the corresponding image block, denote the region formed by the positions of all pixel points as the pixel region of each cluster;
[0120] It should be noted that if there are no defects within the image block, the connected components and pixel regions of each cluster are in one-to-one correspondence. Although for two points with equal gray values, the gradient magnitudes are not necessarily equal, but because they are all in the same region of the mold and the difference is very small, the feature vectors within one region will still be clustered into the same cluster.
[0121] Adopt a corner point detection algorithm to obtain the corner points of the connected components of each cluster and the corner points of the pixel regions of each image block respectively;
[0122] Preferably, in this embodiment, the Harris corner point detection algorithm is used for corner point detection. Among them, the Harris corner point detection algorithm is a well-known technology and will not be elaborated here.
[0123] It can be understood that in this embodiment, the Harris corner point detection algorithm is used for corner point detection. As other implementation manners, the implementer can use other methods of the prior art, for example, the SIFT corner point detection algorithm, etc. This embodiment does not limit this.
[0124] Calculate the distance between any two corner points within the connected component of each cluster in each image block, and denote it as the first distance;
[0125] Take the mean value of all the first distances within the connected component of each cluster as the corner point separation coefficient of the connected component of each cluster in each image block;
[0126] It should be noted that the larger the corner point separation coefficient, the greater the distance between each corner point in the connected component.
[0127] Set a local window with a preset size centered on any corner point;
[0128] Calculate the LBP values of the local windows of each corner point within the connected regions of each cluster of each image block, where the calculation method of the LBP value is a well-known technique and will not be elaborated here;
[0129] Denote the product of the number of all corner points within the local window of each corner point within the connected regions of each cluster of each image block and the LBP value as the corner point texture value of each corner point within the connected regions of each cluster of each image block;
[0130] Determine the corner point feature difference of the connected region of each cluster of each image block according to the dispersion degree of the corner point texture values of all corner points within the connected regions of each cluster of each image block;
[0131] Fuse the corner point distance coefficient and the corner point feature difference to determine the first corner point difference of each cluster of each image block;
[0132] For the corner points within the pixel region of each cluster of each image block, use the same method as the first corner point difference to obtain the second corner point difference of the pixel region of each cluster of each image block;
[0133] Furthermore, the step flow chart of the method for obtaining the first corner point difference of each cluster of each image block in the template image provided by this application is as Figure 3 shown.
[0134] It can be understood that the fusion can be expressed as a multiplication relationship, an addition relationship, etc., which is determined by the actual application, and this application does not make special restrictions on this.
[0135] Preferably, in this embodiment, calculate the Euclidean distance between any two corner points within the connected region of each cluster of each image block as the first distance; set a local window with a preset size of 3*3; the corner point feature difference of the connected region of each cluster of each image block is the standard deviation of the corner point texture values of all corner points; use the product of the corner point distance coefficient and the corner point feature difference as the first corner point difference of each cluster of each image block.
[0136] In this embodiment, the calculation method of the first corner point difference of each cluster of each image block is: Among them, is the first corner point difference of the kth cluster of the mth image block, is the ith corner point within the connected region of the kth cluster of the mth image block, is the jth corner point within the connected region of the kth cluster of the mth image block, is the number of corner points in the connected region of the kth cluster of the mth image block, is the first distance, is the corner point distance coefficient of the connected domain of the k-th cluster of the m-th image block, is the LBP value of the local window of the i-th corner point in the connected domain of the k-th cluster of the m-th image block, is the number of corner points in the local window of the i-th corner point in the connected domain of the k-th cluster of the m-th image block, represents the corner point texture value of the i-th corner point in the connected domain of the k-th cluster of the m-th image block, is the mean value of the corner point texture values of all corner points in the connected domain of the k-th cluster of the m-th image block, is the corner point feature difference of the connected domain of the k-th cluster of the m-th image block.
[0137] Furthermore, analyze the difference in corner points between the connected domain and the pixel region under the same cluster. If there are no defects in the mold, the difference between the connected domain and the pixel region is small, or even the two regions are consistent. Therefore, construct the corner point difference coefficient, specifically:
[0138] wherein, is the corner point difference coefficient of the k-th cluster of the m-th image block, is the number of corner points in the pixel region of the k-th cluster of the m-th image block, is the first corner point difference of the k-th cluster of the m-th image block, is the second corner point difference of the k-th cluster of the m-th image block, and are the mean gray values of all pixel points in the connected domain and the pixel region of the k-th cluster of the m-th image block, respectively.
[0139] It should be noted that the smaller the corner point difference coefficient, the smaller the difference in corner point features and the overall gray value between the connected domain and the pixel region, the higher the matching degree, and the greater the possibility that there are no problems on the mold surface.
[0140] Thus, the corner point difference coefficients of each cluster of each image block are obtained.
[0141] Step 5, determine the region matching degree of each cluster of each image block in the template image according to the similarity degree of local features between the edge pixel points of the pixel region and the connected domain, and the feature difference coefficient and the corner point difference coefficient.
[0142] Based on the above analysis, combined with the texture features of the edge pixel points, analyze the matching degree between the connected domain and the pixel region to reflect the consistency between the connected domain and the pixel region corresponding to the same cluster. Specifically:
[0143] Obtain the connected components of each cluster and all edge pixel points of the pixel region of each image patch;
[0144] Set a local window with a preset size centered on any edge pixel point;
[0145] Extract the corner second moment, contrast, correlation, and entropy through the gray-level co-occurrence matrix of the local window of each edge pixel point to form the texture feature vector of each edge pixel point; the gray-level co-occurrence matrix is a well-known technology and will not be elaborated here again.
[0146] Combine the texture feature vectors of all edge pixel points within the connected component of each cluster of each image patch to form the texture feature matrix of the connected component of each cluster of each image patch;
[0147] Perform dimensionality reduction analysis on the texture feature matrix using a dimensionality reduction algorithm to obtain the dimensionality reduction matrix of the connected component of each cluster of each image patch;
[0148] For all edge pixel points within the pixel region of each cluster of each image patch, use the same method as the dimensionality reduction matrix of the connected component of each cluster of each image patch to obtain the dimensionality reduction matrix of the pixel region of each cluster of each image patch;
[0149] Preferably, in this embodiment, set a window with a preset size of 5*5; use the principal component analysis algorithm for dimensionality reduction analysis to obtain the principal component matrix containing three principal components as the dimensionality reduction matrix of the connected component of each cluster of each image patch, where the principal component analysis algorithm is a well-known technology and will not be elaborated here.
[0150] Furthermore, determine the matching degree between the connected component and the pixel region through the degree of consistency of the dimensionality reduction matrices between the connected component and the pixel region, specifically:
[0151] Determine the regional similarity of each cluster of each image patch according to the similarity degree between the dimensionality reduction matrix of the connected component of each cluster of each image patch and the dimensionality reduction matrix of the pixel region;
[0152] Preferably, in this embodiment, calculate the cosine similarity between the dimensionality reduction matrix of the connected component of each cluster of each image patch and the dimensionality reduction matrix of the pixel region as the regional similarity of each cluster of each image patch.
[0153] It can be understood that this embodiment uses the cosine similarity to measure the similarity degree of two matrices. As other implementation manners, implementers can use other methods in the prior art, such as the Pearson correlation coefficient, Jaccard similarity coefficient, etc. This embodiment does not make special restrictions on this.
[0154] The calculation method of the regional matching degree of each cluster of each image patch is: Wherein, is the region matching degree of the k-th clustering cluster of the m-th image block, is the dimensionality reduction matrix of the connected domain of the k-th clustering cluster of the m-th image block, is the dimensionality reduction matrix of the pixel region of the k-th clustering cluster of the m-th image block, w m is the number of all clustering clusters of the m-th image block, g m is the number of all connected domains of the m-th image block, is the corner point difference coefficient of the k-th clustering cluster of the m-th image block, is the feature difference coefficient of the k-th clustering cluster of the m-th image block, ε is a tuning factor with a value of 0.01 to prevent the denominator from being 0, exp() is an exponential function, and R() represents calculating the similarity, is the region similarity of the k-th clustering cluster of the m-th image block.
[0155] It should be noted that since the degree of consistency of the features inside the mold area is relatively high and the feature differences between different areas are relatively large, the texture features at the edge pixel points are relatively significant. If there are no defects on the mold surface, the connected domain after region growing through the gray value should be relatively consistent with the region composed of the pixel point clustering results, then the edge features are relatively similar, and the number of clustering clusters is the same as the number of connected domains, and the internal features are relatively consistent, then the region similarity is relatively large, |w m -g m | is 0, and the corner point difference coefficient and the feature difference coefficient are relatively small, then the region matching degree is relatively large. If there are defects, then the number of clustering clusters after feature vector clustering is no longer the same as the number of connected domains, and the features of the edge pixel points and the internal features of the region change, then the region similarity is relatively small, |w m -g m | is greater than 0, is relatively large, and the corner point difference coefficient and the feature difference coefficient are relatively large, then the region matching degree is relatively small.
[0156] Thus, the region matching degree of each clustering cluster of each image block is obtained.
[0157] Step 6: Based on the region matching degree of each clustering cluster of each image block in the template image, obtain the point set of each image block in the template image to detect the accuracy of the image to be measured.
[0158] Furthermore, based on the region matching degree, as well as the position and gray value of each pixel point, construct the point set of each image block in the template image, specifically:
[0159] Take the region matching degree of the clustering cluster where each pixel point in each image block is located as the matching value of each pixel point in each image block;
[0160] Calculate the vertical distances from each pixel point in each image block to the left-edge line and the bottom-edge line respectively, and denote them as the left distance and the bottom distance of each pixel point in each image block;
[0161] Combine the left distance, the bottom distance, the gray value and the matching value of each pixel point in each image block to form the position vector of each pixel point in each image block;
[0162] Combine the position vectors of all pixel points in each image block to form the point set of each image block in the template image;
[0163] Further, for the image to be tested, process it to obtain the die surface area of the image to be tested, and obtain the point set of each image block in the image to be tested. Specifically:
[0164] Use the same method as the die surface area of the template image to obtain the die surface area of the image to be tested, and divide the die surface area of the image to be tested into each image block;
[0165] Use the same method as the point set of each image block in the template image to obtain the point set of each module in the image to be tested;
[0166] Use a matching algorithm to match the point sets of all modules in the image to be tested with the point sets of the corresponding modules in the template image to obtain the similarity of the image to be tested;
[0167] Perform normalization processing on the similarity. If the normalization result is less than the preset similarity threshold, there is a defect in the image to be tested, that is, there is a defect in the die to be tested. If the normalization result is greater than or equal to the preset similarity threshold, there is no defect in the image to be tested, that is, there is no defect in the die to be tested, and the accuracy of the injection mold is detected.
[0168] Preferably, in this embodiment, the Best-Buddies Similarity (BBS) template matching algorithm is used for matching; the preset similarity threshold is set to 0.8. As other implementation manners, the implementer can set it according to the actual situation.
[0169] It can be understood that in this embodiment, the BBS matching algorithm is used for matching. As other implementation manners, other methods in the prior art can be used for the value, such as SSD, NCC, etc. This embodiment does not make special restrictions on this.
[0170] It should be understood that although Figure 1 the steps in the flowchart of Figure 1At least some of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed and completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least some of the other steps or sub-steps or stages of the other steps.
[0171] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.
[0172] The above-described embodiments only represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation to the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made. Therefore, any simple modifications, equivalent changes and decorations made to the above embodiments based on the technical essence of the present application without departing from the content of the technical solution of the present application all belong to the protection scope of the technical solution of the present application.
Claims
1. The mold accuracy detection method based on machine vision is characterized by: The method comprises the following steps: Acquire a template image and an image to be tested of the mold, determine the mold surface area of the template image, and obtain each image block of the template image; Based on all the pixels in each image block in the template image, each cluster of each image block in the template image is obtained; Determine the characteristic difference coefficient of each cluster of each image block in the template image according to the characteristic difference and discrete degree between different pixel points in each cluster of each image block in the template image, and the difference between different clusters; According to the positions of the pixels in each cluster in the template image, the area formed by the positions of all the pixels is recorded as the pixel area of each cluster; according to the grayscale difference between the connected domain where the cluster center of each cluster is located and the pixel area of the corresponding cluster, and the degree of texture feature difference, the corner point difference coefficient of each cluster of each image block in the template image is determined; Determine the regional matching degree of each cluster of each image block in the template image according to the similarity of the local features between the pixel region and the edge pixel points of the connected domain, as well as the feature difference coefficient and the corner point difference coefficient; Based on the regional matching degree of each cluster of each image block in the template image, the point set of each image block in the template image is obtained to detect the accuracy of the image to be tested; The step of obtaining a point set of each image block in the template image and detecting the accuracy of the image to be tested includes: The regional matching degree of the cluster where each pixel point in each image block is located is used as the matching value of each pixel point in each image block; Calculate the vertical distances from each pixel point in each image block to the left edge straight line and the bottom edge straight line respectively, and record them as the left distance and the bottom distance of each pixel point in each image block; The left distance, bottom distance, gray value and matching value of each pixel point in each image block are used to form the position vector of each pixel point in each image block; The position vectors of all pixels in each image block form a point set for each image block in the template image; The point set of each image block in the image to be tested is obtained by adopting the same method as the point set of each image block in the template image; Using a matching algorithm, the point sets of all image blocks in the image to be tested are matched with the point sets of corresponding image blocks in the template image to obtain the similarity of the image to be tested; The similarity is normalized. If the normalized result is less than a preset similarity threshold, the image to be tested has defects. Otherwise, the image to be tested does not have defects.
2. The mold precision detection method based on machine vision according to claim 1, characterized in that: The step of determining the mold surface area of the template image and obtaining each image block of the template image includes: The Hough line detection algorithm is used on the template image to calculate the slope and length of each detection line; The detection straight line whose absolute value of the slope is less than or equal to the preset threshold is recorded as a horizontal straight line; the detection straight line whose absolute value of the reciprocal of the slope is less than or equal to the preset threshold is recorded as a vertical straight line; Select the first two detection lines from the horizontal lines in ascending order of length, calculate the mean values of the ordinates of all the pixels on the two detection lines respectively, record the detection line with the larger ordinate mean value as the upper edge line, and record the detection line with the smaller ordinate mean value as the lower edge line; Select the first two detection lines from the vertical lines in ascending order of length, and calculate the mean of the horizontal coordinates of all pixels on the two detection lines respectively. The detection line with the larger horizontal coordinate mean is recorded as the right edge line, and the detection line with the smaller horizontal coordinate mean is recorded as the left edge line. The area formed by the four edge lines of upper, lower, left and right is recorded as the mold surface area of the template image; A rectangular coordinate system is constructed with the lower edge straight line as the x-axis and the left edge straight line as the y-axis; The mold surface area of the template image is evenly divided to obtain image blocks of the template image.
3. The mold accuracy detection method based on machine vision according to claim 1, characterized in that: The method for obtaining each cluster of each image block in the template image is as follows: The gradient direction and gradient amplitude of each pixel in the template image are obtained through the edge detection algorithm; The gray value, gradient direction and gradient amplitude of each pixel in the template image are used to form a feature vector of each pixel in the template image; Cluster analysis is performed on the feature vectors of all pixels in each image block in the template image to obtain clusters of each image block in the template image.
4. The mold accuracy detection method based on machine vision according to claim 3, characterized in that: The step of determining the characteristic difference coefficient of each cluster of each image block in the template image includes: Analyze the deviation trend and discrete degree of the feature vectors of different pixel points in each cluster of each image block, and determine the intra-cluster difference of each cluster of each image block; The distance between the feature vectors of the center points of any two clusters of each image block is recorded as the cluster center difference; The difference between the intra-cluster differences of any two clusters of each image block is recorded as the first difference; The sum of the cluster center difference and the first difference is recorded as a first sum value; Taking the mean of all the first sum values in each image block as the inter-cluster difference of each image block; Recording the ratio of the intra-cluster difference to the inter-cluster difference of each cluster of each image block as a first ratio; If the inter-cluster difference is 0, the characteristic difference coefficient of each cluster of each image block in the template image is the intra-cluster difference, otherwise, the characteristic difference coefficient of each cluster of each image block in the template image is the first ratio.
5. The mold precision detection method based on machine vision according to claim 4, characterized in that: The step of determining the intra-cluster difference of each cluster of each image block comprises: The similarity between the feature vectors of each pixel point in each cluster of each image block and the remaining pixel points is recorded as the first similarity; Recording the mean of all the first similarities of each pixel in each cluster of each image block as the first mean of each pixel; The discrete degree of the first mean value of all pixels in each cluster of each image block is determined as the intra-cluster difference of each cluster of each image block.
6. The mold precision detection method based on machine vision according to claim 1, characterized in that: The step of determining the corner point difference coefficients of each cluster of each image block in the template image includes: ,in, For the The image block The corner difference coefficient of clusters, For the The image block The number of corner points in the pixel area of the cluster, For the The image block The difference of the first corner points of the clusters, For the The image block The difference of the second corner points of the clusters, and Respectively The image block The connected domain of the clusters and the mean gray value of all pixels in the pixel area.
7. The mold accuracy detection method based on machine vision according to claim 6, characterized in that: The method for determining the first corner point difference and the second corner point difference is: The connected domain where the centers of each cluster of each image block are located is recorded as the connected domain of each cluster; Extract the corner points of the connected domain of each cluster and the corner points of the pixel area respectively; For each connected domain of each image block, the distance between any two corner points in the connected domain is calculated, recorded as the first distance; the average of all the first distances in the connected domain of each cluster is used as the corner point distance coefficient of the connected domain; a local window of a preset size is set with any corner point as the center; the LBP value of the local window of each corner point in the connected domain is calculated; The product of the number of corner points in the local window of each corner point in the connected domain and the LBP value is recorded as the corner point texture value of each corner point; Determine the feature difference of the corner points of the connected domains of the clusters of each image block according to the discrete degree of the corner point texture values of all corner points in the connected domains of the clusters of each image block; The corner point distance coefficient and the corner point feature difference are merged to determine the first corner point difference of each cluster of each image block; For the corner points in the pixel area of each cluster of each image block, the same method as the first corner point difference is adopted to obtain the second corner point difference of each cluster of each image block.
8. The mold precision detection method based on machine vision according to claim 1, characterized in that: The determining of the regional matching degree of each cluster of each image block in the template image includes: ,in, For the The image block The regional matching degree of clusters, For the The image block The dimension reduction matrix of the connected domain of clusters, For the The image block The dimension reduction matrix of the pixel area of the clusters, For the The number of all clusters of image patches, For the The number of all connected components of an image patch, For the The image block The corner difference coefficient of clusters, For the The image block The characteristic difference coefficient of clusters, is the tuning factor, is an exponential function with a natural constant as base, Indicates calculating similarity.
9. The mold accuracy detection method based on machine vision according to claim 8, characterized in that: The method for obtaining the dimension reduction matrix is: Obtain all edge pixel points of the connected domain and pixel area of each cluster of each image block; set a local window of a preset size with any edge pixel point as the center; The second-order moment, contrast, correlation, and entropy of the corner points are extracted through the gray-level co-occurrence matrix of the local window of each edge pixel point to form the texture feature vector of each edge pixel point; The texture feature vectors of all edge pixels in the connected domain of each cluster are used to form a texture feature matrix of the connected domain of each cluster; Using a dimensionality reduction algorithm to perform dimensionality reduction analysis on the texture feature matrix to obtain a dimensionality reduction matrix of the connected domain of each cluster; For all edge pixels in the pixel area of each cluster of each image block, the dimension reduction matrix of the pixel area of each cluster is obtained by adopting the same method as the dimension reduction matrix of the connected domain of each cluster of each image block.
Citation Information
Patent Citations
Detection method for fire hose lining defect classification
CN114972833A
Printing defect identification method for textile fabric with periodic patterns
CN115100206A