A method and system for separating and extracting contact lens single color using dual background images
By extracting monochrome images from contact lenses using a dual-background image separation method, the problem of unstable display of light and dark patterns in existing technologies is solved, achieving more accurate monochrome region detection and stability of cluster centers, which is suitable for automated visual inspection of colored contact lenses.
Patent Information
- Application Number
- CN202611353193.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-02
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies in automated visual inspection of colored contact lenses struggle to simultaneously display light and dark patterns, fail to effectively integrate light and dark background response features, resulting in unstable monochrome extraction, easy drift of cluster centers, and insufficient adaptability.
A dual-background image separation method is adopted to obtain images of the same contact lens under test against bright and dark backgrounds. Monochromatic information is extracted by generating candidate masks and color centers, and robust clustering is performed by combining the joint color features of multiple sampled pixels to generate the final monochromatic mask.
It improves the stability and detection accuracy of monochrome areas, reduces confusion caused by transparent substrates and background transmission, improves the problem of missed detection in single-background applications, is suitable for online detection and reduces computational load.
Smart Images

Figure CN123160912A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of visual inspection technology, specifically a method and system for extracting monochrome contact lenses using dual-background image separation. Background Technology
[0002] In the automated visual inspection of colored contact lenses, accurately extracting each monochrome region on the lens (i.e., "monochrome separation") is a core prerequisite for defect detection, color uniformity assessment, and pattern integrity determination. Its function is to decompose complex colored patterns into independent color layers, allowing for layer-by-layer comparison with templates to identify quality defects such as missing colors, color deviations, color mixing, or printing misalignments, thereby ensuring product appearance consistency.
[0003] Existing technologies mainly develop in the following directions: First, multiple images are acquired using multi-field or bright / dark-field illumination, but subsequent processing still involves independently performing grayscale conversion, thresholding, or brightness statistics on the bright and dark field images; second, color space conversion (such as RGB to Lab) and K-means clustering are used to classify the colors of pixels in a single image; third, pattern regions are extracted based on grayscale thresholding, edge detection, or morphological operations. These methods are widely used in industrial vision.
[0004] However, these existing technologies have obvious defects: (1) It is difficult for a single image to simultaneously display light and dark patterns, and some colors are transmitted or submerged in brightness under a specific background; (2) Although bright and dark field images can complement each other to enhance the pattern, the existing schemes do not analyze the color response of the same position under two backgrounds together, and are still "processed independently", failing to give full play to the complementary advantages of the two backgrounds; (3) Ordinary color clustering is based only on the three-channel values of a single image, ignoring the influence of background response differences on color identity under semi-transparent materials, which easily causes different color materials to be mistakenly clustered into one category or the same type of color materials to be split; (4) Fixed thresholds or single-channel thresholds are not adaptable to the light-transmitting color layer and are greatly affected by light and thickness fluctuations; (5) When detecting templates, the stability and order consistency of cluster centers lack an effective mechanism, and re-clustering is prone to drift, while fixed centers are difficult to adapt to imaging fluctuations.
[0005] In summary, existing technologies have not yet established a unified separation framework that integrates the response features of both bright and dark backgrounds, making it difficult to meet the detection requirements for stable monochrome extraction of contact lenses. Summary of the Invention
[0006] In view of this, the purpose of this application is to provide a method and system for extracting monochrome contact lenses using dual background images, so as to solve the problems in the background technology.
[0007] To achieve the above objectives, this application adopts the following technical solution:
[0008] This application discloses a method for extracting monochrome contact lenses using dual-background image separation, comprising the following steps:
[0009] Acquire a first image of the same contact lens under test taken against a first background and a second image taken against a second background, and obtain a pre-constructed effective area mask for the contact lens under test;
[0010] A first region of interest image is extracted from the first image, and a second region of interest image is extracted from the second image, wherein the positions of the first region of interest image and the second region of interest image are consistent;
[0011] Based on the image background, a first candidate mask for the first image and a second candidate mask for the second image are generated respectively. The first candidate mask, the second candidate mask and the effective region mask are then fused to obtain the overall candidate mask.
[0012] Based on the overall candidate mask, an overall candidate pattern region is extracted from the first region of interest image and the second region of interest image, wherein the overall candidate pattern region includes a portion from the first image and a portion from the second image;
[0013] The joint color features of multiple sampled pixels are extracted from the candidate pattern region, and multiple color centers are extracted based on the joint color features of multiple sampled pixels.
[0014] A final monochrome mask is generated based on the color center, the first image, and the second image, and monochrome information is extracted from the overall candidate pattern region based on the final monochrome mask.
[0015] In one embodiment of this application, extracting a first region of interest image from the first image and extracting a second region of interest image from the second image includes:
[0016] Extract contour features from the first image and the second image;
[0017] Based on lens feature localization, the outer contour of the first lens is extracted from the contour features of the first image, and the outer contour of the second lens is extracted from the contour features of the second image. The lens feature localization is circular localization, template localization, or polygon constraint localization.
[0018] Based on the outer contour of the first lens, a first region of interest image is extracted from the first image, and based on the outer contour of the second lens, a second region of interest image is extracted from the second image.
[0019] In one embodiment of this application, generating a first candidate mask for a first image and a second candidate mask for a second image based on the image background includes:
[0020] The foreground regions of the first image and the second image are extracted based on a preset threshold, wherein the preset threshold is a preset fixed threshold, an adaptive threshold, a statistical threshold, or a learned threshold.
[0021] A first candidate mask is constructed based on the first image and the foreground region of the first image, and a second candidate mask is constructed based on the second image and the foreground region of the second image.
[0022] In one embodiment of this application, the first candidate mask, the second candidate mask, and the effective region mask are fused to obtain an overall candidate mask, including:
[0023] The first candidate mask, the second candidate mask, and the effective region mask are subjected to union, intersection constraints, or weighted fusion to obtain the overall candidate mask. The overall candidate mask The mathematical expression is:
[0024]
[0025] In the formula, For fusion operators, As the first candidate mask, As the second candidate mask, For effective area masking.
[0026] In one embodiment of this application, extracting the joint color features of multiple sampled pixels from the candidate pattern region includes:
[0027] Sampling pixels are extracted based on the total number of pixels in the candidate pattern region and a preset sampling scale;
[0028] Extract the joint color features of the sampled pixels, the joint color features including the values of three color channels from the sampled pixel coordinates of the first image and the values of three color channels from the sampled pixel coordinates of the second image.
[0029] In one embodiment of this application, multiple color centers are extracted based on the joint color features of multiple sampled pixels, including:
[0030] Multiple clustering results are obtained by performing multiple clustering operations on the joint color features of multiple sampled pixels;
[0031] Calculate the compactness of each clustering result, and extract the cluster center from the clustering result with the smallest compactness as the color center, wherein the mathematical expression for the compactness is:
[0032]
[0033] In the formula, For the overall candidate mask, Indicates satisfaction conditional pixels , For color class index, For the number of color categories, For pixels The combined color features, Color Cluster centers.
[0034] In one embodiment of this application, generating a final monochrome mask based on the color center, the first image, and the second image includes:
[0035] A color tolerance range is constructed based on each color center;
[0036] Based on the color tolerance range, a first monochrome candidate mask is extracted in the first image, and a second monochrome candidate mask is extracted in the second image based on the color tolerance range;
[0037] A first monochrome candidate mask or a second monochrome candidate mask is selected as the final monochrome mask based on the visibility of monochrome on a first background and the visibility of monochrome on a second background. Alternatively, the first monochrome candidate mask and the second monochrome candidate mask are combined to obtain the final monochrome mask, wherein the visibility is determined based on grayscale difference.
[0038] In one embodiment of this application, the monochrome information includes Lab color space information, RGB color space information, HSV color space information, Hunter Lab color space information, number of pixels in the region, calibration area, and annotation information.
[0039] In one embodiment of this application, the first background is a bright field background and the second background is a dark field background.
[0040] This application also provides a system for separating and extracting monochrome contact lenses using dual-background images, comprising:
[0041] The acquisition module is used to acquire a first image of the same contact lens under test taken against a first background and a second image taken against a second background, and to acquire a pre-constructed effective area mask of the contact lens under test;
[0042] The region extraction module is used to extract a first region of interest image from the first image and a second region of interest image from the second image, wherein the positions of the first region of interest image and the second region of interest image are consistent;
[0043] The mask fusion module is used to generate a first candidate mask for the first image and a second candidate mask for the second image based on the image background, and to fuse the first candidate mask, the second candidate mask and the effective region mask to obtain an overall candidate mask;
[0044] The ROI extraction module is used to extract overall candidate pattern regions from the first region of interest image and the second region of interest image based on the overall candidate mask, wherein the overall candidate pattern region includes a portion from the first image and a portion from the second image;
[0045] The color center extraction module is used to extract the joint color features of multiple sampled pixels from the candidate pattern region, perform robust clustering on the joint color features, and extract multiple color centers based on the clustering results.
[0046] A monochrome information extraction module is used to generate a final monochrome mask based on the color center, the first image, and the second image, and to extract monochrome information from the overall candidate pattern region based on the final monochrome mask.
[0047] The beneficial effects of this application are as follows: This application provides a method and system for extracting monochrome contact lenses using dual-background image separation. It uses the response at the same location under two backgrounds as a joint feature, ensuring that the monochrome category is determined not only by the color value in a single image but also by its background response pattern, reducing confusion caused by transparent substrates and background transmission. Bright and dark background images provide complementary saliency, and fusing candidate masks can simultaneously cover salient areas under both backgrounds, improving the problem of missed detections under single backgrounds. The detection stage introduces template color center constraints or initial label assignment to ensure color number consistency between the first piece modeling and batch detection, facilitating subsequent judgments of color difference, area, missing color, and cross-color. The scheme can be implemented based on conventional cameras, dual-background imaging structures, and general image processing algorithms, without relying on expensive spectral equipment; it also supports reducing computational load through sampling, making it suitable for online detection. It can be extended to multiple backgrounds, multiple exposures, multiple spectra, or joint vectors incorporating positional features; threshold segmentation can also be replaced by statistical thresholds, learned saliency models, or robust optimization. Attached Figure Description
[0048] The present application will be further described below with reference to the accompanying drawings and embodiments:
[0049] Figure 1 This is a system hierarchy diagram for extracting monochrome contact lenses using dual-background image separation in one embodiment of this application;
[0050] Figure 2 This is a flowchart illustrating a method for extracting monochrome contact lenses using dual-background image separation in one embodiment of this application;
[0051] Figure 3 This is a logic structure diagram of a system for separating and extracting monochrome contact lenses using dual background images, as shown in one embodiment of this application. Detailed Implementation
[0052] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.
[0053] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. Therefore, the drawings only show the layers related to this application and are not drawn according to the actual number, shape and size of the layers in the actual implementation. In the actual implementation, the form, number and proportion of each layer can be arbitrarily changed, and the layer layout may also be more complex.
[0054] Numerous details are explored in the following description to provide a more thorough explanation of embodiments of this application; however, it will be apparent to those skilled in the art that embodiments of this application may be practiced without these specific details.
[0055] Figure 1 This is a system hierarchy diagram for extracting monochrome contact lenses using dual-background image separation in one embodiment of this application, such as... Figure 1 As shown, the system hierarchy of this application includes:
[0056] (1) Image acquisition and positioning layer
[0057] This layer is used to acquire images of the same object under two background conditions and obtain the region of interest through circular localization, template localization, or non-circular contour localization. The cropping range of the two images is kept consistent, so that the subsequent joint features can correspond to each other at pixel positions.
[0058] (2) Pretreatment layer
[0059] This layer converts the two images to a color space suitable for color comparison, such as the CIE Lab space, and smooths the luminance channel to reduce the impact of local noise, fine textures, and imaging grain on segmentation. Simultaneously, this layer excludes non-detection areas based on lens outlines, polygonal regions, or other effective area masks.
[0060] (3) Dual background separation layer
[0061] This layer generates candidate pattern masks based on the first background image and the second background image, respectively. The bright background image can emphasize dark or highly saturated patterns, while the dark background image can emphasize light-colored or transparent overlay patterns. The two candidate masks are fused together using union, intersection constraints, or weighted fusion to form a unified candidate pattern mask. This step can use preset thresholds, adaptive thresholds, statistical thresholds, or learned thresholds instead of specific engineering thresholds.
[0062] (4) Joint color modeling layer
[0063] This layer constructs a joint color feature for each sampled pixel in the candidate pattern region. The joint feature includes at least the Lab component of the location in the first background image and the Lab component in the second background image, and can also be extended to include HSV, brightness difference, saturation difference, local texture, or annular position parameters. Robust clustering is then performed in the joint feature space to obtain a preset number of color centers. When detecting existing templates, the color centers stored in the template can be used as initial labels or constraint centers to ensure consistency of the same color number across different batches.
[0064] (5) Result Output Layer
[0065] Based on the representation of each color center in the two images, this layer selects the display color that best represents the true appearance of the color and outputs the mask, CIE Lab, Hunter Lab, RGB, HSV, number of pixels, area, and visual annotations for that monochrome area. For the inspection report, the system can simultaneously output the light background color value, the dark background color value, and the combined color value formed by splicing the two, for subsequent judgment of color difference, color loss, color cross-contamination, or missing color.
[0066] Figure 2 This is a flowchart illustrating a method for extracting monochrome contact lenses using dual-background image separation in one embodiment of this application, as shown below. Figure 2 As shown, a method for extracting monochrome contact lenses using dual-background image separation in this application mainly includes the following steps:
[0067] S210, acquire a first image of the same contact lens under test taken against a first background and a second image taken against a second background, and acquire a pre-constructed effective area mask of the contact lens under test;
[0068] Acquire at least two images of the same contact lens. The background reflections, brightness, or colors of the two images are opposite or significantly different, so that the pattern to be tested exhibits complementary salience in the two images.
[0069] In one embodiment of this application, the first background is a bright field background and the second background is a dark field background.
[0070] S220, extract a first region of interest (ROI) image from the first image and extract a second ROI image from the second image, wherein the positions of the first ROI image and the second ROI image are consistent; the specific localization and ROI extraction process includes:
[0071] S220-1, Extract contour features from the first image and the second image;
[0072] S220-2, extract the outer contour of the first lens from the contour features of the first image based on lens feature localization, and extract the outer contour of the second lens from the contour features of the second image based on lens feature localization, wherein the lens feature localization is circular localization, template localization or polygon constraint localization.
[0073] Specifically, if the lens is circular, it can be cut using the center, radius, or outer diameter; if it is a non-circular object, it can be constrained using a template outline or polygonal region.
[0074] S220-3, extract a first region of interest image from the first image based on the outer contour of the first lens, and extract a second region of interest image from the second image based on the outer contour of the second lens.
[0075] In addition, the first and second region of interest images need to be preprocessed by converting them to a color space and smoothing the luminance channel. This step preserves the chromaticity differences while reducing luminance noise.
[0076] S230, based on the image background, generate a first candidate mask for the first image and a second candidate mask for the second image respectively, and fuse the first candidate mask, the second candidate mask, and the effective region mask to obtain an overall candidate mask; specifically including:
[0077] S230-1, Extract the foreground region of the first image and the foreground region of the second image based on a preset threshold, wherein the preset threshold is a preset fixed threshold, an adaptive threshold, a statistical threshold, or a learned threshold.
[0078] S230-2, construct a first candidate mask based on the first image and the foreground region of the first image, and construct a second candidate mask based on the second image and the foreground region of the second image.
[0079] The first candidate mask is used to capture patterns that are prominent against the first background, and the second candidate mask is used to capture patterns that are prominent against the second background.
[0080] S230-3, perform union, intersection constraint, or weighted fusion on the first candidate mask, the second candidate mask, and the effective region mask to obtain the overall candidate mask. The overall candidate mask The mathematical expression is:
[0081]
[0082] In the formula, For fusion operators, As the first candidate mask, As the second candidate mask, For effective area masking.
[0083] The two types of candidate masks are fused and combined with the effective detection region mask to obtain the overall pattern region. The fusion method can be logical union, binarization after confidence weighting, or union followed by erosion for noise reduction.
[0084] S240, extract an overall candidate pattern region from the first region of interest image and the second region of interest image based on the overall candidate mask, wherein the overall candidate pattern region includes a portion from the first image and a portion from the second image;
[0085] The overall candidate mask extracts the overall candidate pattern region from the first region of interest image and the second region of interest image respectively. The overall candidate pattern region contains information from six channels of the two original images. If necessary, image channel information from other color spaces needs to be added to expand it to more than six channels.
[0086] S250, extract the joint color features of multiple sampled pixels from the candidate pattern region, and extract multiple color centers based on the joint color features of multiple sampled pixels;
[0087] The process of extracting joint color features includes:
[0088] S250-1, Sample pixels are extracted based on the total number of pixels in the candidate pattern region and a preset sampling scale; that is, sample pixels are extracted according to a fixed ratio to reduce the amount of computation and maintain the color distribution.
[0089] S250-2, Extract the joint color features of the sampled pixels, the joint color features including the values of three color channels from the sampled pixel coordinates of the first image and the values of three color channels from the sampled pixel coordinates of the second image.
[0090] Compared with traditional single Figure 3 Unlike traditional color vectors, this invention uses at least a six-dimensional joint color vector to represent the color response at the same location under two different backgrounds. This is represented as:
[0091]
[0092] In the formula, For the Lab component in the first background, This refers to the Lab component in the second background.
[0093] The color center extraction process includes:
[0094] S250-3 performs multiple clustering operations on the joint color features of multiple sampled pixels to obtain multiple clustering results;
[0095] S250-4, calculate the compactness of each clustering result, and extract the cluster center of the clustering result with the smallest compactness as the color center, wherein the mathematical expression for the compactness is:
[0096]
[0097] In the formula, For the overall candidate mask, Indicates satisfaction conditional pixels , For color class index, For the number of color categories, For pixels The combined color features, Color Cluster centers.
[0098] S260, a final monochrome mask is generated based on the color center, the first image, and the second image, and monochrome information is extracted from the overall candidate pattern region based on the final monochrome mask.
[0099] Specifically, it includes;
[0100] S260-1, constructing a color tolerance range based on each color center;
[0101] Simultaneously, color categories are sorted. The initial modeling can be sorted by region size from largest to smallest, and the template order can be maintained during the inspection phase.
[0102] S260-2, extract a first monochrome candidate mask in the first image based on the color tolerance range, and extract a second monochrome candidate mask in the second image based on the color tolerance range;
[0103] S260-3, select a first monochrome candidate mask or a second monochrome candidate mask as the final monochrome mask based on the visibility of monochrome in the first background and the visibility of monochrome in the second background, or combine the first monochrome candidate mask and the second monochrome candidate mask to obtain the final monochrome mask, wherein the visibility is determined based on grayscale difference.
[0104] Specifically, a color tolerance range is constructed for each color center, and candidate masks for that color are generated in both bright and dark background images. The system selects a representative mask based on the visibility of the color in both backgrounds, or combines the two masks into a final monochrome mask.
[0105] For the A color-class, monochrome mask can be represented as:
[0106]
[0107] In the formula, For color observation used in the final color selection, the first background, the second background, or a combination of both can be selected; For the first The class represents color; For indicator functions, satisfying Select 1 otherwise select 0; For color tolerance. The system can determine the color tolerance based on the first... Selection of brightness, area stability, or confidence level under different backgrounds and The source of.
[0108] The monochrome information includes Lab color space information, RGB color space information, HSV color space information, Hunter Lab color space information, number of pixels in the region, calibration area, and annotation information.
[0109] Therefore, compared with the prior art, this application has the following advantages:
[0110] (1) Improve the stability of color separation for semi-transparent objects. This invention uses the response of the same location under two backgrounds as a joint feature, so that the monochrome category is determined not only by the color value in a single image, but also by its background response mode, which can reduce the confusion caused by the transmission of transparent substrate and background.
[0111] (2) It takes into account both light and dark patterns. Bright and dark background images provide complementary saliency. The fusion candidate mask can cover salient areas under both backgrounds at the same time, improving the problem of missed detection under single background.
[0112] (3) Reduce color category drift. In the detection stage, template color center constraints or initial label assignment are introduced to ensure that the color number remains consistent between the first piece modeling and batch detection, which facilitates subsequent judgment of color difference, area, missing color and cross-color.
[0113] (4) Suitable for engineering deployment. The solution can be implemented based on conventional cameras, dual-background imaging structures and general image processing algorithms, without relying on expensive spectral equipment; at the same time, it supports reducing the amount of computation through sampling, making it suitable for online detection.
[0114] (5) The scope of protection is scalable. Although the embodiments are mainly based on Lab six-dimensional joint features, they can be extended to joint vectors with multiple backgrounds, multiple exposures, multiple spectra, or the addition of location features; threshold segmentation can also be replaced by statistical thresholds, learned saliency models, or robust optimization.
[0115] In one specific embodiment of this application, the monochrome extraction process is as follows:
[0116] (1) First piece modeling;
[0117] In the initial modeling scenario, the system first acquires bright and dark background images of the same contact lens and obtains the region of common interest based on the outer circle positioning. Then, the two images are converted to Lab space, smoothing is performed on the luminance channel, and an overall candidate mask is generated based on the effective pattern region.
[0118] The system extracts representative pixels from the overall candidate mask and constructs the dual-background joint color feature for each pixel. If the product specifications pre-define... For each target color, the system performs multiple initial clustering operations in the joint feature space and selects the result with the best compactness as the first color center. For each color center, the system saves its light background Lab, dark background Lab, joint Lab, representative RGB, HSV, Hunter Lab, and area information to form template color information.
[0119] (2) Batch testing;
[0120] In batch detection scenarios, the system repeatedly acquires bright and dark background images of the lens under test and locates the common detection region according to the template. After constructing the joint color features of the current sample against the dual background, the system does not directly re-cluster randomly, but instead reads the color centers in the template. And assign initial labels to the sampled pixels.
[0121] If a template color has too few initial samples in the current sample due to missing color, shallow printing, or local defects, the system can compensate for the samples from the candidate pixels closest to the center of the template, or mark the color as a low-confidence category. The system then performs constrained clustering and outputs the area of each color. .when When the area is below the corresponding area range of the template, it can be considered as a suspected case of missing color or underprinting; when a mask with a similar color appears in a non-target area, it can be considered as a suspected case of color mixing.
[0122] (3) Parameter setting example;
[0123] The following parameters are for illustrative purposes only and are not intended to limit the scope of the claims:
[0124] (1) Number of target monochrome It can be provided by product formula or template configuration, such as single color, two color or multi color chips;
[0125] (2) Candidate masks can be generated using bright background saliency and dark background saliency respectively, and then subjected to morphological denoising and effective region constraints;
[0126] (3) Clustering can adopt a multiple initialization selection strategy, or template center initialization, density clustering, Gaussian mixture model or other robust clustering methods;
[0127] (4) Color tolerance It can be a uniform preset value, or it can be dynamically adjusted according to color category, template variance, or test batch;
[0128] (5) Area calibration coefficient Obtained from the camera calibration board or system calibration process.
[0129] The technical effects are as follows:
[0130] By employing this invention, colors that are significant against a bright background but insignificant against a dark background, as well as colors that are significant against a dark background but insignificant against a bright background, can all be included in a unified candidate region and classified in a joint feature space. Compared to single-background, single-image clustering, this invention reduces the probability of missed detections of light colors, adhesion of dark colors, color category order drift, and background missegmentation. Compared to methods that rely entirely on template thresholds, this invention retains the clustering update capability, adapting to a certain range of imaging fluctuations and batch differences.
[0131] like Figure 3 As shown, this application also provides a system for extracting monochrome contact lenses using dual-background image separation, comprising:
[0132] The acquisition module is used to acquire a first image of the same contact lens under test taken against a first background and a second image taken against a second background, and to acquire a pre-constructed effective area mask of the contact lens under test;
[0133] The region extraction module is used to extract a first region of interest image from the first image and a second region of interest image from the second image, wherein the positions of the first region of interest image and the second region of interest image are consistent;
[0134] The mask fusion module is used to generate a first candidate mask for the first image and a second candidate mask for the second image based on the image background, and to fuse the first candidate mask, the second candidate mask and the effective region mask to obtain an overall candidate mask;
[0135] The ROI extraction module is used to extract overall candidate pattern regions from the first region of interest image and the second region of interest image based on the overall candidate mask, wherein the overall candidate pattern region includes a portion from the first image and a portion from the second image;
[0136] The color center extraction module is used to extract the joint color features of multiple sampled pixels from the candidate pattern region, perform robust clustering on the joint color features, and extract multiple color centers based on the clustering results.
[0137] A monochrome information extraction module is used to generate a final monochrome mask based on the color center, the first image, and the second image, and to extract monochrome information from the overall candidate pattern region based on the final monochrome mask.
[0138] This application discloses a method and system for extracting monochromatic lenses from contact lenses using dual-background images. The system uses the response at the same location under two backgrounds as a joint feature, ensuring that the monochromatic category is determined not only by the color value in a single image but also by its background response pattern, reducing confusion caused by transparent substrates and background transmission. Bright and dark background images provide complementary saliency, and fusing candidate masks can simultaneously cover salient areas under both backgrounds, improving the problem of missed detections under single backgrounds. In the detection stage, template color center constraints or initial label assignments are introduced to ensure color numbering consistency between the first-piece modeling and batch detection, facilitating subsequent judgments of color difference, area, missing color, and cross-color. The solution can be implemented based on conventional cameras, dual-background imaging structures, and general image processing algorithms, without relying on expensive spectral equipment; it also supports reducing computational load through sampling, making it suitable for online detection. It can be extended to multiple backgrounds, multiple exposures, multiple spectra, or joint vectors incorporating location features; threshold segmentation can also be replaced by statistical thresholds, learned saliency models, or robust optimization.
[0139] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0140] The memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory so that the terminal performs any of the methods in this embodiment.
[0141] As will be understood by those skilled in the art, the computer-readable storage medium described in this embodiment allows for the implementation of all or part of the steps in the above method embodiments by computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0142] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver, and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication between them. The memory is used to store computer programs, the communication interface is used to perform communication, and the processor and the transceiver are used to run the computer programs, so that the electronic terminal performs the various steps of the above method.
[0143] In this embodiment, the memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.
[0144] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0145] In the above embodiments, although the present application has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art based on the foregoing description. The embodiments of the present application are intended to cover all such substitutions, modifications, and variations falling within the broad scope of the appended claims.
[0146] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.
Claims
1. A method for extracting monochrome contact lenses using dual-background image separation, characterized in that, include: Acquire a first image of the same contact lens under test taken against a first background and a second image taken against a second background, and obtain a pre-constructed effective area mask for the contact lens under test; A first region of interest image is extracted from the first image, and a second region of interest image is extracted from the second image, wherein the positions of the first region of interest image and the second region of interest image are consistent; Based on the image background, a first candidate mask for the first image and a second candidate mask for the second image are generated respectively. The first candidate mask, the second candidate mask and the effective region mask are then fused to obtain the overall candidate mask. Based on the overall candidate mask, an overall candidate pattern region is extracted from the first region of interest image and the second region of interest image, wherein the overall candidate pattern region includes a portion from the first image and a portion from the second image; The joint color features of multiple sampled pixels are extracted from the candidate pattern region, and multiple color centers are extracted based on the joint color features of multiple sampled pixels. A final monochrome mask is generated based on the color center, the first image, and the second image, and monochrome information is extracted from the overall candidate pattern region based on the final monochrome mask.
2. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, Extracting a first region of interest (ROI) image from the first image and extracting a second ROI image from the second image includes: Extract contour features from the first image and the second image; Based on lens feature localization, the outer contour of the first lens is extracted from the contour features of the first image, and the outer contour of the second lens is extracted from the contour features of the second image. The lens feature localization is circular localization, template localization, or polygon constraint localization. Based on the outer contour of the first lens, a first region of interest image is extracted from the first image, and based on the outer contour of the second lens, a second region of interest image is extracted from the second image.
3. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, Based on the image background, a first candidate mask for the first image and a second candidate mask for the second image are generated, including: The foreground regions of the first image and the second image are extracted based on a preset threshold, wherein the preset threshold is a preset fixed threshold, an adaptive threshold, a statistical threshold, or a learned threshold. A first candidate mask is constructed based on the first image and the foreground region of the first image, and a second candidate mask is constructed based on the second image and the foreground region of the second image.
4. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, The first candidate mask, the second candidate mask, and the effective region mask are fused to obtain a comprehensive candidate mask, including: The first candidate mask, the second candidate mask, and the effective region mask are subjected to union, intersection constraints, or weighted fusion to obtain the overall candidate mask. The overall candidate mask The mathematical expression is: In the formula, For fusion operators, As the first candidate mask, As the second candidate mask, For effective area masking.
5. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, Extracting joint color features from multiple sampled pixels from the candidate pattern region includes: Sampling pixels are extracted based on the total number of pixels in the candidate pattern region and a preset sampling scale; Extract the joint color features of the sampled pixels, the joint color features including the values of three color channels from the sampled pixel coordinates of the first image and the values of three color channels from the sampled pixel coordinates of the second image.
6. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, Multiple color centers are extracted based on the joint color features of multiple sampled pixels, including: Multiple clustering results are obtained by performing multiple clustering operations on the joint color features of multiple sampled pixels; Calculate the compactness of each clustering result, and extract the cluster center from the clustering result with the smallest compactness as the color center, wherein the mathematical expression for the compactness is: In the formula, For the overall candidate mask, Indicates satisfaction conditional pixels , For color class index, For the number of color categories, For pixels The combined color features, Color Cluster centers.
7. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, Generating a final monochrome mask based on the color center, the first image, and the second image includes: A color tolerance range is constructed based on each color center; Based on the color tolerance range, a first monochrome candidate mask is extracted in the first image, and a second monochrome candidate mask is extracted in the second image based on the color tolerance range; A first monochrome candidate mask or a second monochrome candidate mask is selected as the final monochrome mask based on the visibility of monochrome on a first background and the visibility of monochrome on a second background. Alternatively, the first monochrome candidate mask and the second monochrome candidate mask are combined to obtain the final monochrome mask, wherein the visibility is determined based on grayscale difference.
8. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, The monochrome information includes Lab color space information, RGB color space information, HSV color space information, HunterLab color space information, number of pixels in the region, calibration area, and annotation information.
9. The method for extracting monochrome contact lenses using dual-background image separation according to claim 1, characterized in that, The first background is a bright field background, and the second background is a dark field background.
10. A system for separating and extracting monochrome contact lenses using dual-background images, characterized in that, include: The acquisition module is used to acquire a first image of the same contact lens under test taken against a first background and a second image taken against a second background, and to acquire a pre-constructed effective area mask of the contact lens under test; The region extraction module is used to extract a first region of interest image from the first image and a second region of interest image from the second image, wherein the positions of the first region of interest image and the second region of interest image are consistent; The mask fusion module is used to generate a first candidate mask for the first image and a second candidate mask for the second image based on the image background, and to fuse the first candidate mask, the second candidate mask and the effective region mask to obtain an overall candidate mask; The ROI extraction module is used to extract overall candidate pattern regions from the first region of interest image and the second region of interest image based on the overall candidate mask, wherein the overall candidate pattern region includes a portion from the first image and a portion from the second image; The color center extraction module is used to extract the joint color features of multiple sampled pixels from the candidate pattern region, perform robust clustering on the joint color features, and extract multiple color centers based on the clustering results. A monochrome information extraction module is used to generate a final monochrome mask based on the color center, the first image, and the second image, and to extract monochrome information from the overall candidate pattern region based on the final monochrome mask.
