Defect detection method and system based on strong reflection suppression
By identifying and processing the highly reflective areas of the drug pack, a reflection suppression map is generated, which solves the problem of uneven illumination caused by reflectivity in drug pack detection, improves detection accuracy and efficiency, reduces equipment and operation complexity, and is suitable for automation implementation.
Patent Information
- Application Number
- CN202411008166.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-07-26
AI Technical Summary
Due to the strong reflectivity of the outer packaging, the existing drug package defect detection methods cause uneven illumination of the image, making it difficult to identify the accessories and labels inside the drug package, resulting in low detection quality. The commonly used polarized light and polarizing filter methods have high equipment costs and complicated operations. , unable to respond to production line changes in real time.
A defect detection method based on strong reflection suppression is used to identify the drug package area to be inspected by obtaining different reflective image sets, select an identification method based on the brightness standard deviation, divide the strong reflection and weak reflection areas, and use graph convolutional neural network and feature processing Generate a reflection suppression map to detect target defects and reduce the impact of reflectivity and light unevenness.
It improves the accuracy and efficiency of drug package defect detection, reduces equipment and operational complexity, is suitable for stable implementation of automation, improves production line detection quality and efficiency, and reduces costs.
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image analysis, and in particular to a defect detection method and system based on strong reflection suppression. Background Art
[0002] Defect detection of medical tool kits (hereinafter referred to as medicine packages) refers to defect detection of accessories (such as syringes, nozzles, powder and liquid bottles, etc.) in medicine packages (including detection of accessory types, missing parts, positions and foreign objects), which is directly related to the quality of medicine tools and the safety of medicine use. In order to prevent the accessories in the medicine package from shaking or being mixed with foreign objects or being polluted by light, the medicine package is usually sealed with plastic film. As a result, on the defect detection production line, the plastic film on the outside of the medicine package has strong reflectivity, and the medicine package reflects unevenly, resulting in uneven illumination of the obtained medicine package image, poor quality of the medicine package image, and difficulty in identifying the accessories in the medicine package and the labels and text on the accessories, resulting in low quality of medicine package defect detection.
[0003] Currently, polarized light and polarization filters are often used in drug package defect detection to reduce the interference of outer packaging reflections, control and reduce reflected light, thereby improving image clarity and contrast, and facilitating the identification of drug package defects. However, this method has high requirements on equipment and high costs. In addition, the installation and maintenance process of these devices is cumbersome and the operation is complex. They may not be able to respond to rapid changes on the inspection production line in real time. Summary of the invention
[0004] The object of the present invention is to provide a defect detection method and system based on strong reflection suppression.
[0005] The technical solution of the present invention is as follows:
[0006] A defect detection method based on strong reflection suppression includes the following operations:
[0007] S1. Acquire a plurality of different reflective images of the drug package to be inspected to form different reflective image sets; acquire a region of the drug package to be inspected based on the different reflective image sets; and use a reflective image corresponding to the minimum overall contrast value of the region of the drug package to be inspected in different reflective image sets as the reflective image to be inspected;
[0008] S2, judging whether the brightness standard deviation of the reflective image to be inspected is greater than the brightness standard deviation threshold; if greater, identifying the reflective area in the reflective image to be inspected based on the luminosity inconsistency; if not greater, identifying the reflective area in the reflective image to be inspected based on spectral analysis; dividing the reflective area into grids to obtain a plurality of reflective grids; assigning values to a plurality of reflective grids based on the pixel average value and then traversing them; in the process of traversing each reflective grid, connecting the reflective grids whose assignment results are within the same assignment result range within the traversed neighborhood range, and obtaining a plurality of reflective grid connected areas after all reflective grids have been traversed; classifying a plurality of reflective grid connected areas into types according to the sum of the assignment results within the reflective grid connected areas, and obtaining strong reflective areas and weak reflective areas;
[0009] S3, obtaining the strong reflection area, and the area at the corresponding position in all the reflection images in different reflection image sets, to form a set of areas to be fused; the set of areas to be fused is processed by the graph convolutional neural network to obtain a first reflection suppression area; the bright spots and dark blocks in the weak reflection area are respectively processed by opening operation and top hat transformation to obtain a second reflection suppression area; the boundary between the strong reflection area and the weak reflection area is processed by closing operation to obtain a reflection suppression boundary; the first reflection suppression area, the second reflection suppression area and the reflection suppression boundary form a reflection suppression map;
[0010] S4. Perform target defect detection on the reflection suppression image to obtain a drug package defect detection result.
[0011] The method for obtaining the overall contrast in S1 is specifically as follows: obtaining the average pixel value of the drug package area to be inspected, and taking the square root of the ratio of the sum of squares of the differences between the pixels of all position points in the drug package area to be inspected and the average pixel value to the total number of position points as the overall contrast.
[0012] The operations for identifying the reflective area based on the luminosity inconsistency in S2 are as follows: denoising and grayscale processing are performed on the reflective image to be tested to obtain a reflective grayscale image to be tested; convolution operation is performed on the reflective grayscale image to be tested using the convolution kernel of the Laplace operator to calculate the second-order derivative of each pixel; pixels whose second-order derivatives are greater than the derivative threshold are regarded as reflective points; connected domain analysis is performed on all the pixels of the reflective points in the reflective image to be tested to obtain the reflective area.
[0013] The operations for identifying the reflective area based on spectral analysis in S2 are specifically as follows: correcting the reflective image to be tested to obtain a correction image of the reflective image to be tested; converting the correction image of the reflective image to be tested into a Lab color space image to obtain a Lab color map of the reflective image to be tested; taking the pixel points whose color space values of the L channel in the Lab color map of the reflective image to be tested are greater than the color space threshold as reflective points; and performing connected domain analysis on the pixel points of all reflective points in the reflective image to be tested to obtain the reflective area.
[0014] The specific operations of the graph convolutional neural network processing in S3 are as follows: each area to be fused in the set of areas to be fused is processed by channel attention and spatial attention respectively to obtain several weight maps; each area to be fused is fused with its own weight map after weighted processing to obtain a first fused feature map; the first fused feature map and the set of areas to be fused form a first reflection suppression atlas; the first reflection suppression atlas is processed by channel attention, spatial attention, weighted and fused to obtain a second fused feature map; it is determined whether the cross loss entropy between the second fused feature map and the first fused feature map is less than the loss entropy threshold; if so, the second fused feature map is output as the first reflection suppression area; if not, the second fused feature map and the first reflection suppression atlas perform channel attention processing, spatial attention processing, weighted processing, fusion processing and cross loss entropy judgment operations.
[0015] After the operation of forming the reflection suppression map in S3, it also includes obtaining the grayscale co-occurrence matrix of the reflection suppression map, calculating the grayscale contrast of the reflection suppression map based on the grayscale co-occurrence matrix, and judging whether the grayscale contrast is less than the first grayscale contrast threshold; if it is not less than the first grayscale contrast threshold, the reflection suppression map is processed by wavelet transform to obtain a reflection suppression texture enhancement map; if it is between the first grayscale contrast threshold and the second grayscale contrast threshold, the reflection suppression map is sharpened to obtain a reflection suppression texture enhancement map; the first grayscale contrast threshold is greater than the second grayscale contrast threshold; if it is not greater than the second grayscale contrast threshold, the reflection suppression map is filtered to obtain a reflection suppression texture enhancement map; the reflection suppression texture enhancement map is used to execute the operation in S4.
[0016] A defect detection system based on strong reflection suppression, used to implement the above-mentioned defect detection method based on strong reflection suppression, comprising:
[0017] An image acquisition module, used to acquire a number of different reflective images of the drug package to be inspected;
[0018] The image processing module is used to form different reflective image sets from the multiple different reflective images collected by the image acquisition module; based on the different reflective image sets, the drug package area to be inspected is acquired; and the reflective image corresponding to the minimum overall contrast value of the drug package area to be inspected in the different reflective image sets is used as the reflective image to be inspected;
[0019] The reflective region detection module is used to determine whether the brightness standard deviation of the reflective image to be detected in the image processing module is greater than the brightness standard deviation threshold; if greater, the reflective region in the reflective image to be detected is identified based on the luminosity inconsistency; if not greater, the reflective region in the reflective image to be detected is identified based on spectral analysis; the reflective region is gridded to obtain a plurality of reflective grids; based on the pixel average value, a plurality of reflective grids are assigned values and then traversed; in the process of traversing each reflective grid, the reflective grids whose assignment results are within the same assignment result range within the traversed neighborhood are connected, and after all reflective grids are traversed, a plurality of reflective grid connected regions are obtained; according to the sum of the assignment results within the reflective grid connected regions, the plurality of reflective grid connected regions are classified into types to obtain strong reflective regions and weak reflective regions;
[0020] A reflective region suppression module is used to obtain the strong reflective region in the reflective region detection module, and the regions at corresponding positions in all reflective images in different reflective image sets, to form a set of regions to be fused; the set of regions to be fused is processed by a graph convolutional neural network to obtain a first reflective suppression region; the bright spots and dark blocks in the weak reflective region in the reflective region detection module are respectively subjected to opening operations and top-hat transformation processing to obtain a second reflective suppression region; the boundary between the strong reflective region and the weak reflective region in the reflective region detection module is subjected to closing operations to obtain a reflective suppression boundary; the first reflective suppression region, the second reflective suppression region and the reflective suppression boundary form a reflective suppression map;
[0021] The defect detection module is used to perform target defect detection on the reflection suppression map in the reflection area suppression module to obtain a drug package defect detection result.
[0022] The defect detection system based on strong reflection suppression also includes: an image texture enhancement module, which is used to obtain the grayscale co-occurrence matrix of the reflection suppression map in the reflection area suppression module, calculate the grayscale contrast of the reflection suppression map based on the grayscale co-occurrence matrix, and judge whether the grayscale contrast is less than the first grayscale contrast threshold; if it is not less than the first grayscale contrast threshold, the reflection suppression map is processed by wavelet transform to obtain a reflection suppression texture enhancement map; if it is between the first grayscale contrast threshold and the second grayscale contrast threshold, the reflection suppression map is sharpened to obtain a reflection suppression texture enhancement map; the first grayscale contrast threshold is greater than the second grayscale contrast threshold; if it is not greater than the second grayscale contrast threshold, the reflection suppression map is filtered to obtain a reflection suppression texture enhancement map; the reflection suppression texture enhancement map is used to execute the defect detection module.
[0023] The beneficial effects of the present invention are:
[0024] The present invention provides a defect detection method based on strong reflection suppression. First, the area of the medicine package to be inspected is determined by acquiring several different reflection images of the medicine package to be inspected, and the reflection image corresponding to the minimum overall contrast is selected as the reflection image to be inspected; then, according to the brightness standard deviation of the reflection image to be inspected, different reflection area recognition methods are selected to be executed, and based on the pixel value of the reflection area, the strong reflection area and the weak reflection area are determined; finally, different reflection suppression processing is performed on the strong reflection area, the weak reflection area and the boundary between them, while eliminating the influence of reflectivity and light non-uniformity, the image details are enhanced, thereby improving the accuracy of defect recognition; the method is applied to the medicine package defect detection production line, and does not require complex and expensive equipment and cumbersome operating procedures, and can be automatically and stably implemented, which is beneficial to reducing costs while improving the detection quality and detection efficiency of the production line. DETAILED DESCRIPTION
[0025] This embodiment provides a defect detection method based on strong reflection suppression, including the following operations:
[0026] S1. Acquire a plurality of different reflective images of the drug package to be inspected to form different reflective image sets; acquire a region of the drug package to be inspected based on the different reflective image sets; and use a reflective image corresponding to the minimum overall contrast value of the region of the drug package to be inspected in different reflective image sets as the reflective image to be inspected;
[0027] S2, judging whether the brightness standard deviation of the reflective image to be inspected is greater than the brightness standard deviation threshold; if greater, identifying the reflective area in the reflective image to be inspected based on the luminosity inconsistency; if not greater, identifying the reflective area in the reflective image to be inspected based on spectral analysis; dividing the reflective area into grids to obtain a plurality of reflective grids; assigning values to a plurality of reflective grids based on the pixel average value and then traversing them; in the process of traversing each reflective grid, connecting the reflective grids whose assignment results are within the same assignment result range within the traversed neighborhood range, and obtaining a plurality of reflective grid connected areas after all reflective grids have been traversed; classifying a plurality of reflective grid connected areas into types according to the sum of the assignment results within the reflective grid connected areas, and obtaining strong reflective areas and weak reflective areas;
[0028] S3, obtaining the strong reflection area, and the area at the corresponding position in all the reflection images in different reflection image sets, to form a set of areas to be fused; the set of areas to be fused is processed by the graph convolutional neural network to obtain a first reflection suppression area; the bright spots and dark blocks in the weak reflection area are respectively processed by opening operation and top hat transformation to obtain a second reflection suppression area; the boundary between the strong reflection area and the weak reflection area is processed by closing operation to obtain a reflection suppression boundary; the first reflection suppression area, the second reflection suppression area and the reflection suppression boundary form a reflection suppression map;
[0029] S4. Perform target defect detection on the reflection suppression image to obtain a drug package defect detection result.
[0030] S1. Acquire several different reflective images of a drug package to be inspected to form different reflective image sets; acquire a region of the drug package to be inspected based on the different reflective image sets; and use a reflective image corresponding to the minimum overall contrast value of the region of the drug package to be inspected in different reflective image sets as the reflective image to be inspected.
[0031] By acquiring several different reflective images of the drug package to be inspected, the drug package area to be inspected is determined, and the reflective image corresponding to the minimum overall contrast value is selected as the reflective image to be inspected, which is used for subsequent acquisition of the reflective area.
[0032] First, place the medicine package to be inspected on the conveyor belt. When the medicine package to be inspected moves to the camera's camera range, obtain the moving video of the medicine package to be inspected, and select several images with different reflective characteristics at different positions from the video as several different reflective images of the medicine package to be inspected, forming a set of different reflective images. Several different reflective images can be continuous frames or not. The camera is installed above the conveyor belt to take real-time video of the medicine package to be inspected. The distance between the camera and the conveyor belt will be adjusted according to the shape and size of the medicine package to be inspected.
[0033] Then, based on different reflective image sets, the area of the medicine package to be inspected in the reflective image containing the medicine package to be inspected and the conveyor belt is obtained, so as to reduce the reflection suppression processing area and improve the calculation efficiency.
[0034] The operation of obtaining the drug package area to be inspected can be: obtaining a pixel change gradient distribution map of the current reflective image in different reflective image sets, taking the points in the pixel change gradient distribution map where the pixel change gradient is greater than the change gradient threshold as the drug package edge points, and connecting the area formed by all drug package edge points to obtain the drug package area to be inspected in the current reflective image; performing the above operation on all reflective images to obtain the drug package area to be inspected of all reflective images.
[0035] The operation of obtaining the area of the drug package to be inspected can also be: obtaining the difference image of adjacent frames in a set of different reflective images formed by continuous frames; based on the difference threshold, connected area processing and the movement direction of the drug package to be inspected, obtaining the area of the drug package to be inspected in each reflective image.
[0036] Finally, the reflective image corresponding to the minimum overall contrast value of the drug package area to be inspected in different reflective image sets, that is, the reflective image with the lowest reflectivity and the reflective image with a relatively balanced overall contrast, is used as the reflective image to be inspected, so as to improve the accuracy and efficiency of subsequent processing.
[0037] The method for obtaining the overall contrast is specifically as follows: obtaining the average pixel value of the drug package area to be inspected, and taking the square root of the ratio of the sum of squares of the differences between the pixels of all position points in the drug package area to be inspected and the average pixel value to the total number of position points as the overall contrast.
[0038] The overall contrast ratio can be achieved by the following formula:
[0039] ,
[0040] D is the overall contrast, p i The first i The pixels at each location, m is the average pixel value of the drug package area to be inspected, I is the total number of location points.
[0041] S2. Determine whether the brightness standard deviation of the reflective image to be tested is greater than the brightness standard deviation threshold; if greater, identify the reflective area in the reflective image to be tested based on luminosity inconsistency; if not greater, identify the reflective area in the reflective image to be tested based on spectral analysis; divide the reflective area into grids to obtain a number of reflective grids; assign values to the several reflective grids based on the pixel average value; in the process of traversing each reflective grid, connect the reflective grids whose assignment results are within the same assignment result range within the traversed neighborhood range, and after all reflective grids are traversed, obtain a number of reflective grid connected areas; classify the several reflective grid connected areas into types according to the sum of the assignment results in the reflective grid connected areas to obtain strong reflective areas and weak reflective areas.
[0042] According to the brightness standard deviation of the reflective image to be inspected, different reflective area recognition methods are selected, and based on the pixel value of the reflective area, the strong reflective area and the weak reflective area are determined, so as to facilitate the subsequent different reflection suppression processing for different reflective areas, thereby improving the reflection suppression effect.
[0043] First, a brightness standard deviation that can reflect the uniformity of brightness distribution of the reflective image to be inspected is obtained, and it is determined whether the brightness standard deviation of the reflective image to be inspected is greater than a brightness standard deviation threshold.
[0044] If it is greater than, it means that the light source distribution in the reflective image to be tested is very uneven, and the reflective area in the reflective image to be tested needs to be identified based on the inconsistent light intensity. Specifically, the reflective image to be tested is denoised and grayscale processed to obtain a grayscale image of the reflective image to be tested; the convolution kernel of the Laplace operator is used to perform a convolution operation on the grayscale image of the reflective image to be tested, and the second-order derivative of each pixel is calculated; the pixel points whose second-order derivative is greater than the derivative threshold are regarded as reflective points, and the connected domain analysis processing is performed on all the pixel points of the reflective points in the reflective image to be tested to obtain the reflective area.
[0045] If it is not greater than, it means that the uniformity of light source distribution in the reflective image to be inspected is slightly better. Based on spectral analysis, the reflective area in the reflective image to be inspected is identified to improve the recognition efficiency. Specifically, the reflective image to be inspected is corrected to obtain a reflective correction image to be inspected; the reflective correction image to be inspected is converted into a Lab color space image to obtain a reflective Lab color image to be inspected; the pixel points whose color space values of the L channel in the reflective Lab color image to be inspected are greater than the color space threshold value are taken as reflective points, and the connected domain analysis is performed on all the pixel points of the reflective points in the reflective image to be inspected to obtain the reflective area.
[0046] Then, in order to identify the strong reflective area and the weak reflective area in the reflective area and perform targeted reflection suppression processing, thereby improving the effect of reflection suppression, the present embodiment divides the reflective area into grids to obtain a plurality of reflective grids; based on the pixel average value, the plurality of reflective grids are assigned values and then traversed (the larger the pixel average value of the reflective grid, the larger the assignment result); in the process of traversing each reflective grid, the reflective grids whose assignment results are within the same assignment result range within the traversal neighborhood range (within the eight neighborhood ranges of the reflective grid) are connected, and the reflective grids with similar reflectivity are connected; after all the reflective grids have been traversed, a plurality of reflective grid connected areas are obtained.
[0047] Finally, according to the sum of the assignment results in the connected areas of the reflective grid, several connected areas of the reflective grid are divided into categories, and the areas where the sum of the assignment results is greater than and not greater than the assignment and threshold are respectively regarded as strong reflective areas and weak reflective areas, thus obtaining strong reflective areas and weak reflective areas.
[0048] S3. Obtain the strong reflection area, and the area at the corresponding position in all the reflection images in different reflection image sets to form a set of areas to be fused; the set of areas to be fused is processed by the graph convolutional neural network to obtain the first reflection suppression area; open operation and top hat transformation are performed on the bright spots and dark blocks in the weak reflection area respectively to obtain the second reflection suppression area; close operation is performed on the boundary between the strong reflection area and the weak reflection area to obtain the reflection suppression boundary; the first reflection suppression area, the second reflection suppression area and the reflection suppression boundary form a reflection suppression map.
[0049] Different reflection suppression processes are performed on strong reflection areas, weak reflection areas and the boundaries between them, which not only reduces reflection and light unevenness, but also enhances image details, thereby improving the accuracy of subsequent defect identification.
[0050] In order to achieve reflection suppression processing in strong reflective areas, the areas at corresponding positions of the strong reflective areas in all reflective images in different reflective image sets are obtained, and several areas to be fused are obtained to form a set of areas to be fused; the set of areas to be fused is processed by a graph convolutional neural network, and the first reflection suppression area is obtained by fusing images of different reflectivity at the same position.
[0051] Among them, the operations of graph convolutional neural network processing are specifically as follows: in the concentration of areas to be fused, each area to be fused is processed by channel attention and spatial attention respectively to enhance the expression ability of channel features and spatial features, and obtain several weight maps; each area to be fused is fused with its own weight map after weighted processing to obtain a first fused feature map; the first fused feature map and the set of areas to be fused form a first reflection suppression atlas; the first reflection suppression atlas is processed by channel attention, spatial attention, weighted and fused to obtain a second fused feature map; it is determined whether the cross loss entropy of the second fused feature map and the first fused feature map is less than the loss entropy threshold; if it is less than, the second fused feature map is output as the first reflection suppression area; if it is not less than, the second fused feature map and the first reflection suppression atlas form a second reflection suppression atlas, and the operations of channel attention processing, spatial attention processing, weighted processing, fusion processing and cross loss entropy judgment are performed until the conditions are met. The current round of output containing important information required for the fusion task is retained and combined with the current reflection suppression atlas to guide the next round of output, making full use of previous fusion results to improve the quality of subsequent fusion, thereby reducing the reflectivity and light inhomogeneity of strong reflective areas and achieving reflection suppression processing in strong reflective areas.
[0052] In order to achieve the reflection suppression processing in the weak reflection area, the bright spot and dark block in the weak reflection area are respectively subjected to the opening operation and the top hat transformation processing (the dark block minus the result of the dark block opening operation) to obtain the second reflection suppression area. The bright spot is the area formed by the pixel points whose brightness value is greater than the brightness threshold in the weak reflection area, and the dark block is the area formed by the pixel points whose brightness value is not greater than the brightness threshold in the weak reflection area.
[0053] In order to fill the hole at the boundary between the strong reflective area and the weak reflective area and make the boundary of the reflective area clearer, a closing operation is performed on the boundary between the strong reflective area and the weak reflective area to obtain a reflection suppression boundary. The boundary between the strong reflective area and the weak reflective area can be obtained according to the edge of the strong reflective area and / or the edge of the weak reflective area and the first distance and / or the second distance.
[0054] The first reflection suppression area, the second reflection suppression area and the reflection suppression boundary form a reflection suppression map.
[0055] In order to improve the accuracy and efficiency of subsequent target defect detection, after the reflection suppression map is formed, the operation also includes obtaining the grayscale co-occurrence matrix of the reflection suppression map, calculating the grayscale contrast of the reflection suppression map based on the grayscale co-occurrence matrix, and judging whether the grayscale contrast is less than the first grayscale contrast threshold.
[0056] If it is not less than the first grayscale contrast threshold, it means that the texture of the reflection suppression map is not clear. The reflection suppression map is processed by wavelet transform to obtain a reflection suppression texture enhancement map.
[0057] If it is between the first grayscale contrast threshold and the second grayscale contrast threshold, it means that the texture clarity of the reflection suppression image is average, and the reflection suppression image is sharpened to obtain a reflection suppression texture enhanced image; the first grayscale contrast threshold is greater than the second grayscale contrast threshold.
[0058] If it is not greater than the second grayscale contrast threshold, it indicates that the texture clarity of the reflection suppression map is acceptable. The reflection suppression map is filtered (preferably Gabor filter processing) to obtain a reflection suppression texture enhancement map.
[0059] The above-mentioned reflection suppression texture enhancement map is used for the operation in S4.
[0060] S4. Perform target defect detection on the reflection suppression image to obtain a drug package defect detection result.
[0061] The specific operation of performing target defect detection on the reflection suppression map or the reflection suppression texture enhancement map is as follows: the reflection suppression map or the reflection suppression texture enhancement map is processed by bounding box regression and classification to obtain an initial drug package detection map containing multiple bounding boxes in the same area, each bounding box containing multiple classification types and corresponding classification probabilities; the bounding box corresponding to the maximum intersection-and-union ratio with the real box in the same area in the initial drug package detection map is retained to obtain the optimal drug package detection map; the classification type corresponding to the maximum classification probability in the optimal drug package detection map is used as the identification type of the corresponding bounding box; and the drug package defect detection result is obtained based on the identification types of all bounding boxes.
[0062] Among them, the classification processing can be obtained based on the structural similarity between the bounding box to be processed and several standard drug package defect label images.
[0063] The above-mentioned target defect detection operations include but are not limited to being implemented through a deep learning model.
[0064] This embodiment further provides a defect detection system based on strong reflection suppression, which is used to implement the above-mentioned defect detection method based on strong reflection suppression, including:
[0065] An image acquisition module, used to acquire a number of different reflective images of the drug package to be inspected;
[0066] The image processing module is used to form different reflective image sets from the multiple different reflective images collected by the image acquisition module; based on the different reflective image sets, the drug package area to be inspected is acquired; and the reflective image corresponding to the minimum overall contrast value of the drug package area to be inspected in the different reflective image sets is used as the reflective image to be inspected;
[0067] The reflective region detection module is used to determine whether the brightness standard deviation of the reflective image to be detected in the image processing module is greater than the brightness standard deviation threshold; if greater, the reflective region in the reflective image to be detected is identified based on the luminosity inconsistency; if not greater, the reflective region in the reflective image to be detected is identified based on spectral analysis; the reflective region is gridded to obtain a plurality of reflective grids; based on the pixel average value, a plurality of reflective grids are assigned values and then traversed; in the process of traversing each reflective grid, the reflective grids whose assignment results are within the same assignment result range within the traversed neighborhood are connected, and after all reflective grids are traversed, a plurality of reflective grid connected regions are obtained; according to the sum of the assignment results within the reflective grid connected regions, the plurality of reflective grid connected regions are classified into types to obtain strong reflective regions and weak reflective regions;
[0068] A reflective region suppression module is used to obtain the strong reflective region in the reflective region detection module, and the regions at corresponding positions in all reflective images in different reflective image sets, to form a set of regions to be fused; the set of regions to be fused is processed by a graph convolutional neural network to obtain a first reflective suppression region; the bright spots and dark blocks in the weak reflective region in the reflective region detection module are respectively subjected to opening operations and top-hat transformation processing to obtain a second reflective suppression region; the boundary between the strong reflective region and the weak reflective region in the reflective region detection module is subjected to closing operations to obtain a reflective suppression boundary; the first reflective suppression region, the second reflective suppression region and the reflective suppression boundary form a reflective suppression map;
[0069] The defect detection module is used to perform target defect detection on the reflection suppression map in the reflection area suppression module to obtain a drug package defect detection result.
[0070] The defect detection system based on strong reflection suppression also includes:
[0071] An image texture enhancement module is used to obtain the grayscale co-occurrence matrix of the reflection suppression map in the reflection area suppression module, calculate the grayscale contrast of the reflection suppression map based on the grayscale co-occurrence matrix, and determine whether the grayscale contrast is less than a first grayscale contrast threshold; if it is not less than the first grayscale contrast threshold, the reflection suppression map is processed by wavelet transform to obtain a reflection suppression texture enhancement map; if it is between the first grayscale contrast threshold and the second grayscale contrast threshold, the reflection suppression map is sharpened to obtain a reflection suppression texture enhancement map; the first grayscale contrast threshold is greater than the second grayscale contrast threshold; if it is not greater than the second grayscale contrast threshold, the reflection suppression map is filtered to obtain a reflection suppression texture enhancement map; the reflection suppression texture enhancement map is used to execute the defect detection module.
[0072] The present embodiment provides a defect detection method based on strong reflection suppression. First, the area of the medicine package to be inspected is determined by acquiring several different reflection images of the medicine package to be inspected, and the reflection image corresponding to the minimum overall contrast is selected as the reflection image to be inspected; then, different reflection area recognition methods are selected according to the brightness standard deviation of the reflection image to be inspected, and the strong reflection area and the weak reflection area are determined based on the pixel value of the reflection area; finally, different reflection suppression processes are performed on the strong reflection area, the weak reflection area and the boundaries between them, so as to enhance the image details while eliminating the influence of reflectivity and light non-uniformity, thereby improving the accuracy of defect identification; this method is applied to the medicine package defect detection production line, and can be automatically and stably implemented without complex and expensive equipment and cumbersome operating procedures, which is beneficial to reducing costs while improving the detection quality and detection efficiency of the production line.
Claims
1. A defect detection method based on strong reflection suppression, characterized in that: The following operations are included: S1. Acquire a plurality of different reflective images of a drug package to be inspected to form a set of different reflective images; acquire a region of the drug package to be inspected based on the set of different reflective images; and use a reflective image corresponding to the minimum overall contrast value of the region of the drug package to be inspected in the set of different reflective images as the reflective image to be inspected; S2, determining whether the brightness standard deviation of the reflective image to be inspected is greater than a brightness standard deviation threshold; if so, identifying the reflective area in the reflective image to be inspected based on the luminosity inconsistency; If not, identifying the reflective area in the reflective image to be inspected based on spectral analysis; Dividing the reflective area into grids to obtain a plurality of reflective grids; Based on the pixel average value, several reflective grids are assigned values and then traversed; in the process of traversing each reflective grid, reflective grids whose assignment results are within the same assignment result range within the traversal neighborhood are connected, and after all reflective grids are traversed, several reflective grid connected areas are obtained; according to the sum of the assignment results in the reflective grid connected areas, several reflective grid connected areas are classified into types to obtain strong reflective areas and weak reflective areas; S3, obtaining a strong reflection area, and forming a set of regions to be fused by regions at corresponding positions in all the reflection images in the different reflection image sets; the set of regions to be fused is processed by a graph convolutional neural network to obtain a first reflection suppression area; Performing opening operation and top-hat transformation processing on the bright spots and dark blocks in the weak reflection area respectively to obtain a second reflection suppression area; Performing a closing operation on the boundary between the strong reflective area and the weak reflective area to obtain a reflection suppression boundary; The first reflection suppression area, the second reflection suppression area and the reflection suppression boundary form a reflection suppression map; S4. Perform target defect detection on the reflection suppression image to obtain a drug package defect detection result.
2. The defect detection method based on strong reflection suppression according to claim 1 is characterized in that: The method for obtaining the overall contrast in S1 is specifically as follows: The pixel average value of the drug package area to be inspected is obtained, and the square root of the ratio of the sum of squares of the differences between the pixels of all the position points in the drug package area to be inspected and the pixel average value to the total number of the position points is taken as the overall contrast.
3. The defect detection method based on strong reflection suppression according to claim 1 is characterized in that: In S2, the operation of identifying the reflective area based on the inconsistent light intensity is specifically as follows: The reflective image to be inspected is subjected to denoising and grayscale processing to obtain a reflective grayscale image to be inspected; a convolution operation is performed on the reflective grayscale image to be inspected using a convolution kernel of a Laplace operator to calculate the second-order derivative of each pixel; pixels whose second-order derivatives are greater than a derivative threshold are regarded as reflective points; and connected domain analysis processing is performed on pixel points of all reflective points in the reflective image to be inspected to obtain the reflective area.
4. The defect detection method based on strong reflection suppression according to claim 1 is characterized in that: In S2, the operation of identifying the reflective area based on spectral analysis is specifically as follows: Correction processing is performed on the reflection image to be inspected to obtain a reflection correction image to be inspected; the reflection correction image to be inspected is converted into a Lab color space image to obtain a reflection Lab color image to be inspected; and pixels whose color space values of the L channel in the reflection Lab color image to be inspected are greater than a color space threshold are taken as reflection points; Connected domain analysis is performed on pixel points of all reflective points in the reflective image to be inspected to obtain the reflective area.
5. The defect detection method based on strong reflection suppression according to claim 1 is characterized in that: The operations of the graph convolutional neural network processing in S3 are specifically as follows: Each of the regions to be fused in the region set to be fused is subjected to channel attention processing and spatial attention processing respectively to obtain a plurality of weight maps; each region to be fused is subjected to weighted processing with its own weight map respectively and then fused to obtain a first fused feature map; The first fused feature map and the to-be-fused region set form a first reflection suppression atlas; the first reflection suppression atlas is processed by channel attention, spatial attention, weighted and fused to obtain a second fused feature map; Determine whether the cross loss entropy between the second fused feature map and the first fused feature map is less than a loss entropy threshold; If it is less than, output the second fused feature map as the first reflection suppression area; If it is not less than, the second fused feature map and the first reflection suppression atlas perform channel attention processing, spatial attention processing, weighted processing, fusion processing and cross-loss entropy judgment operations.
6. The defect detection method based on strong reflection suppression according to claim 1 is characterized in that: After the operation of forming the reflection suppression map in S3, the method further includes obtaining a gray level co-occurrence matrix of the reflection suppression map, calculating the gray level contrast of the reflection suppression map based on the gray level co-occurrence matrix, and determining whether the gray level contrast is less than a first gray level contrast threshold; If it is not less than the first grayscale contrast threshold, the reflection suppression map is processed by wavelet transform to obtain a reflection suppression texture enhancement map; If it is between the first grayscale contrast threshold and the second grayscale contrast threshold, the reflection suppression map is sharpened to obtain a reflection suppression texture enhancement map; the first grayscale contrast threshold is greater than the second grayscale contrast threshold; If it is not greater than the second grayscale contrast threshold, the reflection suppression map is filtered to obtain a reflection suppression texture enhancement map; The reflection suppression texture enhancement map is used to perform the operation in S4.
7. A defect detection system based on strong reflection suppression, used to implement the defect detection method based on strong reflection suppression according to claim 1, characterized in that: include: An image acquisition module, used to acquire a number of different reflective images of the drug package to be inspected; An image processing module, used to form different reflective image sets from the multiple different reflective images collected by the image acquisition module; based on the different reflective image sets, obtain the drug package area to be inspected; and use the reflective image corresponding to the minimum overall contrast value of the drug package area to be inspected in the different reflective image sets as the reflective image to be inspected; A reflective region detection module, used to determine whether the brightness standard deviation of the reflective image to be detected in the image processing module is greater than a brightness standard deviation threshold; if greater, identifying the reflective region in the reflective image to be detected based on the luminosity inconsistency; If not, identifying the reflective area in the reflective image to be inspected based on spectral analysis; Dividing the reflective area into grids to obtain a plurality of reflective grids; Based on the pixel average value, several reflective grids are assigned values and then traversed; in the process of traversing each reflective grid, reflective grids whose assignment results are within the same assignment result range within the traversal neighborhood are connected, and after all reflective grids are traversed, several reflective grid connected areas are obtained; according to the sum of the assignment results in the reflective grid connected areas, several reflective grid connected areas are classified into types to obtain strong reflective areas and weak reflective areas; a reflective region suppression module, for obtaining the strong reflective region in the reflective region detection module, and the regions at corresponding positions in all reflective images in the different reflective image sets, to form a set of regions to be fused; the set of regions to be fused is processed by a graph convolutional neural network to obtain a first reflective suppression region; the bright spots and dark blocks in the weak reflective region in the reflective region detection module are respectively subjected to an opening operation and a top-hat transformation process to obtain a second reflective suppression region; the boundary between the strong reflective region and the weak reflective region in the reflective region detection module is subjected to a closing operation process to obtain a reflective suppression boundary; the first reflective suppression region, the second reflective suppression region and the reflective suppression boundary form a reflective suppression map; The defect detection module is used to perform target defect detection on the reflection suppression map in the reflection area suppression module to obtain a drug package defect detection result.
8. The defect detection system based on strong reflection suppression according to claim 7 is characterized in that: Also includes: An image texture enhancement module, used to obtain a grayscale co-occurrence matrix of the reflection suppression map in the reflection area suppression module, calculate the contrast of the grayscale of the reflection suppression map based on the grayscale co-occurrence matrix, and determine whether the contrast of the grayscale is less than a first grayscale contrast threshold; If it is not less than the first grayscale contrast threshold, the reflection suppression map is processed by wavelet transform to obtain a reflection suppression texture enhancement map; if it is between the first grayscale contrast threshold and the second grayscale contrast threshold, the reflection suppression map is processed by sharpening to obtain a reflection suppression texture enhancement map; the first grayscale contrast threshold is greater than the second grayscale contrast threshold; If it is not greater than the second grayscale contrast threshold, the reflection suppression map is filtered to obtain a reflection suppression texture enhancement map; the reflection suppression texture enhancement map is used to execute the defect detection module.
Citation Information
Patent Citations
Vehicle detection method for eliminating night road reflective interference
CN104732235A
Method for removing edge reflection light spots in electroplated workpiece surface defect visual inspection
CN112927189A
Defect detection method and system, electronic equipment and computer readable storage medium
CN114219758A
Online welding spot quality detection method
CN115330772A
Intelligent detection method for production quality of power adapter
CN116703909A
