A high-precision method and apparatus for detecting minute color differences
By combining image preprocessing and color feature extraction with detection methods for overall color difference, monochromatic color difference, and local color difference, the problem of strong subjectivity in manual quality inspection of colored contact lenses has been solved, achieving high-precision automated color difference detection and improving detection efficiency and consistency.
Patent Information
- Application Number
- CN202411474235.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-10-22
AI Technical Summary
In the current technology, color difference detection of Sino-Telescopic lenses relies on manual quality inspection, which is highly subjective and difficult to quantify. Furthermore, existing instruments are unable to detect minute color differences under multi-layered patterns, resulting in low detection efficiency and poor consistency.
A high-precision method for detecting minute color differences is adopted. Through image preprocessing, color feature extraction and calculation, combined with the detection of overall color difference, monochromatic color difference and local color difference, machine vision and image processing technology are used to achieve accurate color difference analysis of colored contact lens images and template images.
It improves the accuracy and consistency of color difference detection, reduces labor costs, increases production efficiency, reduces the missed detection rate, adapts to various color difference detection scenarios, and achieves high-precision automated quality inspection.
Smart Images

Figure CN119339112B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision, specifically a high-precision method and apparatus for detecting minute color differences. Background Technology
[0002] In recent years, colored contact lenses (beautiful contact lenses) with a variety of colorful patterns have become very popular among consumers. Major contact lens manufacturers have begun to make beautiful contact lenses their main products. Compared with the production process of transparent contact lenses, the production process of beautiful contact lenses adds a color printing process. This process involves using pad printing equipment to transfer the designed pattern to a mold in different colors, and then transferring the pattern to the lens through processes such as color fixing, filling, and mold closing.
[0003] The pad printing process is a flexible printing process. It uses a curved pad printing head made of silicone material to apply ink from the gravure plate to the surface of the pad printing head. The pad printing machine takes the image from a laser-etched steel plate with the design pattern, and then presses it on the surface of the convex mold to achieve single-layer pattern transfer. By repeating this process, up to 6 colors of patterns can be printed onto the surface of the mold. Since the single-color patterns of colored contact lenses are usually composed of dot or line textures, due to the limitations of mechanical precision, slight overprinting offset and rotation are unavoidable after multi-layer pattern overprinting. In this scenario, color difference is difficult to measure quantitatively using existing instruments such as colorimeters. Existing image-based color difference detection methods can only handle single color blocks or patterns with high overprinting accuracy. Currently, color difference detection of universal molds for colored contact lenses after pad printing mainly relies on human eye recognition. Due to the complexity of color difference in this scenario, quality inspectors on the production line usually need several months of training to perform color difference detection. Moreover, due to efficiency requirements, hundreds of universal molds are usually observed at one time, and small color differences are easily missed. Furthermore, manual quality inspection is highly subjective, which can easily lead to inconsistent conclusions from different individuals, or even inconsistent conclusions from multiple observations by the same person. Therefore, color difference detection of pad-printed patterns for colored contact lenses has always been a difficult problem for manufacturers. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a high-precision method and apparatus for detecting minute color differences, so as to solve the problems in the prior art.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] The present invention provides a high-precision method for detecting minute color differences, comprising the following steps:
[0007] Obtain a colored contact lens image and a template image, and preprocess the colored contact lens image to obtain a first preprocessed image, and preprocess the template image to obtain a second preprocessed image;
[0008] Extract the overall color features and individual color features of the first preprocessed image, extract the overall color features and individual color features of the second preprocessed image, and extract the color moments of the first preprocessed image and the color moments of the second preprocessed image;
[0009] The overall color difference between the contact lens image and the template image is calculated based on the overall color features of the first preprocessed image and the overall color features of the second preprocessed image. The monochromatic color difference between the contact lens image and the template image is calculated based on the single color features of the first preprocessed image and the single color features of the second preprocessed image. The presence of local color difference in the contact lens image is determined based on the color moments of the first preprocessed image and the color moments of the second preprocessed image. Local color difference exists when the difference between the color moments of the first preprocessed image and the color moments of the second preprocessed image is greater than a preset threshold.
[0010] The colored contact lens image is detected based on the overall color difference, the monochromatic color difference, and the local color difference.
[0011] In one embodiment of this application, preprocessing the colored contact lens image to obtain a first preprocessed image, and preprocessing the template image to obtain a second preprocessed image, includes:
[0012] The colored contact lens image is converted from RGB channels to LAB channels to obtain a first LAB image, and the template image is converted from RGB channels to LAB channels to obtain a second LAB image;
[0013] The first LAB image is subjected to channel separation to obtain a first L-channel image, a first A-channel image, and a first B-channel image; and the second LAB image is subjected to channel separation to obtain a second L-channel image, a second A-channel image, and a second B-channel image.
[0014] Gaussian filtering is applied to the first L-channel image and the second L-channel image to obtain the first L-channel image. G Image and second L G image;
[0015] The first L G The image, the first A-channel image, and the first B-channel image are fused to obtain the first L. G AB image, and the second L G The image, the second A-channel image, and the second B-channel image are fused to obtain the second L. G AB image;
[0016] For the first L G AB image and the second L GThe image is segmented by thresholding to obtain a first mask image of the colored ring of the printed area of the colored contact lens image and a second mask image of the colored ring of the printed area of the template image.
[0017] Based on the first mask image, morphological erosion is performed on the colored contact lens image to obtain a first preprocessed image; and based on the second mask image, morphological erosion is performed on the template image to obtain a second preprocessed image.
[0018] In one embodiment of this application, extracting the overall color features of the first preprocessed image and extracting the overall color features of the second preprocessed image includes:
[0019] Extract the first image histogram from the first preprocessed image, and extract the second image histogram from the second preprocessed image;
[0020] The first image histogram is smoothed, and the smoothed first image histogram is used as the overall color feature of the first preprocessed image; the second image histogram is smoothed, and the smoothed second image histogram is used as the overall color feature of the second preprocessed image.
[0021] In one embodiment of this application, extracting single color features from the first preprocessed image and extracting single color features from the second preprocessed image includes:
[0022] The first preprocessed image and the second preprocessed image are converted to v space to obtain the first HSV image of the colored contact lens image and the second HSV image of the template image;
[0023] The first difference image I is obtained by subtracting the V channel and S channel of the first HSV image. V-S The difference between the V and S channels of the second HSV image is calculated to obtain the second difference image I. V-S ';
[0024] For the first difference image I V-S and the second difference image I V-S Perform adaptive threshold segmentation to obtain the first difference image I. V-S Binarized background image I B and the second difference image I V-S Binarized background image I B ';
[0025] For the binarized background image I B and the binarized background image I B Invert the image to obtain the first mask image I of the color dot region of the first preprocessed image. MFAnd the second mask image I of the color dot region of the second preprocessed image. MF ';
[0026] Extract the first mask image I MF The intersection region with the first preprocessed image is used to obtain the first color image I of the color dot region of the first preprocessed image. D Take the second mask image I MF The intersection region with the first preprocessed image is used to obtain the second color image I, which is the color dot region of the second preprocessed image. D ';
[0027] For the first color image I D and the second color image I D Clustering of the non-zero pixel sequence in the image yields multiple colors and multiple color centers; then segmentation is performed using these multiple color centers as origins to obtain the first color image I. D and the second color image I D 'Multiple color categories, where each color category includes multiple pixels;
[0028] The percentage, pixel density, color center brightness, and color center of each color category are statistically analyzed to obtain the single color features of the first preprocessed image and the single color features of the second preprocessed image.
[0029] In one embodiment of this application, extracting the color moments of the first preprocessed image and the second preprocessed image includes:
[0030] Extract the binarized background image I B The first background image of the first preprocessed image is obtained by intersecting the region with the first preprocessed image, and the first color image I is then used to obtain the first background image of the first preprocessed image. D The first foreground image is used as the first preprocessed image; and the binarized background image I is extracted. B The intersection region with the second preprocessed image is used to obtain the second background image of the second preprocessed image, and the second color image I is then used to obtain the second background image of the second preprocessed image. D 'The second foreground image as the second preprocessed image;
[0031] Calculate the first-order color moments E of multiple partitions of the target image. i and second-order color moment σ i The target image includes the first foreground image, the second foreground image, the first background image, and the second background image, and the multiple partitions are multiple regions equally divided by the width of the colored contact lens ring;
[0032]
[0033]
[0034] In the formula, P ij Let N be the pixel value of the pixel at coordinates (i,j), and N be the number of pixels in the partition.
[0035] In one embodiment of this application, calculating the overall color difference between the colored contact lens image and the template image based on the overall color features of the first preprocessed image and the second preprocessed image includes:
[0036] The overall color difference is obtained by calculating the histogram difference ΔH and histogram similarity C between the overall color features of the first preprocessed image and the overall color features of the second preprocessed image.
[0037] In one embodiment of this application, calculating the monochromatic color difference between the contact lens image and the template image based on the single color features of the first preprocessed image and the second preprocessed image includes:
[0038] The color center brightness difference ΔL, color center color difference ΔE, and density difference ΔD of each color category in the first preprocessed image and the corresponding color category in the second preprocessed image are calculated to obtain the monochromatic color difference.
[0039] In one embodiment of this application, detecting the colored contact lens image based on the overall color difference, the monochromatic color difference, and the local color difference includes:
[0040] Calculate the color similarity between the colored contact lens image and the template image based on the monochrome color difference and the overall color difference;
[0041] When the color similarity is greater than or equal to a preset similarity threshold, it is determined that there is no overall color difference or single-color difference, and the presence of local color difference in the colored contact lens image is detected to obtain the detection result;
[0042] When the color similarity is less than a preset similarity threshold, the histogram similarity C is compared with a preset correlation threshold.
[0043] When the histogram similarity C is less than a preset relevance threshold, an overall color difference is determined to exist; when the histogram similarity C is greater than or equal to the preset relevance threshold, the histogram difference ΔH is compared with a preset difference threshold.
[0044] When the histogram difference ΔH is greater than or equal to a preset difference threshold, the histogram distance between the histogram and a preset histogram template is calculated; when the histogram distance is less than a preset distance threshold, it is determined that only a single-color difference exists; when the histogram distance is greater than or equal to the preset distance threshold, it is determined that both overall color difference and single-color difference exist, and the single color with color difference is identified; when the histogram difference ΔH is less than the preset difference threshold, it is determined that neither overall color difference nor single-color difference exists, and the presence of local color difference in the contact lens image is detected to obtain the detection result.
[0045] In one embodiment of this application, calculating the color similarity between the colored contact lens image and the template image based on the monochromatic color difference and the overall color difference includes:
[0046] A color similarity z is constructed based on the histogram difference ΔH, the histogram similarity C, the color center brightness difference ΔL, the color center color difference ΔE, and the density difference ΔD. The mathematical expression for the color similarity z is:
[0047] z=w0+w1ΔH+w2C+w3ΔL+w4ΔE+w5ΔD
[0048] In the formula, w0 is the offset, w1 is the first weighting coefficient, w2 is the second weighting coefficient, w3 is the third weighting coefficient, w4 is the fourth weighting coefficient, and w5 is the fifth weighting coefficient; wherein, the method for determining the offset w0, the first weighting coefficient w1, the second weighting coefficient w2, the third weighting coefficient w3, the fourth weighting coefficient w4, and the fifth weighting coefficient w5 includes:
[0049] Obtain sample data, wherein the sample data includes histogram difference ΔH' of sample images, histogram similarity C', color center brightness difference ΔL', color center color difference ΔE', density difference ΔD', and labels;
[0050] Training data is constructed based on the sample data;
[0051] Based on the training data, a logistic regression model is fitted to obtain the offset w0, the first weighting coefficient w1, the second weighting coefficient w2, the third weighting coefficient w3, the fourth weighting coefficient w4, and the fifth weighting coefficient w5, wherein the mathematical expression of the logistic regression model is:
[0052]
[0053] In the formula, y represents the label.
[0054] This application also provides a high-precision, minute color difference detection device, comprising:
[0055] The acquisition and preprocessing module is used to acquire a colored contact lens image and a template image, and to preprocess the colored contact lens image to obtain a first preprocessed image, and to preprocess the template image to obtain a second preprocessed image;
[0056] The feature extraction module is used to extract the overall color features and single color features of the first preprocessed image, extract the overall color features and single color features of the second preprocessed image, and extract the color moments of the first preprocessed image and the color moments of the second preprocessed image.
[0057] The calculation module is used to calculate the overall color difference between the contact lens image and the template image based on the overall color features of the first preprocessed image and the overall color features of the second preprocessed image, calculate the monochromatic color difference between the contact lens image and the template image based on the single color features of the first preprocessed image and the single color features of the second preprocessed image, and determine whether there is a local color difference in the contact lens image based on the color moments of the first preprocessed image and the color moments of the second preprocessed image, wherein a local color difference exists when the difference between the color moments of the first preprocessed image and the color moments of the second preprocessed image is greater than a preset threshold.
[0058] The detection module is used to detect the colored contact lens image based on the overall color difference, the monochromatic color difference, and the local color difference.
[0059] The beneficial effects of this invention are as follows: This invention provides a high-precision method and apparatus for detecting minute color differences. By extracting monochromatic color differences, overall color differences, and local color differences from contact lens images, it comprehensively obtains color similarity features, thereby improving the detection capability of minute color differences. The color similarity threshold can be adjusted for different patterns or different detection standards, thus adapting to various color difference detection scenarios. It has low requirements for the imaging system, and the results are reproducible, stable, and consistent. Based on machine vision methods, this application uses high-resolution color imaging to acquire molded images of printed patterns. Image processing and machine learning techniques are used to analyze the images, proposing a method that combines overall and local color differences to simulate and quantify the judgment criteria of the human eye, determining whether color differences exist in the corresponding products. This method is fast, has high real-time performance, good consistency, and a low false negative rate, achieving the goals of reducing labor costs, saving time, and improving production yield. Attached Figure Description
[0060] The present invention will be further described below with reference to the accompanying drawings and embodiments:
[0061] Figure 1 This is a schematic diagram illustrating the minute color differences caused by variations in printing density as shown in this application;
[0062] Figure 2This is a flowchart illustrating a high-precision method for detecting minute color differences in one embodiment of this application;
[0063] Figure 3 This is a schematic diagram of the color difference detection process in one embodiment of this application;
[0064] Figure 4 This is a structural diagram of a high-precision micro-color difference detection device shown in one embodiment of this application. Detailed Implementation
[0065] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.
[0066] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the layers related to the present invention and are not drawn according to the actual number, shape and size of the layers in the actual implementation. In the actual implementation, the form, number and proportion of each layer can be arbitrarily changed, and the layer layout may also be more complex.
[0067] Numerous details are explored in the following description to provide a more thorough explanation of embodiments of the invention; however, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details.
[0068] Existing technologies for detecting colored contact lens images have the following drawbacks:
[0069] 1. Color difference judgment based on human visual observation is highly subjective, inconsistent, and cannot be quantified;
[0070] 2: Colorimeters based on the principle of spectrophotometry have high requirements for conditions and can only detect the color difference of a single color patch;
[0071] 3: Image analysis-based color difference detection methods are applicable to simple scenarios, requiring a single background with no overprinting or high overprinting accuracy.
[0072] 4. In multi-color pad printing, if there is a color difference in the ink itself, it will appear as a noticeable difference easily discernible to the naked eye in the final printed product. More often, however, color differences occur even when the ink itself has no inherent color difference, but during the printing process, mechanical and technological issues create minute, visually perceptible color variations. These variations may be related to factors such as the pressure of the printing pad, the moisture content of the ink and the environment, and the precision of the overprinting process. Figure 1 This is a schematic diagram illustrating the minute color differences caused by variations in printing density, as shown in this application. Figure 1 As shown (color difference caused by change in the density of the outer black ring), at this point, it is difficult to distinguish this degree of color difference by relying solely on the ISO13655 color difference calculation standard.
[0073] The purpose of this application is:
[0074] 1. This application presents a high-precision method for detecting minute color differences based on image processing and machine learning, which significantly improves upon the problems of high subjectivity and low accuracy in existing detection methods. Furthermore, this system can be widely applied to color difference detection in the flexographic printing industry, reducing manual re-inspection costs, improving production efficiency, and ultimately increasing the yield of final products.
[0075] This color difference detection method combines overall color difference evaluation and single-color color difference evaluation, and consists of the following process:
[0076] Figure 2 This is a flowchart illustrating a high-precision, minute color difference detection method in one embodiment of this application, as shown below. Figure 2 As shown: This embodiment of a high-precision method for detecting minute color differences may include the following steps:
[0077] S210, acquire the colored contact lens image and the template image, preprocess the colored contact lens image to obtain the first preprocessed image, and preprocess the template image to obtain the second preprocessed image;
[0078] S220, extract the overall color features and single color features of the first preprocessed image, extract the overall color features and single color features of the second preprocessed image, and extract the color moments of the first preprocessed image and the color moments of the second preprocessed image;
[0079] S230, calculate the overall color difference between the contact lens image and the template image based on the overall color features of the first preprocessed image and the overall color features of the second preprocessed image, calculate the monochromatic color difference between the contact lens image and the template image based on the single color features of the first preprocessed image and the single color features of the second preprocessed image, and determine whether there is a local color difference in the contact lens image based on the color moments of the first preprocessed image and the color moments of the second preprocessed image, wherein a local color difference exists when the difference between the color moments of the first preprocessed image and the color moments of the second preprocessed image is greater than a preset threshold;
[0080] S240 detects colored contact lens images based on overall color difference, monochromatic color difference, and local color difference.
[0081] The specific implementation process and principles are explained below:
[0082] A. Image Acquisition and Preprocessing
[0083] Obtain a colored contact lens image and a template image, and preprocess the colored contact lens image to obtain a first preprocessed image, and preprocess the template image to obtain a second preprocessed image;
[0084] The colored contact lens image can be taken on-site or obtained from a lower-level machine, or a template image can be obtained in advance;
[0085] The specific preprocessing steps include:
[0086] A1. Convert the colored contact lens image from RGB channels to LAB channels to obtain the first LAB image, and convert the template image from RGB channels to LAB channels to obtain the second LAB image;
[0087] The LAB color model is more in line with human color perception. Therefore, color images are converted from the RGB color space to the LAB color space.
[0088] A2. Perform channel separation on the first LAB image to obtain the first L channel image, the first A channel image, and the first B channel image; and perform channel separation on the second LAB image to obtain the second L channel image, the second A channel image, and the second B channel image.
[0089] A3. Perform Gaussian filtering on the first L-channel image and the second L-channel image to obtain the first L-channel image. G Image and second L G image;
[0090] A4, the first L G The image, the first A-channel image, and the first B-channel image are fused to obtain the first L-channel image. G AB image, and the second L G The image, the second A-channel image, and the second B-channel image are fused to obtain the second L-channel image. G AB image;
[0091] A5, regarding the first L G AB image and second L G The image is segmented by thresholding to obtain the first mask image of the colored ring of the printed area of the colored contact lens image and the second mask image of the colored ring of the printed area of the template image.
[0092] A6. Perform morphological erosion on the colored contact lens image based on the first mask image to obtain the first preprocessed image; and perform morphological erosion on the template image based on the second mask image to obtain the second preprocessed image.
[0093] To avoid losing color information, only the luminance image L is Gaussian filtered to obtain L. G Then L G Channels A and B are fused to obtain the filtered image L. G AB; Extracting L using threshold segmentation method G To reduce chromatic dispersion interference at the edges of the printed color dots, a morphological erosion operation is performed on the mask image of the LAB printing area color ring. A bitwise AND operation is then performed between the LAB image and the mask image to obtain the color dot image I. cd The same applies to template images.
[0094] B. Extraction of overall color feature information
[0095] Extract the overall color features of the first preprocessed image and extract the overall color features of the second preprocessed image, including:
[0096] B1. Extract the first image histogram of the first preprocessed image and extract the second image histogram of the second preprocessed image;
[0097] B2. Smooth the histogram of the first image and use the smoothed histogram of the first image as the overall color feature of the first preprocessed image; smooth the histogram of the second image and use the smoothed histogram of the second image as the overall color feature of the second preprocessed image.
[0098] Image histograms can reflect the overall distribution of grayscale or color in an image. Therefore, histograms can be used to characterize the overall color features of an image. By comparing the histogram features of the template and the product under test, the overall color difference can be obtained. The color histogram of the LAB image is calculated, and a sliding window smoothing process is applied to the histogram to reduce noise interference.
[0099] C. Extraction of Single Color Feature Information
[0100] In this embodiment, a clustering method (any density clustering method can be selected) is used to cluster the color image to obtain the color center of each monochrome. To better extract and separate color dots from single ink printing, a foreground thresholding segmentation method suitable for texture overprinting scenarios is proposed. Due to the dispersion effect of color imaging, the background area near unprinted color dots will also appear colored rather than white, which greatly hinders accurate extraction and separation of the printed area. To address this, a color foreground thresholding segmentation method and a monochrome color feature extraction method are proposed, specifically including:
[0101] C1. Convert the first preprocessed image and the second preprocessed image to HSV space to obtain the first HSV image of the colored contact lens image and the second HSV image of the template image;
[0102] C2. Subtract the V channel and S channel of the first HSV image to obtain the first subtracted image I. V-S The difference between the V and S channels of the second HSV image is calculated to obtain the second differenced image I. V-S ';
[0103] C3. Calculate the difference between the first image I. V-S The second difference image I V-S Perform adaptive threshold segmentation to obtain the first difference image I. V-S Binarized background image I B The second difference image I V-S Binarized background image I B ';
[0104] In steps C1-C3, since the colors of colored contact lens patterns usually vary in depth, but compared to the background, the color dots generally have higher saturation (S) and lower brightness (V), and conversely, areas with low S and high V are likely background areas. Based on this, a new image I is obtained by subtracting V from S. V-S , then I V-S Regions with higher grayscale values can be considered background regions. An adaptive thresholding method can be used to obtain a binary image of the background (I). B The same applies to template images.
[0105] C4. Binarize the background image I B and binarized background image I B Invert the image to obtain the first mask image I of the color dot region of the first preprocessed image. MF And the second mask image I of the color dot region of the second preprocessed image. MF ';
[0106] C5. Extract the first mask image I MF The intersection region with the first preprocessed image yields the first color image I, which is the color dot region of the first preprocessed image. D Take the second mask image I MF The intersection region with the first preprocessed image is used to obtain the second color image I of the color dot region of the second preprocessed image. D ';
[0107] C6. For the first color image I D Second color image I DClustering of the non-zero pixel sequence in the image yields multiple colors and multiple color centers; then segmentation is performed using these multiple color centers as origins to obtain the first color image I. D Second color image I D 'Multiple color categories, where each color category includes multiple pixels;
[0108] C7. Calculate the percentage, pixel density, color center brightness, and color center of each color category to obtain the single color features of the first preprocessed image and the single color features of the second preprocessed image.
[0109] I B To binarize the background image, for I B Inverting the image yields image I. F That is, the mask image I of the color dot region. MF Color images and I MF By taking the intersection, we can obtain the color image I of the color point region. D , I D For the input image of the clustering algorithm, for I D Clustering is performed on the non-zero pixel sequence to obtain the color centers. With each color center as the origin, given upper and lower thresholds, the pixels belonging to each category are extracted by the color threshold segmentation method. The resulting image is a binary image. By counting the non-zero pixels in the binary image obtained after threshold segmentation of each monochrome center, the number of pixels in each category can be obtained. From this, the proportion of each color and the density of each monochrome can also be calculated. The template image is processed in the same way.
[0110] D. Color information storage
[0111] If the image is a template image without color difference, the template color information is converted into feature data format and stored in a specific path on the hard drive. This step is skipped for the image of the sample to be tested.
[0112] E. Overall color difference calculation
[0113] The overall color difference is obtained by calculating the histogram difference ΔH and histogram similarity C between the overall color features of the first preprocessed image and the overall color features of the second preprocessed image.
[0114] F. Monochrome color difference calculation
[0115] Monochromatic color difference is obtained by calculating the color center brightness difference ΔL, color center color difference ΔE, and density difference ΔD of each color category in the first preprocessed image and the corresponding color category in the second preprocessed image.
[0116] In this application, each color center of the template is matched one-to-one with each color center of the sample to be tested. The brightness difference ΔL is obtained by subtracting the brightness value of each color center of the template from the brightness value of the color center of the sample to be tested. The color difference value ΔE between each color center of the template and each color center of the sample to be tested is calculated according to the color difference calculation standard in ISO13655. The density difference ΔD of each monochrome is obtained by subtracting the number of pixels in each cluster of the template and the sample to be tested.
[0117] G. Calculation of local color difference in zones
[0118] Rotation or offset between multiple layers of colors can also cause local color differences. There is also the possibility that a certain color ink becomes lighter or darker, or that a single layer of ink is missing. The overprinting rules of each layer of color are basically distributed radially. In order to improve the detection effect of this local color difference, a method for detecting color difference based on radial partitioning is proposed.
[0119] A color moment is a mathematical characteristic used to describe the distribution of colors. For a random variable R, its probability distribution can be uniquely represented by its moments. Furthermore, if we consider the color values of all pixels in a digital image as a probability distribution, then the image can also be represented by its moments. A color image has three channels, and each channel has three lower-order moments, therefore, the color moment of a color image has a total of nine components. The first-order color moment uses the first-order origin moment, i.e., the mean, which reflects the overall brightness of the image; the larger the value, the brighter the image. The second-order color moment uses the square root of the second-order central distance, i.e., the standard deviation, which reflects the range of color distribution in the image; the larger the value, the wider the color distribution range.
[0120] Specifically, extracting the color moments of the first preprocessed image and the second preprocessed image includes:
[0121] G1, Extract the binarized background image I B The first background image of the first preprocessed image is obtained by intersecting the region with the first preprocessed image, and the first color image I is then used. D The first foreground image is used as the first preprocessed image; and the binarized background image I is extracted. B The intersection region with the second preprocessed image is used to obtain the second background image of the second preprocessed image, and the second color image I is then used. D 'The second foreground image as the second preprocessed image;
[0122] G2. Calculate the first-order color moments E of multiple partitions of the target image. i and second-order color moment σ i The target image includes a first foreground image, a second foreground image, a first background image, and a second background image, and the multiple partitions are multiple regions equally divided by the width of the colored contact lens ring;
[0123]
[0124]
[0125] Where P ij is the pixel value of the pixel point with coordinates (i, j), and N is the number of pixel points in the partition.
[0126] This method proposes to calculate the foreground color moments and background color moments of the radial partitions for the template and the product to be tested respectively, and compare the two. If it exceeds the given threshold, it is considered that there is a local color difference, otherwise it is a qualified product. The images used are color images in the LAB space. The rule for partitioning is to equally divide according to the width of the color ring. The foreground image is the intersection of the color image of the sub-ring area and the above-mentioned I MF mask image, and the background image is the intersection of the color image of the sub-ring area and the above-mentioned I B mask image. The same applies to the template image.
[0127] H, Color difference detection
[0128] Figure 3 is a schematic diagram of the color difference detection process in an embodiment of this application. As Figure 3 shown, in an embodiment of this application, the colored contact lens image is detected based on the overall color difference, single-color color difference and local color difference, including:
[0129] H1, Initialize parameters. The color difference detection result is jointly determined by two detection results, that is, the color difference result Result S of each single color and the overall color difference result Result W ;
[0130] H2, Calculate the color similarity between the colored contact lens image and the template image based on the single-color color difference and the overall color difference;
[0131] H3, When the color similarity is greater than or equal to the preset similarity threshold, determine that there is no overall color difference and single-color color difference, and detect whether there is a local color difference in the colored contact lens image to obtain the detection result;
[0132] When the color similarity is greater than or equal to the preset similarity threshold, determine that there is no overall color difference and local color difference; at this time, Result S and Result W are both set to qualified; when there is no overall color difference and local color difference, if the color moment detection is enabled, further detect whether there is a color difference in the local single layer of color, and the whole process ends;
[0133] H4, When the color similarity is less than the preset similarity threshold, compare the histogram similarity C with the preset correlation threshold;
[0134] If the color similarity is less than the preset similarity threshold, a warning will be issued indicating that there may be a color difference, and further comparison of histogram similarity is required.
[0135] H5. When the histogram similarity C is less than the preset relevance threshold, an overall color difference is determined to exist; when the histogram similarity C is greater than or equal to the preset relevance threshold, the histogram difference ΔH is compared with the preset difference threshold.
[0136] When the histogram similarity is less than a preset relevance threshold, an overall color difference is determined, and the Result is... W Set to have color difference; when the histogram similarity is greater than or equal to the preset relevance threshold, it is necessary to compare the histogram difference ΔH.
[0137] H6. When the histogram difference ΔH is greater than or equal to the preset difference threshold, calculate the histogram distance between the histogram and the preset histogram template; when the histogram distance is less than the preset distance threshold, determine that only monochrome color difference exists; when the histogram distance is greater than or equal to the preset distance threshold, determine that both overall color difference and monochrome color difference exist and identify the monochrome with color difference; when the histogram difference ΔH is less than the preset difference threshold, determine that neither overall color difference nor monochrome color difference exists, and detect whether there is local color difference in the contact lens image to obtain the detection result.
[0138] When the histogram difference ΔH is less than a preset difference threshold, the overall color difference index between the histogram and the preset histogram template is calculated; when the overall color difference index is less than the preset color difference threshold, it is determined that only a single-color difference exists; that is, the Result is... W Set as Result S This indicates that the overall color difference is determined by the color difference of a single color at this point; if the histogram distance is greater than or equal to a preset distance threshold, it is determined that an overall color difference exists and the single color with the color difference is identified; if the histogram distance is not less than a given threshold, then the Result is... W The determination of color difference indicates the existence of an overall color difference. Further investigation is needed to identify which single color exhibits this color difference, and the result for that color will be determined. S Set to "Color Difference" and end the process.
[0139] The calculation of color similarity between the contact lens image and the template image based on monochromatic color difference and overall color difference includes:
[0140] Color similarity z is constructed based on histogram difference ΔH, histogram similarity C, color center brightness difference ΔL, color center color difference ΔE, and density difference ΔD. The mathematical expression for color similarity z is:
[0141] z=w0+w1ΔH+w2C+w3ΔL+w4ΔE+w5ΔD
[0142] In the formula, w0 is the offset, w1 is the first weighting coefficient, w2 is the second weighting coefficient, w3 is the third weighting coefficient, w4 is the fourth weighting coefficient, and w5 is the fifth weighting coefficient; the methods for determining the offset w0, the first weighting coefficient w1, the second weighting coefficient w2, the third weighting coefficient w3, the fourth weighting coefficient w4, and the fifth weighting coefficient w5 include:
[0143] Obtain sample data, which includes histogram difference ΔH', histogram similarity C', color center brightness difference ΔL', color center color difference ΔE', density difference ΔD', and labels of the sample images;
[0144] Training data is constructed based on sample data;
[0145] The logistic regression model was fitted based on the training data to obtain the bias w0, the first weighted coefficient w1, the second weighted coefficient w2, the third weighted coefficient w3, the fourth weighted coefficient w4, and the fifth weighted coefficient w5. The mathematical expression of the logistic regression model is as follows:
[0146]
[0147] In the formula, y represents the label.
[0148] In this embodiment, to quantitatively characterize the degree of color difference between the product under test and the template, a feature quantity named color similarity is proposed. Color similarity integrates the influence factors of overall color difference and monochrome color difference. Compared with existing single color difference calculation formulas, it incorporates histogram information and monochrome information differences. The calculation formula includes feature quantities such as ΔH, C, ΔL, ΔE, and ΔD. A logistic regression model is used to fit these feature quantities. Logistic regression can be expressed as... Where z = w0 + w1ΔH + w2C + w3ΔL + w4ΔE + w5ΔD, and y is the probability of being qualified. A dataset of images manually classified as color-differenced and qualified is used for training, with color-differenced items labeled 0 and qualified items labeled 1, resulting in the parameter sequence {w0, w1, w2, w3, w4, w5}. When predicting a new sample, simply calculate ΔH, C, ΔL, ΔE, and ΔD of the image, substitute them into the trained parameter sequence, and the probability z of the sample being qualified can be obtained. z is defined as color similarity. Different similarity thresholds can be set for different batches and patterns to perform color difference detection.
[0149] This invention provides a high-precision method for detecting minute color differences. By extracting monochromatic color difference, overall color difference, and local color difference from contact lens images, it comprehensively obtains color similarity features, thereby improving the detection capability of minute color differences. The method allows adjustment of the color similarity threshold for different patterns or detection standards, adapting to various color difference detection scenarios. It has low requirements for the imaging system, and the results are reproducible, stable, and consistent. Based on machine vision methods, this application uses high-resolution color imaging to acquire mold images of printed patterns. Image processing and machine learning techniques are used to analyze the images, proposing a method that combines overall and local color differences to simulate and quantify the judgment criteria of the human eye, determining whether color differences exist in the corresponding products. This method is fast, real-time, consistent, and has a low false negative rate, achieving the goals of reducing labor costs, saving time, and improving production yield.
[0150] like Figure 4 As shown, this application also provides a high-precision micro-color difference detection device, comprising:
[0151] The acquisition and preprocessing module is used to acquire the colored contact lens image and the template image, and to preprocess the colored contact lens image to obtain a first preprocessed image, and to preprocess the template image to obtain a second preprocessed image;
[0152] The feature extraction module is used to extract the overall color features and single color features of the first preprocessed image, extract the overall color features and single color features of the second preprocessed image, and extract the color moments of the first preprocessed image and the color moments of the second preprocessed image.
[0153] The calculation module is used to calculate the overall color difference between the contact lens image and the template image based on the overall color features of the first preprocessed image and the overall color features of the second preprocessed image, calculate the monochromatic color difference between the contact lens image and the template image based on the single color features of the first preprocessed image and the single color features of the second preprocessed image, and determine whether there is a local color difference in the contact lens image based on the color moments of the first preprocessed image and the color moments of the second preprocessed image. When the difference between the color moments of the first preprocessed image and the color moments of the second preprocessed image is greater than a preset threshold, there is a local color difference.
[0154] The detection module is used to detect colored contact lens images based on overall color difference, monochromatic color difference, and local color difference.
[0155] This invention discloses a high-precision micro-color difference detection device. By extracting monochromatic color difference, overall color difference, and local color difference from contact lens images, it comprehensively obtains color similarity features, improving the detection capability of micro-color differences. The device allows adjustment of the color similarity threshold for different patterns or detection standards, thus adapting to various color difference detection scenarios. It has low requirements for the imaging system, and the results are reproducible, stable, and consistent. Based on machine vision methods, this application uses high-resolution color imaging to acquire molded images of printed patterns. Image processing and machine learning techniques are used to analyze the images, proposing a method that combines overall and local color differences to simulate and quantify the human eye's judgment criteria, determining whether color differences exist in the corresponding products. This method is fast, real-time, consistent, and has a low false negative rate, achieving the goals of reducing labor costs, saving time, and improving production yield.
[0156] This embodiment also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements any one of the methods in this embodiment, wherein the method is the execution logic of this system.
[0157] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0158] The memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory so that the terminal performs any of the methods in this embodiment.
[0159] As will be understood by those skilled in the art, the computer-readable storage medium described in this embodiment allows for the implementation of all or part of the steps in the above method embodiments by computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0160] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver, and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication between them. The memory is used to store computer programs, the communication interface is used to perform communication, and the processor and the transceiver are used to run the computer programs, so that the electronic terminal performs the steps of the above method.
[0161] In this embodiment, the memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.
[0162] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0163] In the above embodiments, although the invention has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. The embodiments of the invention are intended to cover all such substitutions, modifications, and variations falling within the broad scope of the appended claims.
[0164] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.
Claims
1. A high-precision method for detecting minute color differences, characterized in that, Including the following steps: Obtain a colored contact lens image and a template image, and preprocess the colored contact lens image to obtain a first preprocessed image, and preprocess the template image to obtain a second preprocessed image; Extract the overall color features and individual color features of the first preprocessed image, extract the overall color features and individual color features of the second preprocessed image, and extract the color moments of the first preprocessed image and the color moments of the second preprocessed image; Extracting single color features from the first preprocessed image and extracting single color features from the second preprocessed image includes: converting the first preprocessed image and the second preprocessed image to... Space, to obtain the first image of the colored contact lenses The second image and template image Image; for the first Image Channels and Channel subtraction yields the first subtracted image. and for the second Image Channels and Channel subtraction yields a second subtracted image. ; for the first difference image and the second difference image Adaptive threshold segmentation is performed to obtain the first difference image. Binarized background image and the second difference image Binarized background image ; for the binarized background image and the binarized background image Invert the image to obtain the first mask image of the color dot region of the first preprocessed image. and the second mask image of the color dot region of the second preprocessed image. Extract the first mask image. The intersection region with the first preprocessed image is used to obtain a first color image of the color dot region of the first preprocessed image. Take the second mask image The intersection region with the first preprocessed image is used to obtain the second color image of the color dot region of the second preprocessed image. ; for the first color image and the second color image The non-zero pixel sequence in the image is clustered to obtain multiple colors and multiple color centers; then, the image is segmented using these multiple color centers as origins to obtain the first color image. and the second color image The image contains multiple color categories, each of which includes multiple pixels. The proportion, pixel density, color center brightness, and color center of each color category are calculated to obtain the single color features of the first preprocessed image and the single color features of the second preprocessed image. The overall color difference between the contact lens image and the template image is calculated based on the overall color features of the first preprocessed image and the overall color features of the second preprocessed image. The monochromatic color difference between the contact lens image and the template image is calculated based on the single color features of the first preprocessed image and the single color features of the second preprocessed image. The presence of local color difference in the contact lens image is determined based on the color moments of the first preprocessed image and the color moments of the second preprocessed image. Local color difference exists when the difference between the color moments of the first preprocessed image and the color moments of the second preprocessed image is greater than a preset threshold. The colored contact lens image is detected based on the overall color difference, the monochromatic color difference, and the local color difference.
2. The high-precision method for detecting minute color differences according to claim 1, characterized in that, The process includes preprocessing the colored contact lens image to obtain a first preprocessed image, and preprocessing the template image to obtain a second preprocessed image, including: The colored contact lens image is from Channel conversion The passage leads to the first... Image, and the template image is generated by Channel conversion The channel, obtained the second image; For the first The image is subjected to channel separation to obtain the first Channel image, first Channel image and first Channel image; and for the second The image undergoes channel separation to obtain the second... Channel image, second Channel image and second Channel image; For the first Channel image and the second Gaussian filtering is applied to the channel image to obtain the first... Image and Second image; The first Image, the first Channel image and the first Channel image fusion to obtain the first Image, and the second Image, the second Channel image and the second Channel image fusion to obtain the second image; For the first Image and the second The image is segmented by thresholding to obtain a first mask image of the colored ring of the printed area of the colored contact lens image and a second mask image of the colored ring of the printed area of the template image. Based on the first mask image, morphological erosion is performed on the colored contact lens image to obtain a first preprocessed image; and based on the second mask image, morphological erosion is performed on the template image to obtain a second preprocessed image.
3. The high-precision method for detecting minute color differences according to claim 1, characterized in that, Extracting the overall color features of the first preprocessed image and extracting the overall color features of the second preprocessed image, including: Extract the first image histogram from the first preprocessed image, and extract the second image histogram from the second preprocessed image; The first image histogram is smoothed, and the smoothed first image histogram is used as the overall color feature of the first preprocessed image; the second image histogram is smoothed, and the smoothed second image histogram is used as the overall color feature of the second preprocessed image.
4. The high-precision method for detecting minute color differences according to claim 1, characterized in that, Extracting the color moments of the first preprocessed image and the second preprocessed image includes: Extract the binarized background image The first background image of the first preprocessed image is obtained by intersecting the region with the first preprocessed image, and the first color image is then... The first foreground image is used as the first preprocessed image; and the binarized background image is extracted. The intersection region with the second preprocessed image is used to obtain the second background image of the second preprocessed image, and the second color image is then used to obtain the second background image. The second foreground image serves as the second preprocessed image; Calculate the first-order color moments of multiple partitions of the target image. and second-order color moments The target image includes the first foreground image, the second foreground image, the first background image, and the second background image, and the multiple partitions are multiple regions equally divided by the width of the colored contact lens ring; In the formula, Coordinates are The pixel value of the pixel, This represents the number of pixels within the partition.
5. The high-precision method for detecting minute color differences according to claim 3, characterized in that, Calculating the overall color difference between the colored contact lens image and the template image based on the overall color features of the first preprocessed image and the second preprocessed image includes: Calculate the histogram difference between the overall color features of the first preprocessed image and the overall color features of the second preprocessed image. Similarity to histogram This yields the overall color difference.
6. The high-precision method for detecting minute color differences according to claim 5, characterized in that, The monochromatic color difference between the contact lens image and the template image is calculated based on the single color features of the first preprocessed image and the second preprocessed image, including: Calculate the color center brightness difference between each color category in the first preprocessed image and the corresponding color category in the second preprocessed image. Color center color difference value and density difference This yields the monochromatic color difference.
7. The high-precision method for detecting minute color differences according to claim 6, characterized in that, The detection of the colored contact lens image based on the overall color difference, the monochromatic color difference, and the local color difference includes: Calculate the color similarity between the colored contact lens image and the template image based on the monochrome color difference and the overall color difference; When the color similarity is greater than or equal to a preset similarity threshold, it is determined that there is no overall color difference or single-color difference, and the presence of local color difference in the colored contact lens image is detected to obtain the detection result; When the color similarity is less than a preset similarity threshold, the histogram similarity is... Compare with the preset relevance threshold; The histogram similarity When the relevance is less than a preset relevance threshold, an overall color difference is determined to exist; in the histogram similarity... When the relevance is greater than or equal to a preset relevance threshold, the histogram difference is... Compare with a preset difference threshold; The histogram differences When the histogram distance is greater than or equal to a preset difference threshold, the histogram distance between the histogram and a preset histogram template is calculated; when the histogram distance is less than a preset distance threshold, it is determined that only a single-color difference exists; when the histogram distance is greater than or equal to a preset distance threshold, it is determined that both an overall color difference and a single-color difference exist, and the single color with the color difference is identified; in the histogram difference... When the difference is less than a preset difference threshold, it is determined that there is no overall color difference or single-color difference, and the presence of local color difference in the colored contact lens image is detected to obtain the detection result.
8. The high-precision method for detecting minute color differences according to claim 7, characterized in that, Calculating the color similarity between the colored contact lens image and the template image based on the monochromatic color difference and the overall color difference includes: Based on the histogram differences The histogram similarity The color center brightness difference The color center color difference value and the density difference value Build color similarity The color similarity The mathematical expression is: In the formula, This is the offset. The first weighting coefficient, This is the second weighting coefficient. The third weighting coefficient, The fourth weighting coefficient, The fifth weighting coefficient; wherein, the offset The first weighting coefficient The second weighting coefficient The third weighting coefficient The fourth weighting coefficient and the fifth weighting coefficient The methods for determining this include: Obtain sample data, wherein the sample data includes histogram differences of sample images. The histogram similarity Color center brightness difference Color center color difference value Density difference And tags; Training data is constructed based on the sample data; The offset is obtained by fitting the logistic regression model based on the training data. The first weighting coefficient The second weighting coefficient The third weighting coefficient The fourth weighting coefficient and the fifth weighting coefficient The mathematical expression for the logistic regression model is: In the formula, For tags.
9. A high-precision device for detecting minute color differences, characterized in that, include: The acquisition and preprocessing module is used to acquire a colored contact lens image and a template image, and to preprocess the colored contact lens image to obtain a first preprocessed image, and to preprocess the template image to obtain a second preprocessed image; The feature extraction module is used to extract the overall color features and single color features of the first preprocessed image, extract the overall color features and single color features of the second preprocessed image, and extract the color moments of the first preprocessed image and the color moments of the second preprocessed image. Extracting single color features from the first preprocessed image and extracting single color features from the second preprocessed image includes: converting the first preprocessed image and the second preprocessed image to... Space, to obtain the first image of the colored contact lenses The second image and template image Image; for the first Image Channels and Channel subtraction yields the first subtracted image. and for the second Image Channels and Channel subtraction yields a second subtracted image. ; for the first difference image and the second difference image Adaptive threshold segmentation is performed to obtain the first difference image. Binarized background image and the second difference image Binarized background image ; for the binarized background image and the binarized background image Invert the image to obtain the first mask image of the color dot region of the first preprocessed image. and the second mask image of the color dot region of the second preprocessed image. Extract the first mask image. The intersection region with the first preprocessed image is used to obtain a first color image of the color dot region of the first preprocessed image. Take the second mask image The intersection region with the first preprocessed image is used to obtain the second color image of the color dot region of the second preprocessed image. ; for the first color image and the second color image The non-zero pixel sequence in the image is clustered to obtain multiple colors and multiple color centers; then, the image is segmented using these multiple color centers as origins to obtain the first color image. and the second color image The image contains multiple color categories, each of which includes multiple pixels. The proportion, pixel density, color center brightness, and color center of each color category are calculated to obtain the single color features of the first preprocessed image and the single color features of the second preprocessed image. The calculation module is used to calculate the overall color difference between the contact lens image and the template image based on the overall color features of the first preprocessed image and the overall color features of the second preprocessed image, calculate the monochromatic color difference between the contact lens image and the template image based on the single color features of the first preprocessed image and the single color features of the second preprocessed image, and determine whether there is a local color difference in the contact lens image based on the color moments of the first preprocessed image and the color moments of the second preprocessed image, wherein a local color difference exists when the difference between the color moments of the first preprocessed image and the color moments of the second preprocessed image is greater than a preset threshold. The detection module is used to detect the colored contact lens image based on the overall color difference, the monochromatic color difference, and the local color difference.
Citation Information
Patent Citations
Contact lens casting mold printing quality detection method and device
CN114742752A
Yarn dyeing quality evaluation method and system based on adaptive mean shift clustering
CN114972345A