Method and system for detecting weak and small defects on surface of transparent medium based on super-resolution
Through the method of multi-stage degradation modeling and regional hierarchical detection, combined with adaptive filtering and morphological operators, the problems of composite degradation and multi-regional differences in the detection of tiny defects on the surface of transparent media are solved, and efficient and accurate defect identification and classification are achieved.
Patent Information
- Application Number
- CN202510984084.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-10-28
AI Technical Summary
Existing technologies for transparent media surface defect detection have limitations such as high-magnification lens depth of field limitations, reduced defect contrast, compound degradation phenomena, high missed detection rates, and lack of multi-region differentiated detection, making it difficult to effectively identify and locate tiny defects.
By adopting multi-stage degradation modeling, regional layered detection and dynamic parameter filtering mechanism, combined with adaptive filtering, nonlinear mapping and morphological operators, the accurate identification and positioning of tiny defects on the surface of transparent media can be achieved through image preprocessing, enhancement, segmentation and classification steps.
It significantly improves the accuracy and efficiency of tiny defect detection, reduces missed detection rate and false detection rate, is applicable to different transparent media surfaces, supports automated online detection, reduces labor costs, improves detection speed and accuracy, and provides data support to optimize production processes.
Smart Images

Figure CN120852873A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing and machine vision technology, specifically a method and system for detecting small defects on the surface of transparent media based on super-resolution. Background Art
[0002] In the field of industrial inspection, there are specific technical bottlenecks in the detection of product defects covered by transparent media (such as glass and resin). High-magnification lenses are limited by depth of field and cannot effectively image surface defects under the transparent media layer, usually requiring the use of low-magnification lenses to complete the inspection task. However, low-magnification imaging leads to a significant reduction in defect contrast (approximately 60-80%) and a substantial reduction in the physical size of defects (approximately 1 / 10 to 1 / 20 times). In addition, the actual imaging process is often accompanied by complex degradation phenomena, including anisotropic blurring, sensor noise, non-uniform illumination, and JPEG compression artifacts, among other interference factors. At the same time, different functional areas have significantly different tolerances for defects (e.g., the defect standards in the display area and the border area differ by 5-10 times), further increasing the complexity of the inspection.
[0003] Existing technical solutions exhibit certain limitations in addressing the aforementioned problems: (1) Traditional super-resolution methods (such as bicubic interpolation) are not well adapted to the complex degradation phenomena in the real world; (2) The general defect detection algorithm has a high false negative rate for small defects (<5 pixels), ranging from 30% to 50%; (3) There is a lack of an effective framework that can uniformly handle the differentiated detection in multiple regions.
[0004] These factors collectively limit the performance improvement of current industrial testing technologies in detecting defects in transparent media products. Summary of the Invention
[0005] The main objective of this invention is to provide a super-resolution-based method for detecting small defects on the surface of transparent media, enabling precise identification and location of minute defects (such as scratches, stains, and dents) on the surface of products covered by transparent media. This method significantly improves the detection capability for low-contrast, small-sized defects through multi-stage degradation modeling, regional layered detection, and dynamic parameter filtering mechanisms, while also meeting the differentiated detection needs of different functional areas.
[0006] This invention achieves the above objective through the following technical solution: a method for detecting small defects on the surface of a transparent medium based on super-resolution, comprising the following steps: S1: Acquire the original image of the product to be inspected; S2: Based on the spatial distribution characteristics of pixel gray values in the original image, after removing the background interference area, the target area is extracted, and an adaptive filter is used to smooth the target area, and the overall brightness average of the target area is calculated. S3: Generate the corresponding gray-level histogram based on the gray-level value distribution of all pixels in the original image; S4: Segment the target area and background area based on the position information of the peaks in the grayscale histogram; S5: Perform adaptive filtering on the segmented target region to generate a new image, denoted as the preliminary preprocessed grayscale image; S6: Calculate the average value of all pixels in the pre-processed grayscale image and use the result as the overall brightness average of the target area; S7: Perform nonlinear mapping processing on the gray values of all pixels in the pre-processed grayscale image based on the overall average brightness value, and the resulting new image is denoted as the first enhanced image; S8: Based on the first enhanced image, a specific morphological operator is used to calculate the local maximum gray value in the neighborhood of each pixel position, and the calculation result is used to replace the gray value of the current pixel. The new image generated after traversing the first enhanced image is called the second enhanced image. S9: Perform threshold segmentation processing based on the first enhanced image and the second enhanced image to extract all defective regions existing within the target region; S10: Calculate the centroid coordinates of each region based on all the defect regions, and crop out several images of fixed size on the original image corresponding to the centroid coordinates to generate several defect cropped images; S11: Input the defect cropped image into the pre-trained classification model, and perform category judgment on all input defect cropped images according to the classification model, and output the corresponding defect type.
[0007] Preferably, step S4, which involves segmenting the target region and the background region based on the peak positions in the grayscale histogram, specifically includes: S41: In the grayscale histogram, the horizontal axis represents the grayscale level of each pixel in the image, and the vertical axis represents the frequency of occurrence of pixels with the corresponding grayscale level in the image; peaks with a vertical axis less than a set threshold are ignored. S42: Sort the peaks that are greater than or equal to the set threshold in ascending order of amplitude, select the two peaks with the largest and smallest amplitudes as segmentation references, and calculate the average gray level corresponding to them as the segmentation threshold. S43: The region consisting of all pixels with gray values lower than the segmentation threshold is the target region, and the region consisting of all pixels with gray values higher than the segmentation threshold is the background region.
[0008] Preferably, step S7, which involves performing non-linear mapping processing on the grayscale values of all pixels in the pre-processed grayscale image based on the overall brightness average to generate the first enhanced image, specifically includes: Let I0 be the input preprocessed grayscale image with grayscale values ranging from [a, b], where a = min(I0) and b = max(I0); and I1 be the output first enhanced image with target grayscale values ranging from [c, d]. Then the mapping formula is: ; in, This represents the new grayscale value output after nonlinear mapping; This represents the original grayscale value input in the initial preprocessing of the grayscale image.
[0009] Preferably, the step of calculating the local maximum gray value in the neighborhood of each pixel location using a specific morphological operator based on the first enhanced image specifically includes: Let the first enhanced image be I1, and the specific morphological operator be S. Calculate the local maximum gray value of each pixel location within the neighborhood of the specific morphological operator. The generated second enhanced image I2 is defined as follows: ; in, For the first enhanced image at location The gray value; S is a specific morphological operator that defines the range of the neighborhood (such as a 3×3 square, cross, circle, etc.); (i,j) is the offset in the specific morphological operator S, which traverses all neighborhood positions of the operator; For the second enhanced image at location The gray value is equal to the maximum gray value of all pixels in the neighborhood.
[0010] For each pixel, the pixel grayscale value at the corresponding position of all morphological operators in its neighborhood is calculated, and the maximum value is taken as the final output result to enhance the highlight features in the image.
[0011] Preferably, the step of performing threshold segmentation processing based on the first enhanced image and the second enhanced image to extract all defect regions existing within the target region specifically includes: The first enhanced image and the second enhanced image are divided into multiple rectangular sub-regions according to their width and height; Calculate the overall average brightness of each rectangular sub-region. In the first enhanced image, subtract the preset defect sensitivity threshold from the overall average brightness of the current sub-region to obtain a new threshold, which is recorded as the first extraction threshold. In the second enhanced image, add the preset defect sensitivity threshold to the overall average brightness of the current sub-region to obtain a new threshold, which is recorded as the second extraction threshold. In the first enhanced image, pixels with gray values lower than the first extraction threshold are extracted, and all rectangular sub-regions are traversed sequentially. All extracted regions are recorded as first defect candidate regions. The first defect candidate region is a defect region containing scratches or stains. In the second enhanced image, pixels with gray values higher than the second extraction threshold are extracted, and all rectangular sub-regions are traversed sequentially. All extracted regions are recorded as second defect candidate regions; the second defect candidate region is a defect region containing pits. The first defect candidate region and the second defect candidate region are merged to generate all defect regions existing within the target region.
[0012] Preferably, dividing the first enhanced image and the second enhanced image into multiple rectangular sub-regions according to their width and height specifically includes: S911: Let the coordinates of the upper left corner of the entire rectangular region of the first enhanced image or the second enhanced image be... The coordinates of the lower right corner are Divide it into m rows and n columns to obtain m×n rectangular sub-regions; S912: Calculate the width of each rectangular sub-region and height They are respectively: ; S913: Calculate the coordinate range of each rectangular sub-region: Top left corner coordinates: ; Bottom right corner coordinates: .
[0013] Preferably, the step of calculating the centroid coordinates of each region based on all defect regions specifically includes: Suppose a single defect region R contains N pixels, where the coordinates of the k-th pixel are... The centroid coordinates The calculation formula is: .
[0014] Preferably, several images of fixed sizes are cropped from the original image corresponding to the centroid coordinate positions to generate the several defect-cropped images, specifically including: The cropping region is defined as having a width of w and a height of h on the original image, using centroid coordinates. Calculate the coordinate range of the cutting area: The coordinates of the top right corner of the cropping area are: ; The coordinates of the bottom right corner of the cropping area are: ; Based on the coordinates of the cropping area, cropping is performed on the original image to generate several defect-cropped images.
[0015] Preferably, the defect-cropped images are input into a pre-trained classification model, and the classification model is used to classify all input defect-cropped images and output the corresponding defect type. Specifically, this includes: For all the acquired defective cropped images, they are input into a pre-trained classification model. After the classification model makes a judgment, all categories of the current defective cropped image and their corresponding confidence values are obtained. The category with the highest confidence value is selected as the predicted category of the current defective cropped image, and the confidence value of this category is compared with a preset confidence threshold. If it is lower than the preset confidence threshold, the result is not output. If it is higher than or equal to the preset confidence threshold, the predicted category of the defective cropped image and its confidence value are output.
[0016] Another object of the present invention is to provide a system for detecting small defects on the surface of a transparent medium based on super-resolution, comprising: The image acquisition module is used to acquire the original image of the product to be inspected; The target region extraction module is used to extract the target region after removing background interference areas based on the spatial distribution characteristics of pixel gray values in the original image, and to smooth the target region. The grayscale histogram generation module is used to generate a corresponding grayscale histogram based on the distribution of grayscale values of all pixels in the original image. The region segmentation module is used to segment the target region and the background region based on the position information of the peaks in the grayscale histogram. The image enhancement module is used to perform nonlinear mapping processing on the target region to generate a first enhanced image, and to generate a second enhanced image using a specific morphological operator; The defect extraction module is used to perform threshold segmentation processing based on the first enhanced image and the second enhanced image to extract all defect regions existing within the target region. The defect cropping module is used to crop out several defect images of fixed size based on the centroid coordinates of all defect areas. The defect classification module is used to input the defect-cropped image into a pre-trained classification model and output the corresponding defect type.
[0017] Compared with existing technologies, the beneficial effects of this invention's method and system for detecting small defects on the surface of transparent media based on super-resolution are as follows: This solution aims to solve the problems of low sensitivity and high false negative rate in traditional methods when detecting small defects on the surface of transparent materials (such as glass and plastics). This method combines multiple steps such as image preprocessing, enhancement, segmentation, feature extraction, and classification, forming a complete detection process. Specifically: (1) Improve detection accuracy: Through image enhancement techniques such as adaptive filtering, nonlinear mapping and morphological operators, the contrast between defect areas and normal areas can be significantly improved, so that small defects (such as microcracks, scratches, stains, etc.) can be detected more accurately. (2) Reduce false negatives and false positives: By adopting a dual threshold segmentation strategy, which combines the local brightness mean and the preset defect sensitivity threshold, it is possible to effectively distinguish between real defects and noise, thereby reducing the false negative rate and false positive rate. (3) Improve detection efficiency: The entire detection process is automated. From image acquisition, preprocessing, enhancement, segmentation to classification, no manual intervention is required, which greatly improves detection efficiency. (4) Wide range of applications: This method is not only applicable to traditional transparent materials such as glass, but also to surface defect detection of other transparent media such as plastics and crystals; (5) Accurate classification: By using deep learning models to classify defects, the automatic identification of defect types (such as scratches, cracks, stains, etc.) can be achieved, and classification confidence scores can be given, which improves the accuracy and reliability of defect classification. (6) High flexibility: By adjusting algorithm parameters (such as defect sensitivity threshold, classification model, etc.), it can adapt to different types of transparent media and different defect detection requirements; (7) Easy to integrate: The system can be easily integrated into existing production lines or quality control systems to achieve online detection and improve the automation level of the production process; (8) High cost-effectiveness: Compared with traditional manual inspection methods, this system can significantly reduce labor costs, improve inspection speed and accuracy, thereby bringing higher economic benefits; (9) Data support: By recording and analyzing the test results, data support can be provided for product quality improvement, helping enterprises to optimize production processes and improve product quality. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating an embodiment of the present invention; Figure 2 This is a schematic diagram of the process of extracting the target region from the original image in an embodiment of the present invention; Figure 3 This is a schematic diagram illustrating the process of extracting the target region and the background region in an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the process of obtaining the first enhanced image and the second enhanced image in an embodiment of the present invention; Figure 5 This is a schematic diagram of the process for extracting defect regions from the first enhanced image and the second enhanced image in an embodiment of the present invention; Figure 6 This is a schematic diagram of the process for generating defect areas in an embodiment of the present invention. DETAILED DESCRIPTION
[0019] Example 1: This invention provides a method and system for detecting small defects on transparent media surfaces based on super-resolution. Its core lies in achieving accurate identification and location of low-contrast, small-sized defects through multi-stage degradation modeling, regional layered detection, and a dynamic parameter filtering mechanism. The following is combined with... Figures 1 to 6 The specific embodiments of the present invention will be described in detail below.
[0020] Please refer to Figures 2-3 The process begins with the original image of the product to be inspected, acquired using a high-resolution industrial camera, covering the entire surface of the transparent medium. The original image contains a target area and a background area; the target area represents regions potentially containing defects, while the background area represents regions without defects or with minimal interference. To extract the target area, the spatial distribution characteristics of pixel grayscale values in the original image need to be analyzed. In this step, an adaptive filter is used to process the original image, removing background interference areas to extract the target area, which is then further smoothed to reduce noise. When calculating the overall average brightness of the target area, the grayscale values of all pixels in the target area are statistically analyzed and averaged; this average value will serve as an important reference parameter for subsequent processing. Next, a grayscale histogram is generated based on the original image. The horizontal axis of the grayscale histogram represents the grayscale level of each pixel in the image, and the vertical axis represents the frequency of occurrence of pixels with the corresponding grayscale level. Based on the positional information of the peaks in the grayscale histogram, the target region and the background region are segmented. Specifically, peaks with a vertical axis less than a set threshold are ignored. Peaks with a vertical axis greater than or equal to the set threshold are sorted in ascending order of amplitude. The two peaks with the largest and smallest amplitudes are selected as segmentation references, and their corresponding average grayscale levels are calculated as the segmentation threshold. The region consisting of all pixels with grayscale values below the segmentation threshold is the target region, and the region consisting of all pixels with grayscale values above the segmentation threshold is the background region. This step ensures accurate separation of the target region and the background region, laying the foundation for subsequent processing of the target region.
[0021] Please refer to Figure 4 After extracting the target region, adaptive filtering is applied to generate a preliminary pre-processed grayscale image. The choice of adaptive filter needs to be adjusted according to the characteristics of the target region; for example, a larger filter window can be selected for regions with more noise, while a smaller filter window is used for regions with rich details. After the preliminary pre-processed grayscale image is generated, the average grayscale value of all pixels is calculated, and the result is used as the overall average brightness value of the target region. Subsequently, nonlinear mapping processing is performed on the grayscale values of all pixels in the preliminary pre-processed grayscale image based on the overall average brightness value to generate the first enhanced image.
[0022] The rule for nonlinear mapping is defined as mapping the gray values of the pre-processed grayscale image from the original range to a new range. The mapping formula is: the new gray value equals the original gray value input in the pre-processed grayscale image minus the minimum value of the original grayscale range, multiplied by the mapped grayscale range span, divided by the original grayscale range span, and finally added to the mapped minimum grayscale range. This step enhances the contrast of defects in the target area through nonlinear mapping, making subsequent processing more efficient.
[0023] After the first enhanced image is generated, a specific morphological operator is used to calculate the local maximum gray value in the neighborhood of each pixel location to generate the second enhanced image. Let the input first enhanced image be I, and the specific morphological operator be S. To calculate the local maximum gray value in the neighborhood of each pixel location within the specific morphological operator's neighborhood, it is necessary to traverse the pixel gray values corresponding to all morphological operators in the neighborhood of the current pixel location and take the maximum value as the final output. This step enhances the highlight features in the image through morphological operators, further highlighting defect information in the target area.
[0024] Please refer to Figures 5-6 After generating the first and second enhanced images, threshold segmentation is performed on them to extract all defective regions within the target area.
[0025] First, the first and second enhanced images are divided into multiple rectangular sub-regions according to their width and height. Let the coordinates of the top-left corner of the entire image rectangular region be... The coordinates of the lower right corner are Divide it into m rows and n columns to obtain m×n rectangular sub-regions.
[0026] The width and height of each rectangular sub-region are respectively: width... ,high .
[0027] The coordinates of the top-left and bottom-right corners of the rectangular sub-region are calculated as follows: Top left corner coordinates: ; Bottom right corner coordinates: .
[0028] Within each rectangular sub-region, calculate its overall average brightness. In the first enhanced image, subtract a preset defect sensitivity threshold from the overall average brightness of the current sub-region to obtain a new threshold, which is recorded as the first extraction threshold. In the second enhanced image, add the preset defect sensitivity threshold to the overall average brightness of the current sub-region to obtain a new threshold, which is recorded as the second extraction threshold. Pixels with grayscale values lower than the first extraction threshold are extracted from the first enhanced image. This process is repeated for all rectangular sub-regions, and all extracted regions are recorded as first defect candidate regions, which mainly contain defects such as scratches or stains. Pixels with grayscale values higher than the second extraction threshold are extracted from the second enhanced image. This process is repeated for all rectangular sub-regions, and all extracted regions are recorded as second defect candidate regions, which mainly contain defects such as dents. The first and second defect candidate regions are merged to generate all defect regions present within the target area.
[0029] After extracting the defect regions, the centroid coordinates of each defect region need to be calculated. The formula for calculating the centroid coordinates is: [Formula for centroid x-coordinate]. The sum of the x-coordinates of each pixel within a single defect region divided by the total number of pixels within that single defect region, and the centroid y-coordinate. It equals the sum of the ordinates of each pixel within a single defect region divided by the total number of pixels within that single defect region. Based on centroid coordinates. Several images of fixed sizes are cropped from the original image to generate several defect-cropped images. The width of the cropping region is set to w, and the height to h, using centroid coordinates... The coordinates of the top-left corner of the cropping area are calculated as follows: the x-coordinate of the top-left corner is equal to the x-coordinate of the centroid minus half the width; the y-coordinate of the top-left corner is equal to the y-coordinate of the centroid minus half the height. The coordinates of the bottom-right corner of the cropping area are calculated as follows: the x-coordinate of the bottom-right corner is equal to the x-coordinate of the top-left corner plus the width; the y-coordinate of the bottom-right corner is equal to the y-coordinate of the top-left corner plus the height. Specifically: The coordinates of the top right corner of the cropping area are: ; The coordinates of the bottom right corner of the cropping area are: .
[0030] Based on the coordinates of the cropping area, cropping is performed on the original image to generate several defect-cropped images.
[0031] The generated defect-cropped images are then input into a pre-trained classification model 7 for category determination. Classification model 7 can be constructed using a deep learning framework, such as a convolutional neural network. For all acquired defect-cropped images, they are input into classification model 7. After classification model 7 determines the categories of the current defect-cropped image and their corresponding confidence values, the category with the highest confidence value is selected as the predicted category of the current defect-cropped image, and the confidence value of this category is compared with a preset confidence threshold. If the confidence value is lower than the preset confidence threshold, no result is output; if it is higher than or equal to the preset confidence threshold, the predicted category and its confidence value for the defect-cropped image are output. This step achieves accurate classification of defect types, providing an important basis for subsequent quality control.
[0032] Throughout the process, the steps are closely interconnected and logically clear. The original image is segmented into the target region using a grayscale histogram. The target region undergoes adaptive filtering and smoothing to generate a preliminary pre-processed grayscale image. This preliminary pre-processed grayscale image is then used to generate a first enhanced image via nonlinear mapping. The first enhanced image is further processed using morphological operators to generate a second enhanced image. The first and second enhanced images are then used for threshold segmentation to extract the defect region. The defect region is then processed using centroid coordinate calculation and cropping to generate a defect-cropped image. Finally, the defect-cropped image is used for type determination by classification model 7. These steps work together to successfully detect small defects on the surface of a transparent medium.
[0033] The specific embodiments of the present invention have been described in detail above, including the acquisition of the original image, the generation of the defect-cropped image, and the category determination of classification model 7. Each step provides a specific implementation method and calculation formula, ensuring that those skilled in the art can implement the technical solution according to the specification. To better enable those skilled in the art to fully understand and implement the present invention, the specific implementation principles of the present invention are further explained below in conjunction with a specific application scenario.
[0034] In practical applications, the product to be inspected is a display panel covered with transparent resin, and its surface defects may include scratches, stains, and dents. First, a high-resolution industrial camera is fixed above the inspection equipment, ensuring its field of view completely covers the area to be inspected. When acquiring the original image through the industrial camera, the angle and brightness of the light source need to be adjusted to reduce the impact of non-uniform lighting on image quality. Subsequently, a grayscale histogram is generated based on the original image, and the target area and background area are segmented based on the peak position information. During this process, the selection of the threshold needs to comprehensively consider the current ambient light intensity and the image noise level; typically, 1.5 times the intensity of the main interfering signal in the image is selected as a reference value.
[0035] After extracting the target region, an adaptive filter is used to process it. For edge regions, a smaller window size is selected to preserve detailed features; while for central regions, a larger window is used to effectively suppress noise. After the initial preprocessing of the grayscale image, its overall average brightness is calculated, and a nonlinear mapping process is performed on the image based on this average. This step significantly enhances the visibility of small defects by expanding the dynamic range of the low grayscale range. For example, in one instance, after nonlinear mapping, the defect contrast increased from the initial 10% to 40%, making subsequent processing more efficient.
[0036] After the first enhanced image is generated, a specific morphological operator is used to extract the local maximum grayscale value. The design of this operator needs to be optimized according to the characteristics of the target region. For example, for scratch-like defects, a horizontally extending structural element can be selected; while for pit-like defects, a circular structural element is more suitable. After the second enhanced image is generated, it is divided into multiple rectangular sub-regions together with the first enhanced image. The size of each sub-region needs to be set to reflect local features without being too small, which would lead to statistical errors. For example, in practice, the width and height of the sub-region are set to 1 / 10 of the width and height of the original image, respectively, which can achieve a balance between accuracy and efficiency.
[0037] In the threshold segmentation stage, the setting of the first and second extraction thresholds directly affects the accurate extraction of defect regions. Experiments have verified that when the defect sensitivity threshold is set to 15% of the overall brightness average, it can effectively distinguish real defects from background noise. After merging the extracted first and second defect candidate regions, the centroid coordinates of each defect region are further calculated. The accurate calculation of the centroid coordinates provides a precise positioning basis for subsequent cropping, thus ensuring that the generated defect-cropped image contains complete defect information.
[0038] Finally, the cropped defect image is input into classification model 7 for type determination. Classification model 7 employs a convolutional neural network structure, and its training dataset must cover a variety of typical defect samples to improve the model's generalization ability. In practical applications, the strictness of the detection results can be flexibly controlled by adjusting the model's confidence threshold. For example, setting the confidence threshold to 85% can effectively reduce the false alarm rate while ensuring detection accuracy.
[0039] The above describes in detail the implementation process of this invention in a specific application scenario. Each step is closely linked and logically clear. From the acquisition of the original image to the generation of the defect-cropped image, and then to the category determination of classification model 7, each step provides specific implementation methods and parameter setting basis, ensuring that those skilled in the art can implement this technical solution according to the contents of the specification.
[0040] For those skilled in the art, various modifications and improvements can be made without departing from the inventive concept of this invention, and these all fall within the protection scope of this invention.
Claims
1. A method for detecting small defects on the surface of a transparent medium based on super-resolution, characterized in that, The method includes the following steps: S1: Acquire the original image of the product to be inspected; S2: Based on the spatial distribution characteristics of pixel gray values in the original image, after removing the background interference area, extract the target area, use an adaptive filter to smooth the target area, and calculate the overall average brightness of the target area. S3: Generate the corresponding gray-level histogram based on the gray-level value distribution of all pixels in the original image; S4: Segment the target area and background area based on the position information of the peaks in the grayscale histogram; S5: Perform adaptive filtering on the segmented target region to generate a new image, denoted as the preliminary preprocessed grayscale image; S6: Calculate the average value of all pixels in the pre-processed grayscale image and use the result as the overall brightness average of the target area; S7: Perform nonlinear mapping processing on the gray values of all pixels in the pre-processed grayscale image based on the overall average brightness value, and the resulting new image is denoted as the first enhanced image; S8: Based on the first enhanced image, a specific morphological operator is used to calculate the local maximum gray value in the neighborhood of each pixel position, and the calculation result is used to replace the gray value of the current pixel. The new image generated after traversing the first enhanced image is called the second enhanced image. S9: Perform threshold segmentation processing based on the first enhanced image and the second enhanced image to extract all defective regions existing within the target region; S10: Calculate the centroid coordinates of each region based on all the defect regions, and crop out several images of fixed size on the original image corresponding to the centroid coordinates to generate several defect cropped images; S11: Input the defect cropped image into the pre-trained classification model, and perform category judgment on all input defect cropped images according to the classification model, and output the corresponding defect type.
2. The method for detecting small defects on the surface of a transparent medium based on super-resolution as described in claim 1, characterized in that, Step S4 involves segmenting the target region and the background region based on the peak positions in the grayscale histogram, specifically including: S41: In the grayscale histogram, the horizontal axis represents the grayscale level of each pixel in the image, and the vertical axis represents the frequency of occurrence of pixels with the corresponding grayscale level in the image; peaks with a vertical axis less than a set threshold are ignored. S42: Sort the peaks that are greater than or equal to the set threshold in ascending order of amplitude, select the two peaks with the largest and smallest amplitudes as segmentation references, and calculate the average gray level corresponding to them as the segmentation threshold. S43: The region consisting of all pixels with gray values lower than the segmentation threshold is the target region, and the region consisting of all pixels with gray values higher than the segmentation threshold is the background region.
3. The method for detecting small defects on the surface of a transparent medium based on super-resolution as described in claim 1, characterized in that, In step S7, the grayscale values of all pixels in the pre-processed grayscale image are non-linearly mapped based on the overall brightness average to generate the first enhanced image. Specifically, this includes: set up The input is a pre-processed grayscale image with grayscale values ranging from [a,b], where a=min(I0) and b=max(I0); For the first enhanced image output, whose target grayscale value range is [c, d], the mapping formula is: ; in, This represents the new grayscale value output after nonlinear mapping; This represents the original grayscale value input in the initial preprocessing of the grayscale image.
4. The method for detecting small defects on the surface of a transparent medium based on super-resolution as described in claim 1, characterized in that, In step S8, a specific morphological operator is applied based on the first enhanced image to calculate the local maximum gray value in the neighborhood of each pixel location, specifically including: Let the first enhanced image be I1, and the specific morphological operator be S. Calculate the local maximum gray value of each pixel location within the neighborhood of the specific morphological operator. The generated second enhanced image I2 is defined as follows: ; in, For the first enhanced image at location The gray value; (i,j) is the offset in a specific morphological operator S, traversing all neighborhood positions of the operator; For the second enhanced image at location The grayscale value.
5. The method for detecting small defects on the surface of a transparent medium based on super-resolution as described in claim 1, characterized in that, In step S9, threshold segmentation is performed based on the first enhanced image and the second enhanced image to extract all defect regions within the target area, specifically including: S91: Divide the first enhanced image and the second enhanced image into multiple rectangular sub-regions according to their width and height; S92: Calculate the overall average brightness of each rectangular sub-region. In the first enhanced image, subtract the preset defect sensitivity threshold from the overall average brightness of the current sub-region to obtain a new threshold, which is recorded as the first extraction threshold. In the second enhanced image, add the preset defect sensitivity threshold to the overall average brightness of the current sub-region to obtain a new threshold, which is recorded as the second extraction threshold. S93: In the first enhanced image, extract pixels with gray values lower than the first extraction threshold, and sequentially traverse all rectangular sub-regions, recording all extracted regions as first defect candidate regions; S94: In the second enhanced image, extract pixels with gray values higher than the second extraction threshold, and sequentially traverse all rectangular sub-regions, recording all extracted regions as second defect candidate regions; S95: Merge the first defect candidate region and the second defect candidate region to generate all defect regions existing within the target region.
6. The method for detecting small defects on the surface of a transparent medium based on super-resolution as described in claim 5, characterized in that, Step S91 divides the first enhanced image and the second enhanced image into multiple rectangular sub-regions according to their width and height, specifically including: S911: Let the coordinates of the upper left corner of the entire rectangular region of the first enhanced image or the second enhanced image be... The coordinates of the lower right corner are Divide it into m rows and n columns to obtain m×n rectangular sub-regions; S912: Calculate the width of each rectangular sub-region and height They are respectively: ; S913: Calculate the coordinate range of each rectangular sub-region: Top left corner coordinates: ; Bottom right corner coordinates: 。 7. The method for detecting small defects on the surface of a transparent medium based on super-resolution as described in claim 1, characterized in that, Step S10 calculates the centroid coordinates of each defect region, specifically including: Suppose a single defect region R contains N pixels, where the coordinates of the k-th pixel are... The centroid coordinates The calculation formula is: 。 8. The method for detecting small defects on the surface of a transparent medium based on super-resolution as described in claim 1, characterized in that, Step S10 involves cropping several images of fixed sizes from the original image corresponding to the centroid coordinate positions, generating several defect-cropped images, specifically including: The cropping region is defined as having a width of w and a height of h on the original image, using centroid coordinates. Calculate the coordinate range of the cutting area: The coordinates of the top right corner of the cropping area are: ; The coordinates of the bottom right corner of the cropping area are: ; Based on the coordinates of the cropping area, cropping is performed on the original image to generate several defect-cropped images.
9. The method for detecting weak defects on the surface of a transparent medium based on super-resolution as described in claim 1, characterized in that, In step S11, the defect-cropped image is input into a pre-trained classification model. The classification model then classifies all input defect-cropped images and outputs the corresponding defect type. Specifically, this includes: For all the acquired defective cropped images, they are input into a pre-trained classification model. After the classification model makes a judgment, all categories of the current defective cropped image and their corresponding confidence values are obtained. The category with the highest confidence value is selected as the predicted category of the current defective cropped image, and the confidence value of this category is compared with a preset confidence threshold. If it is lower than the preset confidence threshold, the result is not output. If it is higher than or equal to the preset confidence threshold, the predicted category of the defective cropped image and its confidence value are output.
10. A system for detecting small defects on the surface of a transparent medium based on super-resolution, characterized in that, include: The image acquisition module is used to acquire the original image of the product to be inspected; The target region extraction module is used to extract the target region after removing background interference areas based on the spatial distribution characteristics of pixel gray values in the original image, and to smooth the target region. The grayscale histogram generation module is used to generate a corresponding grayscale histogram based on the distribution of grayscale values of all pixels in the original image. The region segmentation module is used to segment the target region and the background region based on the position information of the peaks in the grayscale histogram. The image enhancement module is used to perform nonlinear mapping processing on the target region to generate a first enhanced image, and to generate a second enhanced image using a specific morphological operator; The defect extraction module is used to perform threshold segmentation processing based on the first enhanced image and the second enhanced image to extract all defect regions existing within the target region. The defect cropping module is used to crop out several defect images of fixed size based on the centroid coordinates of all defect areas. The defect classification module is used to input the defect-cropped image into a pre-trained classification model and output the corresponding defect type.
Citation Information
Cited By
Detection method for analyzing oil accumulation on top surface of steel rail based on projection quantity
CN121544638A