An optical lens coating defect positioning method based on target detection

CN122657137BActive Publication Date: 2026-10-20NANJING NUOWEI ENVIRONMENTAL PROTECTION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611115541.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-27
Publication Date
2026-10-20
Estimated Expiration
2046-07-27

AI Technical Summary

Technical Problem

[0005]因此,本发明提供了一种基于目标检测的光学镜片镀膜瑕疵定位方法,解决了圆形镀膜区域中不同角向位置下的颜色变化难以统一表征,以及镀膜瑕疵引起的局部颜色异常难以与正常颜色波动区分的问题

Benefits of technology

[0016]本发明有益效果为:通过角向采样位置、径向采样位置和径向排列比值重构有效镀膜区域,并借助坐标转换关系将镀膜瑕疵候选框及候选框中心点映射至光学镜片镀膜检测图像,实现圆形镀膜区域颜色变化的统一表征及径向、角向定位;通过颜色差异强度值、颜色差异基准和颜色差异偏离值表征局部颜色变化,结合差异像素组的数量占比、组内最大相邻差值和差异组间断点间隔筛选候选瑕疵像素,实现局部颜色异常与正常颜色波动的区分及镀膜瑕疵目标连续识别。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122657137B_ABST
    Figure CN122657137B_ABST
Patent Text Reader

Abstract

The application discloses a kind of optical lens coating flaw positioning method based on target detection, it is related to computer vision technical field, including: acquisition optical lens coating detection image, identify optical lens outer contour and calculate lens center point, extract color transition position to form coating boundary and effective coating area;According to angular sampling position and radial sampling position, effective coating area pixel is rearranged, and coating area development chart and coordinate conversion relationship are formed;The pixel difference amplitude between color channel is calculated to form color difference image, generate coating flaw candidate frame and candidate frame center point and identify flaw type;According to coordinate conversion relationship, coating flaw candidate frame and candidate frame center point are mapped back to optical lens coating detection image, obtain coating flaw positioning frame and candidate frame center point mapping coordinates, form optical lens coating flaw positioning result.The application realizes the unified representation of circular coating area and the distinction between local color anomaly and normal color fluctuation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and in particular to a method for locating defects in optical lens coatings based on target detection. Background Technology

[0002] Optical lens coatings are used to control transmittance, reflectance, and spectral response characteristics, and are widely used in optical systems such as imaging, displays, lasers, and precision measurement. As optical component manufacturing evolves towards higher consistency and reliability, the inspection of coating surface quality is gradually shifting from manual observation to machine vision inspection. Machine vision inspection relies on color imaging and digital image analysis to characterize anomalies such as color difference, spots, streaks, and coating unevenness on the lens surface, providing technical support for coating process evaluation, product screening, and quality verification.

[0003] However, existing methods still have two limitations: First, pixels in the same radial layer in a circular coating area are distributed in an arc shape, and the effective radial range varies at different angular positions, making it difficult to compare color changes on a uniform spatial scale; Second, surface reflection of the lens, illumination fluctuations, and gradual changes in the coating background color can cause changes in imaging response, causing local defect features to overlap with normal color fluctuations, increasing the difficulty of separating abnormal areas and determining continuous targets. Summary of the Invention

[0004] In view of the aforementioned existing problems, the present invention is proposed.

[0005] Therefore, this invention provides a method for locating defects in optical lens coatings based on target detection, which solves the problems of difficulty in uniformly representing color changes at different angular positions in a circular coating area, and difficulty in distinguishing local color anomalies caused by coating defects from normal color fluctuations.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: This invention provides a method for locating defects in optical lens coatings based on target detection. The method includes: acquiring an image of the optical lens coating; identifying the outer contour of the optical lens and calculating the lens center point; extracting color transition positions along the direction from the lens center point to the outer contour of the optical lens; connecting these color transition positions in angular order to form a coating boundary; defining the image pixel range defined by the coating boundary as the effective coating area; sampling the effective coating area according to angular and radial sampling positions relative to the lens center point; rearranging the pixels of the effective coating area associated with each sampling position according to the order of the angular and radial sampling positions to form a coating area unfolded image; and recording the relationship between each pixel in the unfolded coating area and the light... The coordinate transformation relationship between pixels in the effective coating area of ​​the lens coating detection image is studied. The red, green, and blue channels are extracted from the unfolded image of the coating area. The pixel difference amplitude between different color channels is calculated to form a color difference image. Coating defects are detected and their types are identified in the color difference image, generating candidate boxes, defect types, and candidate box center points. Based on the coordinate transformation relationship, the candidate boxes and their center points are mapped back to the optical lens coating detection image to obtain the mapping coordinates of the coating defect location box and the candidate box center point. Based on the positional relationship between the candidate box center point mapping coordinates and the lens center point, the optical lens coating defect location result containing radial position, angular position, and defect type is formed.

[0007] As a preferred embodiment of the optical lens coating defect localization method based on target detection described in this invention, the step of identifying the outer contour of the optical lens and calculating the lens center point includes: converting the optical lens coating detection image into an optical lens brightness image; calculating the brightness change amplitude of each pixel in the optical lens brightness image; sorting different brightness change amplitudes; using the arithmetic mean of two adjacent brightness change amplitudes as candidate segmentation values; dividing the pixels into a first pixel group and a second pixel group using each candidate segmentation value; multiplying the product of the pixel quantity ratio of each of the two pixel groups by the square of the difference between the arithmetic mean of the brightness change amplitudes of the two pixel groups to obtain the inter-class variance; using the candidate segmentation value with the largest inter-class variance as the edge segmentation value; using pixels with brightness change amplitudes not less than the edge segmentation value as edge pixels; connecting the edge pixels according to the eight-neighbor relationship to form a closed edge; using the closed edge with the largest number of enclosed pixels as the outer contour of the optical lens; and using the position marked by the arithmetic mean of the horizontal coordinate and the arithmetic mean of the vertical coordinate of each pixel within the enclosed area of ​​the outer contour of the optical lens as the lens center point.

[0008] As a preferred embodiment of the target detection-based optical lens coating defect localization method of the present invention, the step of extracting color transition positions along the direction from the lens center point to the outer contour of the optical lens, connecting each color transition position in angular order to form a coating boundary, and using the image pixel range defined by the coating boundary as the effective coating area includes: starting from the lens center point, establishing radial sampling lines along different angular positions to the outer contour of the optical lens, extracting the red channel pixel value, green channel pixel value, and blue channel pixel value of each pixel passed through the radial sampling line to obtain a radial color pixel sequence; using the separation positions between adjacent pixels in the radial color pixel sequence as candidate segmentation positions, and dividing the radial color pixel sequence into lens... The pixel segments on the center point side and the pixel segments on the outer contour side of the optical lens are used as the color dispersion degree on the center point side and the outer contour side of the optical lens, respectively. The candidate segmentation position with the smallest sum of the two color dispersion degrees is taken as the color segmentation position, and the position of the adjacent pixel on the outer contour side of the color segmentation position is taken as the color transition position. The color transition positions are connected sequentially according to the angular position of the radial sampling line, and the first color transition position is connected to the last color transition position to form the coating boundary. The image pixels on the coating boundary and the image pixels within the coating boundary and located within the outer contour of the optical lens are taken as the effective coating area.

[0009] As a preferred embodiment of the target detection-based optical lens coating defect localization method of the present invention, the sampling of the effective coating area according to the angular and radial sampling positions relative to the center point of the lens includes: counting all color transition positions to obtain the total number of color transition positions; using the ratio of 360 degrees to the total number of color transition positions as the angular sampling interval; taking 0 degrees as the first angular sampling position; setting the same number of angular sampling positions as the total number of color transition positions along the clockwise direction according to the angular sampling interval; establishing a radial sampling ray along each angular sampling position starting from the center point of the lens; and sampling the points where the radial sampling ray intersects with the coating boundary. The intersection point closest to the lens center is taken as the radial termination position. The radial termination distance between each radial termination position and the lens center is calculated. The maximum radial termination distance is rounded up and added to one to obtain the number of radial sampling rows. Radial sampling positions are set at equal intervals between the lens center and each radial termination position. The pixel column coordinates and pixel row coordinates of the coating area unfolded map are set according to the arrangement order of the angular sampling positions and the radial sampling positions, respectively. The ratio of each pixel row coordinate to the last pixel row coordinate is taken as the radial arrangement ratio. Based on the radial arrangement ratio, linear interpolation is performed on the horizontal and vertical coordinates between the lens center and the radial termination positions to obtain the source sampling coordinates.

[0010] As a preferred embodiment of the target detection-based optical lens coating defect localization method of the present invention, the step of rearranging the effective coating area pixels associated with each sampling position according to the arrangement order of each angular sampling position and each radial sampling position to form a coating area unfolded map, and recording the coordinate transformation relationship between each pixel in the coating area unfolded map and the effective coating area pixels in the optical lens coating detection image includes: based on the coordinate distance between the source sampling coordinates and the coordinates of each effective coating area pixel, taking the effective coating area pixel with the smallest coordinate distance as the source pixel, writing the red channel pixel value, green channel pixel value, and blue channel pixel value of the source pixel into the pixel position jointly indicated by the pixel column coordinate of the current angular sampling position and the pixel row coordinate of the current radial sampling position to obtain the unfolded pixel, summarizing each unfolded pixel to form a coating area unfolded map; associating the pixel row coordinate and pixel column coordinate of each unfolded pixel with the source sampling coordinates and the horizontal and vertical coordinates of the source pixel in the optical lens coating detection image to form a coordinate transformation relationship.

