Method and device for detecting printing quality of contact lens mold
Through machine vision technology, the contact lens casting image is obtained and analyzed, and the printing quality is detected, which solves the problem of subjectivity and inefficiency of manual inspection, realizes automated inspection, and improves detection accuracy and production efficiency.
Patent Information
- Application Number
- CN202210200267.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2042-03-02
AI Technical Summary
In the prior art, the method of detecting the printing quality of contact lens casting molds mainly relies on artificial subjective perception, and there are problems such as inconsistent detection conclusions, artificial fatigue leads to wrong judgments and inefficient detection efficiency.
The mold image is obtained by using a machine vision scheme, edge detection and monochrome separation and extraction are performed through digital image analysis and processing methods, and compared with the template image to detect defects such as printing offset, overall color difference, monochrome color difference, ink deficiency and stains.
The automatic detection of the printing quality of contact lens casting molds is achieved, which reduces false inspections caused by human subjective factors, improves production efficiency, and reduces labor demand.
Smart Images

Figure CN114742752B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of optical detection technology, and in particular to a method and device for detecting the printing quality of a contact lens mold. Background Art
[0002] At present, the basic method of testing the printing quality of colored contact lens molds is manual subjective visual inspection, where production line workers who have received 3-6 months of professional training use their eyes or a microscope to check the printing problems of the molds under specific lighting conditions. This testing method has the following shortcomings: using human subjective perception as the testing standard, the test conclusions of different people may differ, making it difficult to unify and lacking in theoretical basis; long-term manual testing leads to fatigue and is prone to misjudgment; and the testing efficiency is relatively low.
[0003] There are also detection systems and methods for color defects in contact lenses, but they do not detect the casting mold, resulting in a high scrap rate, and can only detect a single defect, color defects, which has great limitations. Summary of the invention
[0004] The present disclosure provides a method and device for detecting the printing quality of contact lens molds.
[0005] In a first aspect, the present disclosure provides a method for detecting the printing quality of a contact lens mold, comprising: acquiring a mold image; performing edge detection on the mold image to determine the edge of the mold and the edge of a printing area on the mold, and detecting whether there is a printing offset; performing monochrome separation and extraction on the mold image, comparing the extracted monochrome information with the monochrome information of a template image, and detecting whether there is monochrome color difference or overall color difference; aligning the mold image with the template image, and detecting whether there is ink deficiency or stains in the printing area of the mold image.
[0006] In some optional embodiments, acquiring the mold image includes: acquiring color images of the mold under different lighting conditions, fusing the acquired multiple frames of color images to obtain the mold image to be detected; and generating a grayscale image of the mold image by graying and filtering.
[0007] In some optional embodiments, the method of determining the edge of the mold and the edge of the printing area on the mold to detect whether there is a printing offset includes: determining the edge of the mold using a binarization method, fitting a minimum circumscribed circle, and determining the center of the minimum circumscribed circle to be the center of the mold; using an algorithm to extract color points using color multi-channel enhancement to fit the minimum circumscribed circle of the outer contour of the printing area (i.e., the outer circle of the printing area), and determining the center of the minimum circumscribed circle to be the center of the outer circle of the printing area; determining whether there is a printing offset and indicating the offset direction by determining whether the distance between the center of the mold and the center of the outer circle of the printing area exceeds a threshold, and calculating the offset direction by a vector angle.
[0008] In some optional embodiments, an optical zone is provided at the center of the printing area, and the method further comprises: further fitting to obtain the minimum inscribed circle of the inner contour of the printing area (i.e., the inner circle of the printing area), so as to extract the color ring of the printing area according to the fitted outer circle of the printing area and the inner circle of the printing area, and, by comparing the diameter value of the inner circle of the printing area with the diameter value of the optical zone, preliminarily judging whether there are stains such as color point contamination in the optical zone on the casting mold.
[0009] In some optional embodiments, the monochrome separation and extraction of the mold image includes: utilizing a clustering method or an index image method to perform monochrome separation and extraction on the mold image, and further obtaining color values of each color space; and determining the color center to which each color point belongs through a color range screening method, and counting the number and area of color points corresponding to each monochrome.
[0010] In some optional embodiments, the extracted monochrome information is compared with the monochrome information of the template image to detect whether there is monochrome color difference or overall color difference, including: using the monochrome information of the template image and the extracted monochrome information of the mold image, weighting the color difference index of the color itself, the histogram deviation, the difference in the number of color points and the area difference into a comprehensive color difference index to judge the monochrome color difference and the overall color difference; and, when there is a contradiction between the monochrome color difference and the overall color difference, correcting the color difference detection result.
[0011] In some optional embodiments, determining whether there is ink deficiency or stains in the printing area of the mold image includes: using Gaussian blur and image feature point matching algorithm or template matching algorithm to obtain a difference image between the mold image and the template image, and detecting whether there is ink deficiency or stains in the printing area of the mold image based on the difference image.
[0012] In a second aspect, the present disclosure provides a device for detecting the printing quality of a contact lens mold, comprising: an image acquisition module for acquiring a mold image; an offset detection module for performing edge detection on the mold image, determining the edge of the mold and the edge of a printing area on the mold, and detecting whether there is a printing offset; a color difference detection module for performing monochrome separation and extraction on the mold image, comparing the extracted monochrome information with the monochrome information of a template image, and detecting whether there is monochrome color difference or overall color difference; and a printing area detection module for aligning the mold image with the template image, and detecting whether there is ink deficiency or stains in the printing area of the mold image.
[0013] In a third aspect, the present disclosure provides a computer device, comprising: one or more processors; a storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting the printing quality of contact lens molds as described in the first aspect.
[0014] In a fourth aspect, the present invention discloses a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by one or more processors, implements the method for detecting the printing quality of contact lens casting molds as described in the first aspect.
[0015] As described above, in order to solve the many problems of manually detecting the printing quality of contact lens casting molds, the present disclosure provides a method and device for detecting the printing quality of contact lens casting molds, which obtains the casting mold image through a machine vision solution, and performs edge detection and monochrome separation extraction through a digital image analysis and processing method and compares it with the template image, thereby realizing one-time detection of defects including printing offset, overall color difference and monochrome color difference, ink shortage, stains, etc. The technical effects realized by the present disclosure include but are not limited to: by automatically detecting the printing quality of contact lens casting molds, the disadvantages of manual detection are avoided, the false detection caused by human subjective factors is reduced, the production efficiency is improved, and the labor demand is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0017] Figure 1 is a schematic diagram of a contact lens casting mold;
[0018] Figure 2 is a schematic flow chart of a method for detecting the printing quality of a contact lens mold according to an embodiment of the present disclosure;
[0019] Figure 3 is a structural diagram of a machine vision imaging module according to an embodiment of the present disclosure;
[0020] Figure 4 is a flow chart of a detection algorithm of an embodiment of the present disclosure;
[0021] Figure 5 is a schematic structural diagram of a device for detecting the printing quality of a contact lens mold according to an embodiment of the present disclosure;
[0022] Figure 6 It is a schematic diagram of the structure of a computer device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0024] In the description of the present disclosure, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating directions or positional relationships, are only for the convenience of describing the present disclosure and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as limiting the present disclosure. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0025] In the description of the present disclosure, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", etc. should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the present disclosure can be understood according to specific circumstances.
[0026] In the description of the present disclosure, it should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other.
[0027] In order to solve many problems in manually detecting the printing quality of a color contact lens casting mold, the present disclosure provides a method and device for detecting the printing quality of a contact lens casting mold.
[0028] refer to Figure 1 , Figure 1This is a schematic diagram of a contact lens mold. A contact lens mold is a mold used to make contact lenses. As can be seen from the figure, a pattern is printed on the circular mold. The pattern can be colorful, and the area with the printed pattern is called the printing area. There is also a blank area in the center of the mold, and this area is surrounded by the printing area, which is called the optical area. The printing quality problems that may exist in contact lens molds include: printing offset, single color and overall color difference, lack of ink or missing printing, stains in the optical area, stains in the printing area, and other defects.
[0029] refer to Figure 2 , Figure 2 FIG. 1 is a flow chart of a method for detecting the printing quality of a contact lens mold according to an embodiment of the present disclosure. Figure 2 As shown, a method for detecting the printing quality of a contact lens mold according to an embodiment of the present disclosure comprises the following steps:
[0030] Step 11: Acquire the cast image.
[0031] In this step, the mold product can be imaged by a machine vision imaging module to obtain a mold image. The obtained mold image is usually required to be a color image.
[0032] In some optional embodiments, in order to improve the accuracy and repeatability of detection and enhance the dynamic range of image color so that the color effect of the image is closer to the perception of the human eye, it is preferred to adopt an imaging scheme of multiple image fusion, that is, to obtain color images of the mold under different lighting conditions, for example, color images of the mold when the light source is at different heights, and then fuse the obtained multiple frames of color images, and the color image obtained after fusion is the image of the mold to be detected.
[0033] In some optional implementations, in order to facilitate subsequent processing, this step also pre-processes the acquired casting mold image, including: performing grayscale and filtering processing to generate a grayscale image of the casting mold image.
[0034] In some optional embodiments, after acquiring the mold image, the method further includes: determining whether to set the mold image as a template image, and if so, executing the step of setting the mold image as a template image; if not, executing subsequent detection steps to detect the printing quality of the mold image.
[0035] Step 12: Perform edge detection on the casting mold image to determine the edge of the casting mold and the edge of the printing area on the casting mold, and determine whether there is printing deviation.
[0036] This step identifies the printing area on the mold through edge detection and determines whether there is printing offset.
[0037] In some optional embodiments, a binarization method can be used to determine the edge of the mold, and a minimum circumscribed circle can be fitted, and the center of the minimum circumscribed circle can be determined as the center of the mold; an algorithm for extracting color points using color multi-channel enhancement can be used to fit the minimum circumscribed circle of the outer contour of the printing area (i.e., the outer circle of the printing area), and the center of the minimum circumscribed circle can be determined as the center of the outer circle of the printing area; whether there is a printing offset and the offset direction can be determined by judging whether the distance between the center of the mold and the center of the outer circle of the printing area exceeds a threshold, and calculating the offset direction through the vector angle.
[0038] In some optional embodiments, the minimum inscribed circle of the inner contour of the printing area (i.e., the inner circle of the printing area) is further fitted to extract the colored ring of the printing area based on the fitted outer circle of the printing area and the inner circle of the printing area, and to preliminarily determine whether there are stains such as color spot contamination in the optical area on the mold by comparing the diameter value of the inner circle of the printing area with the diameter value of the optical area.
[0039] Step 13: Perform monochrome separation and extraction on the mold image, compare the extracted monochrome information with the monochrome information of the template image, and detect whether there is monochrome color difference or overall color difference.
[0040] In this step, color difference judgment is performed. Color difference includes monochromatic color difference and overall color difference. The judgment method is to obtain monochromatic information by monochromatic separation and extraction, and then compare the extracted monochromatic information with the monochromatic information of the template image. The template image is pre-set, and a qualified casting mold image without defects can be pre-set as the template image.
[0041] In some optional embodiments, performing monochrome separation and extraction on the mold image includes: performing monochrome separation and extraction on the mold image using a clustering or indexing image method, and further obtaining color values of various color spaces such as RGB, HSV, Hunter LAB, CIELAB, CIE XYZ, etc.; and determining the color center to which each color point belongs through a color range screening method, and counting the number and area of color points corresponding to each monochrome.
[0042] In some optional embodiments, determining whether there is monochromatic color difference or overall color difference includes: utilizing the monochromatic information of the template image and the monochromatic information of the extracted mold image, weighting and synthesizing the color difference index of the color itself, the histogram deviation, the difference in the number of color points, and the area difference into a comprehensive color difference index, and determining the monochromatic color difference and the overall color difference; and, when there is a contradiction between the monochromatic color difference and the overall color difference, correcting the color difference determination result.
[0043] The histogram data of the mold image may be obtained and compared with the histogram data of the template image to obtain the histogram deviation.
[0044] The general CIE DeltaE color difference calculation method can be used to calculate the color difference between the mold image and the template image, and the CIE DeltaE color difference index can be obtained as the color difference index of the color itself. The DeltaE (△E) color difference index is an international standard proposed by CIE (International Commission on Illumination).
[0045] Among them, correcting the color difference detection result may include: taking the overall color difference result as the standard, if the overall color difference is detected but the monochrome color difference is not detected, then correcting the color with the highest printing density to the monochrome color difference, otherwise, if the overall color difference is less than the set overall color difference threshold lower limit, then correcting the monochrome color difference to no color difference, otherwise, if the monochrome color difference is detected, then correcting the overall color difference to having color difference.
[0046] Step 14: Align the mold image with the template image to detect whether there is ink deficiency or stains in the printed area of the mold image.
[0047] In some optional implementations, Gaussian blur and image feature point matching or template matching algorithm can be used to obtain a difference image between the mold image and the template image, and based on the difference image, it can be detected whether there is ink shortage or stains in the printed area of the mold image.
[0048] The above describes a method for detecting the printing quality of a contact lens mold according to an embodiment of the present disclosure. The method uses an edge detection method to determine whether there are defects such as printing offset and stains in the optical area, and uses a comparison method with a template image to detect whether there are defects such as single color and overall color difference, ink shortage or missing printing, and stains in the printing area.
[0049] In some optional implementation manners, the process of setting the mold image as the template image in the embodiment of the present disclosure includes the following steps:
[0050] Step 21, performing edge detection on the casting mold image, acquiring edge detection data, and identifying the printing area and the optical area of the casting mold;
[0051] Step 22, performing monochrome separation and extraction on the mold image to obtain monochrome information data;
[0052] Step 23, performing histogram processing on the mold image to obtain histogram data;
[0053] Step 24: Set the mold image as a template image, and save its edge detection data, monochrome information data and histogram data together as template information.
[0054] To facilitate understanding and implementation of the technical solution of the present disclosure, further explanation is given below in conjunction with an application scenario embodiment.
[0055] Considering the variety of pattern textures and colors of colored contact lenses, in order to adapt to printed patterns with different characteristics, the detection scheme of this embodiment includes: imaging the mold product through a machine vision imaging module composed of a camera, a lens, and a light source, and detecting it through a machine vision software module composed of a background algorithm module and a front-end user interaction software. The detection process may include: first establishing a template image of a qualified mold product, extracting and storing relevant information, and then calculating and comparing the mold image to be tested with the template image, so as to use a digital image analysis and processing method to achieve different types of printing quality detection requirements. Among them, in order to improve the accuracy and repeatability of the detection, and enhance the dynamic range of the image color, so that the color effect of the image is closer to the perception of the human eye, it is preferred to adopt a multi-image fusion imaging scheme.
[0056] In some embodiments, reference Figure 3 , the machine vision imaging module may include: a camera 6 and its lens 5, a light source 4, a mechanical transmission module and an electrical control module. Among them: the mechanical transmission module includes a horizontal module 1, a rotating module 11 and a vertical module 2, the rotating module 11 is used to place the mold to be detected and is rotatable, the horizontal module 1 is provided with a rotating module 11 and can move horizontally, and the light source 4 is provided on the vertical module 2 and is used to irradiate the mold. The electrical control module includes a controller and its control button 10 and a motor group 3, the controller is used to control the motor group, and the motor group 3 is used to drive the translation of the horizontal module and the rotation of the rotating module and the vertical movement of the vertical module. Optionally, the overall housing of the machine vision imaging module can be a cabinet structure, which has a base 9, a cabinet wall 8 and a protective cover 7. The horizontal module 1 can be arranged on the base 9, and the camera 6 and the vertical module 2 can be arranged on the cabinet wall 8. The machine vision imaging module can be used to capture images of the mold under different conditions, such as color images when the light source is at different heights, and images of the mold at different rotation angles.
[0057] In some embodiments, the machine vision software module can be deployed in a computer device, including a front-end user interaction software module and a background algorithm module, and coupled to the machine vision imaging module. Among them, the front-end user interaction software module provides functions such as camera configuration, triggering the camera to collect images, etc. to drive the machine vision module, and also provides a user interaction interface, including image and detection result display, providing an interface for users to adjust detection parameters and trigger calling algorithms, and can also store detection history data for easy retrospective query. The background algorithm module provides functions such as image fusion, image preprocessing, and detection algorithms for various printing qualities of casting molds, and can eventually output the detection results to the front-end user interaction software module.
[0058] The detection algorithm can detect three major types of defects, including:
[0059] (1) Printing deviation detection;
[0060] (2) Color difference detection;
[0061] (3) Detection of missing prints and printing stains.
[0062] Referring to the detection items shown in Table 1, the detection algorithm can be used to detect all or part of the sub-items in the three detection items shown in the table.
[0063] Table 1 Test items
[0064]
[0065] refer to Figure 4 ,The overall process of the detection algorithm is as follows:
[0066] (I) Obtaining images
[0067] (1.1) Fusion Image
[0068] Input data: includes four parameters: single-frame color images of the mold taken when the light source is at different heights, the name of the mold, whether it is a template image, and meta tuple data, which includes the task ID and the request ID;
[0069] Processing logic: Call the multi-image fusion function to obtain a fused image by averaging multiple frames of images. The fused image has a higher dynamic range and the color is closer to the perception of the human eye. Of course, this method also includes the special case where the number of multiple images is 1 frame, and returns the image itself;
[0070] Output data: If the accumulated number of images does not reach the set number of multiple images, it returns the waiting image signal, otherwise it returns the fused image after averaging multiple images and the image acquisition completion signal.
[0071] (1.2) Preprocessing
[0072] Input data: fused image, detection parameter configuration file;
[0073] Processing logic: Call the preprocessing function to convert the RGB color image into a grayscale image, and then perform median filtering and Gaussian filtering to reduce image noise interference and avoid subsequent repeated calculations of the grayscale image;
[0074] Output data: filtered grayscale image, public configuration parameter and private configuration parameter data, initialization parameters.
[0075] (1.3) Determine whether to detect
[0076] Input data: whether it is a template image, public configuration parameter and private configuration parameter data, initialization parameters;
[0077] Processing logic: If it is a template image, call the template generation function, otherwise, call the detection function;
[0078] Output data: detection results and annotation information.
[0079] (II) The process of generating template function is as follows:
[0080] (2.1) Edge detection
[0081] Input data: original image, filtered grayscale image, public configuration parameters and private configuration parameter data;
[0082] Processing logic: Call the edge detection function to obtain the mold printing area and optical area of the template image, and use the optical area for subsequent targeted detection and analysis;
[0083] Output data: template edge detection data.
[0084] (2.2) Color extraction
[0085] Input data: edge detection data, number of mold colors, public configuration parameters and private configuration parameter data;
[0086] Processing logic: The color extraction function is called to separate a single color from a multi-color overprinted pattern, so as to analyze the color difference of a single color, and provide feedback to guide the production line to adjust the single-color ink. For the template image, the background color average of the non-color point area of the mold is also calculated and stored. When testing the sample, the parameter is called and used, so as to avoid the error introduced by the color difference of the color point affecting the background color;
[0087] Output data: template monochrome information data, template non-color point area background color average.
[0088] (2.3) Histogram processing
[0089] Input data: LAB image of the template printing area fitting polygon ROI, mask binary image of the template printing area, public configuration parameter data, number of histogram colors;
[0090] Processing logic: Call the function to calculate the LAB image histogram to obtain the histogram data of the template image, which is used to compare with the histogram data of the sample and analyze the color difference;
[0091] Output data: histogram data of the template.
[0092] (2.4) Generate template
[0093] Input data: mold name, edge detection data, monochrome information data, mold non-color point area background color mean, template histogram data;
[0094] Processing logic: calling the template information storage function to store the template information data calculated in the above steps into the local hard disk of the industrial computer, so as to facilitate subsequent retrieval and comparison analysis with the sample;
[0095] Output data: the result of whether the template is generated successfully.
[0096] (III) The detection function process is as follows:
[0097] (3.1) Reading template
[0098] Input data: mold name;
[0099] Processing logic: Call the function to read the corresponding template information, the purpose is to read the template information data from the hard disk and store it in a specific variable;
[0100] Output data: If the reading is successful, the template information data is returned, otherwise the reading failure result is returned and the program exits.
[0101] (3.2) Edge detection
[0102] Input data: original image, filtered grayscale image, public configuration parameters and private configuration parameter data;
[0103] Processing logic: Call the edge detection function to obtain the mold printing area and the optical area of the sample image, and use the optical area for subsequent targeted detection and analysis;
[0104] Output data: sample edge detection data.
[0105] (3.3) Color extraction
[0106] Input data: edge detection data, number of mold colors, average background color of non-color point area of corresponding template mold, public configuration parameter and private configuration parameter data;
[0107] Processing logic: The purpose of calling the color extraction function is to separate a single color from a multi-color overprinted pattern, so as to analyze the color difference of a single color, and then provide feedback to guide the production line to adjust the single-color ink. In the logic of detecting the sample, it is necessary to retrieve the background color mean parameter of the non-color point area of the corresponding template, without recalculating the parameter, thus avoiding the error introduced by the color difference of the color point affecting the background color;
[0108] Output data: sample monochrome information data.
[0109] (3.4) Color difference calculation
[0110] Input data: template information data, sample monochrome information data, sample edge detection data, public configuration parameters and private configuration parameter data;
[0111] Processing logic: Call the color difference detection function to compare and analyze the color information of the template and the sample, so as to analyze the overall color difference and monochromatic color difference;
[0112] Output data: color difference results, various color difference data indicators, and sample monochrome data sorted according to the template monochrome order.
[0113] (3.5) Printing area inspection
[0114] Input data: template ROI image, sample edge detection data, public configuration parameters and private configuration parameter data;
[0115] Processing logic: Call the printing area detection function to detect defects such as ink shortage or stains in the printing area by aligning the sample and template images;
[0116] Output data: printing area inspection results, printing area related defect information.
[0117] The processing flow of each sub-function in the above detection function is as follows:
[0118] (A) Edge detection function
[0119] (A1) Edge positioning
[0120] Input data: filtered grayscale image, public configuration parameter and private configuration parameter data, initialization parameters;
[0121] Processing logic: Call the edge location function of the upper surface of the mold, perform adaptive binarization operation on the filtered grayscale image, and perform morphological closing operation, opening operation and Gaussian filtering to connect the edges and remove edge burrs. After that, perform contour extraction operation on the processed binary image, use the upper and lower limits of the mold area threshold to screen out the candidate mold contours, select the contour with the largest area among the candidate contours, and calculate its minimum circumscribed circle, that is, obtain the edge of the upper surface of the mold, and draw the circle annotation;
[0122] Output data: If the positioning is successful, the mold edge information data will be output, including the center and radius of the mold circumscribed circle, and the mold mask binary image. Otherwise, the positioning failure result will be output, and the prompt message "Mold edge not found" will be displayed, and the program will exit.
[0123] (A2) Inner and outer contour detection of printing area
[0124] Input data: original image, edge detection data, public configuration parameter data;
[0125] Processing logic: Call the inner and outer contour detection function of the mold printing area. In order to adapt to mold patterns with different color depths, only considering the brightness information will lead to the inability to perfectly adapt to all products. Therefore, it is necessary to make full use of the color information of the image for positioning. Method F1 "Algorithm for extracting color points using color multi-channel enhancement" is proposed: Consider the printing area extraction operation in the HSV color space, where H represents hue, S represents saturation, and V represents brightness. Considering that the hues of various inks vary greatly, but the S and V channels of the printed color area are significantly different from those of the non-color point area, because the non-color point area itself is close to white, but due to the different colors of the color points, the color of the background area will be affected during the printing process. For example, if pink color points are printed, the background area around the color points will also tend to be light pink. However, no matter how the background color is biased, its S value should be smaller and the V value should be larger. According to this feature, the non-color point area image can be first screened out, and the image is inverted to obtain the color point grayscale image with the color point highlighted. Then calculate the binary image, search for contours, set the upper and lower limits of the contour area threshold, and find the inner and outer contours for the mold with a closed color ring pattern in the printing area. However, for the case of a non-closed pattern, only one contour can be detected. At the same time, in the process of searching for the contour of the printing area, in order to prevent the method F1 from failing to find, a secondary search is also performed. After obtaining the binary image using the brightness image, the contour search is performed.
[0126] Output data: If the positioning is successful, the number of detected contours and mold edge information data will be output, including the center and radius of the circumscribed circle of the printing area, the area of the outer circle of the printing area, the binary image of the colored ring mask of the printing area, the binary image of the mask of the fitted polygon of the printing area, the colored ROI (region of interest) image of the printing area, and the x and y offsets of the ROI. Otherwise, the positioning failure result will be output, and the prompt message "The edge of the printing area was not found" will be prompted, and the program will exit.
[0127] (A3) Detection of the inscribed circle contour in the printing area
[0128] Input data: original image, filtered grayscale image, edge detection data, public configuration parameter data;
[0129] Processing logic: The function of detecting the inscribed circle of the mold printing area is called to calculate the inscribed circle of the color ring in the printing area for subsequent stain detection in the optical area. The detection method of the maximum inscribed circle proposed here is as follows: first, the minimum circumscribed circle of the inner contour of the color ring is obtained, and the center of the circumscribed circle is taken as the center of the inscribed circle. Then, the distance from each point on the inner contour to the center is calculated, and the minimum distance is taken as the diameter of the inscribed circle. Compared with the traditional method, this method has a smaller amount of calculation and the error introduced is within the allowable range.
[0130] Output data: If the positioning is successful, the mold edge information data will be output, including the center and radius of the inscribed circle in the printing area, the binary mask image of the color ring in the printing area, the area of the color ring, the total area of the color points, the binary mask image of the fitting polygon of the color ring in the printing area, and the ROI image of the color ring in the printing area. Otherwise, the positioning failure result will be output, and the prompt message "The edge of the printing area is not found" will be displayed, and the program will exit.
[0131] (A4) Optical area stain detection
[0132] Input data: filtered grayscale image, edge information data, public configuration parameters and private configuration parameter data;
[0133] Processing logic: Call the optical area stain detection function to detect defects in the optical area. The size of the optical area is usually set by the customer and is concentric with the mold. Its diameter is smaller than the inner ring diameter of the printing area, that is, the printed color dots cannot fall into the optical area, otherwise it will be considered a defective product. Therefore, first compare the two diameter values to preliminarily determine whether there is color dot contamination in the optical area. Then, extract the optical area through the mask, and use the adaptive binarization and contour search method to further detect dark stains;
[0134] Output data: If stains are detected in the optical area, the result code and stain mark of the optical area stains are output; otherwise, a qualified result code is output.
[0135] (A5) Printing deviation detection
[0136] Input data: edge information data, public configuration parameters and private configuration parameter data;
[0137] Processing logic: Call the printing offset detection function to detect printing offset. It can detect overall offset or obvious single-color offset (slight single-color offset is detected by color difference detection). The distance between the center of the minimum circumscribed circle of the mold and the center of the minimum circumscribed circle of the printing area is calculated and compared with the upper limit of the offset threshold. If it exceeds the upper limit, it is judged that there is printing offset. The offset direction is obtained by calculating the angle between the vectors. The horizontal unit vector Q1 is used as the reference vector, and the unit vector Q2 in the offset direction is calculated. The offset angle can be obtained by calculating the arc cosine value of the dot product of the unit vector Q1 and the unit vector Q2. The value range is [0,180°], and the specific direction is indicated by the marked arrow;
[0138] Output data: Output the absolute value of the offset, the offset angle and the indicating arrow of the direction. If printing offset is detected, the result code of printing offset and the red arrow mark are output, otherwise the qualified result code and the green arrow mark are output.
[0139] (B) Color extraction function
[0140] (B1) Color extraction preprocessing
[0141] Input data: edge information data;
[0142] Processing logic: Call the color extraction preprocessing function to perform an erosion operation on the mask image of the color point to remove the color error caused by dispersion at the edge of the color point as much as possible;
[0143] Output data: color image of the printed area fitted with polygonal ROI, binary image of the printed area fitted with polygonal mask after corrosion.
[0144] (B2) Calculate the center of a single color
[0145] Input data: color extraction method (index image method or clustering method);
[0146] Processing logic: Call the function to calculate the monochrome color center in order to extract monochrome information from the aliased color;
[0147] Output data: monochrome information data.
[0148] The above function can choose any of the following options:
[0149] (01) Index Image Method
[0150] Input data: Printing area fitting polygon ROI color image, public configuration parameters and private configuration parameter data;
[0151] Processing logic: Call the function to get the index image, the purpose is to use the image palette to extract the color. The principle of this method is that given a fixed color palette, a sequence of stored color index values can be obtained, corresponding to each pixel in the image. Therefore, the color of each pixel in the image can be mapped to a fixed color in the palette, achieving the effect of reducing the number of image colors.
[0152] Output data: index color, number of points of each color.
[0153] (02) Clustering method
[0154] Input data: printed area fitting polygon ROI color image, printed area fitting polygon mask binary image after corrosion treatment, edge information data, template casting non-color point area background color average, public configuration parameter and private configuration parameter data;
[0155] Processing logic: Call the color clustering function to take the color value of each pixel of the image as a data sequence. The number of clusters is the total number of printed colors input by the user. The color center of each monochrome is obtained by clustering. Before using the clustering method, it is necessary to call method F1 to extract color points. The image used for clustering is a color image in the LAB color space, because this color space can separate the brightness L from the color AB, and is more in line with the human eye's perception of color.
[0156] Output data: the average background color of the non-color point area of the mold, monochrome information, including monochrome LAB value, the number of color points of each category, and the total number of color points.
[0157] (B3) Monochrome area segmentation
[0158] Input data: printed area fitting polygon ROI color image, monochrome information;
[0159] Processing logic: Calling the monochrome area segmentation function aims to obtain the color values of various color spaces (such as RGB, HSV, HunterLAB, CIE LAB, CIE XYZ) for user reference. At the same time, more accurately obtain the distribution of monochrome color points and the number of pixels occupied by each monochrome, so as to carry out subsequent color difference analysis. By setting the upper and lower limit thresholds of the range of the three channels L, A, and B from the color center, the mask binary image corresponding to each monochrome can be obtained respectively, and then the AND operation is performed with the original image to obtain the distribution of the monochrome area and determine the color center to which each monochrome color point belongs. By counting the number of non-zero pixels in the mask image, the number and area of the monochrome color points, i.e., the printing density information, can be obtained.
[0160] Output data: monochrome information, including monochrome color values in HSV, RGB, HunterLAB, and CIELAB spaces, the number of monochrome color points, the area of monochrome color points, monochrome RGB labeled color blocks, and monochrome highlight area labels.
[0161] (C) Color difference calculation function
[0162] (C1) Histogram processing
[0163] Input data: LAB image of the sample printing area fitting polygon ROI, mask binary image of the sample printing area, public configuration parameter data, number of histogram colors;
[0164] Processing logic: Call the function to calculate the LAB image histogram in order to obtain the histogram information of the sample LAB image;
[0165] Output data: LAB histogram data of samples.
[0166] (C2) Overall color difference calculation
[0167] Input data: template histogram data, sample histogram data, public configuration parameters and private configuration parameter data;
[0168] Processing logic: Call the overall color difference calculation function, the purpose is to judge the overall color difference by comparing the difference between the image histograms of the template and the sample, and propose a method for judging the overall color difference: the impact of multi-color overprinting on the overall color perception can be reflected through the color histogram. First, calculate the correlation coefficient of the template and sample histograms. The value range is [0,1]. The larger the value, the higher the similarity. Then calculate the sum of the Euclidean distances of the A and B channels of the two histograms, which is the histogram deviation. Finally, make an overall color difference judgment and cause analysis. If the correlation coefficient value is less than the set correlation coefficient threshold lower limit, it is determined that there is a color difference caused by the correlation coefficient deviation. If the histogram deviation value is greater than the set deviation threshold lower limit, it is determined that there is a color difference caused by the histogram deviation. At the same time, the similarity index obtained by weighting the correlation coefficient and the deviation can also be calculated;
[0169] Output data: color difference information, including the overall color difference result code, histogram correlation coefficient, histogram deviation value, and overall similarity index between the sample and the template.
[0170] (C3) Monochrome color difference calculation
[0171] Input data: template monochrome information, sample monochrome information, color difference information, public configuration parameters and private configuration parameter data;
[0172] Processing logic: calling the monochrome color difference calculation function is aimed at obtaining the color difference of each color ink. The human eye's judgment mechanism for macro color difference is relatively complex. On the one hand, it may be due to the difference in hue, saturation or brightness between colors. On the other hand, the density of printing also seriously affects the human eye's judgment of color difference. Therefore, the present disclosure proposes a color difference judgment index that comprehensively considers the color itself and the color point density. The difference in color itself can be obtained by the general CIE DeltaE color difference calculation method, but the final color difference index is obtained by weighting the brightness difference, color point density difference, histogram deviation, and CIE DeltaE color difference value. If one of the following conditions is met: (1) the color difference index exceeds the set monochrome difference threshold upper limit, (2) the color difference index exceeds the set monochrome difference threshold lower limit and the CIE DeltaE color difference value is greater than the set color difference value upper limit, then it is determined that the color has color difference;
[0173] Output data: sample monochrome information sorted by template monochrome order, color difference information, including color difference result code of each monochrome, monochrome color difference index, difference in the proportion of monochrome color points between sample and template, difference in monochrome brightness between sample and template, difference in area and area proportion of monochrome color points between sample and template, CIE DeltaE color difference value.
[0174] (C4) Comprehensive judgment of color difference
[0175] Input data: color difference information;
[0176] Processing logic: The color difference function is comprehensively judged based on the overall and monochromatic color differences. The purpose is to correct the color difference results when there is a conflict between the overall color difference and the monochromatic color difference results. The correction logic is based on the overall color difference result. If the overall color difference is detected but the monochromatic color difference is not detected, the color with the highest printing density is corrected to the monochromatic color difference. Otherwise, if the overall color difference is less than the set overall color difference threshold lower limit, the monochromatic color difference is corrected to no color difference. Otherwise, if the monochromatic color difference is detected, the overall color difference is corrected to have color difference.
[0177] Output data: Corrected overall and monochrome color difference result code. If the result is that there is color difference, the "color difference" prompt message is output next to the color block with color difference and the program terminates. Otherwise, it enters the printing area detection function.
[0178] (D) Printing area detection function
[0179] (D1) Ink shortage detection
[0180] Input data: ROI color image of the area surrounded by the circumscribed circle of the template printing area, ROI color image of the area surrounded by the circumscribed circle of the sample printing area, sample edge information data, public configuration parameters and private configuration parameter data;
[0181] Processing logic: Calling the ink shortage detection function aims to detect ink shortage or missing printing defects in the sample printing area. Since the texture patterns of the casting molds are different, the samples themselves often have irregular or asymmetric gaps. Therefore, they must be compared with the patterns of the standard templates to accurately detect ink shortage defects without causing a large number of misjudgments. Since the angle when placing the casting mold is arbitrary, the sample image must first be registered with the template image. The present disclosure proposes to use a feature point matching method (including but not limited to SIFT, SURF, ORB and other algorithms) to find the homography matrix, or to obtain a linear image of the printing area through polar coordinate expansion, and then use a template matching method to register the images, and then transform the template image to correspond to the sample image (or transform the sample image to correspond to the template image) through affine transformation. After that, the ink shortage area is extracted by obtaining the difference image between the sample image and the template image after Gaussian blur;
[0182] Output data: detection result code, printing area information data, including the grayscale image of the ROI area surrounded by the circumscribed circle of the template printing area after image registration, the area of the maximum ink-deficient area, the total area of the ink-deficient area, and the marking of the ink-deficient area.
[0183] (D2) Printing area stain detection
[0184] Input data: sample edge information data, printing area information data, public configuration parameters and private configuration parameter data;
[0185] Processing logic: Call the printing area stain detection function to detect stains or overprinting defects in the sample printing area. Since the image has been registered in the previous step, the stain area can be extracted by obtaining the difference image between the template image after Gaussian blur and the sample image.
[0186] Output data: test result code, printing area information data, including the area of the largest stain area, the total area of the stain area, and the marking of the stain area.
[0187] The above detection algorithms include a printing offset detection algorithm, a single color separation and extraction algorithm, a single color color difference and overall color difference judgment algorithm, an ink shortage or missing print detection algorithm, an optical area stain detection algorithm and a printing area stain detection algorithm, etc., which can realize the detection functions of three major types of defects, including: (1) printing offset detection; (2) color difference detection; (3) missing print and printing stain detection.
[0188] The beneficial effects achieved by the embodiments of the present disclosure include but are not limited to:
[0189] (1) A method for automatically detecting the printing quality of contact lens molds has been realized. The color imaging effect is very close to the perception of the human eye, and can truly present the color information of the printed pattern. Various types of defects can be detected, including printing offset, single color and overall color difference, ink deficiency, stains in various areas, etc., achieving the purpose of covering all manual quality inspection links;
[0190] (2) A scientific numerical quantitative standard for measuring the quality of mold printing has been established, reducing false detection caused by human subjective factors;
[0191] (3) It has the characteristics of high accuracy, high repeatability, low missed detection rate and low misjudgment rate of test results, and can be adapted to various specifications and models of contact lens molds, effectively reducing labor costs;
[0192] (4) The entered qualified product template data is stored in the local hard disk of the industrial computer and can be easily traced back and exported with one click. The inspection related data is stored in the database and can be traced back and searched, effectively guiding users to improve processes and increase productivity.
[0193] refer to Figure 5 The embodiment of the present disclosure also provides a contact lens casting mold printing quality detection device 500, the device 500 comprises:
[0194] An image acquisition module 51 is used to acquire a casting mold image;
[0195] An offset detection module 52 is used to perform edge detection on the mold image, determine the edge of the mold and the edge of the printing area on the mold, and detect whether there is a printing offset;
[0196] The color difference detection module 53 is used to separate and extract the mold image in monochrome, compare the extracted monochrome information with the monochrome information of the template image, and determine whether there is a monochrome color difference or an overall color difference;
[0197] The printing area detection module 54 is used to align the mold image with the template image and detect whether there is ink shortage or stain in the printing area of the mold image.
[0198] refer to Figure 6 The present disclosure also provides a computer device 600, including:
[0199] One or more processors 601;
[0200] A memory 602 on which one or more programs 603 are stored;
[0201] Components such as the processor 601 and the memory 602 may be coupled together via a bus system 604; the bus system 604 is used to implement connection and communication between these components;
[0202] When one or more programs 603 are executed by one or more processors 601 , the one or more processors 601 implement the method for detecting the printing quality of the contact lens casting mold as disclosed in the above method embodiment.
[0203] The bus system 604 may include a power bus, a control bus, and a status signal bus in addition to a data bus. The memory 602 may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. The processor 601 may be an integrated circuit chip with signal processing capabilities, and may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0204] The embodiments of the present disclosure also provide a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by one or more processors, the method for detecting the printing quality of the contact lens mold disclosed in the above method embodiment is implemented.
[0205] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0206] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0207] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0208] It should be understood that the terms "system" and "network" are often used interchangeably in this disclosure. The term "and / or" in this disclosure is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this disclosure generally indicates that the associated objects before and after are in an "or" relationship.
[0209] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the protection scope of the present disclosure. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.
Claims
1. A method for detecting the printing quality of a contact lens mold, comprising: acquiring a cast image; Performing edge detection on the casting mold image to determine the edge of the casting mold and the edge of the printing area on the casting mold, and detecting whether there is printing deviation; Performing monochrome separation and extraction on the mold image, comparing the extracted monochrome information with the monochrome information of the template image, and detecting whether there is monochrome color difference or overall color difference; Registering the mold image with the template image to detect whether there is ink shortage or stain in the printing area of the mold image; The performing edge detection on the casting mold image, determining the edge of the casting mold and the edge of the printing area on the casting mold, and detecting whether there is printing deviation comprises: The edge of the mold is determined by a binarization method, and a minimum circumscribed circle is fitted, and the center of the minimum circumscribed circle is determined as the center of the mold; An algorithm for extracting color points by means of color multi-channel enhancement is used to fit the minimum circumscribed circle of the outer contour of the printing area, and the center of the minimum circumscribed circle is determined as the center of the outer circle of the printing area; By judging whether the distance between the center of the mold circle and the center of the outer circle of the printing area exceeds a threshold, and calculating the offset direction through the vector angle, it is judged whether there is a printing offset and indicates the offset direction; The step of comparing the extracted monochrome information with the monochrome information of the template image to detect whether there is monochrome color difference or overall color difference includes: Using the monochrome information of the template image and the extracted monochrome information of the mold image, the color difference index of the color itself, the histogram deviation, the color point quantity difference and the area difference are weighted and integrated into a comprehensive color difference index to judge the monochrome color difference and the overall color difference; Also, when there is a contradiction between the monochromatic color difference and the overall color difference, the color difference detection result is corrected.
2. The method according to claim 1, wherein acquiring the casting mold image comprises: Acquire color images of the mold under different lighting conditions, and fuse multiple frames of acquired color images to obtain an image of the mold to be detected; And, by performing gray-scaling and filtering processing, a gray-scale image of the mold image is generated.
3. The method according to claim 1, wherein an optical zone is disposed at the center of the printing zone, the method further comprising: The minimum inscribed circle of the inner contour of the printing area is further fitted, and by comparing the diameter of the minimum inscribed circle with the diameter of the optical zone, it is determined whether there is stain in the optical zone.
4. The method according to claim 1, wherein: The monochrome separation and extraction of the casting mold image comprises: The casting image is subjected to monochrome separation and extraction using a clustering method or an indexed image method, and the color values of each color space are further obtained; and the color center to which each color point belongs is determined by a color range screening method, and the number and area of the color points corresponding to each monochrome are counted.
5. The method according to claim 1, wherein: The step of detecting whether the printing area of the mold image is lacking ink or having stains comprises: Gaussian blur and image feature point matching algorithm or template matching algorithm are used to obtain a difference image between the mold image and the template image, and based on the difference image, it is detected whether there is ink shortage or stain in the printing area of the mold image.
6. A device for detecting the printing quality of a contact lens mold, comprising: An image acquisition module, used for acquiring a casting mold image; An offset detection module is used to perform edge detection on the mold image, determine the edge of the mold and the edge of the printing area on the mold, and detect whether there is a printing offset; A color difference detection module is used to separate and extract the mold image in monochrome, compare the extracted monochrome information with the monochrome information of the template image, and detect whether there is a monochrome color difference or an overall color difference; A printing area detection module, used to register the mold image with the template image and detect whether there is ink shortage or stain in the printing area of the mold image; The offset detection module is further used to determine the edge of the mold by using a binarization method, and fit the minimum circumscribed circle, and determine that the center of the minimum circumscribed circle is the center of the mold; use an algorithm to extract color points in a color multi-channel enhancement manner to fit the minimum circumscribed circle of the outer contour of the printing area, and determine that the center of the minimum circumscribed circle is the center of the outer circle of the printing area; by judging whether the distance between the center of the mold and the center of the outer circle of the printing area exceeds a threshold, and calculating the offset direction by a vector angle, it is judged whether there is a printing offset and indicates the offset direction; The color difference detection module is further used to use the monochrome information of the template image and the extracted monochrome information of the mold image to weight the color difference index of the color itself, the histogram deviation, the difference in the number of color points and the area difference into a comprehensive color difference index to judge the monochrome color difference and the overall color difference; and when there is a contradiction between the monochrome color difference and the overall color difference, correct the color difference detection result.
7. A computer device comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting the printing quality of the contact lens casting mold as described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by one or more processors, implements the method for detecting the printing quality of a contact lens casting mold as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Detection method and detection system for color defects of contact lenses
CN105938088A
Contact lens edge defect detection method based on deep learning
CN111062961A