A method and device for detecting ink leakage in the inner circle of the printed area of contact lenses
By using machine vision technology to pre-process and align multiple original images and template images of contact lenses, ink leakage in the inner circle of the printing area can be automatically identified, solving the problems of false detection and low efficiency of traditional detection methods, and improving detection accuracy and production yield.
Patent Information
- Application Number
- CN202411403517.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2044-10-09
AI Technical Summary
Traditional contact lens printing area inner circle ink leakage detection relies on manual inspection, which is prone to errors and inefficient. Existing computer image processing methods are prone to misdetection of products with large deviations.
A machine vision-based method is used to obtain multiple original images and template images of the contact lens, perform preprocessing, registration and difference image analysis, and automatically identify ink leakage in the inner circle of the printing area.
It realizes the automatic identification of ink leakage in the inner circle of the contact lens printing area, improves the detection accuracy, saves costs and improves the production yield.
Smart Images

Figure CN119355001B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of machine vision, and in particular to a method and device for detecting ink leakage in the inner circle of a printed area of a contact lens. Background Art
[0002] The main method for printing patterns on contact lenses is pad printing. Since the printing ink is easily affected by the ink concentration itself, environmental temperature and humidity, it is easy for defects such as ink leakage to occur during the printing process. Ink leakage can occur in any area of the printing area. Among them, the frequency of ink leakage in the inner circle of the printing area is the highest. The ink in the inner circle has the characteristics of large printing deviation, unstable ink concentration, and small leakage area.
[0003] Traditional printing quality inspection methods rely on manual inspection, which has the following shortcomings: long-term manual inspection causes eye fatigue, is prone to misjudgment, and has relatively low inspection efficiency; the ink omission detection method based on computer image processing requires the establishment of a template for qualified products first, and detects omission defects by comparing them with the template. However, this method is prone to false detection of products with large deviations. Summary of the Invention
[0004] In view of this, an object of the present invention is to provide a method and device for detecting ink leakage in the inner circle of the printed area of a contact lens, so as to solve the problems in the background technology.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A method for detecting ink leakage in the inner circle of a printed area of a contact lens according to the present invention comprises the following steps:
[0007] acquiring a plurality of original images and a template image of the contact lens;
[0008] Preprocessing the multiple original images of the contact lens to obtain preprocessed images, wherein the preprocessed images include positioning results of the edge of the contact lens mold and the edge of the printing area;
[0009] registering the preprocessed image and the template image so that the preprocessed image is aligned with the same position of the template image;
[0010] Based on the registered pre-processed image and the template image, ink leakage detection is performed on the inner circle of the printed area of the contact lens to obtain a detection result.
[0011] In one embodiment of the present application, preprocessing is performed on a plurality of original images of the contact lens to obtain preprocessed images, including:
[0012] Binarizing the multiple original images to obtain initial binary images;
[0013] Performing median filtering on multiple initial binary images to obtain binary images with mold edges;
[0014] Extracting contours from the binary image, and screening the contours in the binary image based on a preset first area condition to obtain a mold contour that meets the preset area condition;
[0015] Extracting the centroid of the mold contour to obtain the mold center, and overlapping the multiple original images based on the mold center;
[0016] Calculate the average image of multiple overlapping original images;
[0017] performing binarization processing on the average image to obtain an intermediate binary image;
[0018] Performing morphological operations on the intermediate binary image to obtain a target binary image including an outer boundary of the printing area and an inner boundary of the printing area;
[0019] Extracting the contours in the target binary image, and screening the contours in the target binary image based on a preset second area condition to obtain an outer boundary contour of the printing area and an inner boundary contour of the printing area;
[0020] The outer boundary contour of the printing area and the inner boundary contour of the printing area are fitted to obtain the outer circle center of the printing area, the outer circle radius of the printing area, the inner circle center of the printing area and the inner circle radius of the printing area.
[0021] In one embodiment of the present application, registering the preprocessed image and the template image includes:
[0022] Extracting a target area image from the pre-processed image and the template image based on a pre-constructed printing area outer circle mask, wherein the target area image only includes the optical area and the printing area;
[0023] Extracting the outer circle center of the printing area from the positioning result of the printing area edge, and performing polar coordinate expansion on the target area image of the preprocessed image based on the outer circle center of the printing area in the positioning result to obtain a first polar coordinate image; and performing polar coordinate expansion on the target area image in the template image based on the outer circle center of the printing area in the template image to obtain a second polar coordinate image;
[0024] Sliding the second polar coordinate image along the angular axis of the first polar coordinate image in a sliding window manner, calculating the cross-correlation between the first polar coordinate image and the second polar coordinate image during each sliding operation, and taking the position with the maximum cross-correlation as the first registration result;
[0025] Converting the first polar coordinate image and the second polar coordinate image back into a two-dimensional coordinate system based on the first registration result to obtain a roughly registered target area image of the preprocessed image and a target area image in the template image;
[0026] Extracting an inner circle region from the target region image of the roughly registered preprocessed image and the target region image in the template image, wherein the inner circle region is a circular region with the inner circle center as the center and the inner circle radius plus the target width as the radius;
[0027] Downsampling the inner circle area to obtain a downsampled image of the template image and a downsampled image of the preprocessed image;
[0028] Based on the inner circle of the template image, and in combination with the pre-constructed rotation range and rotation step, the downsampled image of the template image is rotated multiple times, and at each rotation, the cross-correlation between the downsampled image of the template image and the downsampled image of the preprocessed image is calculated, and the angle with the maximum cross-correlation is used as the alignment angle of the template image and the preprocessed image to obtain a second alignment result.
[0029] In one embodiment of the present application, the cross-correlation calculation formula is:
[0030]
[0031] Wherein, R(x,y) is the cross-correlation between the first polar coordinate image and the second polar coordinate image, or the downsampled image of the template image and the downsampled image of the preprocessed image at the point (x,y), T'(x',y') is the pixel value of the second polar coordinate image or the downsampled image of the template image at the position (x',y'), and I'(x+x',y+y') is the pixel value of the first polar coordinate image or the downsampled image of the preprocessed image at the position (x+x',y+y').
[0032] In one embodiment of the present application, ink leakage detection is performed on the inner circle of the printed area of the contact lens based on the registered pre-processed image and the template image, including:
[0033] Extracting a difference map between the registered preprocessed image and the template image;
[0034] Extracting candidate missing printing areas in the difference map;
[0035] The candidate missing printing areas are screened to obtain missing printing areas.
[0036] In one embodiment of the present application, extracting a difference map between the registered pre-processed image and the template image includes:
[0037] Extracting a first inner circle image of the registered preprocessed image and a second inner circle image of the registered template image;
[0038] Performing Gaussian filtering on the first inner circle image and the second inner circle image to obtain a first intermediate image and a second intermediate image;
[0039] The first intermediate image and the second intermediate image are subtracted to obtain a difference map.
[0040] In one embodiment of the present application, extracting a candidate missing printing area from the difference map includes:
[0041] Binarizing the difference map to obtain a difference binary map, and extracting a difference contour from the difference binary map;
[0042] Filter out the difference contours whose area is smaller than the preset area threshold to obtain candidate contours;
[0043] Drawing the candidate contour into a binary image to obtain a difference mask;
[0044] Performing a dilation operation on the difference mask to connect isolated areas to obtain a difference area; and inverting the difference area to obtain a high-difference binary image;
[0045] filtering the difference map based on the high-discrepancy binary map to obtain a filtered difference map;
[0046] Binarization and contour extraction are performed on the filtered difference image to obtain a candidate missing printing area.
[0047] In one embodiment of the present application, the candidate missing printing areas are screened to obtain the missing printing areas, including:
[0048] Extracting a first inner circle image of the registered preprocessed image and a second inner circle image of the registered template image;
[0049] Binarizing each color channel of the first inner circle image and each color channel of the second inner circle image to obtain a plurality of single-channel binary images of the first inner circle image and a plurality of single-channel binary images of the second inner circle image;
[0050] Performing an AND operation on multiple single-channel binary images of the first inner circle image to obtain a product binary image; and performing an AND operation on multiple single-channel binary images of the second inner circle image to obtain a template binary image;
[0051] Performing an expansion operation on the product binary image and the template binary image to obtain a product expansion image and a template expansion image;
[0052] Subtracting the product expansion map from the template expansion map to obtain a suspected missing print area;
[0053] Extracting a binary image of the optical zone in the template image, and performing an XOR operation on the binary image of the optical zone and the suspected missing printing area to obtain an image with eliminated motion differences;
[0054] Traverse each candidate missing printing area and perform binarization to obtain a candidate missing printing binary map;
[0055] Subtracting the candidate missing print binary image from the offset difference elimination image to obtain a binary image of the region of interest;
[0056] The minimum circumscribed rectangle of each region-of-interest binary image is generated, and candidate missing printing areas are screened based on the area of the region-of-interest binary image and the size of the minimum circumscribed rectangle to obtain ink missing printing areas.
[0057] In one embodiment of the present application, it further includes:
[0058] When the detection result includes an ink missing area, generating a minimum circumscribed rectangle of the ink missing area;
[0059] transforming the coordinates of the minimum circumscribed rectangle of the ink missing area into coordinates in the original image;
[0060] A prompt box is drawn based on the coordinates in the original image, and the prompt box is output.
[0061] The present application also provides a device for detecting ink leakage in the inner circle of a printed area of a contact lens, comprising:
[0062] an acquisition module, used for acquiring a plurality of original images and template images of the contact lens;
[0063] A preprocessed image is used to preprocess the multiple original images of the contact lens to obtain a preprocessed image, wherein the preprocessed image includes the positioning results of the edge of the contact lens mold and the edge of the printing area;
[0064] a registration module, configured to register the pre-processed image and the template image so as to align the pre-processed image with the same position of the template image;
[0065] The missing printing detection module is used to perform ink missing printing detection on the inner circle of the printed area of the contact lens based on the registered pre-processed image and the template image to obtain a detection result.
[0066] The beneficial effects of the present invention are as follows: a method and device for detecting ink leakage in the inner circle of the printed area of a contact lens of the present invention obtains multiple original images and template images of the contact lens; pre-processes the multiple original images of the contact lens to obtain a pre-processed image, wherein the pre-processed image includes the positioning results of the edge of the contact lens mold and the edge of the printed area; aligns the pre-processed image and the template image so that the pre-processed image is aligned with the same position of the template image; based on the aligned pre-processed image and template image, the inner circle of the printed area of the contact lens is detected for ink leakage to obtain a detection result. This application realizes automatic identification of inner circle leakage detection by aligning and comparing the template and the product, and then performing ink leakage detection on the inner circle of the printed area. Compared with traditional methods, this method can improve identification accuracy, save costs, and increase production yield. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0068] Figure 1 is a characteristic schematic diagram of a contact lens image shown in an embodiment of the present application;
[0069] Figure 2 This is a flow chart of a method for detecting ink leakage in the inner circle of a printed area of a contact lens, shown in one embodiment of the present application;
[0070] Figure 3 This is a schematic diagram of the preprocessing process in one embodiment of the present application;
[0071] Figure 4 This is a schematic diagram of the image registration process in one embodiment of the present application;
[0072] Figure 5 Schematic diagram of the process of inner ring missing print detection in one embodiment of the present application;
[0073] Figure 6 Schematic diagram of the difference map extraction process in one embodiment of the present application;
[0074] Figure 7 Schematic diagram of the candidate missing printing area extraction process in one embodiment of the present application;
[0075] Figure 8 Schematic diagram of the process of determining candidate missing printing areas in one embodiment of the present application;
[0076] Figure 9 This is a schematic diagram of the result output process in the embodiments of this application;
[0077] Figure 10 This is a structural diagram of a device for detecting ink leakage in the inner circle of a printed area of a contact lens shown in one embodiment of the present application. DETAILED DESCRIPTION
[0078] The following describes the embodiments of the present invention through specific examples. 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. The 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 the following embodiments and features in the embodiments can be combined with each other unless they conflict.
[0079] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations 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 number, shape and size of the layers in actual implementation. In actual implementation, the type, quantity and proportion of each layer can be changed arbitrarily, and the layer layout type may also be more complicated.
[0080] In the following description, numerous details are set forth to provide a more thorough explanation of the embodiments of the present invention; however, it is apparent to one skilled in the art that the embodiments of the present invention may be practiced without these specific details.
[0081] Figure 1 is a characteristic schematic diagram of a contact lens image shown in an embodiment of the present application, such as Figure 1 As shown, the green area in the original image tested in this application is the printing area, that is, the ink leakage defect detection area, the white area between the outer edge of the optical area and the printing area and the edge of the mold is not printed with ink and is not tested, and the gray area is the base of the detection equipment.
[0082] Figure 2 FIG. 1 is a flow chart of a method for detecting ink leakage in the inner circle of a printed area of a contact lens, as shown in one embodiment of the present application. Figure 2 As shown in the figure: a method for detecting ink leakage in the inner circle of the printed area of a contact lens according to this embodiment may include the following steps:
[0083] S210, acquiring multiple original images and template images of the contact lens;
[0084] S220, preprocessing the multiple original images of the contact lens to obtain a preprocessed image, wherein the preprocessed image includes positioning results of the edge of the contact lens mold and the edge of the printing area;
[0085] S230, registering the pre-processed image and the template image so that the pre-processed image is aligned with the same position of the template image;
[0086] S240 , performing ink leakage detection on the inner circle of the printed area of the contact lens based on the registered pre-processed image and the template image to obtain a detection result.
[0087] The specific implementation process and principles are as follows:
[0088] A. Preprocessing
[0089] This step is responsible for loading the configuration files required by the algorithm and reading, aligning, fusing, and locating the contact lens images captured by the camera. Ultimately, the fused contact lens image and the positioning results of the mold edge and the printing area edge are obtained. First, multiple original images and template images of the contact lens are acquired. These multiple original images are then preprocessed to obtain preprocessed images, which include the positioning results of the contact lens mold edge and the printing area edge.
[0090] Figure 3 This is a schematic diagram of the preprocessing process in one embodiment of the present application, as shown in FIG. Figure 3 As shown, the preprocessing process includes:
[0091] A11. Loading images, including reading multiple original images (5 original images in this embodiment), converting the images from Bayer format to BGR format; loading a configuration file, including mold size information, printing area information, algorithm configuration parameters, etc.
[0092] A12. Binarize the multiple original images to obtain initial binary images; perform median filtering on the multiple initial binary images to obtain binary images with mold edges; extract contours from the binary images and filter the contours in the binary images based on a preset first area condition to obtain mold contours that meet the preset area condition; extract the centroid of the mold contour to obtain the mold center, and overlap the multiple original images based on the mold center;
[0093] For the five images read, binarization and median filtering operations are performed respectively to obtain a binary image containing the mold boundary. The contour of the binary image is extracted and the contour is filtered according to the area to obtain the mold contour. The centroid is fitted according to the mold contour as the mold center. Finally, the centers of the five images are translated to the same position to achieve image alignment.
[0094] A13. Calculate the average image of the overlapping original images;
[0095] For the five aligned images, we directly take the average operation to obtain a fused image with better contrast and richer colors.
[0096] A14. Binarize the average image to obtain an intermediate binary image; perform morphological operations on the intermediate binary image to obtain a target binary image including the outer boundary of the printing area and the inner boundary of the printing area; extract the contours in the target binary image, and filter the contours in the target binary image based on a preset second area condition to obtain the outer boundary contour of the printing area and the inner boundary contour of the printing area; fit the outer boundary contour of the printing area and the inner boundary contour of the printing area to obtain the outer circle center of the printing area, the outer circle radius of the printing area, the inner circle center of the printing area and the inner circle radius of the printing area.
[0097] For the fused image, binarization and morphological operations are performed to obtain a binary image containing the outer boundary of the printing area and the inner boundary of the printing area. The contour of the binary image is extracted and filtered according to the area to obtain the outer boundary contour of the printing area and the inner boundary contour of the printing area. The center and radius of the inner and outer boundary contours are fitted respectively to obtain the center and radius of the outer circle of the printing area and the center and radius of the inner circle of the printing area.
[0098] B. Image Registration
[0099] Figure 4 FIG. 1 is a schematic diagram of an image registration process in an embodiment of the present application. Figure 4 As shown in Figure 2, the image registration process includes:
[0100] B11. Extracting the target area image from the pre-processed image and the template image based on the pre-constructed outer circular mask of the printing area, wherein the target area image only includes the optical area and the printing area;
[0101] First, the input of this process is the product image and the template image, which are filtered using the pre-built outer circle mask of the printing area to obtain the target area image containing only the printing area and the optical area;
[0102] B12. Extracting the outer circle center of the printing area from the positioning result of the printing area edge, and performing polar coordinate expansion on the target area image of the preprocessed image based on the outer circle center of the printing area in the positioning result to obtain a first polar coordinate image; and performing polar coordinate expansion on the target area image in the template image based on the outer circle center of the printing area in the template image to obtain a second polar coordinate image;
[0103] In step B12, the masked product image and the template image are polar-coordinate expanded, the template image is resampled according to the registration angle, and the template image after polar-coordinate expansion is tangentially copied for template matching in the polar coordinate system.
[0104] Since the printed area of cosmetic contact lenses is circular, the polar coordinate expanded image can be viewed as a strip-shaped image, with the abscissa being the radius and the ordinate being the angle. Therefore, copying the image tangentially is equivalent to copying it along the ordinate.
[0105] B13. Slide the second polar coordinate image along the angular axis of the first polar coordinate image in a sliding window manner, and calculate the cross-correlation between the first polar coordinate image and the second polar coordinate image during each slide, and use the position with the maximum cross-correlation as the first registration result;
[0106] The processed template image is matched with the product image. Template matching uses a cross-correlation calculation method to calculate the similarity between the template and the product. Specifically, the template is slid across the image using a sliding window, and the cross-correlation is calculated position by position. In this embodiment, the calculation method is:
[0107]
[0108] Where R(x,y) is the cross-correlation between the first polar image and the second polar image at the point (x,y), T'(x',y') is the pixel value of the second polar image at the position (x',y'), and I'(x+x',y+y') is the pixel value of the first polar image at the position (x+x',y+y').
[0109] The template is slid across the image using a sliding window, which is equivalent to aligning the center of the printed area of the original image with the template image. The template rotates, and the correlation is calculated for each rotation. The angle with the highest correlation is the registration position. This process is called coarse registration.
[0110] B14. Based on the first registration result, the first polar coordinate image and the second polar coordinate image are converted back to a two-dimensional coordinate system to obtain a roughly registered target area image of the preprocessed image and a target area image in the template image;
[0111] The product is registered according to the template matching results, the product image is translated to the template matching position in the polar coordinate system, and then transformed back to the image coordinate system according to the polar coordinates to obtain the overall registered product image.
[0112] During the printing process, the product will rotate to a certain extent, so it is necessary to perform a fine registration on the inner circle area to improve the registration accuracy. The second registration process is as follows:
[0113] B15. Extract an inner circle region from the target region image in the coarsely registered preprocessed image and the target region image in the template image, wherein the inner circle region is a circular region centered at the inner circle center and having a radius equal to the inner circle radius plus the target width;
[0114] Specifically, the inner circle area of the printing area is generated according to the inner circle of the printing area of the template image, with the center of the inner circle as the center and the radius of the inner circle plus a certain width as the radius. The added width of the product image is greater than the width of the template image. Two circular areas are generated respectively, and they are masked respectively to obtain the inner circle area of the template and the inner circle area of the product.
[0115] B16. Downsample the inner circle area to obtain a downsampled image of the template image and a downsampled image of the preprocessed image. To balance program execution speed and registration accuracy, it is necessary to downsample the product and template images to obtain downsampled images.
[0116] B17. Based on the inner circle of the template image, and in combination with the pre-constructed rotation range and rotation step, the downsampled image of the template image is rotated multiple times, and during each rotation, the cross-correlation between the downsampled image of the template image and the downsampled image of the preprocessed image is calculated, and the angle with the largest cross-correlation is used as the alignment angle of the template image and the preprocessed image to obtain a second alignment result.
[0117] During the printing process, the product will rotate to a certain extent, and the rotation range is within the range of plus or minus 5 degrees. Within this range, an angle step is set, and a series of angle values are obtained according to the angle range.
[0118] In the second registration process, each angle value is traversed, and the template image is rotated according to the angle value to obtain the rotated template image. Then, the template matching method introduced in B13 is used to template match the rotated template image and the product image to obtain the maximum cross-correlation at the angle. Then, from the maximum cross-correlation of each angle obtained after traversal, the angle corresponding to the maximum cross-correlation among these angles and the registration position at the angle are selected. In this way, high-precision registration under constrained angles is achieved.
[0119] In this embodiment, the cross-correlation is calculated as follows:
[0120]
[0121] Wherein, R(x,y) is the cross-correlation between the downsampled image of the template image and the downsampled image of the preprocessed image at the point (x,y), T'(x',y') is the pixel value of the downsampled image of the template image at the position (x',y'), and I'(x+x',y+y') is the pixel value of the downsampled image of the preprocessed image at the position (x+x',y+y').
[0122] C. Inner ring missing print detection
[0123] Figure 5FIG. 1 is a flow chart of inner circle missing print detection in an embodiment of the present application, as shown in FIG. Figure 5 As shown in the figure, the process of inner circle missing print detection includes:
[0124] C1. Extract the difference map between the pre-processed image and the template image after the registration. This part directly compares the product and the difference map to obtain an image with differences between the template and the product.
[0125] Figure 6 This is a schematic diagram of the difference map extraction process in an embodiment of the present application, as shown in FIG. Figure 6 As shown in Figure 2, the process of extracting the difference map includes:
[0126] C11. Extracting the first inner circle image of the pre-processed image after registration and the second inner circle image of the template image after registration;
[0127] C12. Perform Gaussian filtering on the first inner circle image and the second inner circle image to obtain a first intermediate image and a second intermediate image. The purpose of Gaussian filtering is to perform smoothing and denoising.
[0128] C13. Calculate the difference between the first intermediate image and the second intermediate image to obtain a difference map.
[0129] C2. Extracting the candidate missing printing area in the difference map, which is obtained by filtering the difference area due to the registration error in the difference map;
[0130] Figure 7 FIG. 1 is a flow chart of extracting candidate missing printing areas in an embodiment of the present application. Figure 7 As shown in FIG, the extraction process of candidate missing printing areas includes:
[0131] C21. Input is the difference image between the product and the template obtained in the previous step;
[0132] C22. Binarize the difference map to obtain a binary difference map, and extract difference contours from the binary difference map; these difference contours represent where the product differs from the template;
[0133] C23. Filter out the difference contours whose area is smaller than a preset area threshold to obtain candidate contours;
[0134] The purpose of filtering the contours is to filter out the contours with smaller surfaces. These contours may be generated by noise and need to be filtered out.
[0135] C24. Draw the candidate contour into a binary image to obtain a difference mask;
[0136] C25. Performing an expansion operation on the difference mask to connect the isolated areas to obtain a difference area; and inverting the difference area to obtain a high-difference binary image;
[0137] The purpose of dilating the difference mask is to connect the isolated areas of the mask, and then perform the inversion operation to obtain a high-difference binary image between the product and the template.
[0138] C26. Filtering the difference map based on the high-difference binary map to obtain a filtered difference map;
[0139] The high-difference binary image obtained by C25 is used to perform mask filtering on the difference image to obtain a filtered difference image. Compared with the difference image without filtering, the filtered difference image can eliminate a large amount of interference and avoid the occurrence of false detection.
[0140] C27. Binarize and extract the contours of the filtered difference image to obtain a candidate missing printing area.
[0141] C3. Screen the candidate omission areas to obtain omission areas. This part first uses a morphological method to obtain possible omission areas, then filters them using the optical zone contour and the candidate omission contours. Finally, each candidate omission area is determined to determine whether omission has occurred through size and area judgment.
[0142] Figure 8 FIG. 1 is a flow chart of determining a candidate missing printing area in an embodiment of the present application. Figure 8 As shown in FIG, the process of identifying candidate missing printing areas includes:
[0143] C31. Input the candidate missing outline, the inner circle product image, and the inner circle template image, where the inner circle product image is the first inner circle image of the extracted pre-processed image after registration, and the inner circle template image is the second inner circle image of the template image after registration;
[0144] C32. Binarize each color channel of the first inner circle image and each color channel of the second inner circle image to obtain multiple single-channel binary images of the first inner circle image and multiple single-channel binary images of the second inner circle image; perform an AND operation on the multiple single-channel binary images of the first inner circle image to obtain a product binary image; and perform an AND operation on the multiple single-channel binary images of the second inner circle image to obtain a template binary image.
[0145] Specifically, the BGR channels of the inner circle product image and the inner circle template image are binarized respectively, and the images after the BGR channel binarization are performed with an AND operation to obtain the binarized images of the product and the template.
[0146] C33 performs an expansion operation on the product binary image and the template binary image to obtain a product expansion image and a template expansion image;
[0147] The binary images of the product and template are expanded. The expansion size is the ink dot distance. The adjacent ink dots are connected by taking advantage of the continuity of the ink dots. The expansion operation cannot expand to the area where printing is missed, while the area where printing is not missed will be filled by the expansion operation.
[0148] C34. Subtract the product expansion map from the template expansion map to obtain a suspected missing print area;
[0149] C35. Extract the binary image of the optical zone in the template image, and perform an XOR operation on the binary image of the optical zone and the suspected missing printing area to obtain an image with eliminated motion differences. This can eliminate the motion differences caused by the registration error in the subtraction image.
[0150] C36. Traverse each candidate omission region and perform binarization to obtain a candidate omission binary image;
[0151] C37. Subtract the candidate missing binary image from the offset difference elimination image to obtain a binary image of the region of interest;
[0152] C38. Generate a minimum circumscribed rectangle of each binary image of the region of interest, and screen candidate missed printing areas based on the area of the binary image of the region of interest and the size of the minimum circumscribed rectangle to obtain ink missed printing areas.
[0153] Specifically, an area range may be set for screening, or an area threshold may be set, and candidate missed printing areas with an area greater than the area threshold are regarded as ink missed printing areas.
[0154] D. Result output
[0155] Figure 9 This is a schematic diagram of the result output process in the embodiment of this application, such as Figure 9 As shown in the figure, the mask image containing the defect target frame in C is subjected to minimum bounding rectangle extraction, coordinate transformation and other operations, and finally the final detection result is displayed on the image, including:
[0156] D1. When the detection result includes an ink omission area, generating a minimum circumscribed rectangle of the ink omission area;
[0157] D2. transforming the coordinates of the minimum circumscribed rectangle of the ink leakage area to the coordinates in the original image;
[0158] D3. Draw a prompt box based on the coordinates in the original image and output the prompt box.
[0159] The present invention provides a method for detecting ink leakage in the inner circle of the printed area of a contact lens, which comprises obtaining a plurality of original images and a template image of the contact lens; preprocessing the plurality of original images of the contact lens to obtain a preprocessed image, wherein the preprocessed image includes the positioning results of the edge of the contact lens mold and the edge of the printed area; registering the preprocessed image and the template image so that the preprocessed image is aligned with the same position of the template image; and performing ink leakage detection on the inner circle of the printed area of the contact lens based on the registered preprocessed image and template image to obtain a detection result. This application realizes automatic identification of inner circle leakage detection by aligning and comparing the template and the product, and then performing ink leakage detection on the inner circle of the printed area. Compared with traditional methods, this method can improve identification accuracy, save costs, and increase production yield.
[0160] like Figure 10 As shown, the present application also provides a device for detecting ink leakage in the inner circle of the printed area of a contact lens, comprising:
[0161] an acquisition module, used for acquiring a plurality of original images and template images of the contact lens;
[0162] A preprocessed image is used to preprocess the multiple original images of the contact lens to obtain a preprocessed image, wherein the preprocessed image includes the positioning results of the edge of the contact lens mold and the edge of the printing area;
[0163] a registration module, configured to register the pre-processed image and the template image so as to align the pre-processed image with the same position of the template image;
[0164] An inner circle missing print detection module is used to perform ink missing print detection on the inner circle of the printed area of the contact lens based on the registered pre-processed image and the template image to obtain a detection result;
[0165] The result output module is used to output the result based on the detection result.
[0166] The present invention provides a device for detecting ink leakage in the inner circle of the printed area of a contact lens. The device obtains a plurality of original images and a template image of the contact lens; pre-processes the plurality of original images of the contact lens to obtain a pre-processed image, wherein the pre-processed image includes the positioning results of the edge of the contact lens mold and the edge of the printed area; aligns the pre-processed image and the template image so that the pre-processed image is aligned with the same position of the template image; and performs ink leakage detection on the inner circle of the printed area of the contact lens based on the aligned pre-processed image and template image to obtain a detection result. The present application realizes automatic identification of inner circle leakage detection by aligning and comparing the template and the product, and then performing ink leakage detection on the inner circle of the printed area. Compared with traditional methods, this method can improve identification accuracy, save costs, and increase production yield.
[0167] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, any one of the methods in this embodiment is implemented, wherein the method is the execution logic of this system.
[0168] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0169] 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 executes any one of the methods in this embodiment.
[0170] Regarding the computer-readable storage medium in this embodiment, those skilled in the art will appreciate that all or part of the steps in the aforementioned method embodiments can be implemented using hardware associated with the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps in the aforementioned method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0171] 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 with each other. The memory is used to store computer programs, the communication interface is used for communication, and the processor and the transceiver are used to run computer programs so that the electronic terminal executes the various steps of the above method.
[0172] In this embodiment, the memory may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.
[0173] 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.
[0174] In the above embodiments, although the present invention has been described in conjunction with specific embodiments of the present invention, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art based on the foregoing description. The embodiments of the present invention are intended to cover all such replacements, modifications and variations that fall within the broad scope of the appended claims.
[0175] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may 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 one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.
Claims
1. A method for detecting ink leakage in the inner circle of the printed area of a contact lens, characterized in that: Including steps: acquiring a plurality of original images and a template image of the contact lens; Preprocessing the multiple original images of the contact lens to obtain preprocessed images, wherein the preprocessed images include positioning results of the edge of the contact lens mold and the edge of the printing area; The preprocessed image and the template image are registered so that the preprocessed image is aligned with the same position of the template image; the preprocessed image and the template image are registered, including: extracting the target area images in the preprocessed image and the template image based on a pre-constructed printing area outer circle mask, wherein the target area image only includes the optical area and the printing area; extracting the printing area outer circle center in the positioning result of the printing area edge, and performing polar coordinate expansion on the target area image of the preprocessed image based on the printing area outer circle center in the positioning result to obtain a first polar coordinate image; and performing polar coordinate expansion on the target area image in the template image based on the printing area outer circle center in the template image to obtain a second polar coordinate image; sliding the second polar coordinate image along the angular axis of the first polar coordinate image based on a sliding window method, and calculating the cross-correlation between the first polar coordinate image and the second polar coordinate image at each sliding, and maximizing the cross-correlation as the first registration result; based on the first registration result, the first polar coordinate image and the second polar coordinate image are converted back to the two-dimensional coordinate system to obtain the target area image of the roughly registered preprocessed image and the target area image in the template image; in the target area image of the roughly registered preprocessed image and the target area image in the template image, an inner circle area is extracted, wherein the inner circle area is a circular area with the inner circle center as the center and the inner circle radius plus the target width as the radius; the inner circle area is downsampled to obtain a downsampled image of the template image and a downsampled image of the preprocessed image; based on the inner circle of the template image, and in combination with the pre-constructed rotation range and rotation step, the downsampled image of the template image is rotated multiple times, and at each rotation, the cross-correlation between the downsampled image of the template image and the downsampled image of the preprocessed image is calculated, and the angle with the largest cross-correlation is used as the registration angle of the template image and the preprocessed image to obtain a second registration result; Based on the registered pre-processed image and the template image, ink leakage detection is performed on the inner circle of the printed area of the contact lens to obtain a detection result.
2. The method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 1, characterized in that: Preprocessing the multiple original images of the contact lens to obtain preprocessed images includes: Binarizing the multiple original images to obtain initial binary images; Performing median filtering on multiple initial binary images to obtain binary images with mold edges; Extracting contours from the binary image, and screening the contours in the binary image based on a preset first area condition to obtain a mold contour that meets the preset area condition; Extracting the centroid of the mold contour to obtain the mold center, and overlapping the multiple original images based on the mold center; Calculate the average image of multiple overlapping original images; performing binarization processing on the average image to obtain an intermediate binary image; Performing morphological operations on the intermediate binary image to obtain a target binary image including an outer boundary of the printing area and an inner boundary of the printing area; Extracting the contours in the target binary image, and screening the contours in the target binary image based on a preset second area condition to obtain an outer boundary contour of the printing area and an inner boundary contour of the printing area; The outer boundary contour of the printing area and the inner boundary contour of the printing area are fitted to obtain the outer circle center of the printing area, the outer circle radius of the printing area, the inner circle center of the printing area and the inner circle radius of the printing area.
3. The method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 1, characterized in that: The cross-correlation calculation formula is: Where, The first polar coordinate image and the second polar coordinate image, or the downsampled image of the template image and the downsampled image of the preprocessed image are The cross-correlation at the point, is the second polar coordinate image or the downsampled image of the template image The pixel value of the position, is the first polar coordinate image or the downsampled image of the preprocessed image The pixel value at the location.
4. The method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 1, characterized in that: Based on the registered pre-processed image and template image, ink leakage detection is performed on the inner circle of the printed area of the contact lens, including: Extracting a difference map between the registered preprocessed image and the template image; Extracting candidate missing printing areas in the difference map; The candidate missing printing areas are screened to obtain missing printing areas.
5. The method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 4, characterized in that: Extracting a difference map between the registered pre-processed image and the template image, including: Extracting a first inner circle image of the registered preprocessed image and a second inner circle image of the registered template image; Performing Gaussian filtering on the first inner circle image and the second inner circle image to obtain a first intermediate image and a second intermediate image; The first intermediate image and the second intermediate image are subtracted to obtain a difference map.
6. The method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 4, characterized in that: Extracting a candidate missing printing area from the difference map includes: Binarizing the difference map to obtain a difference binary map, and extracting a difference contour from the difference binary map; Filter out the difference contours whose area is smaller than the preset area threshold to obtain candidate contours; Drawing the candidate contour into a binary image to obtain a difference mask; Performing a dilation operation on the difference mask to connect isolated areas to obtain a difference area; and inverting the difference area to obtain a high-difference binary image; filtering the difference map based on the high-discrepancy binary map to obtain a filtered difference map; Binarization and contour extraction are performed on the filtered difference image to obtain a candidate missing printing area.
7. The method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 4, characterized in that: The candidate missing printing areas are screened to obtain missing printing areas, including: Extracting a first inner circle image of the registered preprocessed image and a second inner circle image of the registered template image; Binarizing each color channel of the first inner circle image and each color channel of the second inner circle image to obtain a plurality of single-channel binary images of the first inner circle image and a plurality of single-channel binary images of the second inner circle image; Performing an AND operation on multiple single-channel binary images of the first inner circle image to obtain a product binary image; and performing an AND operation on multiple single-channel binary images of the second inner circle image to obtain a template binary image; Performing an expansion operation on the product binary image and the template binary image to obtain a product expansion image and a template expansion image; Subtracting the product expansion map from the template expansion map to obtain a suspected missing print area; Extracting a binary image of the optical zone in the template image, and performing an XOR operation on the binary image of the optical zone and the suspected missing printing area to obtain an image with eliminated motion differences; Traverse each candidate missing printing area and perform binarization to obtain a candidate missing printing binary map; Subtracting the candidate missing print binary image from the offset difference elimination image to obtain a binary image of the region of interest; The minimum circumscribed rectangle of each region-of-interest binary image is generated, and candidate missing printing areas are screened based on the area of the region-of-interest binary image and the size of the minimum circumscribed rectangle to obtain ink missing printing areas.
8. The method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 1, characterized in that: Also includes: When the detection result includes an ink missing area, generating a minimum circumscribed rectangle of the ink missing area; transforming the coordinates of the minimum circumscribed rectangle of the ink missing area into coordinates in the original image; A prompt box is drawn based on the coordinates in the original image, and the prompt box is output.
9. A device for detecting ink leakage in the inner circle of the printed area of a contact lens, characterized in that: include: an acquisition module, used for acquiring a plurality of original images and template images of the contact lens; A preprocessed image is used to preprocess the multiple original images of the contact lens to obtain a preprocessed image, wherein the preprocessed image includes the positioning results of the edge of the contact lens mold and the edge of the printing area; A registration module is used to register the preprocessed image and the template image so that the preprocessed image is aligned with the same position of the template image; the registration of the preprocessed image and the template image includes: extracting the target area image in the preprocessed image and the template image based on a pre-constructed printing area outer circle mask, wherein the target area image only includes the optical area and the printing area; extracting the printing area outer circle center in the positioning result of the printing area edge, and performing polar coordinate expansion on the target area image of the preprocessed image based on the printing area outer circle center in the positioning result to obtain a first polar coordinate image; and performing polar coordinate expansion on the target area image in the template image based on the printing area outer circle center in the template image to obtain a second polar coordinate image; sliding the second polar coordinate image along the angular axis of the first polar coordinate image based on a sliding window method, and calculating the cross-correlation between the first polar coordinate image and the second polar coordinate image during each sliding, and converting the cross-correlation into the second polar coordinate image. The position with the largest polar coordinate is taken as the first registration result; based on the first registration result, the first polar coordinate image and the second polar coordinate image are converted back to the two-dimensional coordinate system to obtain the target area image of the roughly registered preprocessed image and the target area image in the template image; in the target area image of the roughly registered preprocessed image and the target area image in the template image, an inner circle area is extracted, wherein the inner circle area is a circular area with the center of the inner circle as the center and the distance of the inner circle radius plus the target width as the radius; the inner circle area is downsampled to obtain a downsampled image of the template image and a downsampled image of the preprocessed image; based on the inner circle of the template image, and in combination with the pre-constructed rotation range and rotation step, the downsampled image of the template image is rotated multiple times, and in each rotation, the cross-correlation between the downsampled image of the template image and the downsampled image of the preprocessed image is calculated, and the angle with the largest cross-correlation is used as the registration angle of the template image and the preprocessed image to obtain a second registration result; The missing printing detection module is used to perform ink missing printing detection on the inner circle of the printed area of the contact lens based on the registered pre-processed image and the template image to obtain a detection result.
Citation Information
Patent Citations
Image processing method, terminal and computer readable storage medium
CN112396638A
Contact lens casting mold printing quality detection method and device
CN114742752A