[0011] As a preferred embodiment of the optical lens coating defect localization method based on target detection described in this invention, the step of extracting the red, green, and blue channels from the unfolded image of the coating area and calculating the pixel difference amplitude between different color channels to form a color difference image includes: calculating the pixel difference amplitude between each pair of red, green, and blue channel pixel values ​​in the unfolded image of the coating area; taking the maximum value among the three pixel difference amplitudes as the color difference intensity value; arranging the color difference intensity values ​​according to pixel row coordinates and pixel column coordinates to form a color difference image; taking the median of the color difference intensity value of each pixel row as the color difference reference; and taking the difference amplitude between each color difference intensity value and the color difference reference of its respective pixel row as the color difference deviation value.

[0012] As a preferred embodiment of the target detection-based optical lens coating defect localization method of the present invention, the detection of coating defect targets in the color difference image includes: arranging different color difference deviation values ​​from smallest to largest, using the arithmetic mean of adjacent values ​​as the candidate color difference segmentation value; classifying pixels with color difference deviation values ​​less than and not less than the candidate color difference segmentation value into a first difference pixel group and a second difference pixel group, respectively; multiplying the product of the pixel count percentages of the two difference pixel groups by the square of the difference between the arithmetic mean of the color difference deviation values ​​of the two difference pixel groups to obtain the inter-class variance of color difference, and using the candidate color difference segmentation value with the largest inter-class variance of color difference as the color difference segmentation value; and separating adjacent values ​​within the two difference pixel groups corresponding to the color difference segmentation value. The maximum difference is used as the maximum adjacent difference within the first difference group and the maximum adjacent difference within the second difference group, and is recorded as zero when a single value is taken. The difference between the minimum color difference deviation of the second difference pixel group and the maximum color difference deviation of the first difference pixel group is used as the interval between the discontinuities of the difference groups. When the proportion of pixels in the second difference pixel group is less than the proportion of pixels in the first difference pixel group, and the interval between the discontinuities of the difference groups is greater than the maximum adjacent difference within the first and second difference groups respectively, the pixels in the second difference pixel group are used as candidate defect pixels. The candidate defect pixels are connected according to the eight-neighbor relationship, and the first and last pixel columns of the color difference image are connected according to the angular head-to-tail relationship to form a coating defect connected region. Each coating defect connected region is used as the coating defect target.

[0013] As a preferred embodiment of the target detection-based optical lens coating defect localization method of the present invention, the steps of identifying defect types and generating candidate boxes for coating defects, defect types, and candidate box center points include: forming candidate boxes for coating defects based on the extreme values ​​of pixel row coordinates and pixel column coordinates of candidate defect pixels in the connected region of the coating defect; for a connected region of coating defects that simultaneously contains the first and last pixel columns of a color difference image, deduplicating the pixel column coordinates occupied by candidate defect pixels and arranging them from smallest to largest, using the difference between the sum of the first pixel column coordinate and the total number of pixel columns in the color difference image and the last pixel column coordinate as the cyclic column coordinate difference, comparing the difference between adjacent pixel column coordinates with the cyclic column coordinate difference, using the occupied pixel column coordinate after the maximum difference as the adjustment starting pixel column coordinate, and adding the pixel column coordinates smaller than the adjustment starting pixel column coordinate to the total number of pixel columns in the color difference image to form the candidate box for coating defects; iteratively deleting boundary images while keeping the number of eight-neighbor connected regions and closed background regions of the connected region of the coating defect unchanged. The defect refinement structure is obtained by extracting the basic structure. Refinement pixels adjacent to only one refinement pixel are designated as endpoints, and refinement pixels adjacent to three or more refinement pixels are designated as branch points. When the connected region of the coating defect contains only one candidate defect pixel, has branch points, has a closed background region but no endpoints or branch points, or has no closed background region and no branch points but has two endpoints, the defect type is identified as point-like defect, branch-like defect, ring-like defect, or strip-like defect, respectively. The defect types of the remaining connected regions of the coating defect are then identified as... For surface defects, the arithmetic mean of the extreme values ​​of the pixel row coordinates of the candidate box for coating defects is used as the pixel row coordinate of the candidate box center point, and the arithmetic mean of the extreme values ​​of the pixel column coordinates is used as the pixel column coordinate of the candidate box center point. When crossing the first and last pixel columns, the adjusted extreme values ​​of the pixel column coordinates are used to calculate the pixel column coordinate of the candidate box center point, and the total number of pixel columns of the color difference image is subtracted when the calculation result is not less than the total number of pixel columns of the color difference image. The candidate box for coating defects, the defect type, and the center point of the candidate box are associated.

[0014] As a preferred embodiment of the target detection-based optical lens coating defect localization method of the present invention, the step of mapping the coating defect candidate box and the candidate box center point back to the optical lens coating detection image according to the coordinate transformation relationship to obtain the mapped coordinates of the coating defect localization box and the candidate box center point includes: determining the covered pixel position according to the pixel row coordinate range and pixel column coordinate range of the coating defect candidate box; subtracting the total number of pixel columns of the color difference image from the pixel column coordinates that are not less than the total number of pixel columns of the color difference image, while keeping the remaining pixel column coordinates unchanged, to obtain the query pixel column coordinates. The coordinate transformation relationship is queried based on the pixel row coordinates and the query pixel column coordinates to extract the source pixel horizontal and vertical coordinates. The extreme values ​​of the source pixel horizontal and vertical coordinates are used to form the coating defect location box. The coordinate transformation relationship is queried based on the pixel positions around the center point of the candidate box to extract the source sampling coordinates. When the pixel positions around the center point of the candidate box span the first and last pixel columns of the color difference image, the source sampling coordinates are selected according to the angular first-to-last connection relationship. The source sampling coordinates are linearly interpolated along the pixel column direction and the pixel row direction to obtain the mapped coordinates of the candidate box center point.

[0015] As a preferred embodiment of the optical lens coating defect localization method based on target detection described in this invention, the step of forming an optical lens coating defect localization result including radial position, angular position, and defect type based on the positional relationship between the candidate frame center point mapping coordinates and the lens center point includes: calculating the lateral position difference and the longitudinal position difference between the candidate frame center point mapping coordinates and the lens center point; taking the square root of the sum of the squares of the two position differences as the radial position; and performing a four-quadrant arctangent operation using the lateral position difference and the longitudinal position difference as coordinate components; converting the operation result into an angle to obtain the angular position; when the angular position is less than zero degrees, adding the angular position to 360 degrees; when the candidate frame center point mapping coordinates coincide with the lens center point, recording the radial position and angular position as zero pixels and zero degrees, respectively; associating and summarizing the coating defect localization frame, the candidate frame center point mapping coordinates, the radial position, the angular position, and the defect type to form the optical lens coating defect localization result.

[0016] The beneficial effects of this invention are as follows: by reconstructing the effective coating area through angular sampling position, radial sampling position and radial arrangement ratio, and by using coordinate transformation relationship to map the candidate box of coating defects and the center point of the candidate box to the optical lens coating detection image, a unified representation of color change in circular coating area and radial and angular positioning are achieved; by representing local color change through color difference intensity value, color difference benchmark and color difference deviation value, and by combining the number ratio of difference pixel groups, the maximum adjacent difference within the group and the interval of discontinuity between difference groups to screen candidate defect pixels, the distinction between local color abnormality and normal color fluctuation and the continuous identification of coating defect targets are achieved. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart of a method for locating defects in optical lens coatings based on target detection.

[0019] Figure 2 A flowchart for determining the outer contour of an optical lens and the effective coating area.

[0020] Figure 3 A flowchart generated for the unfolded diagram of the coating area and the coordinate transformation relationship.

[0021] Figure 4 This is a flowchart for the detection, identification, and localization of coating defects.

[0022] Figure 5 This is a graph showing the relationship between the radial arrangement ratio and the radial position at different angular sampling positions.

[0023] Figure 6 This is a graph showing the color difference intensity value, color difference baseline, and color difference deviation value within the same pixel row. Detailed Implementation

[0024] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0025] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0026] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0027] Reference Figures 1-6 This is one embodiment of the present invention, which provides a method for locating defects in optical lens coatings based on target detection, including the following steps: S1. Acquire images of optical lens coating detection, identify the outer contour of the optical lens and calculate the center point of the lens, extract color transition positions along the direction from the center point of the lens to the outer contour of the optical lens, connect each color transition position in angular order to form the coating boundary, and use the image pixel range defined by the coating boundary as the effective coating area.

[0028] Furthermore, the optical lens to be inspected is placed on the positioning fixture of the coating inspection station, so that the coated surface of the optical lens faces the color industrial camera, and the complete optical lens and the background around the outer edge of the optical lens are within the imaging range of the color industrial camera; the coated surface of the optical lens is illuminated with uniform white light, and under the condition that the illumination conditions and camera acquisition parameters remain unchanged, a color image containing the imaging area of ​​the complete lens and the background area around the outer edge of the lens is acquired, and the color image is used as the optical lens coating inspection image.

