High-precision detection method and device for stains in near-optical region of contact lens casting mold
By pre-processing and area division of contact lens images, masks are constructed and combined with adaptive binarization and area screening, high-precision automatic detection of stains in the near-optical area of contact lens casting molds is achieved, solving the problems of low efficiency and accuracy of traditional manual detection.
Patent Information
- Application Number
- CN202510009309.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-04-15
AI Technical Summary
Traditional contact lens casting molds rely on manual stain detection, which has problems such as eye fatigue, wrong judgment and low detection efficiency.
A high-precision detection method for near-optical zone stains in contact lens casting mold is adopted. By acquiring multiple contact lens images, pre-processing and area division, optical zone and near-optical zone mask are constructed, and the image is stain detection based on adaptive binarization and area screening.
Automatic stain identification is realized, reducing manual inspection costs, saving time and improving production yield.
Smart Images

Figure CN119827516A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of machine vision, and in particular to a method and a device for high-precision detection of stains in a near optical zone of a contact lens casting mold. Background Art
[0002] The main method of printing patterns on contact lenses is pad printing. When printing ink, the mold is exposed to the air, and impurities such as dust are easily dropped near the optical area of the mold, resulting in defects.
[0003] The traditional optical area stain detection method relies on manual detection, which has the following shortcomings: long-term manual detection causes eye fatigue and is prone to misjudgment; small stains near the optical area are difficult to distinguish from ink; and the detection efficiency is relatively low. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a method and device for high-precision detection of stains in the near optical zone of a contact lens mold, 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 high-precision method for detecting stains in the near optical zone of a contact lens casting mold of the present invention comprises the steps of:
[0007] Acquire a plurality of contact lens images, and preprocess the plurality of contact lens images to obtain preprocessed images;
[0008] Dividing the preprocessed image into regions to obtain an optical zone and a near optical zone, wherein the optical zone is the region within the inner edge of the annular printed area of the contact lens, and the near optical zone is the annular region excluding the optical zone drawn with the inner edge of the printed area of the contact lens as the center and with a radius x times the inner edge of the printed area, where x is the multiple;
[0009] constructing an optical zone mask based on the optical zone, and extracting the optical zone image in the preprocessed image based on the optical zone mask; and performing stain detection on the optical zone image based on adaptive binarization and area screening;
[0010] A near optical zone mask is constructed based on the near optical zone, and a near optical zone image in the preprocessed image is extracted based on the near optical zone mask; and stain detection is performed on the near optical zone image.
[0011] In this embodiment, performing stain detection on the near optical zone image includes:
[0012] Adaptively binarizing the near optical zone image to obtain a near optical zone binarized image including a plurality of contours in the near optical zone image;
[0013] Traversing a plurality of contours in the near optical zone binary image to obtain centroid coordinates of the plurality of contours in the near optical zone binary image;
[0014] Extracting a plurality of color points to be identified in the preprocessed image based on the centroid coordinates of a plurality of contours in the near optical zone binary image, and extracting color information of each color point to be identified in, is the grayscale mean of the b channel of all pixels in the nth color point to be identified, is the mean grayscale value of the g channel of all pixels in the nth color point to be identified, is the mean grayscale value of the r channel of all pixels in the nth color point to be identified;
[0015] Abnormal color points are detected based on the centroid coordinates of the color point to be identified, the color information of the color point to be identified, the centroid coordinates of other color points to be identified in the near optical zone, and the color information of other color points to be identified in the near optical zone, and the abnormal color points are regarded as stains.
[0016] In this embodiment, abnormal color point detection is performed based on the centroid coordinates of the color point to be identified, the color information of the color point to be identified, the centroid coordinates of other color points to be identified in the near optical zone, and the color information of other color points to be identified in the near optical zone, and the abnormal color point is used as a stain, including:
[0017] Calculate the position Euclidean distance and color Euclidean distance of each color point to be identified and other color points to be identified, and get the spatial distance set {D1, D2, ..., D n} and the color distance set {C1, C2, ..., C n}, where D1 is the set of spatial distances between the first color point to be identified and other color points to be identified, D2 is the set of spatial distances between the second color point to be identified and other color points to be identified, and D n is the set of spatial distances between the nth color point to be identified and other color points to be identified; C1 represents the set of color space distances between the first color point to be identified and other color points to be identified, C2 represents the set of color space distances between the second color point to be identified and other color points to be identified, and C n represents a set of color space distances between the nth color point to be identified and other color points to be identified, where the other color points to be identified are color points in the printed area of the contact lens;
[0018] The spatial distance set {D1, D2, ..., D n} and the color distance set {C1, C2, ..., C n}Sort in ascending order;
[0019] Extract the spatial distance set {D1, D2, ..., D n Arrange the Nth minimum distance of each set in ascending order in} to obtain the minimum value set of spatial distance And extract the color distance set {C1, C2, ..., C n Arrange the Nth smallest distance of each set in ascending order to get the minimum color distance set
[0020] Calculate the minimum value set of the spatial distance The average And calculate the color distance set {C1, C2, ..., C n The average value of
[0021] Calculate the minimum value set of the spatial distance The minimum distance between each space and the average value Absolute value of the difference And calculate the minimum value set of color distance The minimum distance between each color and the average value The absolute value of the difference exist or, When , the nth color point to be identified is determined to be a stain.
[0022] In this embodiment, the plurality of contact lens images are preprocessed to obtain preprocessed images, including:
[0023] Convert the plurality of contact lens images from a Bayer format to a BGR format to obtain a plurality of RGB images;
[0024] The multiple RGB images are synthesized to obtain a preprocessed image.
[0025] In this embodiment, the pre-processed image is divided into regions to obtain an optical zone and a near optical zone, including:
[0026] Performing Gaussian filtering on the preprocessed image to obtain a filtered image;
[0027] Adaptively binarizing the R channel image, the G channel image, and the B channel image of the filtered image to obtain an R channel binarized image, a G channel binarized image, and a B channel binarized image;
[0028] Performing a logical OR operation on the R channel binary image, the G channel binary image, and the B channel binary image to obtain a detail image containing depth and shallowness detail information;
[0029] Performing a closing operation and an opening operation on the detail image to obtain an intermediate image;
[0030] extracting the inner circle contour of the printing area in the intermediate image;
[0031] The maximum inscribed circle of the inner circle contour is calculated, and the maximum inscribed circle is used as the inner edge of the annular printing area to obtain the optical zone; and a circular area with a radius x times the inner edge of the annular printing area as the center is drawn to obtain the near optical zone, wherein the near optical zone is an annular area within the circular area excluding the optical zone, x>1, and the contour of the near optical zone is on the inner side of the outer edge of the annular printing area.
[0032] In this embodiment, extracting the inner circle contour of the printing area in the intermediate image includes:
[0033] The contour that meets the target condition in the intermediate image is used as the initial inner circle contour, wherein the target condition includes:
[0034] (1) The contour area is between the preset minimum threshold and maximum threshold of the optical zone area;
[0035] (2) The ratio of the shortest side to the longest side of the contour is greater than or equal to a preset aspect ratio threshold;
[0036] (3) The ratio of the contour area to the area of the minimum circumscribed rectangle of the contour is greater than or equal to a preset ratio threshold;
[0037] When the number of the initial inner circle contours is 1, the initial inner circle contour is used as the inner circle contour; when the number of the initial inner circle contours is greater than 1, the initial inner circle contour with the smallest contour area is used as the inner circle contour.
[0038] In this embodiment, constructing an optical zone mask based on the optical zone includes:
[0039] Generate an all-zero-pixel mask image with the same size as the preprocessed image;
[0040] The optical zone contour is drawn in the all-zero pixel mask image, and pixels with target pixel values are filled inside the optical zone contour in the all-zero pixel mask image to obtain an optical zone mask.
[0041] In this embodiment, stain detection is performed on the optical zone image based on adaptive binarization and area screening, including:
[0042] Adaptively binarizing the optical zone image to obtain a binarized optical zone image including a stain outline in the optical zone;
[0043] Performing corrosion processing on the optical zone binary image to obtain an optical zone corrosion image;
[0044] Traversing all contours in the optical zone corrosion image, and taking contours in the optical zone corrosion image whose areas are smaller than a preset screening threshold as stain contours;
[0045] The stain outline in the optical zone is drawn in the pre-processed image.
[0046] In this embodiment, constructing a near optical zone mask based on the near optical zone includes:
[0047] Generate an all-zero-pixel mask image with the same size as the preprocessed image;
[0048] The near optical zone outline is drawn in the all-zero pixel mask image, and pixels with target pixel values are filled inside the near optical zone outline in the all-zero pixel mask image to obtain a near optical zone mask.
[0049] The present application discloses a high-precision stain detection device for the near optical zone of a contact lens casting mold, comprising:
[0050] A preprocessing module, used for acquiring a plurality of contact lens images, and preprocessing the plurality of contact lens images to obtain preprocessed images;
[0051] A region division module is used to divide the pre-processed image into regions to obtain an optical zone and a near optical zone, wherein the optical zone is the region within the inner edge of the annular printed area of the contact lens, and the near optical zone is an annular region excluding the optical zone drawn with the inner edge of the printed area of the contact lens as the center and with a radius x times the inner edge of the printed area, where x is the multiple;
[0052] an optical zone detection module, configured to construct an optical zone mask based on the optical zone, extract an optical zone image in the preprocessed image based on the optical zone mask, and perform stain detection on the optical zone image based on adaptive binarization and area screening;
[0053] The near optical zone detection module is used to construct a near optical zone mask based on the near optical zone, extract a near optical zone image in the preprocessed image based on the near optical zone mask, and perform stain detection on the near optical zone image.
[0054] The beneficial effects of the present invention are as follows: a method and device for high-precision detection of stains in the near optical zone of a contact lens mold of the present invention obtains a preprocessed image by acquiring a plurality of contact lens images and preprocessing the plurality of contact lens images; divides the preprocessed image into regions to obtain an optical zone and a near optical zone; constructs an optical zone mask based on the optical zone, and extracts the optical zone image in the preprocessed image based on the optical zone mask; and performs stain detection on the optical zone image based on adaptive binarization and area screening; constructs a near optical zone mask based on the near optical zone, and extracts the near optical zone image in the preprocessed image based on the near optical zone mask; and performs stain detection on the near optical zone image. The present application automatically recognizes the image, and can determine whether the photographed product is qualified or not without manual detection, so as to reduce labor costs, save time, and improve production yield. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0056] Figure 1 is an ideal schematic diagram of a contact lens casting mold in one embodiment of the present application;
[0057] Figure 2 A schematic diagram of contact lens casting stains in one embodiment of the present application;
[0058] Figure 3 It is a flow chart of a method for high-precision detection of stains in the near optical zone of a contact lens mold shown in one embodiment of the present application;
[0059] Figure 4 A schematic diagram of the algorithm configuration and preprocessing process in an embodiment of the present application;
[0060] Figure 5 This is a schematic diagram of the area division process in one embodiment of the present application;
[0061] Figure 6 Schematic diagram of the process of optical area detection in one embodiment of the present application;
[0062] Figure 7 Schematic diagram of the process of near optical area detection in one embodiment of the present application;
[0063] Figure 8 It is a structural diagram of a high-precision detection device for stains in the near optical zone of a contact lens mold shown in one embodiment of the present application. DETAILED DESCRIPTION
[0064] 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.
[0065] 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.
[0066] 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.
[0067] Figure 1 is an ideal schematic diagram of a contact lens mold in an embodiment of the present application. The contact lens structure in the present application is as follows Figure 1 As shown in the figure, the black area is the background and the green area is the printing area. The dotted lines shown at the inner and outer edges of the printing area are actually formed by fitting the maximum inscribed circle and the minimum circumscribed circle according to the ink position. The white circle wrapped around the inner edge of the printing area is the optical area, i.e. the detection area.
[0068] However, in actual production, there may be stains near the inner edge of the printing area of the contact lens mold. When performing the maximum inscribed circle fitting, the stains may be regarded as ink, interfering with the fitting of the inner edge of the printing area and causing missed detection.
[0069] Figure 2 This is a schematic diagram of contact lens casting stains in one embodiment of the present application. Figure 2 In the example, since the inner edge of the printing area is fitted by the largest inscribed circle, the stain is located in the printing area and cannot be detected by the optical area stain detection, resulting in missed detection. In order to detect the stain in this case, the part of the printing area close to the optical area is regarded as the near optical area. The near optical area is Figure 2 The area between the edge of the near optical zone and the inner edge of the printing zone. The yellow dotted line shown at the edge of the near optical zone is a concentric circle of the inner edge of the printing zone, and the radius is obtained by enlarging the radius of the inner edge of the printing zone by a preset ratio.
[0070] Figure 3 FIG. 1 is a flow chart of a method for high-precision detection of stains in the near optical zone of a contact lens mold shown in one embodiment of the present application. Figure 3As shown, a high-precision method for detecting stains in the near optical zone of a contact lens mold of this embodiment may include the following steps:
[0071] A. acquiring a plurality of contact lens images, and preprocessing the plurality of contact lens images to obtain preprocessed images;
[0072] B. performing regional division on the pre-processed image to obtain an optical zone and a near optical zone, wherein the optical zone is a zone within the inner edge of the annular printed area of the contact lens, and the near optical zone is an annular zone excluding the optical zone, which is drawn with the center of the inner edge of the printed area of the contact lens as the center and with a radius x times the inner edge of the printed area;
[0073] C. constructing an optical zone mask based on the optical zone, and extracting the optical zone image in the preprocessed image based on the optical zone mask; and performing stain detection on the optical zone image based on adaptive binarization and area screening;
[0074] D. constructing a near optical zone mask based on the near optical zone, and extracting a near optical zone image in the preprocessed image based on the near optical zone mask; and performing stain detection on the near optical zone image.
[0075] The specific implementation process and principles are as follows:
[0076] A. Algorithm configuration and preprocessing;
[0077] It is responsible for loading the configuration files required by the algorithm, reading the contact lens mold images captured by the camera, and converting the color space, ultimately obtaining a group of five high-definition color images with highly synthesized light sources.
[0078] Figure 4 FIG. 1 is a flow chart of algorithm configuration and preprocessing in an embodiment of the present application. Figure 4 As shown, the algorithm configuration and preprocessing process are as follows:
[0079] A11 reads a configuration file, which includes a minimum threshold value of the mold area MouldAreaLowerLimit, a maximum threshold value of the mold area MouldAreaUpperLimit, a minimum threshold value of the optical zone area InnerZoneAreaLowerLimit, a maximum threshold value of the optical zone area InnerZoneAreaUpperLimit, and the like.
[0080] A12 loads images, including loading, decoding, and reading camera image data.
[0081] A13 color space conversion converts the Bayer format image obtained from the camera into BGR format.
[0082] A14 synthesizes the image and finally synthesizes the five images taken at different light source heights to obtain the preprocessed image Image.
[0083] B. Regional division;
[0084] After obtaining the synthesized preprocessed image Image, a series of image processing techniques are first used to obtain the ink contour at the inner edge of the printing area, and then the inner edge of the printing area and the edge of the near optical area are fitted respectively to divide the printing area, near optical area and optical area in the schematic diagram.
[0085] Figure 5 FIG. 1 is a schematic diagram of a process of dividing regions in an embodiment of the present application. Figure 5 As shown in the figure, the specific process of regional division includes:
[0086] B1, Gaussian filtering, performing Gaussian filtering on the preprocessed image Image to obtain a filtered image, the purpose of which is to reduce noise interference;
[0087] B2, channel binarization, firstly separating the filtered image according to the three channels of RGB, and then adaptively binarizing the R channel image, the G channel image and the B channel image of the filtered image to obtain the R channel binarized image R_Image, the G channel binarized image G_Image and the B channel binarized image B_Image;
[0088] B3, a logical OR operation is performed on the R channel binary image, the G channel binary image and the B channel binary image to obtain a detail image containing depth and shallowness detail information;
[0089] B4, morphological processing, performing closing and opening operations on the detail image to obtain an intermediate image; the morphological processing closes the holes and removes noise at the same time;
[0090] B5. Locate the inner circle contour and extract the inner circle contour of the printing area in the intermediate image. First, filter out the contour in the image after morphological processing in step B14, and filter out the inner circle contour according to the preset contour area and the aspect ratio of the minimum fitting rectangle. That is, the contour to be filtered must meet the following conditions:
[0091] Its area area is within the intersection interval IZAL of the minimum threshold value InnerZoneAreaLowerLimit of the optical zone area and the maximum threshold value InnerZoneAreaUpperLimit of the optical zone area;
[0092] The ratio of its shortest side length to its longest side length asp must be greater than or equal to the preset threshold aspect limit ;
[0093] The ratio of its contour area to the area of the minimum enclosing rectangle area ratio Must be greater than or equal to the preset threshold area limit ;
[0094] Finally, when the number of the initial inner circle contours is 1, the initial inner circle contour is used as the inner circle contour; when the number of the initial inner circle contours is greater than 1, the initial inner circle contour with the smallest contour area is used as the inner circle contour.
[0095] The expression of the screening process is:
[0096]
[0097] B6. Calculate the inscribed circle, calculate the maximum inscribed circle of the inner circle contour, and use the maximum inscribed circle as the inner edge of the annular printing area to obtain the optical zone; and use the center of the inner edge of the annular printing area as the center to draw an annular area excluding the optical zone with a radius x times the inner edge of the annular printing area to obtain the near optical zone, wherein x>1, and the contour of the near optical zone is on the inner side of the outer edge of the annular printing area.
[0098] C. Optical area detection;
[0099] First, a mask image containing only the optical area is generated, and a logical AND operation is performed with the binary image of the mold to obtain a binary image of the optical area. Then, stains in the optical area are detected through contour search and stain screening, and finally the result is drawn.
[0100] Figure 6 FIG. 1 is a flow chart of optical region detection in an embodiment of the present application. Figure 6 As shown, the specific process of optical area detection includes:
[0101] C1. Generate a mask, generate a full zero pixel mask image with the same size as the pre-processed image; draw the optical zone outline in the full zero pixel mask image, that is, draw a circle with the same size and position as the inner edge of the printing area, and fill the optical zone outline in the full zero pixel mask image with pixels of the target pixel value to obtain the optical zone mask. Specifically, fill with 255 pixel values;
[0102] C2, logical AND operation, performing logical AND operation on the mask image obtained by C1 and the original image to obtain an image OpticalImage of only the optical area;
[0103] C3, adaptive binarization, performing adaptive binarization processing on the optical zone image OpticalImage obtained in C2 to obtain a binarized image of the optical zone including the outline of the stain in the optical zone;
[0104] C4, morphological processing, performing an erosion operation on the image obtained in C3 to obtain an eroded image of the optical area to remove noise interference;
[0105] C5, stain screening, traversing all contours in the optical zone corrosion image, and taking contours in the optical zone corrosion image whose areas are smaller than a preset screening threshold as stain contours;
[0106] Specifically, the contour obtained by traversing C4 has a contour area of cnt area , according to the preset optical zone minimum stain area OpticalZoneSmudgeAreaLimit, the stain contour SmudgeContour is filtered out, and its expression is:
[0107]
[0108] C6, drawing results, drawing the stain outline screened out in C5 in the pre-processed image.
[0109] D. Near optical zone detection;
[0110] First, obtain the binary image of the near optical area, and then obtain the contour of each color point to be identified through contour search. Then traverse each contour and obtain its position information and color information, and finally filter out the outliers to obtain the detection results and draw them.
[0111] Figure 7 FIG. 1 is a flow chart of near optical area detection in an embodiment of the present application. Figure 7 As shown, the specific process of near optical area detection includes:
[0112] D1. Acquire a near optical zone image and generate an all-zero pixel mask image of the same size as the preprocessed image; draw the near optical zone outline in the all-zero pixel mask image, and fill the near optical zone outline in the all-zero pixel mask image with pixels of target pixel values to obtain a near optical zone mask.
[0113] Specifically, firstly, a mask image of all zero pixels of the same size as the input image is generated, and then circles of the same size and position as the edge of the near optical area and the inner edge of the printing area are drawn on it respectively, the inner edge of the near optical area is filled with 255 pixel values, and the inner edge of the printing area is filled with 0 pixel values, and finally the mask image and the input image are logically ANDed to obtain the image NearOpticalImage of the near optical area;
[0114] D2. Acquire position information, adaptively binarize the near optical zone image, and obtain a near optical zone binary image including a plurality of contours in the near optical zone image; traverse the plurality of contours in the near optical zone binary image to obtain the centroid coordinates {(x1, y1), (x2, y2), ..., (x n ,y n )}, that is, the position information of each color point to be identified; (x1, y1) is the centroid coordinate of the first contour, (x2, y2) is the centroid coordinate of the second contour, (x n ,y n ) is the centroid coordinate of the nth contour;
[0115] D3, obtaining color information, extracting multiple color points to be identified in the preprocessed image based on the centroid coordinates of multiple contours in the near optical zone binary image, and extracting color information of each color point to be identified in, is the grayscale mean of the b channel of all pixels in the nth color point to be identified, is the mean grayscale value of the g channel of all pixels in the nth color point to be identified, is the mean grayscale value of the r channel of all pixels in the nth color point to be identified;
[0116] Specifically, traverse the contours obtained in D2, match them one by one with the input color image (preprocessed image), and then take the mean of the grayscale values of each channel of each pixel in the n contours in the color image as the color information of the contour. The color information of each color point to be identified is
[0117] D4. Calculate the distance between each point, and calculate the position Euclidean distance and color Euclidean distance of each color point to be identified and other color points to be identified, and obtain the spatial distance set {D1, D2, ..., D n} and the color distance set {C1, C2, ..., C n}, where D1 is the set of spatial distances between the first color point to be identified and other color points to be identified, D2 is the set of spatial distances between the second color point to be identified and other color points to be identified, and D n is the set of spatial distances between the nth color point to be identified and other color points to be identified, that is, {d n1 , d n2 , …, d nn}; C1 represents the color space distance set between the first color point to be identified and other color points to be identified, C2 represents the color space distance set between the second color point to be identified and other color points to be identified, C n represents the color space distance set between the nth color point to be identified and other color points to be identified, that is, {cn1 , c n2 , …, c nn}, the other color points to be identified are color points in the printed area of the contact lens;
[0118] D5, sorting, and putting the spatial distances of each color point to be identified obtained in D4 and the color space distance set {D1, D2, ..., D n}, {C1, C2, ..., C n}Sort in ascending order;
[0119] D6, obtain the Nth distance, extract the spatial distance set {D1, D2, ..., D n Arrange the Nth minimum distance of each set in ascending order in} to obtain the minimum value set of spatial distance And extract the color distance set {C1, C2, ..., C n Arrange the Nth smallest distance of each set in ascending order to get the minimum color distance set
[0120] N is a preset value. Since it is arranged in ascending order, the Nth element is the minimum value, that is, the Nth minimum distance when the distances of the color points to be identified in D5 in the position coordinates and color space are arranged in ascending order. express;
[0121] D7, calculate the mean, take the set in D6 The average
[0122] D8. Outlier screening, calculation of the minimum set of spatial distances The minimum distance between each space and the average value Absolute value of the difference And calculate the minimum value set of color distance The minimum distance between each color and the average value The absolute value of the difference exist or, When , the nth color point to be identified is determined to be a stain.
[0123] Its mathematical expression is:
[0124]
[0125] D9, drawing results, drawing the stain outline filtered out in D8 in the original image.
[0126] The present invention provides a high-precision stain detection method for the near optical zone of a contact lens casting mold, which obtains a plurality of contact lens images and pre-processes the plurality of contact lens images to obtain a pre-processed image; divides the pre-processed image into regions to obtain an optical zone and a near optical zone; constructs an optical zone mask based on the optical zone, and extracts the optical zone image in the pre-processed image based on the optical zone mask; and performs stain detection on the optical zone image based on adaptive binarization and area screening; constructs a near optical zone mask based on the near optical zone, and extracts the near optical zone image in the pre-processed image based on the near optical zone mask; and performs stain detection on the near optical zone image. The present application automatically recognizes the image, and can determine whether the photographed product is qualified or not without manual detection, so as to reduce labor costs, save time, and improve production yield.
[0127] like Figure 8 As shown, the present application also provides a high-precision stain detection device for the near optical zone of a contact lens mold, comprising:
[0128] A preprocessing module, used for acquiring a plurality of contact lens images, and preprocessing the plurality of contact lens images to obtain preprocessed images;
[0129] A region division module is used to divide the pre-processed image into regions to obtain an optical zone and a near optical zone, wherein the optical zone is the region within the inner edge of the annular printed area of the contact lens, and the near optical zone is an annular region excluding the optical zone, which is drawn with the center of the inner edge of the printed area of the contact lens as the center and with a radius x times the inner edge of the printed area;
[0130] an optical zone detection module, configured to construct an optical zone mask based on the optical zone, extract an optical zone image in the preprocessed image based on the optical zone mask, and perform stain detection on the optical zone image based on adaptive binarization and area screening;
[0131] The near optical zone detection module is used to construct a near optical zone mask based on the near optical zone, extract a near optical zone image in the preprocessed image based on the near optical zone mask, and perform stain detection on the near optical zone image.
[0132] The present invention discloses a method and device for high-precision stain detection in the near optical zone of a contact lens casting mold. The method and device obtain a plurality of contact lens images, and pre-process the plurality of contact lens images to obtain a pre-processed image; divide the pre-processed image into regions to obtain an optical zone and a near optical zone; construct an optical zone mask based on the optical zone, and extract the optical zone image in the pre-processed image based on the optical zone mask; and detect stains on the optical zone image based on adaptive binarization and area screening; construct a near optical zone mask based on the near optical zone, and extract the near optical zone image in the pre-processed image based on the near optical zone mask; and detect stains on the near optical zone image. The present application automatically recognizes the image, and can determine whether the photographed product is qualified or not without manual detection, so as to reduce labor costs, save time, and improve production yield.
[0133] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0134] 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.
[0135] 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.
[0136] 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.
[0137] 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.
[0138] 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.
[0139] 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.
[0140] 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 high-precision method for detecting stains in the near optical zone of a contact lens mold, characterized in that: Includes steps: Acquire a plurality of contact lens images, and preprocess the plurality of contact lens images to obtain preprocessed images; Dividing the preprocessed image into regions to obtain an optical zone and a near optical zone, wherein the optical zone is the region within the inner edge of the annular printed area of the contact lens, and the near optical zone is the annular region excluding the optical zone drawn with the inner edge of the printed area of the contact lens as the center and with a radius x times the inner edge of the printed area, where x is the multiple; constructing an optical zone mask based on the optical zone, and extracting the optical zone image in the preprocessed image based on the optical zone mask; and performing stain detection on the optical zone image based on adaptive binarization and area screening; A near optical zone mask is constructed based on the near optical zone, and a near optical zone image in the preprocessed image is extracted based on the near optical zone mask; and stain detection is performed on the near optical zone image.
2. A high-precision detection method for stains in the near optical zone of a contact lens mold according to claim 1, characterized in that: Performing stain detection on the near optical zone image includes: Adaptively binarizing the near optical zone image to obtain a near optical zone binarized image including a plurality of contours in the near optical zone image; Traversing a plurality of contours in the near optical zone binary image to obtain centroid coordinates of the plurality of contours in the near optical zone binary image; Extracting a plurality of color points to be identified in the preprocessed image based on the centroid coordinates of a plurality of contours in the near optical zone binary image, and extracting color information of each color point to be identified in, is the grayscale mean of the b channel of all pixels in the nth color point to be identified, is the mean grayscale value of the g channel of all pixels in the nth color point to be identified, is the mean grayscale value of the r channel of all pixels in the nth color point to be identified; Abnormal color points are detected based on the centroid coordinates of the color point to be identified, the color information of the color point to be identified, the centroid coordinates of other color points to be identified in the near optical zone, and the color information of other color points to be identified in the near optical zone, and the abnormal color points are regarded as stains.
3. A high-precision detection method for stains in the near optical zone of a contact lens mold according to claim 2, characterized in that: Detecting abnormal color points based on the centroid coordinates of the color point to be identified, the color information of the color point to be identified, the centroid coordinates of other color points to be identified in the near optical zone, and the color information of other color points to be identified in the near optical zone, and treating the abnormal color points as stains, including: Calculate the position Euclidean distance and color Euclidean distance of each color point to be identified and other color points to be identified, and get the spatial distance set {D1, D2, …, D n } and the color distance set {C1,C2,…,C n }, where D1 is the set of spatial distances between the first color point to be identified and other color points to be identified, D2 is the set of spatial distances between the second color point to be identified and other color points to be identified, and D n is the set of spatial distances between the nth color point to be identified and other color points to be identified; C1 represents the set of color space distances between the first color point to be identified and other color points to be identified, C2 represents the set of color space distances between the second color point to be identified and other color points to be identified, and C n represents a set of color space distances between the nth color point to be identified and other color points to be identified, where the other color points to be identified are color points in the printed area of the contact lens; The spatial distance set {D1, D2, ..., D n } and the color distance set {C1,C2,…,C n }Sort in ascending order; Extract the spatial distance set {D1, D2, ..., D n Arrange the Nth minimum distance of each set in ascending order in} to obtain the minimum value set of spatial distance And extract the color distance set {C1, C2, ..., C n Arrange the Nth smallest distance of each set in ascending order to get the minimum color distance set Calculate the minimum value set of the spatial distance The average And calculate the color distance set {C1, C2, ..., C n The average value of Calculate the minimum value set of the spatial distance The minimum distance between each space and the average value Absolute value of the difference And calculate the minimum value set of color distance The minimum distance between each color and the average value The absolute value of the difference exist or, When , the nth color point to be identified is determined to be a stain.
4. A high-precision method for detecting stains in the near optical zone of a contact lens mold according to claim 1, characterized in that: Preprocessing the plurality of contact lens images to obtain preprocessed images comprises: Convert the plurality of contact lens images from a Bayer format to a BGR format to obtain a plurality of RGB images; The multiple RGB images are synthesized to obtain a preprocessed image.
5. A high-precision method for detecting stains in the near optical zone of a contact lens mold according to claim 1, characterized in that: The pre-processed image is divided into regions to obtain an optical zone and a near optical zone, including: Performing Gaussian filtering on the preprocessed image to obtain a filtered image; Adaptively binarizing the R channel image, the G channel image, and the B channel image of the filtered image to obtain an R channel binarized image, a G channel binarized image, and a B channel binarized image; Performing a logical OR operation on the R channel binary image, the G channel binary image, and the B channel binary image to obtain a detail image containing depth and shallowness detail information; Performing a closing operation and an opening operation on the detail image to obtain an intermediate image; extracting the inner circle contour of the printing area in the intermediate image; The maximum inscribed circle of the inner circle contour is calculated, and the maximum inscribed circle is used as the inner edge of the annular printing area to obtain the optical zone; and a circular area with a radius x times the inner edge of the annular printing area as the center is drawn to obtain the near optical zone, wherein the near optical zone is an annular area within the circular area excluding the optical zone, x>1, and the contour of the near optical zone is on the inner side of the outer edge of the annular printing area.
6. A high-precision method for detecting stains in the near optical zone of a contact lens mold according to claim 5, characterized in that: Extracting the inner circle contour of the printing area in the intermediate image, comprising: The contour that meets the target condition in the intermediate image is used as the initial inner circle contour, wherein the target condition includes: (1) The contour area is between the preset minimum threshold and maximum threshold of the optical zone area; (2) The ratio of the shortest side to the longest side of the contour is greater than or equal to a preset aspect ratio threshold; (3) The ratio of the contour area to the area of the minimum circumscribed rectangle of the contour is greater than or equal to a preset ratio threshold; When the number of the initial inner circle contours is 1, the initial inner circle contour is used as the inner circle contour; when the number of the initial inner circle contours is greater than 1, the initial inner circle contour with the smallest contour area is used as the inner circle contour.
7. A high-precision method for detecting stains in the near optical zone of a contact lens mold according to claim 1, characterized in that: Constructing an optical zone mask based on the optical zone, comprising: Generate an all-zero-pixel mask image with the same size as the preprocessed image; The optical zone contour is drawn in the all-zero pixel mask image, and pixels with target pixel values are filled inside the optical zone contour in the all-zero pixel mask image to obtain an optical zone mask.
8. A high-precision method for detecting stains in the near optical zone of a contact lens mold according to claim 1, characterized in that: Performing stain detection on the optical zone image based on adaptive binarization and area screening includes: Adaptively binarizing the optical zone image to obtain a binarized optical zone image including a stain outline in the optical zone; Performing corrosion processing on the optical zone binary image to obtain an optical zone corrosion image; Traversing all contours in the optical zone corrosion image, and taking contours in the optical zone corrosion image whose areas are smaller than a preset screening threshold as stain contours; The stain outline in the optical zone is drawn in the pre-processed image.
9. A high-precision method for detecting stains in the near optical zone of a contact lens mold according to claim 1, characterized in that: Constructing a near optical zone mask based on the near optical zone, comprising: Generate an all-zero-pixel mask image with the same size as the preprocessed image; The near optical zone outline is drawn in the all-zero pixel mask image, and pixels with target pixel values are filled inside the near optical zone outline in the all-zero pixel mask image to obtain a near optical zone mask.
10. A high-precision stain detection device for the near optical zone of a contact lens mold, characterized in that: include: A preprocessing module, used for acquiring a plurality of contact lens images, and preprocessing the plurality of contact lens images to obtain preprocessed images; A region division module is used to divide the pre-processed image into regions to obtain an optical zone and a near optical zone, wherein the optical zone is the region within the inner edge of the annular printed area of the contact lens, and the near optical zone is an annular region excluding the optical zone drawn with the inner edge of the printed area of the contact lens as the center and with a radius x times the inner edge of the printed area, where x is the multiple; an optical zone detection module, configured to construct an optical zone mask based on the optical zone, extract an optical zone image in the preprocessed image based on the optical zone mask, and perform stain detection on the optical zone image based on adaptive binarization and area screening; The near optical zone detection module is used to construct a near optical zone mask based on the near optical zone, extract a near optical zone image in the preprocessed image based on the near optical zone mask, and perform stain detection on the near optical zone image.
Citation Information
Cited By
Method for identifying ferrite pearlite metallographic structure of steel
CN120088493A