Optical film surface flaw detection method and system, product and medium
By segmenting the connection domain and analyzing the shape feature of the surface defects of the optical film, combining the single-defect feature model and feature library matching, the problem of low detection accuracy of multiple defects dense areas on the surface of the optical film is solved, and higher defect recognition accuracy and classification accuracy are achieved.
Patent Information
- Application Number
- CN202510004844.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2045-01-02
AI Technical Summary
When there are many defect-intensive areas on the surface of the optical film, existing machine vision detection technology is difficult to accurately identify the number and type of defects, resulting in a decrease in detection accuracy.
By acquiring edge detection images, connecting domain segmentation and shape feature calculations are performed, similar connecting domains are merged, and error values are evaluated through a single defect feature model, split or merge the connected domains, and finally build a defect type feature library for matching.
It improves the accuracy of optical film defect detection, reduces the rate of misjudgment, can more accurately identify and classify defects, and improves the scientific nature of product quality control.
Smart Images

Figure CN119919387A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of new material industry, and in particular to a method, system, product and medium for detecting surface defects of optical films. Background Art
[0002] Optical films play a key role in many industries such as electronic displays and optical instruments. Their surface defects can significantly reduce the optical performance and reliability of products. Detecting surface defects of optical films can quickly and accurately locate defects and prevent defective products from entering the market. In recent years, detection technology has developed from manual visual inspection to intelligent and automated detection, and detection accuracy and efficiency have been greatly improved, which has effectively guaranteed the quality of optical film products, promoted the refined production and technological progress of related industries, and has extremely important industrial value.
[0003] At present, the surface defect detection of optical films mainly adopts machine vision detection technology, which uses light sources to illuminate from different angles to highlight the defect features; the image acquisition system transmits these images to computer software, and the software will pre-process the images, such as grayscale, filtering and other operations to improve the image quality. Then, edge detection, threshold segmentation and other algorithms are used to extract the defect part, and finally the defect type is determined based on the size, shape, grayscale and other characteristics of the defect.
[0004] However, when there are multiple defect-dense areas on the surface of the optical film, the defect areas are divided and the defect characteristics are determined based on the size, shape, grayscale and other characteristics of the defects. Due to the uneven distribution of internal features of the defects, the number, type and other characteristics of the defects may be misjudged, thereby affecting the accuracy of optical film defect identification. Summary of the invention
[0005] The present application provides a method, system, product and medium for detecting defects on the surface of an optical film, which are used to improve the accuracy of defect identification.
[0006] In a first aspect, the present application provides a method for detecting surface defects of an optical film, comprising: Acquire an edge detection image; perform connected domain segmentation in the edge detection image to obtain a connected domain; The shape features of the connected domain are calculated; the shape features include circularity, rectangularity and aspect ratio; the shape features of every two connected domains are compared to determine whether the shape features are similar; when two connected domains are similar connected domains, the similar connected domains are merged into a merged connected domain; the merged gray value distribution features and the merged gradient change features of the merged connected domain are calculated, and the merged gray value distribution and the merged gradient change features are input into a single defect feature model to obtain a merged single defect error value; the merged connected domain whose merged single defect error is greater than a preset single defect error threshold is split into the original similar connected domains as defect connected domains; the defect connected domain also includes a merged connected domain whose merged single defect error is not greater than a preset single defect error threshold and a non-similar connected domain; a defect type feature library is constructed to perform defect type matching on all defect connected domains in the edge detection image.
[0007] In the above embodiment, the edge detection image is segmented into connected domains to obtain multiple connected domains, and their shape features are calculated and compared for similarity. Connected domains with similar shapes are merged, and then the grayscale and gradient features of the merged connected domains are calculated and input into the model to obtain the error value. Based on this, the original connected domains are selected to be split or the merged connected domains are retained. After the feature library is built, the types of all defective connected domains are matched. Through multi-feature analysis and model evaluation, defective connected domains are identified and defects are classified, the misjudgment rate is reduced, and the accuracy of optical film defect detection is improved.
[0008] In conjunction with some embodiments of the first aspect, in some embodiments, connected domain segmentation is performed in the edge detection image to obtain a connected domain, which specifically includes: Calculate the grayscale average and grayscale standard deviation of the local area of each pixel in the edge detection image; the local area of the pixel is the area covered by sliding a window of a preset size with the pixel as the center; determine the defect judgment threshold through the grayscale average and the grayscale standard deviation; connect the adjacent pixels of all the pixels in the edge detection image and the pixel whose grayscale average is greater than the defect judgment threshold to obtain a connected domain.
[0009] In the above embodiment, the threshold is determined by calculating the local area features of the pixel points, and then the related pixel points are connected according to the threshold, so that the connected domain can be accurately divided, which provides a basis for the subsequent precise detection and analysis of optical film defects and improves the accuracy and efficiency of defect identification.
[0010] In combination with some embodiments of the first aspect, in some embodiments, calculating the grayscale average value and grayscale standard deviation of the local area of each pixel point in the edge detection image specifically includes: From the upper left corner of the edge detection image, select each pixel as the central pixel in row priority order; for the current central pixel, create an empty data group, and store the pixel grayscale values in the area covered by the window sliding of the preset size with the current central pixel as the center into the data group; use the first formula to calculate the grayscale average value of the local area of the current central pixel; wherein the first formula is: The grayscale standard deviation of the local area of the current central pixel is calculated using the second formula; wherein the second formula is: in, is the grayscale average value of the local area of the current central pixel, σ is the grayscale standard deviation of the local area of the current central pixel, the size of the preset window is m×n, in the edge detection image, a coordinate axis is established with the upper left corner fixed point as the origin, the direction from the upper left corner fixed point to the lower left corner fixed point is the x-axis, and the direction from the upper left corner fixed point to the upper right corner fixed point is the y-axis, the coordinate axis plane is divided into squares with a pixel unit as the size, and the coordinate position of the current central pixel in the coordinate axis is (i, j).
[0011] In the above embodiment, the local features of the pixels in the edge detection image are calculated one by one using the mean and standard deviation calculation formula combined with the Gaussian formula, so that the conditions of each local area of the image can be accurately quantified, laying the foundation for the subsequent accurate identification of defects and improving the accuracy of defect detection.
[0012] In conjunction with some embodiments of the first aspect, in some embodiments, the step of building a defect type feature library and matching defect types of all defect connected domains in the edge detection image specifically includes: Collect multiple known types of optical film defect samples, and extract sample feature data of the sample connected domain for each sample connected domain of the optical film defect sample; the sample feature data includes sample gray value distribution characteristics, sample gradient change characteristics, sample circularity and sample rectangularity of the sample connected domain; associate the sample feature data with the corresponding sample defect type of the sample connected domain and store them to build a defect type feature library; calculate the defect feature data of the defect connected domain; the defect feature data includes defect gray value distribution characteristics, defect gradient change characteristics, defect circularity and defect rectangularity; perform similarity calculation on the defect feature data and each sample feature data in the defect type feature library to obtain a similarity value group; take the maximum defect type as the defect type that matches the defect connected domain; the maximum defect type is the defect type of the sample connected domain corresponding to the maximum similarity data in the similarity value group.
[0013] In the above embodiment, by constructing a feature library and comparing similarities, the defect type of the defect connected domain can be accurately determined based on existing samples, thereby improving the accuracy and efficiency of optical film defect classification.
[0014] In conjunction with some embodiments of the first aspect, in some embodiments, after calculating the similarity between the defect feature data and each sample feature data in the defect type feature library to obtain a similarity value group, the method further includes: In the case that all the similarity data in the similarity data group are lower than a preset minimum similarity threshold, the defective connected domain is marked as an unknown type connected domain.
[0015] In the above embodiment, by marking the connected domains with relatively low similarity to all defect types in the feature library as connected domains of unknown type, misclassification is avoided, which helps to improve the defect classification system.
[0016] In combination with some embodiments of the first aspect, in some embodiments, after the defect type matching the defect connected domain is the maximum defect type, the method further includes: The defect connected domain area of the defect connected domain is calculated; and the defect level of the defect connected domain is determined according to the defect connected domain area, the defect grayscale mean value in the defect grayscale value distribution characteristics, and the defect aspect ratio using a preset level classification threshold.
[0017] In the above embodiment, by calculating the area of the defect connected domain and combining the grayscale mean and aspect ratio in its grayscale value distribution characteristics, the defect level to which the defect connected domain belongs is comprehensively judged with reference to the preset level classification threshold, so that a more detailed quantitative evaluation of the defects on the optical film can be performed.
[0018] In combination with some embodiments of the first aspect, in some embodiments, after the merged connected domain in which the merged single defect error is greater than a preset single defect error threshold is split into the original similar connected domains as defect connected domains, it also includes: determining the center position of the defect connected domain as the connected domain center; calculating the connected domain center distance between every two centers of the connected domain and the connected domain center density of the edge detection image; when the short distance ratio value in the connected domain center distance in the edge detection image is greater than a preset short distance ratio threshold or the connected domain center density is greater than a preset maximum density threshold, marking the optical film corresponding to the edge detection image as a high-defect optical film; the short distance ratio value is the ratio of the connected domain center distance less than the preset distance threshold to all the connected domain center distances in the edge detection image.
[0019] In the above embodiment, by analyzing the parameters related to the center of the connected domain, the density of optical film defects can be judged according to specific standards, and then high-defect optical films with denser defects or a large number of defects can be identified, which is convenient for screening out poor quality products and ensuring the overall quality level of the product.
[0020] In a second aspect, an embodiment of the present application provides an optical film surface defect detection system, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the optical film surface defect detection system to perform the method described in the first aspect and any possible implementation method of the first aspect.
[0021] In a third aspect, an embodiment of the present application provides a computer program product comprising instructions. When the above-mentioned computer program product is run on an optical film surface defect detection system, the above-mentioned optical film surface defect detection system executes the method described in the first aspect and any possible implementation method of the first aspect.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium comprising instructions. When the instructions are executed on an optical film surface defect detection system, the optical film surface defect detection system executes the method described in the first aspect and any possible implementation method of the first aspect.
[0023] It can be understood that the optical film surface defect detection system provided in the second aspect, the computer program product provided in the third aspect, and the computer storage medium provided in the fourth aspect are all used to execute the optical film surface defect detection method provided in the embodiment of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, and will not be repeated here.
[0024] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. This application performs connected domain segmentation on the edge detection image to obtain multiple connected domains, calculates their shape features and compares their similarity, merges connected domains with similar shapes, and then calculates the grayscale and gradient features of the merged connected domain to input the model to obtain the error value, and then chooses to split into the original connected domain or retain the merged connected domain. After building a feature library, all defect connected domains are matched. Through multi-feature analysis and model evaluation, defect connected domains are identified and defects are classified, reducing the misjudgment rate and improving the accuracy of optical film defect detection.
[0025] 2. This application constructs a feature library and compares similarities, so that the defect type of the defect connected domain can be accurately determined based on existing samples, thereby improving the accuracy and efficiency of optical film defect classification.
[0026] 3. This application calculates the area of the defect connected domain, combines the grayscale mean and aspect ratio in its grayscale value distribution characteristics, and refers to the preset level classification threshold to comprehensively judge the defect level to which the defect connected domain belongs, so that a more detailed quantitative evaluation of defects on the optical film can be performed. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a structural schematic diagram of an applicable system architecture of the optical film surface defect detection method in the embodiment of the present application; Figure 2 It is a flow chart of a method for detecting surface defects of an optical film in an embodiment of the present application; Figure 3 is another flow chart of the optical film surface defect detection method in the embodiment of the present application; Figure 4 It is a schematic diagram of an exemplary hardware structure of an optical film surface defect detection system in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.
[0029] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
[0030] Figure 1 It is a structural schematic diagram of a system architecture that can be applied to the optical film surface defect detection method in the embodiment of the present application.
[0031] See also Figure 1 The system architecture includes an imaging device 110, a data transmission device 120 and a server 130.
[0032] The imaging device 110 includes an industrial camera 111, an optical lens 112 and a lighting system 113, which are used to obtain the original image of the optical film surface, provide basic data for subsequent defect detection, and are the data source of the entire detection system. Among them, a high-resolution, high-precision industrial camera 111 is used to capture a clear image of the optical film surface at a suitable frame rate to meet the requirements of the detection for image details and provide a high-quality source of original image data for subsequent defect analysis; according to the different needs of the detection scene, an optical lens 112 with different focal lengths and apertures that is compatible with the industrial camera 111 can be selected to ensure that the field of view and clarity of the imaging meet the detection standards; the lighting system 113 includes various types of light sources, such as uniform surface light sources, ring light sources, etc. By reasonably arranging and adjusting the brightness, angle, color and other parameters of the light source, sufficient and uniform lighting conditions are provided for the optical film, reducing the impact of shadows and reflections on image quality, so that the captured image can clearly present the true situation of the optical film surface.
[0033] The data transmission device 120 is a data cable 121, which transmits the image data collected by the imaging device to the data processing server stably and quickly, ensures the efficiency and accuracy of data transmission, and is a bridge connecting the data collection and processing links. The data cable 121 uses a high-speed and stable data cable, such as an optical fiber, a high-speed network cable, etc., to transmit the image data collected by the industrial camera to the hardware equipment for subsequent processing in real time, ensuring the continuity and timeliness of the detection process.
[0034] In some embodiments of the present application, the data transmission device uses data cable devices such as optical fibers and network cables for data transmission; in other embodiments of the present application, the data transmission method also includes a network switch, and data is transmitted using a network transmission method, which is not limited here.
[0035] The server 130 includes a processor 131 and a memory and storage device 132, which performs complex calculations on the transmitted image data and is the core computing unit of the entire system. The processor 131 is a high-performance central processing unit or graphics processor, which can improve detection efficiency and reduce detection time for complex image data calculation tasks; the storage device 132 is used to temporarily store the image data being processed, intermediate calculation results, etc., to ensure that the data reading and writing speed can keep up with the processor operation speed, and at the same time, long-term storage of a large amount of historical detection data, training model data, and detection result data, etc., to facilitate subsequent data analysis.
[0036] The following is a description of a method for detecting optical film surface defects in one embodiment of the present application: See also Figure 2 , is a flow chart of a method for detecting optical film surface defects provided in an embodiment of the present application, which can be applied to Figure 1The system architecture shown includes the following steps: S201, acquiring an edge detection image; First, use imaging equipment, such as industrial cameras with appropriate optical lenses and lighting systems, to shoot the optical film and obtain its original image. Then use the Canny edge detection algorithm to process the original image, highlight the edge of the object by identifying features such as pixel grayscale changes in the image, and thus obtain an edge detection image.
[0037] In some embodiments of the present application, the Canny edge detection algorithm is used to process the original image; in other embodiments of the present application, the Laplacian edge detection algorithm and other image processing algorithms may also be used to process the original image, which is not limited here.
[0038] The above technical steps use edge detection algorithms on the original image of the optical film, so that the originally complex image that is difficult to directly analyze defects is converted into an image that highlights edge information, providing an image basis for subsequent operations and improving detection accuracy.
[0039] S202, performing connected domain segmentation in the edge detection image to obtain a connected domain; In the edge detection image, the image pixels are scanned first, and the grayscale values of the pixels are used to determine which pixels are defective pixels. The defective pixels are grouped together, and different connected domains are gradually marked and distinguished. By continuously traversing all the pixels in the image, the entire image is finally divided into independent connected domains.
[0040] In some embodiments of the present application, whether a pixel is a defective pixel is determined by the grayscale value of the pixel; in other embodiments of the present application, whether a pixel is a defective pixel can also be determined by the gradient characteristics or other characteristics of the pixel, which is not limited here.
[0041] The above technical steps divide the connected domain according to the grayscale features of the pixels, so that the image originally presented as edges is further refined into different connected areas, providing more targeted objects for subsequent operations such as accurately analyzing the characteristics of each area and accurately judging defects, which is conducive to improving detection accuracy.
[0042] S203, calculating shape features of connected domains; For each connected domain, the corresponding mathematical algorithms and geometric calculation methods are used to obtain its shape characteristics. For example, the circularity of the connected domain is calculated through a specific formula to measure its similarity to a circle; the rectangularity is calculated using a related algorithm to see how close it is to a rectangle; and the aspect ratio is calculated to know the proportional relationship between its length and width, thereby obtaining these key characteristic data in the shape of each connected domain.
[0043] In some embodiments of the present application, the shape characteristics of the connected domain include circularity, rectangularity, and aspect ratio; in other embodiments of the present application, the shape characteristics of the connected domain may also include fractal dimensions, etc., which are not limited here.
[0044] The above technical steps calculate the shape features of the connected domains, so that different connected domains can be described and distinguished from the perspective of geometric morphology, which facilitates the subsequent comparison of the similarities between the connected domains, provides an important basis for accurately merging similar connected domains, determining defect categories, and other operations, and helps to improve the accuracy and efficiency of defect detection.
[0045] S204, determining whether every two connected domains are similar connected domains; If the two connected domains are similar connected domains, the following step S205 is executed; If a connected domain and all other connected domains are non-similar connected domains, the following step S207 is executed; For each connected domain, select every two connected domains one by one, extract their shape features, and then compare whether the shapes are similar according to a preset difference range, for example, whether the roundness difference is within the preset roundness difference threshold range, and the same applies to the rectangularity and aspect ratio differences; when the two connected domains are similar in shape, determine whether the distance between the two connected domains is less than the preset distance threshold. If the distance is less than the preset distance threshold, the two connected domains are determined to be similar connected domains, and the following step S205 is executed to merge the similar connected domains into one connected domain; if one connected domain and all other connected domains do not meet the requirements of the above-mentioned similar connected domains, then this connected domain is determined to be a non-similar connected domain, and the following step S207 is executed to add the non-similar connected domain to the defective connected domain.
[0046] In some embodiments of the present application, the distance between two connected domains can be determined by using the center of the connected domain method and then calculating the distance between the centers of the two connected domains; in other embodiments of the present application, the distance between two connected domains can also be determined by calculating the distance between the two closest pixel points in the two connected domains, etc., which is not limited here.
[0047] The above technical steps distinguish similarities by comparing the shape features and distances of connected domains, so that the connected domains can be merged or otherwise processed in a targeted manner later, avoiding the misjudgment of features such as the number and type of defects due to uneven distribution of internal features of defects, thereby avoiding incorrect division of connected domains, which helps to improve the accuracy of connected domain processing in defect detection.
[0048] S205, merging the similar connected domains into a merged connected domain; When two connected domains are determined to be similar connected domains, they are operated through the image region merging algorithm, such as selecting a pixel in one of the connected domains as the starting point, and then adding the pixels in the other connected domain one by one to the area where the starting point is located, thereby achieving merging and completing the merging operation.
[0049] In some embodiments of the present application, similar connected domains are merged into one connected domain using the reverse effect of the region growing method; in other embodiments of the present application, similar connected domains can also be merged into one connected domain using image merging algorithms such as a combination of dilation and rescreening operations, which is not limited here.
[0050] The above technical steps merge similar connected domains to avoid the situation where the same defect is divided into multiple connected domains due to uneven distribution of internal features of the defect, which helps to improve the accuracy of operations such as matching defect types.
[0051] S206, calculating the gray value distribution characteristics and gradient change characteristics of the merged connected domain, inputting the merged gray value distribution and merged gradient change characteristics into a single defect feature model, and obtaining a merged single defect error value; Specifically, the single defect feature model is obtained by training a preset neural network using multiple sets of historical grayscale value distribution features, historical gradient change features and corresponding marked single defect error values, and is used to output a single defect error value based on a set of input grayscale value feature distribution and historical gradient change features.
[0052] First, the corresponding algorithm is used to statistically merge the gray value distribution characteristics and gradient change characteristics of the pixels in the connected domain, such as calculating the gray mean and gray median as gray distribution characteristics, and using the Sobel operator to calculate the gradient change characteristics. Then these feature data are input into the single defect feature model that has been trained with historical data in advance, and after internal calculations in the model, the merged single defect error value is finally output.
[0053] In some embodiments of the present application, the grayscale distribution characteristics are the grayscale mean and the grayscale median; in other embodiments of the present application, the grayscale distribution characteristics may also include grayscale mode, grayscale range and other values, which are not limited here.
[0054] In some embodiments of the present application, the Sobel operator is used to calculate the gradient change feature; in other embodiments of the present application, the Prewitt operator or other methods may also be used to calculate the gradient change feature, which is not limited here.
[0055] The above technical steps extract features and use model operations to evaluate the difference between the merged connected domain and the single defect, thereby avoiding the incorrect merging of connected domains of different defects. If the error value of a single defect is large, it is determined that the similar connected domains are not the same defect, thereby improving the accuracy of defect detection.
[0056] S207, splitting the merged connected domain whose merged single defect error is greater than a preset single defect error threshold into original similar connected domains as defect connected domains, the defect connected domains also including merged connected domains whose merged single defect error is not greater than the preset single defect error threshold and non-similar connected domains; When the merged single defect error value obtained by merging connected domains is greater than the preset single defect error threshold, it means that this merged connected domain does not meet the requirements. It is then restored and split back into the original similar connected domains based on the previously recorded similar connected domain divisions, and the merged connected domains whose error values do not exceed the threshold and the non-similar connected domains that cannot form similar connected domains with all other connected domains are treated as defective connected domains.
[0057] The above technical steps are reasonably split through error comparison, so that the real defect connected domain can be accurately screened out, the defect judgment errors caused by incorrect merging can be avoided, and the accuracy of the definition of defects on the optical film surface can be improved.
[0058] S208, constructing a defect type feature library, and performing defect type matching on all defect connected domains in the edge detection image.
[0059] First, we collect various known optical film defect samples, extract the feature data of the sample connected domain, and associate the corresponding defect types to build a defect type feature library. Then, we extract the above-mentioned related feature data from the defect connected domain in the edge detection image, and compare and match it with the data in the feature library to determine its defect type.
[0060] The above technical steps construct a feature library and match it, so that the type of defect connected domain can be accurately determined by referring to the existing sample data, thereby improving the accuracy and efficiency of optical film defect detection and classification, and helping to better control the quality of optical film products.
[0061] In the above embodiment, multiple connected domains are obtained by segmenting the edge detection image, calculating their shape features and comparing their similarity, and similar shape connected domains are merged, and then the grayscale and gradient features of the merged connected domain are calculated and input into the model to obtain the error value, and then the original connected domain is selected or the merged connected domain is retained. After the feature library is built, the types of all defective connected domains are matched. Through multi-feature analysis and model evaluation, defective connected domains are identified and defects are classified, the misjudgment rate is reduced, and the accuracy of optical film defect detection is improved.
[0062] In some embodiments, some special situations may be encountered during the optical film surface defect detection process. For example, in the case where there are too many defects on the surface of some optical films or some defects are too dense, these optical films need to be specially processed. In this case, the optical film surface defect detection method can specially mark the optical film with too many defects or more defects at close range according to the distance and density between the defects on the surface of the optical film. Figure 3 FIG. 1 is another flow chart of the optical film surface defect detection method provided in an embodiment of the present application. The method can be used to Figure 1 The system architecture shown includes the following steps: S301, acquiring an edge detection image; S302, selecting each pixel point as the central pixel point in sequence according to the row priority order from the upper left corner of the edge detection image; For edge detection images, the image is considered as a matrix consisting of many pixels. Starting from the first pixel in the upper left corner of the image, each pixel is regarded as the central pixel in the order of columns from left to right and rows from top to bottom, so as to prepare for subsequent operations such as calculating local area features for each pixel.
[0063] The above technical steps select central pixels in a specific order, so that each pixel in the image can be processed regularly and without omission, which facilitates the unified calculation of relevant features.
[0064] S303, for the current central pixel, create an empty data group, and store the grayscale values of pixels in the area covered by the sliding window of a preset size with the current central pixel as the center into the data group; After the current center pixel is selected, an empty data group is initialized first. According to the preset window size (such as 3×3, 5×5, etc.), the window is centered on the current center pixel and slides on the image. The grayscale values corresponding to each pixel in the area covered by the window are extracted in turn, and then stored in order in the previously created empty data group.
[0065] The above technical steps collect the grayscale values of pixels in the area covered by the window and store them in a data group, so that statistics such as mean and standard deviation can be accurately calculated based on these data later, providing an effective numerical basis for operations such as defect judgment and connected domain segmentation, thereby improving the accuracy of defect detection.
[0066] S304, using the first formula to calculate the grayscale average value of the local area of the current central pixel; Specifically, in the edge detection image, a coordinate axis is established with the upper left corner fixed point as the origin, the direction from the upper left corner fixed point to the lower left corner fixed point is the x-axis, and the direction from the upper left corner fixed point to the upper right corner fixed point is the y-axis. The coordinate axis plane is divided into squares with a pixel unit as the size, and the coordinate position of the current center pixel point in the coordinate axis is (i, j). The first formula is: in, is the grayscale average of the local area of the current central pixel, and the size of the preset window is m×n.
[0067] For the calculation of local area features, it is necessary to determine a window range centered on the current pixel point. The integral domain calculation form involved in the formula here is as follows: and This is to accurately define the window area centered on pixel (i, j).
[0068] In the image coordinate system, when we want to construct a local window of size m×n with a pixel point (i, j) as the center, we need to accurately determine the start and end positions of the window. arrive (The same is true for the y direction) This form ensures that the window is centered at (i, j). When m is an odd number (which is a common window size choice in image processing, because an odd number can ensure that there is a clear center pixel), this calculation method can accurately determine the range of the window so that the center of the window is exactly at (i, j).
[0069] When performing pixel-by-pixel local area calculations on the entire image, this form of calculation can ensure relatively consistent processing at the edges of the image. Although the window may exceed the image boundary at the edge of the image, this form of calculation can ensure the consistency and accuracy of the calculation through reasonable boundary processing (such as ignoring the part beyond the boundary or using a specific filling method).
[0070] By calculating the grayscale average value within this local area, the local grayscale features can be better captured. In image processing, many features (such as edges, textures, etc.) are often presented in local areas. This local calculation helps to accurately discover and describe these features.
[0071] By selecting the integral domain based on the central pixel point, the boundary effect can be avoided or reduced to a certain extent. If a global or inappropriate integral domain is selected, inaccurate calculation results may be generated at the edge of the image or at the junction of different feature areas. However, this local area integral domain selection makes the calculation of each local area relatively independent, reducing the mutual interference between different areas.
[0072] S305, using the second formula to calculate the grayscale standard deviation of the local area of the current central pixel; Specifically, the second formula is: Among them, σ is the grayscale standard deviation of the local area of the current central pixel.
[0073] The second formula is based on the grayscale average value calculated in the above local area when calculating the standard deviation. The calculation of the standard deviation is closely related to the grayscale distribution of the local area and can better reflect the discrete degree of the pixel grayscale values in the local area.
[0074] The second formula is similar to the first formula. It is calculated based on the local area and helps to describe the change of pixel grayscale in the local area. In image processing, the grayscale standard deviation can reflect the characteristics of the image texture complexity. Through this local calculation method, the local texture characteristics of the image can be more accurately characterized.
[0075] Calculating the standard deviation in a local area can suppress the influence of noise to a certain extent. If the standard deviation is calculated on the entire image, the noise points may have a greater interference on the result. By calculating in a local area, only the noise in the local area will affect the result, and the normal pixels in the local area can balance the influence of the noise to a certain extent, thus obtaining a more reliable grayscale standard deviation result.
[0076] In the above two steps, the grayscale mean and grayscale standard deviation are calculated by the first formula and the second formula, which can reduce the interference of noise pixels in the local area on the results, which helps to improve the accuracy of subsequent threshold determination based on the grayscale mean and grayscale standard deviation and connected domain segmentation.
[0077] S306, determining a defect judgment threshold through the grayscale average value and the grayscale standard deviation; After obtaining the grayscale average value and grayscale standard deviation of the local area of each pixel, the defect judgment threshold is determined according to the grayscale average value and grayscale standard deviation. For example, the average value plus several times the standard deviation is used as the defect judgment threshold.
[0078] In some embodiments of the present application, the defect judgment threshold is obtained by calculating the weighted average of the grayscale mean and the grayscale standard deviation; in other embodiments of the present application, the defect judgment threshold can also be obtained by machine learning methods, using known defect and defect-free samples to train the model, allowing the model to output the threshold based on the input mean and grayscale standard deviation, etc., which is not limited here.
[0079] The above technical steps use the grayscale average and standard deviation to determine the threshold, so that normal pixels and pixels that may have defects can be clearly distinguished, providing a quantitative standard for subsequent accurate screening of defective pixels and reducing misjudgments.
[0080] S307, connecting adjacent pixel points whose grayscale average value is greater than the defect judgment threshold among all pixel points of the edge detection image to obtain a connected domain; Specifically, all pixels in the edge detection image are traversed, and for each pixel, the pixels adjacent to it (such as the upper, lower, left, and right pixels) are checked. Then their grayscale averages are compared with the determined defect judgment threshold. If the grayscale average of the adjacent pixels exceeds this threshold, these adjacent pixels that meet the conditions are connected through the corresponding algorithm to form a whole, that is, the connected domain is obtained.
[0081] The above technical steps determine defective pixels based on a threshold value and connect adjacent defective pixels in the detection image, so that areas where defects may exist can be segmented from the image as connected domains, which facilitates subsequent further analysis of the features of these connected domains.
[0082] S308, calculating shape features of connected domains; S309, determining whether every two connected domains are similar connected domains; If the two connected domains are similar connected domains, the following step S205 is executed; If a connected domain and all other connected domains are non-similar connected domains, the following step S207 is executed; S310, merging the similar connected domains into a merged connected domain; S311, calculating the merged gray value distribution characteristics and the merged gradient change characteristics of the merged connected domain, inputting the merged gray value distribution and the merged gradient change characteristics into a single defect feature model, and obtaining a merged single defect error value; S312, splitting the merged connected domain whose merged single defect error is greater than a preset single defect error threshold into original similar connected domains as defect connected domains, the defect connected domains also including merged connected domains whose merged single defect error is not greater than the preset single defect error threshold and non-similar connected domains; S313, collecting multiple known types of optical film defect samples, and extracting sample feature data of the sample connected domain for each optical film defect sample; Specifically, the sample feature data includes sample gray value distribution characteristics, sample gradient change characteristics, sample circularity, and sample rectangularity.
[0083] Collect samples of known optical film defects of different types, such as scratches, spots, holes, etc. For the connected domain in each sample, use the corresponding algorithm to extract feature data, such as calculating the grayscale value distribution characteristics, gradient change characteristics, circularity and rectangularity of the connected domain, so as to obtain the sample feature data of the connected domain of each sample in an all-round way.
[0084] The above technical steps can accumulate feature information corresponding to various defects by extracting feature data of sample connected domains, providing a data basis for building a defect type feature library, which is conducive to accurately matching unknown defect types.
[0085] S314, constructing a defect type feature library; When building a defect type feature library, first create a suitable data storage structure, such as a database table or a file in a specific format, and then match the collected and extracted sample feature data with the sample defect type of the corresponding sample connected domain, and store them in the created storage structure in the form of key-value pairs or records to complete the associated storage and build the defect type feature library.
[0086] The above technical steps associate and store sample feature data with defect types, so that in subsequent inspections, feature comparison can be used to determine the type of unknown defects.
[0087] S315, calculating defect feature data of the defect connected domain; Specifically, the defect feature data includes defect gray value distribution characteristics, defect gradient change characteristics, defect circularity and defect rectangularity.
[0088] The above technical steps calculate the feature data of the defect connected domain, so that it can be compared and matched with the data in the defect type feature library later, so as to accurately determine the defect type to which it belongs.
[0089] S316, calculating the similarity between the defect feature data and each sample feature data in the defect type feature library to obtain a similarity value group; The defect feature data of the defect connected domain is calculated in turn with the feature data of each sample in the defect type feature library according to the similarity algorithm. Each comparison will result in a corresponding similarity value. By summing up these values, a similarity value group containing multiple similarity values is obtained.
[0090] In some embodiments of the present application, the similarity algorithm used for similarity calculation is the Euclidean distance algorithm; in other embodiments of the present application, similarity calculation may also be performed using a cosine similarity algorithm or other similarity algorithms, which is not limited here.
[0091] The above technical steps calculate the similarity value group, so that the similarity between the defect connected domain and the sample can be measured based on these values, and then the most matching sample can be found to determine the defect type corresponding to the defect connected domain.
[0092] S317, the defect type matching the defect connected domain is the maximum defect type; After obtaining the similarity value group, the similarity values in the group are compared to obtain the maximum similarity value, and the defect type of the defect connected domain is determined to be the defect type of the sample corresponding to the maximum similarity value, that is, the maximum defect type.
[0093] The above technical steps can accurately classify the defect connected domain and clarify the defect type by matching the maximum defect type.
[0094] S318: When all similarity data in the similarity data group are lower than a preset minimum similarity threshold, mark the defective connected domain as an unknown type connected domain; After obtaining the similarity data group, the similarity values in the group are compared to obtain the maximum similarity value. If the maximum similarity value is lower than the preset minimum similarity threshold, it indicates that the defective connected domain is too different from the sample features in the feature library and cannot be accurately matched to the existing type. In this case, it is marked as an unknown type connected domain.
[0095] The above technical steps mark unknown type connected domains by reasonably setting thresholds, so that special defect situations not covered in the feature library can be distinguished, which facilitates further analysis and research of these new situations, continuously improves the defect type feature library, and improves the comprehensiveness of various defect recognition.
[0096] S319, calculating the defect connected domain area of the defect connected domain; Determine all the pixels included in the defect connected domain and count the number of pixels. Since each pixel in the image can be regarded as occupying a certain unit area (for example, the area of a single pixel is set to 1), the counted number of pixels is equivalent to the area size of the defect connected domain.
[0097] In some embodiments of the present application, the pixel calculation method is used to calculate the area of the defect connected domain; in other embodiments of the present application, the integration method or other methods may also be used to calculate the area of the next connected domain, which is not limited here.
[0098] The above technical steps provide a basis for evaluating the impact of defects on the optical film by calculating the area of the connected domain of the defects, and provide a data basis for subsequent operations such as grading the defects according to factors such as area size.
[0099] S320, determining the defect level of the defect connected domain according to a preset level classification threshold; The area, defect grayscale mean and defect aspect ratio data of the defect connected domain are obtained, and they are compared with the corresponding level classification thresholds, such as the area reaches a certain range, the grayscale mean is in a specific interval, the aspect ratio meets the corresponding conditions, etc. After comprehensive judgment, it is determined which defect level the defect connected domain meets.
[0100] The above technical steps determine the defect level based on multi-indicator comparison thresholds, so that the severity of the defects can be quantitatively distinguished, effectively improving the scientificity and rationality of optical film defect management.
[0101] S321, determining the center position of the defective connected domain as the connected domain center; For the defective connected domain, mark all the pixels belonging to the connected domain, and then count the coordinate values of these pixels in the horizontal and vertical directions respectively. The average value of the horizontal coordinate value is used as the abscissa, and the average value of the vertical coordinate value is used as the ordinate. The coordinate point position determined in this way is the center of the connected domain.
[0102] In some embodiments of the present application, the center position of the defective connected domain is determined using the centroid method; in other embodiments of the present application, the center position of the defective connected domain may also be determined using methods such as the bounding box center method, which is not limited here.
[0103] S322, calculate the connected domain center distance between every two connected domain centers and the connected domain center density of the edge detection image; for each determined connected domain center, calculate the distance between every two connected domain centers, and substitute the coordinates into the distance formula between two points to calculate the value; and the connected domain center density is the number of connected domain centers divided by the total area of the edge detection image, so as to measure the distribution of connected domain centers within a unit area.
[0104] The above technical steps calculate the distance and density, so as to understand the distribution density and relative position relationship of the defects in the image, and obtain the defect distribution on the surface of the optical film.
[0105] S323. When the short distance ratio value in the connected domain center distance in the edge detection image is greater than a preset short distance ratio threshold or the connected domain center density is greater than a preset maximum density threshold, mark the optical film corresponding to the edge detection image as a high-defect optical film.
[0106] Specifically, the short distance ratio value is a ratio of the connected domain center distances less than a preset distance threshold to the center distances of all connected domains in the edge detection image.
[0107] The proportion of short distances in the center distance of the connected domain in the edge detection image is counted, the short distance ratio value is calculated, and the center density of the connected domain is calculated at the same time. Then, these two values are compared with the preset short distance ratio threshold and the maximum density threshold respectively. When the short distance ratio value is greater than the preset short distance ratio threshold or the center density is greater than the maximum density threshold, the corresponding optical film is marked as a high-defect optical film.
[0108] The above technical steps set threshold comparison and judgment to quickly screen out optical films with denser defect distribution or a larger number of defects, so as to give priority to special treatment of such high-defect optical films and improve the efficiency of overall optical film product quality control.
[0109] Steps S301, S308-S312 and Figure 2 Steps S201, S203-S207 in the illustrated embodiment are similar, and the descriptions in steps S201, S203-S207 may be referred to, and will not be repeated here.
[0110] In the embodiment of the present application, first, an edge detection image is acquired and a connected domain is segmented, and the local area features of each pixel are calculated to determine a threshold to divide the connected domain, so that possible defective areas can be accurately located; secondly, the shape features of the connected domains are compared and similar connected domains are merged, and the merged connected domain features are calculated and input into a model for evaluation, and then a feature library is constructed based on error splitting or retention, and the defect type is matched by similarity, which helps to accurately identify the type of defect and improve the classification accuracy; the area of the defective connected domain and other features are calculated to determine the defect grade, and the center position is determined to calculate the center distance and density to identify high-defect optical films, thereby enabling quantitative evaluation and distribution analysis of defects, effectively reducing the misjudgment rate, ensuring the quality of optical film products, and improving the accuracy of defect detection.
[0111] The following introduces an exemplary optical film surface defect detection system 400 provided in an embodiment of the present application. Figure 4 Schematic diagram of an exemplary hardware structure of an optical film surface defect detection system 400 provided in an embodiment of the present application.
[0112] In some embodiments, the optical film surface defect detection system 400 includes a computer device. The computer device includes a processor, a memory and a network interface connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with other external terminals or servers through a network connection. In some embodiments, the network interface can be a wired network interface, and in some embodiments, the network interface can also be a wireless network interface. When the computer program is executed by the processor, the method in the embodiment of the present application is implemented.
[0113] Those skilled in the art will understand that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0114] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0115] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.
[0116] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0117] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.
Claims
1. A method for detecting surface defects of an optical film, characterized in that: include: Get edge detection image; Performing connected domain segmentation in the edge detection image to obtain a connected domain; Calculating shape features of connected domains; the shape features include circularity, rectangularity, and aspect ratio; Compare the shape features of every two connected domains to determine whether the shape features are similar; the shape features are similar if the circularity difference is within a preset circularity difference threshold range, the rectangularity difference is within a preset rectangularity difference threshold range, and the aspect ratio difference is within a preset aspect ratio difference threshold range; In the case where two connected domains are similar connected domains, merging the similar connected domains into a merged connected domain; The similar connected domains are two connected domains with similar shape features and a distance less than a preset distance threshold; The merged gray value distribution feature and the merged gradient change feature of the merged connected domain are calculated, and the merged gray value distribution and the merged gradient change feature are input into a single defect feature model to obtain a merged single defect error value; the single defect feature model is obtained by training a preset neural network using multiple groups of historical gray value distribution features, historical gradient change features and correspondingly marked single defect error values; The merged connected domain whose merged single defect error is greater than a preset single defect error threshold is split into the original similar connected domain as a defect connected domain; the defect connected domain also includes the merged connected domain whose merged single defect error is not greater than the preset single defect error threshold and a non-similar connected domain; the non-similar connected domain is a connected domain in the edge detection image that cannot form a similar connected domain with all other connected domains; A defect type feature library is constructed, and defect type matching is performed on all defect connected domains in the edge detection image.
2. The method according to claim 1, characterized in that: The segmentation of the connected domain in the edge detection image to obtain the connected domain specifically includes: Calculate the grayscale average and grayscale standard deviation of the local area of each pixel in the edge detection image; the local area of the pixel is the area covered by sliding a window of a preset size with the pixel as the center; Determine a defect judgment threshold value by using the grayscale average value and the grayscale standard deviation; Adjacent pixel points of all pixel points of the edge detection image whose grayscale average value is greater than the defect judgment threshold are connected to obtain a connected domain.
3. The method according to claim 2, characterized in that The step of calculating the grayscale average value and grayscale standard deviation of the local area of each pixel point in the edge detection image specifically includes: From the upper left corner of the edge detection image, select each pixel point as the central pixel point in row priority order; For the current central pixel, an empty data group is created, and the grayscale values of pixels in the area covered by the sliding window of a preset size are stored in the data group with the current central pixel as the center; Calculate the grayscale average value of the local area of the current central pixel using the first formula; Among them, the first formula is: Calculate the grayscale standard deviation of the local area of the current central pixel using the second formula; Among them, the second formula is: in, is the grayscale average value of the local area of the current central pixel point, σ is the grayscale standard deviation of the local area of the current central pixel point, the size of the preset window is m×n, in the edge detection image, a coordinate axis is established with the upper left corner fixed point as the origin, the direction from the upper left corner fixed point to the lower left corner fixed point is the x-axis, and the direction from the upper left corner fixed point to the upper right corner fixed point is the y-axis, the coordinate axis plane is divided into squares with a pixel unit as the size, and the coordinate position of the current central pixel point in the coordinate axis is (i, j).
4. The method according to claim 1, characterized in that: The step of constructing a defect type feature library and matching defect types of all defect connected domains in the edge detection image specifically includes: Collecting multiple known types of optical film defect samples, and extracting sample feature data of the sample connected domain for each sample of the optical film defect sample; the sample feature data includes sample gray value distribution characteristics, sample gradient change characteristics, sample circularity, and sample rectangularity of the sample connected domain; The sample feature data is associated with the sample defect type of the corresponding sample connected domain and stored to construct a defect type feature library; Calculating defect feature data of the defect connected domain; the defect feature data includes defect gray value distribution characteristics, defect gradient change characteristics, defect circularity and defect rectangularity; Calculate the similarity between the defect feature data and each of the sample feature data in the defect type feature library to obtain a similarity value group; The maximum defect type is used as the defect type matched with the defect connected domain; the maximum defect type is the defect type of the sample connected domain corresponding to the maximum similarity data in the similarity value group.
5. The method according to claim 4, characterized in that After calculating the similarity between the defect feature data and each of the sample feature data in the defect type feature library to obtain a similarity value group, the method further includes: when all the similarity data in the similarity data group are lower than a preset minimum similarity threshold, marking the defect connected domain as an unknown type connected domain.
6. The method according to claim 4, characterized in that After the defect type of the defect connected domain is matched to be the maximum defect type, the method further includes: Calculating the defect connected domain area of the defect connected domain; The defect level of the defect connected domain is determined according to the area of the defect connected domain, the defect grayscale mean value in the defect grayscale value distribution feature, and the defect aspect ratio using a preset level classification threshold.
7. The method according to claim 1, characterized in that After splitting the merged connected domain whose merged single defect error is greater than the preset single defect error threshold into the original similar connected domains as defect connected domains, the method further includes: Determine the center position of the defective connected domain as the connected domain center; Calculate the connected domain center distance between every two connected domain centers and the connected domain center density of the edge detection image; When the short distance ratio value in the connected domain center distance in the edge detection image is greater than a preset short distance ratio threshold or the connected domain center density is greater than a preset maximum density threshold, the optical film corresponding to the edge detection image is marked as a high-defect optical film; the short distance ratio value is the ratio of the connected domain center distance less than the preset distance threshold to all the connected domain center distances in the edge detection image.
8. An optical film surface defect detection system, characterized in that: The optical film surface defect detection system includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the optical film surface defect detection system to execute the method described in any one of claims 1-7.
9. A computer program product comprising instructions, characterized in that When the computer program product runs on an optical film surface defect detection system, the optical film surface defect detection system is enabled to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium comprising instructions, characterized in that: When the instruction is executed on an optical film surface defect detection system, the optical film surface defect detection system is enabled to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Lung image segmentation method and device, electronic equipment and storage medium
CN112884792A
Table detection method and device based on semantic segmentation, equipment and medium
CN113449620A
Vision-based turbocharger impeller appearance defect detection system and method
CN116109637A
Wafer surface defect detection method, device and system
CN117252861A
Electroplated product surface flaw detection method based on image features
CN117314924A
Cited By
Thermal insulation decorative plate appearance defect detection method and system based on image recognition
CN120823207A
An image recognition-based decorative plate appearance defect detection method and system
CN120823207B
Vision-based accessory appearance defect detection method and system
CN121329969A
Vision-based method and system for detecting cosmetic defects of a component
CN121329969B