[0029] The positioning fixture is used to support the optical lens to be inspected and to limit the translation and rotation of the optical lens during the image acquisition process. Keeping the lighting conditions and camera acquisition parameters unchanged means that after the light source arrangement, color industrial camera focusing and camera acquisition parameter adjustment are completed, the position, direction of illumination, illuminance and color temperature of the light source are kept unchanged during the image acquisition process of optical lens coating inspection, and the position, focal length, exposure time, gain and white balance parameters of the color industrial camera are kept unchanged, so as to avoid the change of the imaging color of the optical lens surface caused by the change of shooting conditions.

[0030] The optical lens coating detection image includes a red channel, a green channel, and a blue channel. The red, green, and blue channels record the pixel values ​​of each pixel in the three color components of red, green, and blue, respectively. The lens imaging area is the image area occupied by the optical lens in the optical lens coating detection image. The background area around the outer edge of the lens is the image area located outside the lens imaging area and adjacent to the outer edge of the lens, used to identify the outer edge position of the lens imaging area.

[0031] It should also be noted that the background area around the outer edge of the lens uses a single color and no pattern. The positioning fixture does not obstruct the outer edge of the optical lens, and the imaging area of ​​the positioning fixture in the optical lens coating detection image does not form a closed edge with an area larger than the lens imaging area.

[0032] Furthermore, the optical lens coating detection image is converted into an optical lens brightness image. Edge pixels are extracted based on the brightness change amplitude of adjacent pixels in the optical lens brightness image. Edge pixels are connected according to pixel adjacency and the outer contour of the optical lens is filtered. The center point of the lens is calculated based on the position of each pixel within the area enclosed by the outer contour of the optical lens.

[0033] Specifically, an image coordinate system is established with the top-left pixel of the optical lens coating detection image as the origin, the horizontal direction to the right as the positive direction of the x-axis, and the vertical direction downward as the positive direction of the y-axis. The arithmetic mean of the red channel pixel value, green channel pixel value, and blue channel pixel value of each pixel in the optical lens coating detection image is calculated. The arithmetic mean is used as the pixel brightness value. The pixel brightness values ​​are arranged according to the position of each pixel in the image coordinate system to obtain the optical lens brightness image.

[0034] For each pixel in the brightness image of the optical lens, excluding the pixels on the outermost image row and the outermost image column, calculate the brightness difference amplitude between adjacent pixels on both sides in the horizontal direction and the brightness difference amplitude between adjacent pixels on both sides in the vertical direction. The sum of the brightness difference amplitudes in the two directions is taken as the brightness change amplitude of the current pixel. The brightness change amplitude is used to reflect the degree of brightness change around the current pixel. The larger the brightness change amplitude, the more obvious the brightness change around the current pixel.

[0035] The brightness variation amplitude of each pixel in the optical lens brightness image, excluding those in the outermost row and column, is statistically analyzed and arranged in ascending order. If only one brightness variation amplitude is found, the current optical lens coating detection image is deemed not to meet the edge recognition criteria, and further processing of the current optical lens coating detection image is stopped. If more than one brightness variation amplitude is found, the arithmetic mean of two adjacent brightness variation amplitudes in the sorted image is calculated, and each arithmetic mean is used sequentially as a candidate segmentation value. Pixels participating in the statistical analysis are then classified according to their brightness variation amplitude, with each candidate segmentation value less than the candidate segmentation value. The first pixel group and the second pixel group whose brightness change amplitude is not less than the candidate segmentation value are used to calculate the first ratio of the number of pixels in the first pixel group to the total number of pixels involved in the statistics, the second ratio of the number of pixels in the second pixel group to the total number of pixels involved in the statistics, the arithmetic mean of the brightness change amplitude of the first pixel group and the arithmetic mean of the brightness change amplitude of the second pixel group. The first ratio and the second ratio are multiplied together, and the resulting product is multiplied by the square of the difference between the arithmetic mean of the brightness change amplitude of the first pixel group and the second pixel group to obtain the inter-class variance. The inter-class variance is used to reflect the difference in brightness change between the first pixel group and the second pixel group.

[0036] The candidate segmentation value with the largest inter-class variance is used as the edge segmentation value. When the inter-class variances corresponding to two or more candidate segmentation values ​​are the same and are both the maximum values, the candidate segmentation value with the larger value is used as the edge segmentation value to reduce the number of image pixels with low brightness change amplitude being identified as edge pixels. Pixels with brightness change amplitude not less than the edge segmentation value are used as edge pixels to distinguish between image areas with gentle brightness changes and edge positions with obvious brightness changes.

[0037] Furthermore, an eight-neighbor edge tracking method is used to connect adjacent edge pixels, and edge pixels are recorded sequentially in a clockwise direction. When the edge tracking passes the starting edge pixel again and continues to connect along the first tracking direction, the edge pixel sequence that is connected end to end is taken as a closed edge. When the next edge pixel cannot be found, the edge pixel sequence that is not connected end to end is excluded. All edge pixels are processed to obtain each closed edge. When no closed edge is obtained, it is determined that the current optical lens coating detection image does not meet the optical lens outer contour recognition conditions, and subsequent processing of the current optical lens coating detection image is stopped.

[0038] Scan each closed edge line by line in the image. Pixels located between the left and right intersection points of the closed edges in the same image line are included in the enclosed area of ​​the closed edge. The number of pixels within the enclosed area of ​​each closed edge is counted. When only one closed edge has the largest number of enclosed pixels, the closed edge with the largest number of enclosed pixels is taken as the outer contour of the optical lens. When two or more closed edges have the same number of enclosed pixels and both have the largest number, it is determined that the current optical lens coating detection image cannot uniquely determine the outer contour of the optical lens, and subsequent processing of the current optical lens coating detection image is stopped. The outer contour of the optical lens is used to represent the boundary between the lens imaging area and the background area surrounding the lens outer edge.

[0039] Furthermore, the abscissa and ordinate of each pixel within the outer contour of the optical lens are extracted, and the arithmetic mean of all abscissas and all ordinates are calculated. The image position marked by the arithmetic mean of the abscissas and ordinates is used as the center point of the lens. The center point of the lens is used to represent the center position of the lens imaging area in the optical lens coating detection image.

[0040] It should be noted that in this embodiment, the optical lens coating layer covers the central area of ​​the lens, and the outer edge of the coating layer is distributed around the center point of the lens. Each radial sampling line intersects the outer edge of the coating layer once from the center point of the lens to the outer contour of the optical lens.

[0041] Furthermore, taking the center point of the lens as a common starting point, radial sampling lines are established along different angular positions to the outer contour of the optical lens. The color channel pixel values ​​of the pixels passed through each radial sampling line are extracted to obtain a radial color pixel sequence. Based on the degree of color dispersion on both sides of the candidate segmentation position in the radial color pixel sequence, a color transition position is extracted on the radial sampling line that can form a unique color segmentation position.

[0042] Specifically, taking the positive direction of the horizontal coordinate of the image coordinate system as the starting direction of the angular direction, the direction of the line connecting the center point of the lens to the contour pixels on the outer contour of the optical lens is taken as the angular position; the angular position represents the angle formed by rotating the line direction clockwise relative to the starting direction of the angular direction, with a value range of zero degrees to less than 360 degrees; the line segment between the center point of the lens and the contour pixels is taken as the radial sampling line; when two or more contour pixels have the same angular position as the line connecting them to the center point of the lens, the distance between each contour pixel and the center point of the lens is compared, and the contour pixel with the largest distance is taken as the endpoint of the radial sampling line, so that each angular position retains a radial sampling line.

[0043] Along each radial sampling line, starting from the center point of the lens, sampling positions are set sequentially at radial intervals of one pixel. The x and y coordinates of each sampling position are rounded to integer pixel coordinates, duplicate integer pixel coordinates are excluded, and the integer pixel coordinates are arranged in ascending order of distance from the center point of the lens. The red channel pixel value, green channel pixel value, and blue channel pixel value of each pixel position after arrangement are extracted sequentially to obtain the radial color pixel sequence. The radial color pixel sequence is used to record the color changes of each pixel from the center point of the lens to the outer contour of the optical lens.

[0044] Furthermore, when the radial color pixel sequence contains fewer than four pixels, the current radial sampling line does not form candidate segmentation positions, and color transition positions are not extracted; when the radial color pixel sequence contains at least four pixels, the separation positions between two adjacent pixels in the radial color pixel sequence are sequentially used as candidate segmentation positions, and candidate segmentation positions that result in fewer than two pixels on either side are excluded; through each candidate segmentation position, the radial color pixel sequence is divided into a lens center point side pixel segment and an optical lens outer contour side pixel segment; all pixels located on the side of the lens center point direction of the candidate segmentation position are used as the lens center point side pixel segment, and all pixels located on the side of the optical lens outer contour direction of the candidate segmentation position are used as the optical lens outer contour side pixel segment; at least two pixels are reserved on both sides of the candidate segmentation position to ensure that the color channel arithmetic mean and color dispersion of the lens center point side pixel segment and the optical lens outer contour side pixel segment are calculated by multiple pixels, avoiding a single end pixel directly determining the color segmentation position.

[0045] Calculate the arithmetic mean of the red, green, and blue channel pixel values ​​in the pixel segment at the center point of the lens. For each pixel in the pixel segment at the center point of the lens, calculate the squared difference between the red channel pixel value and the arithmetic mean of the red channel pixel value, the squared difference between the green channel pixel value and the arithmetic mean of the green channel pixel value, and the squared difference between the blue channel pixel value and the arithmetic mean of the blue channel pixel value. Sum the three squared differences as the pixel color deviation. Sum the color deviations of all pixels in the pixel segment at the center point of the lens as the color dispersion at the center point of the lens. Following the calculation process for the color dispersion at the center point of the lens, calculate the color dispersion at the outer contour of the optical lens. The color dispersion reflects the overall deviation of each pixel within the same pixel segment from the average color of the pixel segment. The smaller the color dispersion, the more concentrated the color distribution of each pixel within the pixel segment.

