Contact lens printing area inner ring ink skip printing detection method and device
By preprocessing and registering the original image and template image of the contact lens, the ink leakage area in the inner circle of the printing area is automatically identified, which solves the problems of manual dependence and misdetection in traditional detection methods and achieves high-precision leakage printing. detection.
Patent Information
- Application Number
- CN202411403517.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-10-09
AI Technical Summary
The detection of ink leakage printing in the inner circle of traditional contact lens printing area relies on manual labor, which has problems such as fatigue, misjudgment and inefficiency. Computer image processing methods are prone to mischecking of products with large deviations.
By obtaining multiple original images and template images of contact lenses, preprocessing and registration are performed, and the ink leakage area in the inner circle of the printing area is extracted to achieve automatic identification.
It improves the identification accuracy of leakage detection, saves detection costs, and improves the production yield rate.
Smart Images

Figure CN119355001A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of machine vision, in particular to a method and a device for detecting ink leakage in the inner circle of a printed area of a contact lens. Background Art
[0002] The main method of printing patterns on contact lenses is pad printing. Since the printing ink is easily affected by the ink concentration, ambient temperature and humidity, etc., 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 which the frequency of 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 leads to eye fatigue, prone to misjudgment, and relatively low inspection efficiency; the ink omission inspection method based on computer image processing requires the establishment of a template for qualified products first, and then detects omission defects by comparing with the template. However, this method is prone to misdetection 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 of the present invention comprises the following steps:
[0007] Acquire multiple original images and template images of the contact lens;
[0008] Preprocessing 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;
[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, the ink leakage detection is performed on the inner circle of the printed area of the contact lens to obtain the detection result.
[0011] In one embodiment of the present application, a plurality of original images of the contact lens are preprocessed to obtain preprocessed images, including:
[0012] Binarizing the multiple original images to obtain initial binary images;
[0013] Performing median filtering on a plurality of initial binary images to obtain a binary image with a mold edge;
[0014] Extracting contours in the binary image, and screening the contours in the binary image based on a preset first area condition to obtain a casting 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] Binarizing 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 the target area image in the preprocessed image and the template image based on the pre-constructed outer circle mask of the printing area, wherein the target area image only includes the optical area and the printing area;
[0023] Extracting the outer circle center of the printing area in the positioning result of the edge of the printing area, 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 angle 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, and taking the position with the maximum cross-correlation as the first registration result;
[0025] Based on the first registration result, the first polar coordinate image and the second polar coordinate image are converted back into 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;
[0026] Extracting an inner circle area from the target area image of the roughly registered preprocessed image and the target area image in the template image, 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;
[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 largest 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 a candidate missing printing area 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 preprocessed 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 the candidate missing printing area in 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 a 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-difference 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 printing area;
[0053] Extracting a binary image of an 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-eliminated 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 the 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 the ink missing printing area.
[0057] In one embodiment of the present application, it also 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 leakage area to the 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 contact lens printing area inner circle ink leakage detection device, comprising:
[0062] An acquisition module, used for acquiring a plurality of original images and template images of the contact lens;
[0063] Preprocessing images, used to preprocess the multiple original images of the contact lens to obtain preprocessing images, wherein the preprocessing images include positioning results of the edges of the contact lens casting mold and the edges of the printing area;
[0064] A registration module, used for registering the preprocessed image and the template image so that the preprocessed image is aligned 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 printing area of the contact lens based on the registered pre-processed image and the template image to obtain the 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 registered 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. 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. 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 It 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 It is a schematic diagram of the process of inner circle missing printing detection in one embodiment of the present application;
[0073] Figure 6 This is a 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 determination process of candidate missing printing areas in one embodiment of the present application;
[0076] Fig. 9 This is a schematic diagram of the result output process in the embodiments of this application;
[0077] Fig.10 It is a structural diagram of a contact lens printing area inner circle ink leakage detection device shown in one embodiment of the present application. DETAILED DESCRIPTION
[0078] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways 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 without 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, and thus the drawings only show the layers related to the present invention rather than being 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 may be changed arbitrarily, and the layer layout may also be more complicated.
[0080] In the following description, numerous details are discussed to provide a more thorough explanation of embodiments of the present invention; however, it is apparent to one skilled in the art that 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 shown in an 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 of this embodiment may include the steps of:
[0083] S210, acquiring a plurality of 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 preprocessed image and the template image so that the preprocessed 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 introduced as follows:
[0088] A. Pretreatment
[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, and finally obtaining the fused contact lens images and the positioning results of the mold edge and the printing area edge. First, multiple original images and template images of the contact lens are obtained; then, the multiple original images of the contact lens are preprocessed to obtain preprocessed images, wherein the preprocessed images include the positioning results of the contact lens mold edge and the printing area edge;
[0090] Figure 3 Schematic diagram of the preprocessing process in one embodiment of the present application. 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 configuration files, including mold size information, printing area information, algorithm configuration parameters, etc.
[0092] A12. Binarizing the multiple original images to obtain initial binary images; performing median filtering on the multiple initial binary images to obtain binary images with mold edges; extracting contours in the binary images, and screening the contours in the binary images 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;
[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 screened 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 multiple 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 an outer boundary of the printing area and an inner boundary of the printing area; extract the contour in the target binary image, and filter the contour 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; fit the outer boundary contour of the printing area and the inner boundary contour of the printing area to obtain the center of the outer circle of the printing area, the radius of the outer circle of the printing area, the center of the inner circle of the printing area and the radius of the inner circle of the printing area.
[0097] The fused image is binarized and morphologically operated to obtain a binary image containing the outer boundary and the inner boundary of the printing area. The contour of the binary image is extracted and screened according to the area to obtain the outer boundary contour 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 in the preprocessed image and the template image based on the pre-constructed outer circle mask of the printing area, wherein the target area image only includes the optical area and the printing area;
[0101] First, the input in this process is the product image and the template image, which are filtered by the pre-constructed 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 in the positioning result of the edge of the printing area, 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 expanded in polar coordinates, the template image is resampled according to the registration angle, and the template image after polar coordinate expansion is copied along the tangent direction for template matching in the polar coordinate system;
[0104] Among them, since the printing area of the cosmetic contact lens is a ring, the image after polar coordinate expansion can be regarded as a strip-shaped image, with the horizontal coordinate being the radius and the vertical coordinate being the angle. Therefore, copying the image along the tangent direction is to copy the image along the vertical coordinate.
[0105] B13. Slide the second polar coordinate image along the angle 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 sliding, and take the position with the maximum cross-correlation as the first registration result;
[0106] The processed template image is matched with the product image. The template matching adopts a cross-correlation calculation method to calculate the similarity between the template and the product. Specifically, the template is slid on the image in a sliding window manner, and the cross-correlation is calculated position by position. In this embodiment, the calculation method is:
[0107]
[0108] Wherein, R(x, y) is the cross-correlation between the first polar coordinate image and the second polar coordinate image at the point (x, y), T'(x', y') is the pixel value of the second polar coordinate image at the position (x', y'), and I'(x+x', y+y') is the pixel value of the first polar coordinate image at the position (x+x', y+y').
[0109] The template is slid on the image in a sliding window manner, which is equivalent to coinciding the center of the printed area of the original image with that of the template image, and rotating. The correlation is calculated every time it rotates, and the angle with the highest correlation is the registration position. This process is the coarse registration process.
[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 result of template matching, the product image is translated to the position where the template image matches in the polar coordinate system, and then the polar coordinates are inversely transformed back to the image coordinate system 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. 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;
[0114] Specifically, an 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, wherein the added width of the product image is greater than the width of the template image, and two circular areas are generated respectively, and masked respectively to obtain the template inner circle area and the product inner circle area.
[0115] B16. Downsample the inner circle area to obtain a downsampled image of the template image and a downsampled image of the preprocessed image; in order to balance the program execution speed and the registration accuracy, it is necessary to downsample the product and template images to obtain the 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 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 based on 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 perform template matching on the rotated template image and the product image to obtain the maximum cross-correlation at the angle. Then, the angle corresponding to the maximum cross-correlation among these angles and the registration position at the angle are selected from the maximum cross-correlation of each angle obtained after traversal, thereby achieving high-precision registration under constrained angles.
[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 circle 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, 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 alignment. 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 FIG. 1 is a schematic diagram of a difference map extraction process in an embodiment of the present application. Figure 6 As shown in FIG. 1 , the process of extracting the difference map includes:
[0126] C11. extracting the first inner circle image of the preprocessed image after registration and the second inner circle image of the template image after registration;
[0127] C12. 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, wherein the purpose of the Gaussian filtering is to perform smoothing and denoising processing;
[0128] C13. Subtract the first intermediate image from the second intermediate image to obtain a difference map.
[0129] C2. Extracting the candidate missing printing area in the difference map, which obtains the candidate missing printing area by filtering the difference area caused by the registration error in the difference map;
[0130] Figure 7 FIG. 1 is a schematic diagram of a candidate missing printing area extraction process in an embodiment of the present application. Figure 7 As shown in FIG. 1 , the process of extracting the candidate missing printing area includes:
[0131] C21. Input is the difference map between the product and the template obtained in the previous step;
[0132] C22. Binarize the difference map to obtain a difference binary map, and extract difference contours from the difference binary map; these difference contours represent where the product and the template have certain differences;
[0133] C23. filtering out the difference contours whose areas are smaller than a preset area threshold to obtain candidate contours;
[0134] The purpose of filtering contours is to filter out 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 regions to obtain a difference region; and negating the difference region 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 a negation operation to obtain a high-difference binary image of 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 lot of interference and avoid the occurrence of false detection.
[0140] C27. Binarize and extract contours of the filtered difference image to obtain a candidate missed printing area.
[0141] C3. Screen the candidate missed printing areas to obtain missed printing areas. This part first obtains possible missed printing areas through morphological methods, and then filters them through optical zone contours and candidate missed printing contours. Finally, each candidate missed printing area is judged by size and area to determine whether missed printing occurs.
[0142] Figure 8 FIG. 1 is a schematic diagram of a flow chart of determining a candidate missing printing area in an embodiment of the present application. Figure 8 As shown, the identification process of the candidate missed printing area includes:
[0143] C31. Input the candidate missing print contour, the inner circle product image and the inner circle template image, wherein the inner circle product image is the first inner circle image of the extracted registered preprocessed image, and the inner circle template image is the second inner circle image of the registered template image;
[0144] C32. Binarize 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; perform an AND operation on the plurality of single-channel binary images of the first inner circle image to obtain a product binary image; and perform an AND operation on the plurality of 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. Perform 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, and the expansion size is the ink dot distance. The adjacent ink dots are connected by utilizing the continuity of the ink dots. For the missed printing area, the expansion operation cannot expand to this area, while the area without missed printing will be filled by the expansion operation.
[0148] C34. Subtracting the product expansion map from the template expansion map to obtain a suspected missed printing 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 missed 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 missing printing area and perform binarization to obtain a candidate missing printing binary map;
[0151] C37. Subtracting the candidate missed printing 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 region of interest binary image, and screen candidate missed printing areas based on the area of the region of interest binary image 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 larger than the area threshold are regarded as ink missed printing areas.
[0154] D. Result output
[0155] Fig. 9 The result output process diagram of the embodiment of this application is as follows: Fig. 9 As shown, the mask image containing the defect target frame in C is subjected to minimum bounding rectangle frame 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 leakage area, generating a minimum circumscribed rectangle of the ink leakage 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 acquiring multiple original images and template images of the contact lens; preprocessing 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 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. The present application realizes automatic identification of inner circle leakage detection by registering 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 Fig.10 As shown, the present application also provides a contact lens printing area inner circle ink leakage detection device, comprising:
[0161] An acquisition module, used for acquiring a plurality of original images and template images of the contact lens;
[0162] Preprocessing images, used to preprocess the multiple original images of the contact lens to obtain preprocessing images, wherein the preprocessing images include positioning results of the edges of the contact lens casting mold and the edges of the printing area;
[0163] A registration module, used for registering the preprocessed image and the template image so that the preprocessed image is aligned 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, which 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 registered 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 a computer program, and the processor is used to execute the computer program stored in the memory, so that the terminal executes any one of the methods in this embodiment.
[0170] The computer-readable storage medium in this embodiment can be understood by ordinary technicians in this field: all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[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 to communicate, and the processor and the transceiver are used to run computer programs so that the electronic terminal executes each step 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 memory.
[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, discrete hardware components.
[0174] In the above-mentioned embodiments, although the present invention has been described in conjunction with the specific embodiments of the present invention, many replacements, modifications and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. The embodiments of the present invention are intended to cover all such replacements, modifications and variations falling 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 familiar with 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 a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still 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: Includes steps: Acquire multiple original images and template images of the contact lens; Preprocessing 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; Registering the preprocessed image and the template image so that the preprocessed image is aligned with the same position of the template image; Based on the registered pre-processed image and the template image, the ink leakage detection is performed on the inner circle of the printed area of the contact lens to obtain the detection result.
2. A 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 a plurality of 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 a plurality of initial binary images to obtain a binary image with a mold edge; Extracting contours in the binary image, and screening the contours in the binary image based on a preset first area condition to obtain a casting 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; Binarizing 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. A method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 1, characterized in that: Registering the preprocessed image and the template image includes: Extracting the target area image in the preprocessed image and the template image based on the pre-constructed outer circle mask of the printing area, wherein the target area image only includes the optical area and the printing area; Extracting the outer circle center of the printing area in the positioning result of the edge of the printing area, 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; Sliding the second polar coordinate image along the angle 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, and taking the position with the maximum 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 into 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; Extracting an inner circle area from the target area image of the roughly registered preprocessed image and the target area image in the template image, 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; Downsampling the inner circle area 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 alignment angle of the template image and the preprocessed image to obtain a second alignment result.
4. A method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 3, characterized in that: The cross-correlation calculation formula is: 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').
5. A 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, the 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 a candidate missing printing area in the difference map; The candidate missing printing areas are screened to obtain missing printing areas.
6. A method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 5, characterized in that: Extracting a difference map between the registered preprocessed image and the template image includes: 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.
7. A method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 5, characterized in that: Extracting a candidate missing printing area in 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 a 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-difference 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.
8. A method for detecting ink leakage in the inner circle of the printed area of a contact lens according to claim 5, 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 printing area; Extracting a binary image of an 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-eliminated 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 the 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 the ink missing printing area.
9. A 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 leakage area to the coordinates in the original image; A prompt box is drawn based on the coordinates in the original image, and the prompt box is output.
10. 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; Preprocessing images, used to preprocess the multiple original images of the contact lens to obtain preprocessing images, wherein the preprocessing images include positioning results of the edges of the contact lens casting mold and the edges of the printing area; A registration module, used for registering the preprocessed image and the template image so that the preprocessed image is aligned with the same position of the template image; The missing printing detection module is used to perform ink missing printing detection on the inner circle of the printing area of the contact lens based on the registered pre-processed image and the template image to obtain the 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
Method and system for detecting flaws of printed contact lenses based on cloud-machine vision
CN118505634A
Method and apparatus for positioning pupil, storage medium, electronic device
US20190347824A1