[0046] The sum of the color dispersion on the lens center side and the color dispersion on the optical lens outer contour side is calculated for each candidate segmentation position, and the result is used as the candidate segmentation color dispersion. The candidate segmentation color dispersion of each candidate segmentation position is compared, and the candidate segmentation position with the smallest color dispersion is selected as the color segmentation position. When the candidate segmentation color dispersion of two or more candidate segmentation positions is the same and all are minimum values, the sum of the difference amplitudes of the red channel pixel values, green channel pixel values, and blue channel pixel values ​​of the adjacent pixels on both sides of each candidate segmentation position is calculated. When only one candidate segmentation position has the largest sum of difference amplitudes, the candidate segmentation position with the largest sum of difference amplitudes is selected as the color segmentation position. When the sum of the difference amplitudes of two or more candidate segmentation positions is the same and all are maximum values, the current radial sampling line does not form a color segmentation position. For radial sampling lines that form color segmentation positions, the pixel positions of the adjacent pixels on both sides of the color segmentation position located on the optical lens outer contour side are selected as color transition positions. The color transition positions are used to represent the pixel positions where the color distribution on the lens center side of the radial color pixel sequence changes to the color distribution on the optical lens outer contour side.

[0047] All radial sampling lines are processed using the same color transition position extraction process, and the color transition positions on each radial sampling line are summarized to form the color segmentation position, thus obtaining all color transition positions.

[0048] Furthermore, when the number of color transition positions is less than three, the current optical lens coating detection image is determined not to meet the coating boundary formation condition, and subsequent processing of the current optical lens coating detection image is stopped. When the number of color transition positions is not less than three, the color transition positions are arranged in ascending order of angular position according to the angular position of the radial sampling line where each color transition position is located. Adjacent angular color transition positions are connected sequentially by straight line segments, where adjacent angular color transition positions refer to two adjacent color transition positions in the angular sequence. Then, the first and last color transition positions in the angular sequence are connected by straight line segments, forming a closed boundary. When the center point of the lens is within the closed boundary, the closed boundary is used as the coating boundary. When the center point of the lens is not within the closed boundary, the current optical lens coating detection image is determined not to meet the coating boundary formation condition, and subsequent processing of the current optical lens coating detection image is stopped. The coating boundary represents the boundary of the area formed by the color transition positions on each radial sampling line along the angular direction.

[0049] Image pixels on the coating boundary and image pixels within the area enclosed by the coating boundary and located within the outer contour of the optical lens are defined as the effective coating area. The effective coating area represents the range of image pixels defined by the coating boundary and located within the outer contour of the optical lens, and is used to define the range of image pixels that participate in the rearrangement when generating the coating area unfolded map.

[0050] S2. Sample the effective coating area according to the angular and radial sampling positions relative to the center point of the lens. Rearrange the effective coating area pixels associated with each sampling position according to the arrangement order of each angular sampling position and each radial sampling position to form a coating area unfolded diagram. Record the coordinate transformation relationship between each pixel in the coating area unfolded diagram and the effective coating area pixels in the optical lens coating detection image.

[0051] Furthermore, all color transition positions are counted to obtain the total number of color transition positions; the ratio of 360 degrees to the total number of color transition positions is used as the angular sampling interval, with zero degrees as the first angular sampling position, and the same number of angular sampling positions as the total number of color transition positions are set in a clockwise direction according to the angular sampling interval, so that the last angular sampling position is less than 360 degrees; starting from the center point of the lens, a radial sampling ray is established along the direction represented by each angular sampling position, and the radial sampling range is defined according to the intersection of the radial sampling ray and the coating boundary; the pixel column coordinates of the coating area unfolded map are set according to the arrangement order of each angular sampling position, and the pixel row coordinates of the coating area unfolded map are set according to the arrangement order of each radial sampling position.

[0052] Specifically, the angular sampling positions are arranged in ascending order of the angle represented by each angular sampling position. The sequence number starting from zero is used as the pixel column coordinate of the unfolded map of the coating area, so that each angular sampling position forms a pixel column. The angular sampling position represents the sampling angle formed by rotating clockwise relative to the positive direction of the horizontal coordinate of the image coordinate system. The number of angular sampling positions is the same as the total number of color transition positions, so that the number of pixel columns in the unfolded map of the coating area is consistent with the total number of color transition positions forming the coating boundary. The radial sampling ray is a ray that starts from the center point of the lens and extends outward along the direction represented by the angular sampling position.

[0053] Calculate the intersection points of each radial sampling ray with each straight line segment constituting the coating boundary; when the radial sampling ray passes through the common endpoint of two adjacent straight line segments, making the two adjacent straight line segments form an intersection point with the same coordinates, it is recorded only once; when the current radial sampling ray does not form an intersection point with the coating boundary, it is determined that the current optical lens coating detection image does not meet the conditions for generating the coating area unfolded map, and subsequent processing of the current optical lens coating detection image is stopped; when the current radial sampling ray forms at least one intersection point with the coating boundary, the intersection point with the smallest distance from the lens center point is taken as the radial termination position of the current angular sampling position; the radial termination position indicates the coating boundary position first reached when the radial sampling ray extends outward from the lens center point, and the line segment between the lens center point and the radial termination position is taken as the radial sampling range of the current angular sampling position.

[0054] Furthermore, after determining the radial termination position for all angular sampling positions, the arithmetic square root of the sum of the squares of the horizontal and vertical coordinate differences between each radial termination position and the center point of the lens is calculated to obtain the radial termination distance of each angular sampling position. The radial termination distances are compared, and the largest radial termination distance is rounded up. The sum of the rounded result and one is used as the number of radial sampling rows. The number of radial sampling rows is used to determine the total number of pixel rows in the unfolded map of the coating area, and to ensure that the distance between adjacent radial sampling positions within the radial sampling range with the largest radial termination distance is no more than one pixel.

[0055] At each angular sampling position, a number of radial sampling positions are set at equal intervals from the center point of the lens to the radial termination position, equal to the number of radial sampling rows, so that the first radial sampling position is located at the center point of the lens and the last radial sampling position is located at the radial termination position; the arrangement sequence number is set according to the arrangement order of each radial sampling position from the center point of the lens to the radial termination position, and the arrangement sequence number starting from zero is used as the pixel row coordinate of the coating area unfolded map.

[0056] The ratio of each pixel row coordinate to the last pixel row coordinate is used as the radial alignment ratio of the current pixel row; the radial alignment ratio of the first pixel row is zero, the radial alignment ratio of the last pixel row is one, and the radial alignment ratio of the middle pixel rows increases at equal intervals with the pixel row coordinates; the radial alignment ratio represents the relative arrangement position of the radial sampling position between the center point of the lens and the radial termination position.

[0057] Based on the lens center point, radial termination position, and radial arrangement ratio, calculate the source sampling coordinates of each radial sampling position in the optical lens coating detection image; calculate the difference between the abscissa of the radial termination position and the abscissa of the lens center point, and add the product of the abscissa difference and the radial arrangement ratio to the abscissa of the lens center point to obtain the abscissa of the source sampling coordinates; calculate the difference between the ordinate of the radial termination position and the ordinate of the lens center point, and add the product of the ordinate difference and the radial arrangement ratio to the ordinate of the lens center point to obtain the ordinate of the source sampling coordinates.

[0058] It should be noted that the same pixel row represents radial sampling positions with the same radial arrangement ratio under different angular sampling positions, and does not mean that the actual distance between each radial sampling position and the center point of the lens is the same. By unifying the number of radial sampling rows and the radial arrangement ratio under each angular sampling position, radial sampling ranges of different lengths are arranged according to the same number of pixel rows, and together with the pixel columns formed by each angular sampling position, the rectangular pixel position range of the coating area unfolded map is determined.

[0059] Furthermore, within the effective coating area, for each source sampling coordinate, the arithmetic square root of the sum of the squares of the differences in the horizontal and vertical coordinates between the source sampling coordinates and the pixel coordinates of each effective coating area is calculated. The calculation result is used as the coordinate distance, and the effective coating area pixel with the smallest coordinate distance is selected as the source pixel. When the coordinate distances of two or more effective coating area pixels are the same and both are the minimum values, source pixels are selected in ascending order of the vertical and horizontal coordinates, so that each source sampling coordinate is associated with a source pixel. The source pixel is the effective coating area pixel that provides the red channel pixel value, green channel pixel value, and blue channel pixel value to the expanded pixels in the coating area unfolded image.

[0060] Read the red, green, and blue channel pixel values ​​of the source pixel. Write these three color channel pixel values ​​into the pixel position jointly indicated by the pixel column coordinates of the current angular sampling position and the pixel row coordinates of the current radial sampling position to obtain the expanded pixel. The expanded pixel is the image pixel formed by writing the color channel pixel values ​​of the source pixel into the coating area unfolded map according to the ratio of angular sampling position to radial arrangement. Process all radial sampling positions under each angular sampling position in turn to obtain the coating area unfolded map.

[0061] Furthermore, the pixel row coordinates and pixel column coordinates of each expanded pixel are associated with the angular sampling position, radial arrangement ratio, source sampling coordinates, and the horizontal and vertical coordinates of the source pixel in the optical lens coating detection image to obtain the coordinate transformation record of the current expanded pixel; the coordinate transformation records of all expanded pixels are summarized to form a coordinate transformation relationship.

[0062] Wherein, the source sampling coordinates represent the geometric position of the unfolded pixel in the optical lens coating detection image mapped according to the ratio of angular sampling position and radial arrangement; the horizontal and vertical coordinates of the source pixel represent the effective coating area pixel position that actually provides red channel pixel value, green channel pixel value and blue channel pixel value; the coordinate transformation relationship represents the transformation relationship between the position of each unfolded pixel in the coating area unfolded image and the source sampling coordinates and source pixel position in the optical lens coating detection image.

[0063] S3. Extract the red, green and blue channels from the unfolded image of the coating area, calculate the pixel difference amplitude between different color channels to form a color difference image, detect coating defects and identify defect types in the color difference image, and generate coating defect candidate boxes, defect types and candidate box center points.

[0064] Furthermore, the red, green, and blue channel pixel values ​​are extracted from each unfolded pixel in the unfolded image of the coated area. For the same unfolded pixel, the difference between the larger and smaller values ​​of the two color channel pixel values ​​is used to obtain the pixel difference amplitude between the red and green channel pixel values, the red and blue channel pixel values, and the green and blue channel pixel values, respectively. The maximum value of the three pixel difference amplitudes is taken as the color difference intensity value. The color difference intensity values ​​are arranged according to the pixel row coordinates and pixel column coordinates of each unfolded pixel to obtain the color difference image.

[0065] It should be noted that when changes in light intensity cause the pixel values ​​of the red, green, and blue channels to change in the same direction and with similar magnitudes, the impact on the magnitude of the pixel difference between different color channels is less than the impact on the pixel value of a single color channel. The maximum value among the three pixel difference magnitudes is used as the color difference intensity value to retain the most obvious color channel difference when the coating color undergoes local changes.

[0066] Furthermore, the color difference intensity values ​​are arranged according to the pixel rows of the color difference image, the median of the color difference intensity values ​​in each pixel row is calculated, and the median is used as the color difference benchmark for the current pixel row; the difference magnitude between each color difference intensity value and the color difference benchmark of its pixel row is calculated, and the difference magnitude is used as the color difference deviation value.

[0067] It should be noted that this embodiment is used to locate coating defect targets whose color difference intensity values ​​deviate locally from the color difference reference of their respective pixel rows. For any pixel row, the sum of the number of pixels occupied by each coating defect target in the current pixel row is less than half of the total number of pixels in the current pixel row. The same pixel row consists of expanded pixels with the same radial arrangement ratio at different angular sampling positions. Under normal coating conditions, the color difference intensity values ​​of each expanded pixel in the same pixel row are generally close. Using the median of the color difference intensity values ​​in each pixel row as the color difference reference can reduce the influence of a small number of coating defect pixels on the color difference reference. The color difference deviation value is used to reflect the degree of deviation of local pixels from the overall color difference level under the same radial arrangement ratio, and at the same time reflects the local anomalies formed by the increase and decrease of color difference intensity.

[0068] Furthermore, it is determined whether there are more than two possible values ​​for the color difference deviation value of each pixel. When there is only one possible value for the color difference deviation value, the deviation of each pixel from the color difference baseline of its row is the same, and local anomalies cannot be distinguished based on the degree of color difference deviation, so no candidate defective pixels are formed. When there are more than two possible values ​​for the color difference deviation value, the color difference deviation values ​​of each pixel are deduplicated and arranged from smallest to largest. The arithmetic mean of two adjacent color difference deviation values ​​in the sorted sequence is calculated, and each arithmetic mean is used as a candidate color difference segmentation value. Through each candidate color difference segmentation value, the pixels in the color difference image are divided into a first group of difference pixels with a color difference deviation value less than the candidate color difference segmentation value and a second group of difference pixels with a color difference deviation value not less than the candidate color difference segmentation value.

[0069] Calculate the first difference ratio of the number of pixels in the first difference pixel group to the total number of pixels in the color difference image, the second difference ratio of the number of pixels in the second difference pixel group to the total number of pixels in the color difference image, and the arithmetic mean of the color difference deviation values ​​of the first and second difference pixel groups respectively; multiply the first difference ratio by the second difference ratio, and multiply the resulting product by the square of the difference between the arithmetic mean of the color difference deviation values ​​of the first and second difference pixel groups to obtain the inter-class variance of color difference.

[0070] The first difference pixel group is used to represent pixels with a low degree of color difference deviation, and the second difference pixel group is used to represent pixels with a high degree of color difference deviation. The inter-class variance of color difference reflects both the pixel quantity distribution and the difference in the degree of color difference deviation between the two difference pixel groups. The larger the inter-class variance of color difference, the more obvious the separation between the two difference pixel groups.

[0071] The candidate color difference segmentation value with the largest inter-class variance of color difference is used as the color difference segmentation value; when two or more candidate color difference segmentation values ​​form the same inter-class variance of color difference and are both the maximum value, the candidate color difference segmentation value with the larger value is used as the color difference segmentation value, so as to reduce the normal fluctuation pixels with low color difference deviation from being classified as candidate defect pixels.

[0072] Determine the first difference pixel group, the second difference pixel group, the first difference quantity ratio, and the second difference quantity ratio corresponding to the color difference segmentation value.

[0073] The color difference deviation values ​​in the first difference pixel group are deduplicated and sorted from smallest to largest. When the color difference deviation value in the first difference pixel group has only one value, the largest adjacent difference within the first difference group is recorded as zero. When the color difference deviation value in the first difference pixel group has more than two values, the difference between two adjacent color difference deviation values ​​in the sorting is calculated, and the largest difference is taken as the largest adjacent difference within the first difference group. Following the same calculation process for the largest adjacent difference within the first difference group, the largest adjacent difference within the second difference pixel group is calculated.

[0074] Extract the maximum color difference deviation value in the first difference pixel group and the minimum color difference deviation value in the second difference pixel group. Calculate the difference between the minimum color difference deviation value in the second difference pixel group and the maximum color difference deviation value in the first difference pixel group. Use the calculation result as the interval between the discontinuities of the difference groups.

[0075] When the second difference ratio is less than the first difference ratio, and the interval between the discontinuities of the difference groups is greater than the maximum adjacent difference in the first difference group and the maximum adjacent difference in the second difference group, the pixels in the second difference pixel group are selected as candidate defective pixels; when the second difference ratio is not less than the first difference ratio, or the interval between the discontinuities of the difference groups is not greater than the maximum adjacent difference in the first difference group, or the interval between the discontinuities of the difference groups is not greater than the maximum adjacent difference in the second difference group, no candidate defective pixels are formed.

[0076] Furthermore, adjacent candidate defect pixels are connected according to the eight-neighbor relationship. Candidate defect pixels that can be reached pixel by pixel through the candidate defect pixels are included in the same coating defect connected region, and each coating defect connected region is used as a coating defect target.

[0077] The first and last pixel columns of the color difference image represent angularly adjacent positions. Therefore, the first and last pixel columns are connected in an eight-neighborhood according to the angular beginning and end relationship, so that candidate defect pixels that cross the angular starting position are included in the same coating defect connected region.

[0078] Furthermore, for the connected regions of coating defects that do not simultaneously contain the first and last pixel columns of the color difference image, the minimum pixel row coordinates, maximum pixel row coordinates, minimum pixel column coordinates, and maximum pixel column coordinates of the candidate defect pixels are counted, and the rectangular range defined by the four boundary coordinates is used as the candidate box for coating defects.

[0079] For a connected region of coating defects that simultaneously contains the first and last pixel columns of a color difference image, the pixel column coordinates of each candidate defect pixel in the connected region are extracted. The pixel column coordinates are deduplicated and arranged in ascending order. The difference between two adjacent pixel column coordinates is calculated, and the difference between the sum of the first pixel column coordinate and the total number of pixel columns in the color difference image and the last pixel column coordinate is used as the cyclic column coordinate difference. The difference between two adjacent pixel column coordinates is compared with the cyclic column coordinate difference, and the largest difference is taken as the maximum cyclic column interval. When two or more differences are the same and both are maximum values, the occupied pixel column coordinates after each maximum difference are compared, and the maximum difference containing the smallest occupied pixel column coordinate is taken as the maximum cyclic column interval. The occupied pixel column coordinates after the cyclic column coordinate difference are taken as the first pixel column coordinate. The occupied pixel column coordinates after the maximum circular column interval are used as the starting pixel column coordinates for adjustment. The pixel column coordinates of candidate defect pixels smaller than the starting pixel column coordinates are added to the total number of pixel columns in the color difference image, while keeping the pixel column coordinates of the remaining candidate defect pixels unchanged, so that the pixel column coordinates occupied by the connected region of the coating defect form a continuous pixel column coordinate interval. The minimum and maximum pixel column coordinates after adjustment are counted, and the minimum and maximum pixel row coordinates are combined to form the candidate box of coating defect. At the same time, the cross-column boundary marker is recorded. The cross-column boundary marker indicates that the candidate box of coating defect spans the first and last pixel columns of the color difference image.

[0080] Furthermore, the pixel structure of each connected region of coating defects is refined.

[0081] Candidate defect pixels that contain non-candidate defect pixels within their eight neighboring regions are designated as boundary pixels; the range of pixels located within the coating defect candidate box and that cannot reach the boundary of the coating defect candidate box through adjacent non-candidate defect pixels in the horizontal or vertical direction are designated as closed background regions.

[0082] The boundary pixels are checked in ascending order of row coordinates and in ascending order of column coordinates within the same row. If the current boundary pixel has two or more eight-neighbor pixels in the connected region of the coating defect, and the connected region of the coating defect remains connected to eight neighbors and the number of closed background regions remains unchanged after deleting the current boundary pixel, the current boundary pixel is deleted. After completing one round of boundary pixel checks, the boundary pixels are re-determined until no boundary pixels are deleted in one round of boundary pixel checks. The remaining candidate defect pixels are used as thinning pixels to obtain the defect thinning structure. The connected region of the coating defect that records the cross-column boundary mark is used to refine the pixel structure using the adjusted pixel column coordinates.

[0083] In the defect refinement structure, the refinement pixel adjacent to only one refinement pixel is designated as the endpoint, and the refinement pixel adjacent to three or more refinement pixels is designated as the branch point. When the connected region of the coating defect contains only one candidate defect pixel, the defect type is identified as a dot defect. When the connected region of the coating defect contains two or more candidate defect pixels and the defect refinement structure has branch points, the defect type is identified as a branch defect. When the connected region of the coating defect has a closed background region and the defect refinement structure has no endpoints or branch points, the defect type is identified as a ring defect. When the connected region of the coating defect has no closed background region, the defect refinement structure has no branch points, and the number of endpoints is two, the defect type is identified as a strip defect. The defect type of the remaining connected regions of the coating defect is identified as a planar defect.

[0084] It should be noted that the defect type refers to the image morphology of the coating defect target in the color difference image, including dot defects, ring defects, branch defects, strip defects and surface defects, and does not indicate the cause of the coating defect target.

[0085] Furthermore, the arithmetic mean of the minimum and maximum pixel row coordinates of the candidate boxes for coating defects is calculated to obtain the pixel row coordinates of the center point of the candidate box.

[0086] For candidate boxes of coating defects that do not record cross-column boundary markers, the arithmetic mean of the minimum and maximum pixel column coordinates is calculated to obtain the pixel column coordinates of the candidate box center point. For candidate boxes of coating defects that record cross-column boundary markers, the arithmetic mean of the adjusted minimum and maximum pixel column coordinates is calculated to obtain the adjusted pixel column coordinates of the candidate box center point. When the adjusted pixel column coordinates of the candidate box center point are not less than the total number of pixel columns in the color difference image, the difference between the adjusted pixel column coordinates of the candidate box center point and the total number of pixel columns in the color difference image is used as the pixel column coordinates of the candidate box center point; otherwise, the adjusted pixel column coordinates of the candidate box center point are used as the pixel column coordinates of the candidate box center point.

[0087] Each candidate box for coating defects is associated with the defect type and the center point of the candidate box in the same connected region of the coating defect; when there are no candidate defect pixels in the color difference image, the candidate box for coating defects, the defect type, and the center point of the candidate box are all empty.

[0088] S4. Based on the coordinate transformation relationship, the candidate box of coating defects and the center point of the candidate box are mapped back to the optical lens coating detection image to obtain the coordinates of the coating defect location box and the center point of the candidate box. Based on the positional relationship between the coordinates of the center point of the candidate box and the center point of the lens, the optical lens coating defect location result including radial position, angular position and defect type is formed.

[0089] Furthermore, for each candidate box for coating defects, the pixel positions covered by the candidate box are determined based on the pixel row coordinate range and pixel column coordinate range of the candidate box. The coordinate transformation relationship is queried based on the pixel row coordinate and pixel column coordinate of each pixel position, and the source pixel horizontal coordinate and source pixel vertical coordinate associated with each pixel position are extracted.

[0090] It should be noted that each pixel in the color difference image uses the same row and column coordinates as each expanded pixel in the coating area unfolded image. Therefore, the pixel positions covered by the coating defect candidate box can be used to query the coordinate transformation records of each expanded pixel in the coating area unfolded image.

[0091] For candidate boxes of coating defects that do not record cross-column boundary markers, the minimum pixel row coordinate to the maximum pixel row coordinate of the candidate box of coating defects is taken as the pixel row coordinate range, and the minimum pixel column coordinate to the maximum pixel column coordinate is taken as the pixel column coordinate range. The source pixel horizontal coordinate and source pixel vertical coordinate associated with each pixel position covered by the candidate box of coating defects are queried in turn.

[0092] For candidate bounding boxes of coating defects that record cross-column boundary markers, the range of pixel row coordinates (from the minimum to the maximum pixel row coordinates) is used as the range of pixel row coordinates, and the range of adjusted minimum to maximum pixel column coordinates is used as the range of adjusted pixel column coordinates. When the adjusted pixel column coordinates are not less than the total number of pixel columns in the color difference image, the difference between the adjusted pixel column coordinates and the total number of pixel columns in the color difference image is used as the query pixel column coordinates. When the adjusted pixel column coordinates are less than the total number of pixel columns in the color difference image, the adjusted pixel column coordinates are used as the query pixel column coordinates. Based on the transformation relationship between pixel row coordinates and query pixel column coordinates, the source pixel x-coordinates and source pixel y-coordinates associated with each pixel position covered by the coating defect candidate bounding box are extracted.

[0093] By comparing the x-coordinates and y-coordinates of each source pixel associated with the same candidate box for coating defects, the minimum x-coordinate, maximum x-coordinate, minimum y-coordinate, and maximum y-coordinate of the source pixel are obtained. The rectangular range formed by the horizontal range defined by the minimum x-coordinate to the maximum x-coordinate and the vertical range defined by the minimum y-coordinate to the maximum y-coordinate is used as the coating defect location box. The coating defect location box is used to mark the bounding rectangle range formed by the mapping of the candidate box for coating defects in the optical lens coating inspection image.

[0094] Furthermore, based on the pixel row coordinates and pixel column coordinates of the candidate box center point, the source sampling coordinates associated with the expanded pixels around the candidate box center point are extracted from the coordinate transformation relationship, and linear interpolation is performed on each source sampling coordinate to obtain the mapped coordinates of the candidate box center point.

[0095] Specifically, the pixel row coordinates of the candidate box center point are rounded down and up to obtain the smaller and larger pixel row coordinates; the pixel column coordinates of the candidate box center point are rounded down and up to obtain the smaller and larger pixel column coordinates; when the pixel row coordinates of the candidate box center point are integers, the smaller and larger pixel row coordinates are the same; when the pixel column coordinates of the candidate box center point are integers, the smaller and larger pixel column coordinates are the same.

[0096] The smaller pixel column coordinate is used as the smaller query pixel column coordinate; when the larger pixel column coordinate is less than the total number of pixel columns in the color difference image, the larger pixel column coordinate is used as the larger query pixel column coordinate; when the larger pixel column coordinate is equal to the total number of pixel columns in the color difference image, the larger pixel column coordinate is retained to determine the column interpolation position, and zero is used as the larger query pixel column coordinate, so that the last pixel column and the first pixel column participate in the candidate box center point mapping according to the angular head-to-tail connection relationship.

[0097] Based on the smaller pixel row coordinates, larger pixel row coordinates, smaller query pixel column coordinates, and larger query pixel column coordinates, the source sampling coordinates associated with each pixel position are extracted from the coordinate transformation relationship. Based on the relative position of the candidate box center point's pixel column coordinates between the smaller and larger pixel column coordinates, linear interpolation is performed on the x and y coordinates of the two source sampling coordinates under the smaller pixel row coordinates to obtain the smaller pixel row interpolated coordinates. Similarly, linear interpolation is performed on the x and y coordinates of the two source sampling coordinates under the larger pixel row coordinates to obtain the larger pixel row interpolated coordinates. Based on the relative position of the candidate box center point's pixel row coordinates between the smaller and larger pixel row coordinates, linear interpolation is performed on the x and y coordinates of both the smaller and larger pixel row interpolated coordinates. The interpolated x and y coordinates are then used as the mapped coordinates of the candidate box center point.

[0098] When the column coordinates of the smaller pixel are the same as those of the larger pixel, the row-wise linear interpolation is performed directly using the source sampling coordinates associated with the current pixel column; when the row coordinates of the smaller pixel are the same as those of the larger pixel, the column-wise interpolation coordinates of the current pixel row are performed directly; when the row coordinates of the smaller pixel are the same as those of the larger pixel, and the column coordinates of the smaller pixel are the same as those of the larger pixel, the source sampling coordinates associated with the current pixel position are used directly as the coordinates of the candidate box center point.

[0099] It should be noted that the coating defect location box is formed using the source pixel's x-coordinate and y-coordinate recorded in the coordinate transformation relationship, and is used to mark the bounding rectangle range of the coating defect candidate box in the optical lens coating inspection image; the candidate box center point mapping coordinates are linearly interpolated using the source sampling coordinates, and are used to represent the geometric position of the candidate box center point mapped to the optical lens coating inspection image, so as to reduce the center position offset caused by integer source pixel selection; the candidate box center point mapping coordinates do not represent the geometric centroid of all candidate defect pixels in the coating defect target.

[0100] Furthermore, the difference between the x-coordinate of the candidate box center point mapping coordinates and the x-coordinate of the lens center point is calculated to obtain the lateral position difference; the difference between the y-coordinate of the candidate box center point mapping coordinates and the y-coordinate of the lens center point is calculated to obtain the lateral position difference; the arithmetic square root of the sum of the squares of the lateral position difference and the squares of the lateral position difference is calculated, and the result is used as the radial position; the radial position is used to represent the image distance between the candidate box center point mapping coordinates and the lens center point, in pixels.

[0101] Using the positive x-axis direction of the image coordinate system as the starting direction of the angular direction, the horizontal position difference is used as the x-axis component and the vertical position difference is used as the y-axis component to perform a four-quadrant arctangent operation, and the result is converted into an angle. When the converted angle is less than zero degrees, the sum of the converted angle and 360 degrees is used as the angular position, so that the value range of the angular position is from zero degrees to less than 360 degrees. Since the positive y-axis direction of the image coordinate system is vertically downward, the angular position starts from the positive x-axis direction of the image coordinate system and increases in a clockwise direction, which is consistent with the angular direction used for the angular sampling position.

[0102] When the coordinates of the candidate box center point coincide with the center point of the lens, the radial position is recorded as zero pixels; since there is no unique angular direction at the coincident position, the angular position is recorded as zero degrees.

[0103] Furthermore, the coordinates of the center point of each coating defect location frame, the radial position, the angular position, and the defect type associated with each candidate frame are recorded to obtain the location record of a single coating defect target. The location records of each coating defect target are then summarized to form the optical lens coating defect location result.

[0104] When the candidate box for coating defects, the defect type, and the center point of the candidate box are all empty, the result of locating the coating defects of the optical lens is recorded as empty.

[0105] It should also be noted that, to verify that the radial arrangement ratio can uniformly arrange the effective coating areas at different angular sampling positions, and to verify that the color difference deviation value can distinguish local color anomalies from normal color fluctuations, a simulation scenario for locating coating defects in optical lenses was constructed. In the simulation scenario, multiple optical lens coating inspection images were generated, with the outer contour of the optical lens, the center point of the lens, the lighting conditions, and the camera acquisition parameters using normal values. Coating boundaries distributed around the center point of the lens were set within the outer contour of the optical lens, so that the radial termination distance differed at different angular sampling positions, and locally distributed coating defect targets were set within the effective coating area. After the optical lens coating inspection image is processed by this invention, the coating boundary and effective coating area are formed according to the color transition position. The coating area unfolding diagram is formed according to the angular sampling position, radial sampling position and radial arrangement ratio, and the coordinate transformation relationship is recorded. Then, a color difference image is formed according to the color difference intensity value, color difference reference and color difference deviation value. Candidate defect pixels are screened, coating defect candidate boxes, defect type and candidate box center point are generated, and the candidate box center point mapping coordinates, radial position and angular position are formed according to the coordinate transformation relationship.

[0106] Figure 5 This is used to demonstrate the relationship between the radial arrangement ratio and the radial position at different angular sampling positions. Figure 5 In the diagram, the horizontal axis represents the radial arrangement ratio, and the vertical axis represents the radial position, with units in pixels. Solid dot circles, dashed squares, dotted triangles, and dotted rhombuses represent the radial position changes at 0°, 90°, 180°, and 270° angular sampling positions, respectively. From... Figure 5 It can be seen that, at different angular sampling positions, the radial position continuously increases with the increase of the radial arrangement ratio, indicating that the radial sampling positions from the lens center point to the radial termination position can be stably arranged according to the radial arrangement ratio. The curves at different angular sampling positions have different heights, indicating that the coordinate transformation relationship preserves the actual differences in the radial termination distance at different angular sampling positions. Therefore, it can be seen that this invention does not simply treat the effective coating area as a fixed radius region, but rather forms a coating area unfolded diagram through angular sampling positions, radial sampling positions, and the radial arrangement ratio, and obtains the candidate box center point mapping coordinates through coordinate transformation relationships. This allows the color change of the circular coating area to be characterized under a unified arrangement, while simultaneously forming both radial and angular positions.

[0107] Figure 6 Used to display the relationship between the color difference intensity value, color difference baseline, and color difference deviation value within the same pixel row. Figure 6 In the diagram, the horizontal axis represents the pixel column coordinates, and the vertical axis represents the pixel difference magnitude; solid lines represent color difference intensity values, dashed lines represent color difference baselines, dotted lines represent color difference deviation values, and hollow circles represent the pixel positions identified as candidate defective pixels. Figure 6 It can be seen that within the normal coating area, the color difference intensity value fluctuates slightly and continuously around the color difference reference, while the color difference deviation value remains within a low range. At the location of the local coating defect target, the color difference intensity value deviates significantly from the color difference reference, with local peaks appearing in the color difference deviation value, and candidate defect pixels concentrated at these local peaks. Therefore, this invention characterizes local color changes through color difference intensity value, color difference reference, and color difference deviation value. By combining the proportion of different pixel groups, the maximum adjacent difference within a group, and the interval between discontinuities in different groups to screen candidate defect pixels, it can distinguish local color anomalies from normal color fluctuations and provide a continuous basis of candidate defect pixels for forming connected regions of coating defects.

[0108] In summary, this invention reconstructs the effective coating area by using angular sampling positions, radial sampling positions, and radial arrangement ratios, and maps the candidate boxes for coating defects and their center points to the optical lens coating detection image using coordinate transformation relationships, thereby achieving a unified representation of color changes in circular coating areas and radial and angular localization; it characterizes local color changes by using color difference intensity values, color difference benchmarks, and color difference deviation values, and filters candidate defect pixels by combining the proportion of different pixel groups, the maximum adjacent difference within a group, and the interval between discontinuities in different groups, thereby achieving the distinction between local color anomalies and normal color fluctuations and the continuous identification of coating defect targets.

[0109] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for locating coating defects in optical lenses based on target detection, characterized in that, include: Acquire images of optical lens coating detection, identify the outer contour of the optical lens and calculate the center point of the lens, extract color transition positions along the direction from the center point of the lens to the outer contour of the optical lens, connect each color transition position in angular order to form the coating boundary, and use the image pixel range defined by the coating boundary as the effective coating area. The process of identifying the outer contour of the optical lens and calculating the lens center point includes: The optical lens coating detection image is converted into an optical lens brightness image. The brightness change amplitude of each pixel in the optical lens brightness image is calculated. Different brightness change amplitudes are sorted, and the arithmetic mean of two adjacent brightness change amplitudes is used as a candidate segmentation value. The pixels are divided into a first pixel group and a second pixel group by each candidate segmentation value. The inter-class variance is obtained by multiplying the product of the pixel number ratio of each of the two pixel groups by the square of the difference between the arithmetic mean of the brightness change amplitudes of the two pixel groups. The candidate segmentation value with the largest inter-class variance is used as the edge segmentation value, and the pixels with a brightness change amplitude not less than the edge segmentation value are used as edge pixels. Connect edge pixels according to the eight-neighbor relationship to form a closed edge. The closed edge with the most enclosed pixels is taken as the outer contour of the optical lens. The position marked by the arithmetic mean of the horizontal coordinate and the arithmetic mean of the vertical coordinate of each pixel within the enclosed area of ​​the outer contour of the optical lens is taken as the center point of the lens. The effective coating area is sampled according to the angular and radial sampling positions relative to the center point of the lens. The effective coating area pixels associated with each sampling position are rearranged according to the arrangement order of each angular sampling position and each radial sampling position to form a coating area unfolded map. The coordinate transformation relationship between each pixel in the coating area unfolded map and the effective coating area pixels in the optical lens coating detection image is recorded. The red, green and blue channels are extracted from the unfolded image of the coating area. The pixel difference amplitude between different color channels is calculated to form a color difference image. Coating defects are detected and the defect type is identified in the color difference image. Candidate boxes for coating defects, defect types and candidate box center points are generated. Based on the coordinate transformation relationship, the candidate box of coating defects and the center point of the candidate box are mapped back to the optical lens coating detection image to obtain the coordinates of the coating defect location box and the center point of the candidate box. Based on the positional relationship between the coordinates of the center point of the candidate box and the center point of the lens, the optical lens coating defect location result including radial position, angular position and defect type is formed.

2. The method for locating optical lens coating defects based on target detection as described in claim 1, characterized in that, The step of extracting color transition positions along the direction from the center point of the lens to the outer contour of the optical lens, connecting each color transition position in angular order to form the coating boundary, and using the image pixel range defined by the coating boundary as the effective coating area includes: Starting from the center point of the lens, radial sampling lines are established along different angular positions to the outer contour of the optical lens. The red channel pixel value, green channel pixel value and blue channel pixel value of each pixel passed through the radial sampling line are extracted to obtain the radial color pixel sequence. The separation positions between adjacent pixels in the radial color pixel sequence are used as candidate segmentation positions. The radial color pixel sequence is divided into a pixel segment on the lens center point side and a pixel segment on the outer contour side of the optical lens through each candidate segmentation position. The sum of the squares of the differences between the pixel values ​​of each color channel in the two pixel segments and the arithmetic mean of the corresponding color channel pixel values ​​are used as the color dispersion degree on the lens center point side and the color dispersion degree on the outer contour side of the optical lens. The candidate segmentation position with the smallest sum of the two color dispersion degrees is used as the color segmentation position, and the position of the adjacent pixel on the outer contour side of the color segmentation position is used as the color transition position. Connect each color transition position sequentially according to the angular position of the radial sampling line, and connect the first color transition position with the last color transition position to form the coating boundary; the image pixels on the coating boundary and the image pixels within the area enclosed by the coating boundary and located within the outer contour of the optical lens are taken as the effective coating area.

3. The method for locating optical lens coating defects based on target detection as described in claim 2, characterized in that, The sampling of the effective coating area according to the angular and radial sampling positions relative to the center point of the lens includes: Count all color transition positions to obtain the total number of color transition positions. Use the ratio of 360 degrees to the total number of color transition positions as the angular sampling interval. Take 0 degrees as the first angular sampling position and set the same number of angular sampling positions as the total number of color transition positions in a clockwise direction according to the angular sampling interval. Establish a radial sampling ray along each angular sampling position with the center point of the lens as the starting point. Take the intersection point of the radial sampling ray and the coating boundary that is closest to the center point of the lens as the radial termination position. Calculate the radial termination distance between each radial termination position and the center point of the lens. Round the maximum radial termination distance up and add it to one to obtain the number of radial sampling rows. Radial sampling positions are set at equal intervals between the center point of the lens and each radial termination position. The pixel column coordinates and pixel row coordinates of the unfolded image of the coating area are set according to the arrangement order of the angular sampling positions and the radial sampling positions. The ratio of each pixel row coordinate to the last pixel row coordinate is used as the radial arrangement ratio. Based on the radial arrangement ratio, linear interpolation is performed on the horizontal and vertical coordinates between the center point of the lens and the radial termination position to obtain the source sampling coordinates.

4. The method for locating optical lens coating defects based on target detection as described in claim 3, characterized in that, The process of rearranging the effective coating area pixels associated with each sampling position according to the arrangement order of each angular sampling position and each radial sampling position to form a coating area unfolded map, and recording the coordinate transformation relationship between each pixel in the coating area unfolded map and the effective coating area pixels in the optical lens coating detection image includes: Based on the coordinate distance between the source sampling coordinates and the pixel coordinates of each effective coating area, the effective coating area pixel with the smallest coordinate distance is taken as the source pixel. The red channel pixel value, green channel pixel value, and blue channel pixel value of the source pixel are written into the pixel position jointly indicated by the pixel column coordinates of the current angular sampling position and the pixel row coordinates of the current radial sampling position to obtain the expanded pixel. The expanded pixels are then summarized to form the coating area unfolded map. The pixel row coordinates and pixel column coordinates of each expanded pixel are associated with the source sampling coordinates and the horizontal and vertical coordinates of the source pixel in the optical lens coating detection image to form a coordinate transformation relationship.

5. The method for locating optical lens coating defects based on target detection as described in claim 3, characterized in that, The step of extracting the red, green, and blue channels from the unfolded image of the coated area, calculating the pixel difference magnitude between different color channels, and forming a color difference image includes: Calculate the pixel difference magnitude between each pair of red, green and blue channel pixel values ​​in the unfolded image of the coated area. Take the maximum value of the three pixel difference magnitudes as the color difference intensity value, and arrange the color difference intensity values ​​according to the pixel row coordinates and pixel column coordinates to form a color difference image. The median of the color difference intensity value of each pixel row is used as the color difference benchmark, and the magnitude of the difference between each color difference intensity value and the color difference benchmark of its respective pixel row is used as the color difference deviation value.

6. The method for locating optical lens coating defects based on target detection as described in claim 5, characterized in that, The detection of coating defects in color difference images includes: Arrange the different color difference deviation values ​​from smallest to largest, and use the arithmetic mean of adjacent values ​​as the candidate color difference segmentation value. Pixels with color difference deviation values ​​less than and not less than the candidate color difference segmentation value are respectively assigned to the first difference pixel group and the second difference pixel group. Multiply the product of the pixel count ratio of each of the two difference pixel groups by the square of the difference between the arithmetic mean of the color difference deviation values ​​of the two difference pixel groups to obtain the inter-class variance of color difference, and use the candidate color difference segmentation value with the largest inter-class variance of color difference as the color difference segmentation value. The maximum difference between adjacent different values ​​in two groups of different color difference segments is taken as the maximum adjacent difference in the first and second groups of different color difference segments, respectively, and is recorded as zero when a single value is taken. The difference between the minimum color difference deviation in the second group of different color difference segments and the maximum color difference deviation in the first group of different color difference segments is taken as the interval between the discontinuities of the different color difference segments. When the proportion of pixels in the second group of different color difference segments is less than that in the first group of different color difference segments, and the interval between the discontinuities of the different color difference segments is greater than the maximum adjacent difference in the first and second groups of different color difference segments, the pixels in the second group of different color difference segments are taken as candidate defective pixels. Candidate defect pixels are connected according to the eight-neighbor relationship, and the first and last pixel columns of the color difference image are connected according to the angular head-to-tail relationship to form a coating defect connected region. Each coating defect connected region is used as the coating defect target.

7. The method for locating optical lens coating defects based on target detection as described in claim 6, characterized in that, The process of identifying defect types and generating candidate boxes for coating defects, defect types, and candidate box center points includes: Candidate boxes for coating defects are formed based on the extreme values ​​of the row and column coordinates of the candidate defect pixels in the connected region of the coating defect. For a connected region of coating defects that simultaneously contains the first and last column of pixels of the color difference image, the column coordinates of the candidate defect pixels are deduplicated and arranged from smallest to largest. The difference between the sum of the first column coordinate and the total number of columns of pixels in the color difference image and the last column coordinate is used as the difference of the circular column coordinate. The difference between the column coordinates of adjacent pixels is compared with the difference of the circular column coordinate. The column coordinate of the occupied pixels after the largest difference is used as the starting column coordinate of the adjustment. The column coordinates of pixels smaller than the starting column coordinate of the adjustment are added to the total number of columns of pixels in the color difference image to form the candidate boxes for coating defects. While maintaining the number of eight-neighbor connected regions and closed background regions in the connected region of coating defects, boundary pixels are iteratively deleted to obtain the defect refinement structure. Refinement pixels adjacent to only one refinement pixel are taken as endpoints, and refinement pixels adjacent to three or more refinement pixels are taken as branch points. When the connected region of coating defects contains only one candidate defect pixel, has branch points, has closed background regions but no endpoints or branch points, or has no closed background regions and branch points but has two endpoints, the defect type is identified as point defects, branch defects, ring defects, or strip defects, respectively. The defect type of the remaining connected regions of coating defects is identified as surface defects. The arithmetic mean of the extreme values ​​of the pixel row coordinates of the candidate box for coating defects is used as the pixel row coordinate of the candidate box center point, and the arithmetic mean of the extreme values ​​of the pixel column coordinates is used as the pixel column coordinate of the candidate box center point. When crossing the first and last pixel columns, the adjusted extreme values ​​of the pixel column coordinates are used to calculate the pixel column coordinate of the candidate box center point, and the total number of pixel columns of the color difference image is subtracted when the calculation result is not less than the total number of pixel columns of the color difference image. The candidate box for coating defects, the defect type and the candidate box center point are associated.

8. The method for locating optical lens coating defects based on target detection as described in claim 4, characterized in that, The step of mapping the candidate bounding box of coating defects and the center point of the candidate bounding box back to the optical lens coating detection image according to the coordinate transformation relationship, and obtaining the coordinates of the coating defect location box and the center point of the candidate bounding box, includes: The pixel positions to be covered are determined based on the pixel row coordinate range and pixel column coordinate range of the candidate box for coating defects. The total number of pixel columns in the color difference image is subtracted from the pixel column coordinates that are not less than the total number of pixel columns in the color difference image, while the remaining pixel column coordinates remain unchanged, to obtain the query pixel column coordinates. Based on the coordinate transformation relationship between the pixel row coordinates and the query pixel column coordinates, the horizontal and vertical coordinates of the source pixels are extracted, and the coating defect location box is formed based on the extreme values ​​of the horizontal and vertical coordinates of the source pixels. Based on the coordinate transformation relationship of the pixel positions around the center point of the candidate box, the source sampling coordinates are extracted. When the pixel positions around the center point of the candidate box span the first and last pixel columns of the color difference image, the source sampling coordinates are selected according to the angular connection relationship. The source sampling coordinates are linearly interpolated along the pixel column direction and pixel row direction to obtain the mapped coordinates of the center point of the candidate box.

9. The method for locating optical lens coating defects based on target detection as described in claim 8, characterized in that, The process of generating optical lens coating defect localization results, which include radial position, angular position, and defect type, based on the positional relationship between the candidate box center point mapping coordinates and the lens center point, includes: Calculate the lateral and longitudinal position differences between the candidate box center point mapping coordinates and the lens center point. Take the square root of the sum of the squares of the two position differences as the radial position. Perform arctangent operation in four quadrants using the lateral and longitudinal position differences as coordinate components. Convert the result into an angle to obtain the angular position. When the angular position is less than zero degrees, add the angular position to 360 degrees. When the candidate box center point mapping coordinates coincide with the lens center point, record the radial position and angular position as zero pixels and zero degrees, respectively. The coating defect location box, the center point mapping coordinates of the candidate box, the radial position, the angular position, and the defect type are associated and summarized to form the optical lens coating defect location result.

Citation Information

Patent Citations

  • Edge detection method based on dispersion light band extraction and multi-modal fitting

    CN120451192A

  • Optical lens coating defect detection method based on image detection

    CN121921318A