An intelligent detection system for capsule appearance defect recognition
Through the intelligent detection system, the capsule image is blocked and targeted analysis is performed, and adaptive enhancement is combined with the CLAHE algorithm, which solves the problem of difficult identification of stains on the capsule surface, and improves the accuracy of detection and the enhancement effect of contrast.
Patent Information
- Application Number
- CN202510065350.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2045-01-16
AI Technical Summary
The capsule surface is stained due to wet or viscous fillers and uneven drying conditions, which affects the uniformity and solubility of the capsule, and is difficult to effectively identify through traditional image enhancement algorithms.
Using an intelligent detection system, the target degree of the sub-graph is calculated through image chunking, grayscale distribution similarity and change feature analysis, and divided it into important sub-graphs and non-important sub-graphs. The capsule images are adaptively enhanced by combining the CLAHE algorithm to identify and screen capsules containing stains.
It improves the accuracy of capsule surface defect detection, avoids excessively enhanced noise points, and ensures smoothness and effective enhancement of the grayscale histogram.
Smart Images

Figure CN119540226B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of capsule appearance defect detection, and in particular to an intelligent detection system for capsule appearance defect recognition. Background Art
[0002] During the production process of capsules, stains may appear on the surface of the capsules due to excessive moisture or viscosity of the capsule filling material, uneven temperature or humidity during the capsule drying process, and thus appearance defects. The stains on the surface of the capsules will not only affect the uniformity of the capsules, causing problems with their solubility in the digestive system, and not dissolving and releasing drugs in the gastrointestinal tract in the predetermined manner, affecting the drug properties; they will also cause patients to doubt the quality of the drugs, thereby affecting their willingness to purchase and use them. Therefore, it is very necessary to screen out capsules with appearance defects such as stains on the surface. Since the surface of the capsule is smooth and reflects ambient light and shadow, and the stains are similar to the ambient light and shadow characteristics reflected by the capsules and are difficult to distinguish, it is necessary to perform image enhancement on the capsule stain area in order to better screen out the capsules containing stains.
[0003] Traditionally, when enhancing capsule images, the Contrast-Limited Adaptive Histogram Equalization (CLAHE) algorithm is usually used to effectively improve the local contrast of the image. During the image enhancement process, this algorithm sets a contrast limit value (ClipLimit) parameter for the image, and evenly distributes the part exceeding the parameter to each gray level to limit the degree of local enhancement of the image. However, evenly distributing the part exceeding the parameter to each gray level will change the peak trend of the gray histogram of the original image and weaken the contrast of important sub-images. Summary of the invention
[0004] In order to solve the above technical problems, the purpose of the present invention is to provide an intelligent detection system for capsule appearance defect recognition, and the technical solution adopted is as follows:
[0005] An embodiment of the present invention provides an intelligent detection system for capsule appearance defect recognition, the system comprising:
[0006] An image segmentation module is used to collect capsule images and grayscale them to obtain grayscale images; the grayscale images are segmented to obtain sub-images;
[0007] A grayscale distribution similarity acquisition module is used to calculate the grayscale distribution similarity of the sub-images based on the grayscale levels of the sub-images and the entropy values of the gradient directions of the pixels;
[0008] The target degree acquisition module is used to obtain the similarity of the grayscale image change characteristics of the sub-image according to the change of the pixel points in each row of the sub-image; the target degree of the sub-image is obtained by multiplying the grayscale distribution similarity of the sub-image and the grayscale image change characteristic similarity and normalizing them;
[0009] The importance calculation module is used to obtain the peak area and the trough area in the grayscale histogram curve corresponding to the sub-image, and divide the sub-image into important sub-images and unimportant sub-images according to the target degree; the importance of the peak area is obtained according to the peak value of the peak area corresponding to the important sub-image;
[0010] A trend allocation part acquisition module is used to calculate the trend allocation part of each peak area according to the target degree of the non-important sub-image and the part exceeding the contrast limit value parameter; and calculate the trend allocation part of each peak area according to the target degree of the important sub-image, the part exceeding the contrast limit value parameter and the importance of each peak area;
[0011] The defect detection module is used to enhance the capsule image based on the trend distribution part of each peak area in the non-important sub-image and the important sub-image combined with the CLAHE algorithm; and use the enhanced capsule image to identify the appearance defects of the capsule.
[0012] Preferably, the grayscale distribution similarity of the sub-images is calculated based on the grayscale levels of the sub-images and the entropy values of the gradient directions of the pixels, including:
[0013] The entropy value of the gradient direction of the pixel point in a sub-image is inverted and multiplied with the grayscale level of the sub-image to obtain the multiplication result, and the multiplication result is mapped using an exponential function with a natural constant as the base to obtain the grayscale distribution similarity of the sub-image.
[0014] Preferably, obtaining the similarity of grayscale image change characteristics of the sub-images according to the change of pixel points in each row of the sub-images includes:
[0015] Map each row of pixels in the sub-image to a two-dimensional plane coordinate system to obtain the grayscale curve corresponding to each row of pixels, where the pixel position is the horizontal axis and the grayscale value is the vertical axis; obtain the standard deviation of the slope corresponding to each pixel on the grayscale curve, recorded as the grayscale standard deviation; obtain the number of peak points on the grayscale curve, recorded as the number of fluctuations; average the product of the grayscale standard deviation and the number of fluctuations of the grayscale curve corresponding to each row of pixels in the sub-image to obtain the grayscale change feature; use an exponential function with a natural constant as the base to map the inverse of the grayscale change feature to obtain the similarity of the grayscale image change features of the sub-image.
[0016] Preferably, obtaining the peak area and the trough area in the grayscale histogram curve corresponding to the sub-image includes:
[0017] Construct a grayscale histogram of the sub-image, perform Gaussian smoothing on the amplitude sequence corresponding to the grayscale histogram of the sub-image, and obtain a smoothed curve, which is recorded as a grayscale histogram curve; obtain each peak point and each trough point in the grayscale histogram curve; for a trough point, take the difference between the ordinate of the peak point with a smaller peak value among its adjacent peak points and the ordinate of the trough point to obtain a difference, and use the sum of the difference of a preset multiple and the ordinate of the trough point as the first distance; draw a straight line parallel to the horizontal axis at the first distance from the horizontal axis of the coordinate system, intersecting with the trough corresponding to the trough point respectively, and obtain two intersection points, which are recorded as boundary points; obtain the dividing point corresponding to each trough point, connect the two dividing points on the trough to obtain the trough area, and connect the two dividing points on the peak to obtain the peak area.
[0018] Preferably, the subgraphs are divided into important subgraphs and unimportant subgraphs using the target degree, including:
[0019] A subgraph whose target degree is greater than a first threshold is marked as an important subgraph, and a subgraph whose target degree is less than or equal to the first threshold is marked as a non-important subgraph.
[0020] Preferably, obtaining the importance of the peak area according to the peak value of the peak area corresponding to the important sub-graph includes:
[0021] The inverse of the peak value of the peak area corresponding to the important sub-image is obtained, and recorded as the importance of the peak area corresponding to the important sub-image.
[0022] Preferably, the trend allocation part of each peak area is calculated according to the target degree of the non-important sub-image and the parameter part exceeding the contrast limit value, including:
[0023] The parameter portion of the non-important sub-image that exceeds the contrast limit value, the target degree and the adjustment factor are multiplied and compared with the data of the peak area corresponding to the non-important sub-image to obtain the trend distribution portion of the peak area corresponding to the non-important sub-image.
[0024] Preferably, the trend allocation part of each peak area is calculated according to the target degree of the important sub-image, the part exceeding the contrast limit value parameter and the importance degree of each peak area, including:
[0025] The target degree of the important sub-image, the part exceeding the contrast limit parameter, the normalized result of the importance degree of a peak area corresponding to the important sub-image and the adjustment factor are multiplied together to obtain the trend allocation part of the peak area corresponding to the important sub-image.
[0026] Preferably, using the enhanced capsule image to identify the appearance defects of the capsule includes:
[0027] The enhanced capsule image is input into the defect recognition model to identify the defects on the capsule surface.
[0028] The embodiments of the present invention have at least the following beneficial effects: the present application divides the grayscale image corresponding to the capsule image into blocks according to the steps of the CLAHE algorithm to obtain various sub-images, and then calculates the grayscale distribution similarity of the sub-image based on the grayscale level of the sub-image and the entropy value of the gradient direction of the pixel point, and then obtains the similarity of the grayscale image change characteristics of the sub-image according to the change of each row of pixel points in the sub-image, and obtains the target degree of the sub-image by comprehensively analyzing the grayscale distribution similarity of the sub-image and the grayscale image change characteristic similarity, and can perform a preliminary analysis based on the grayscale level of the sub-image, pixel change and change of each row of pixel points to obtain a more comprehensive and accurate target degree, and then obtain important sub-images and unimportant sub-images. sub-image; further, obtain the peak area and trough area in the grayscale histogram curve corresponding to the sub-image, calculate the importance of the peak area corresponding to the important sub-image, that is, the importance of the grayscale level in the important sub-image; finally, separate the important sub-image and the unimportant sub-image for analysis, calculate the trend distribution part of each peak area of the unimportant sub-image and the trend distribution part of each peak area of the important sub-image, and then enhance the capsule image with the CLAHE algorithm, while ensuring that the cumulative distribution function of the grayscale histogram becomes flat, enhance the contrast of the sub-image containing stains to the greatest extent, avoid excessive enhancement of noise points, and improve the accuracy of capsule surface defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1 A system block diagram of an intelligent detection system for capsule appearance defect recognition provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation, structure, features and effects of an intelligent detection system for capsule appearance defect recognition proposed according to the present invention in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures, or characteristics in one or more embodiments may be combined in any suitable form.
[0032] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0033] The following is a detailed description of a specific solution of an intelligent detection system for capsule appearance defect recognition provided by the present invention in conjunction with the accompanying drawings.
[0034] Example:
[0035] The main application scenario of the present invention is: when the capsule image is enhanced traditionally, the CLAHE algorithm is usually used to effectively improve the local contrast of the image. During the image enhancement process, the algorithm sets a contrast limit value (ClipLimit) parameter for the image, and evenly distributes the part exceeding the parameter to each gray level to limit the degree of local enhancement of the image. However, evenly distributing the part exceeding the parameter to each gray level will change the peak trend of the gray histogram of the original image and weaken the contrast of important sub-images. Therefore, it is necessary to calculate the part exceeding the parameter distributed to each gray level and then distribute it.
[0036] See also Figure 1 , which shows a system block diagram of an intelligent detection system for capsule appearance defect recognition provided by an embodiment of the present invention, the system includes the following modules:
[0037] The image segmentation module is used to collect capsule images and grayscale them to obtain grayscale images; the grayscale images are segmented to obtain sub-images.
[0038] The surface image of the capsule placed on the transmission track is collected by an industrial camera arranged above the transmission track of the quality inspection line, which is recorded as a capsule image, and then the capsule image is gray-processed to obtain a gray-scale image. When performing the CLAHE algorithm (Contrast Limited Adaptive Histogram Equalization algorithm), the image needs to be processed in blocks, so the capsule image and the gray-scale image are divided in this application. Specifically, the currently collected capsule image and the corresponding gray-scale image are processed in blocks by the default 8×8 in the algorithm to obtain multiple image blocks, and each image block is recorded as a sub-image, thereby obtaining multiple sub-images.
[0039] The grayscale distribution similarity acquisition module is used to calculate the grayscale distribution similarity of the sub-images based on the grayscale levels of the sub-images and the entropy values of the gradient directions of the pixels.
[0040] Since the capsule surface is smooth, it will reflect ambient light and shadow, which is similar to the characteristics of the capsule stains and difficult to distinguish, so the capsule image needs to be enhanced. When using the CLAHE algorithm to enhance the capsule image, evenly distributing the part that exceeds the contrast limit value parameter to each gray level will change the peak trend of the grayscale histogram of the original image, causing the grayscale of the restricted sub-image to deviate from the original grayscale, resulting in insufficient or excessive enhancement of some grayscale levels of the sub-image, thereby affecting the display effect of the area and being unfavorable for the subsequent identification and screening of capsules with appearance defects. Therefore, according to the target degree of each sub-image, it is necessary to adaptively distribute the part of the histogram of each sub-image that exceeds the parameter to each gray level, while ensuring that the cumulative distribution function of the grayscale histogram becomes flat, and maximize the contrast of the sub-image containing stains, and avoid excessive enhancement of noise points.
[0041] Although the capsule surface stain area and the ambient light and shadow interference area (hereinafter referred to as the interference area) are both block areas with low grayscale values in the grayscale image, the ambient interference area reflects the surrounding environment, so the internal grayscale value is variable, that is, the corresponding grayscale image changes more dramatically, and the capsule surface stains are mostly caused by improper temperature and humidity, which causes the drug in the capsule to melt and cause stains on the capsule surface, so the stain area shows a gradual change in the internal grayscale value, that is, the corresponding grayscale image changes more slowly. Based on the above characteristics, the target degree can be obtained according to the change characteristics of the grayscale image corresponding to each sub-image.
[0042] Since the grayscale change characteristics of the stain and interference area on the capsule surface are different, the target degree is obtained according to the grayscale change characteristics of the sub-image. Although there is no large difference in grayscale value between the stain area and the interference area on the capsule surface, there is a large difference in the grayscale distribution similarity and grayscale image change characteristics in the corresponding sub-image. Therefore, the corresponding target degree can be obtained according to the grayscale distribution similarity and grayscale image change characteristics of any sub-image.
[0043] First, obtain the grayscale histogram of any sub-image, and count the number of grayscale levels of the sub-image. The more grayscale levels there are, the higher the corresponding grayscale distribution similarity. Then obtain the gradient corresponding to each pixel of the sub-image. Since the grayscale level of the target area, i.e., the stain area, and the grayscale level of the interference area are both high, it is also necessary to calculate the grayscale gradient chaos corresponding to each sub-image to more accurately obtain the target degree of the sub-image. The grayscale gradient of the target area has a certain regularity due to the gradient characteristics of the edge, while the grayscale gradient of the interference area is irregular and more complex and chaotic due to the complex formation reasons. In summary, the grayscale distribution similarity of any sub-image is composed of the grayscale level and gradient chaos corresponding to the sub-image.
[0044] Specifically, the grayscale distribution similarity of the sub-images is calculated based on the grayscale level of the sub-images and the entropy value of the gradient direction of the pixel points, including: inverting the entropy value of the gradient direction of the pixel points in a sub-image and multiplying it with the grayscale level of the sub-image to obtain the multiplication result, and using an exponential function with a natural constant as the base to map the multiplication result to obtain the grayscale distribution similarity of the sub-image. The specific calculation formula is:
[0045] ,
[0046] Among them, αj represents the grayscale distribution similarity of the j-th sub-image; exp() represents the exponential function with the natural constant e as the base; Lj represents the grayscale level of the j-th sub-image. The larger the grayscale level, the more likely the sub-image contains the target area; di is the gradient direction of the i-th pixel; p(di) is the probability that the gradient direction of the i-th pixel in the j-th sub-image appears in the sub-image; Represents the entropy value of the gradient direction of the jth subgraph. The more chaotic the gradient direction is, the larger the entropy value is, and the lower the degree of the subgraph target is. It means that the larger the grayscale level of the jth sub-image is and the lower the gradient chaos is, the more similar the grayscale distribution is to the target area, and the larger the value is.
[0047] Thus, the grayscale distribution similarity of each sub-image can be obtained.
[0048] The target degree acquisition module is used to obtain the similarity of the grayscale image change characteristics of the sub-image according to the change of the pixel points in each row of the sub-image; the grayscale distribution similarity of the sub-image and the grayscale image change characteristic similarity are multiplied and normalized to obtain the target degree of the sub-image.
[0049] The grayscale distribution similarity of each sub-image is obtained above. Furthermore, the grayscale image change characteristics of the sub-image need to be considered. Since the change characteristics of the grayscale image need to be considered, the grayscale image of the sub-image needs to be obtained first. For this sub-image, the pixel position is used as the horizontal axis and the grayscale value is used as the vertical axis, and a grayscale image is drawn for each row of pixels. Since the stain area is shown as a gradual change in grayscale value from the center to the outside, and the ambient light and shadow are mapped to the surrounding environment and the capsule is smooth, its grayscale value does not have a gradual change feature and the edge is relatively clear, and there is no gradual change feature. The target area corresponds to each row of the grayscale image, which shows a smooth curve change without many fluctuations; the interference area is a relatively drastic change in the grayscale curve, with more fluctuations.
[0050] After obtaining the grayscale image corresponding to each row, it is necessary to calculate whether the grayscale curve changes smoothly or violently. The degree of change of the grayscale curve can be represented by the slope of the grayscale curve. If the slope changes slightly, the fluctuation is gentle, otherwise it changes violently. Therefore, it is necessary to calculate the slope of each pixel on the grayscale curve and obtain the standard deviation of the slope. The larger the standard deviation, the greater the slope change, otherwise it changes slightly. The number of fluctuations of the grayscale curve can be obtained by using the AMPD (Automatic Multiscale Peak Detection) algorithm to obtain the peak point in the current grayscale curve and the number of peak points in the grayscale curve. According to the standard deviation of the slope of each pixel on the grayscale curve in the grayscale image and the number of peak points, the similarity of the change characteristics of the grayscale image corresponding to each row of pixels is obtained, and then the mean is taken as the similarity of the change characteristics of the grayscale image of the sub-image.
[0051] Specifically, each row of pixels in the sub-image is mapped to a two-dimensional plane coordinate system to obtain a grayscale curve corresponding to each row of pixels, wherein the pixel position is the horizontal axis and the grayscale value is the vertical axis; the standard deviation of the slope corresponding to each pixel on the grayscale curve is obtained, recorded as the grayscale standard deviation; the number of peak points on the grayscale curve is obtained, recorded as the number of fluctuations; the product of the grayscale standard deviation and the number of fluctuations of the grayscale curves corresponding to each row of pixels in the sub-image is averaged to obtain the grayscale change feature; the inverse of the grayscale change feature is mapped using an exponential function with a natural constant as the base to obtain the similarity of the grayscale image change features of the sub-image.
[0052] The specific calculation formula is:
[0053] ,
[0054] Among them, βj is the similarity of the grayscale image change characteristics of the j-th sub-image, θk is the standard deviation of the slope of each pixel on the grayscale curve corresponding to the pixel point in the k-th row of the j-th sub-image, that is, the grayscale standard deviation; is the number of peak points on the grayscale curve corresponding to the k-th row of the j-th sub-image, that is, the number of fluctuations; Represents the grayscale image change characteristics of the jth sub-image. The smoother the grayscale change, the smaller the value, the more similar the grayscale change characteristics are to the stain area, and the greater the similarity of the grayscale image change characteristics. K represents the total number of pixel rows in the sub-image.
[0055] After obtaining the grayscale distribution similarity and grayscale image change feature similarity of any sub-image, the target degree of the sub-image can be obtained by combining the two. The target degree of the sub-image is obtained by multiplying the grayscale distribution similarity and the grayscale image change feature similarity of the sub-image and normalizing them. The specific calculation formula is:
[0056] ,
[0057] Among them, γj represents the target degree of the j-th sub-image, αj and βj represent the grayscale distribution similarity of the j-th sub-image and the similarity of the grayscale image change characteristics of the j-th sub-image respectively, αj*βj means that the greater the similarity of the grayscale distribution and the grayscale image change characteristics of the j-th sub-image, the greater the target degree of the sub-image, and norm() represents the normalization operation.
[0058] Thus, the target degree of each subgraph can be obtained.
[0059] The importance calculation module is used to obtain the peak area and trough area in the grayscale histogram curve corresponding to the sub-image, and divide the sub-image into important sub-images and unimportant sub-images according to the target degree; the importance of the peak area is obtained according to the peak value of the peak area corresponding to the important sub-image.
[0060] Since the pixels of the stain part are an absolute minority of all the pixels of each sub-image, when a sub-image contains stains, not only is the target degree large, but its grayscale histogram will also have obvious peaks and valleys, but compared with the background area, its peak is significantly lower than the background area peak. When thresholding the sub-image, it is necessary not only to retain the change trend of each part, but also to assign different weights according to the degree to which the grayscale of the sub-image belongs to the stain area, focusing on allocating the grayscale corresponding to the stain area, and enhancing the contrast between the stain area and the surrounding background area.
[0061] Construct the grayscale histogram of any sub-image in order to better analyze the current sub-image. Further perform Gaussian smoothing on the amplitude sequence corresponding to the grayscale histogram of the sub-image to obtain a smoothed curve, recorded as the grayscale histogram curve; obtain each peak point and each trough point in the grayscale histogram curve; for a trough point, take the vertical coordinate of the peak point with a smaller peak value among its adjacent peak points and the vertical coordinate of the trough point to obtain the difference, and use the sum of the difference of the preset multiple and the vertical coordinate of the trough point as the first distance; draw a straight line parallel to the horizontal axis at the first distance from the horizontal axis of the coordinate system, intersecting with the trough corresponding to the trough point respectively, and obtain two intersection points, recorded as boundary points; obtain the dividing point corresponding to each trough point, connect the two dividing points on the trough to obtain the trough area, and connect the two dividing points on the peak to obtain the peak area.
[0062] It should be noted that the preset multiple is 0.4, and the implementer can set it according to actual conditions. The area enclosed by the connected line segment and the curve of the trough below is the trough area; the area enclosed by the connected line segment and the curve of the peak above is the peak area.
[0063] After obtaining the peak area and trough area in the grayscale histogram curve corresponding to the sub-image, the sub-image with a target degree greater than the first threshold f is marked as an important sub-image, where the empirical value of f is f=0.7. The important sub-image needs to continue to obtain the importance of each grayscale level, focusing on allocating the grayscale corresponding to the stain area; the sub-image with a target degree less than or equal to f is an unimportant sub-image. Since the probability of an unimportant sub-image containing stains is small, when restricting the histogram distribution, only the histogram trend is retained, and the importance of the grayscale level is not analyzed.
[0064] In order to maintain the overall trend and highlight the stain area in the important sub-image, it is necessary to determine the importance of each peak area according to the size of the peak area, that is, the importance of the gray level mentioned above. Since the pixels of the stain part are an absolute minority of all the pixels of each sub-image, when the sub-image contains stains, not only is the target degree large, but its grayscale histogram will also have obvious peaks and valleys, but compared with the background area, its peak is significantly lower than the background area peak.
[0065] Therefore, after obtaining the peak point of the entire grayscale histogram of the important sub-image, the value of the peak point is used as the importance of the corresponding peak area. The smaller the peak value, the greater the importance of the corresponding peak area, that is, it is more likely to be the grayscale interval corresponding to the stain area.
[0066] Furthermore, the inverse of the peak value of the peak area corresponding to the important sub-image is obtained, and recorded as the importance of the peak area corresponding to the important sub-image. The specific calculation formula is: , Indicates the importance of the h-th peak area corresponding to the important sub-graph, Indicates the peak value of the h-th peak area corresponding to the important sub-image.
[0067] In this way, the importance of the peak area corresponding to the important sub-graph is obtained, and the sub-graph is divided into important sub-graphs and unimportant sub-graphs.
[0068] The trend allocation part acquisition module is used to calculate the trend allocation part of each peak area according to the target degree of the non-important sub-image and the part of the parameter exceeding the contrast limit value; and calculate the trend allocation part of each peak area according to the target degree of the important sub-image, the part of the parameter exceeding the contrast limit value and the importance of each peak area.
[0069] In order to maintain the overall coherence of the histogram, when restricting the distribution of the histogram, only part of the grayscale is intercepted to better reflect the fluctuation trend of the histogram, and the other part is evenly distributed to each grayscale to maintain the coherence of the entire histogram. Therefore, when performing adaptive allocation, a part of the appropriate size is selected according to the target degree to allocate the grayscale corresponding to the peak area of each sub-image. Among them, important sub-images are allocated according to the importance corresponding to each peak area, and non-important sub-images are evenly distributed.
[0070] For non-important sub-images, since their target degree is low, when adaptively allocating them, a portion of the part exceeding the contrast limit value parameter is directly obtained according to its target degree to fill the gray level corresponding to the peak area. The remaining part exceeding the contrast limit value parameter is evenly distributed to each gray level.
[0071] Furthermore, the trend allocation part of each peak area therein is calculated according to the target degree of the non-important sub-image and the part of the parameter exceeding the contrast limit value. Specifically, the part of the parameter exceeding the contrast limit value of the non-important sub-image, the target degree and the adjustment factor are multiplied together, and compared with the data of the peak area corresponding to the non-important sub-image, to obtain the trend allocation part of the peak area corresponding to the non-important sub-image; the trend allocation part is a part of the part exceeding the contrast limit value parameter.
[0072] The calculation formula is: ,
[0073] in, represents the trend allocation part of the part exceeding the contrast limit value parameter corresponding to the h-th peak area corresponding to the non-important sub-image; ϵj is the part exceeding the contrast limit value parameter of the j-th non-important sub-image; γj is the target degree of the j-th non-important sub-image; z is the adjustment factor, and the empirical value is z=0.2 to prevent too much from being allocated as the trend part; H is the number of peak areas corresponding to the sub-image; It means that the higher the target degree of the unimportant sub-image is, the more it is necessary to maintain the trend of the entire histogram, maintain more details to the greatest extent, and enhance the contrast.
[0074] For important sub-images, since their target degree is high, different peak areas need to be allocated according to their target degree and the importance of each gray level. Similarly, the remaining part exceeding the contrast limit value parameter is evenly distributed to each gray level.
[0075] The trend allocation part of each peak area is calculated according to the target degree of the important sub-image, the part exceeding the contrast limit value parameter and the importance of each peak area. Specifically, the normalized result of the target degree of the important sub-image, the part exceeding the contrast limit value parameter and the importance of a peak area corresponding to the important sub-image is multiplied with the adjustment factor to obtain the trend allocation part of the peak area corresponding to the important sub-image.
[0076] The calculation formula is: ,
[0077] in, The trend allocation part of the h-th peak area corresponding to the important sub-graph, represents the part of the jth important sub-image that exceeds the contrast limit parameter. represents the target degree of the jth important subgraph, It indicates the importance of the h-th peak area corresponding to the important sub-image. The higher the importance of the h-th peak area, the more likely it is to be a stain area, and the more it needs to maintain its original trend, that is, to allocate as much of the trend as possible to the area with low importance, that is, the background area, to improve the contrast.
[0078] Thereby, the trend distribution part of each peak area corresponding to the non-important sub-graph and the trend distribution part of each peak area corresponding to the important sub-graph can be obtained.
[0079] The defect detection module is used to enhance the capsule image based on the trend distribution part of each peak area in the non-important sub-image and the important sub-image combined with the CLAHE algorithm; and use the enhanced capsule image to identify the appearance defects of the capsule.
[0080] Through the above operation, based on the trend allocation part of each peak area in the non-important sub-image and the important sub-image, the parameter part exceeding the contrast limit value in each sub-image is allocated to each gray level, and then the capsule image is further enhanced in combination with the CLAHE algorithm to obtain the enhanced capsule image.
[0081] Through the above operation, it is ensured that the grayscale histogram cumulative distribution function becomes smooth, and at the same time, the contrast of the sub-image containing stains is enhanced to the greatest extent. The enhanced capsule image is further input into the defect recognition model to identify the defects on the capsule surface. The embodiment of the present invention adopts a convolutional neural network as a defect recognition model. Specifically:
[0082] Obtain a large number of enhanced capsule images, including defective capsules and normal capsules, and manually annotate the images as "defective" or "normal". Adjust all images to a uniform size and grayscale them to reduce color interference. During training, the model automatically learns various features (such as edges, colors, textures, etc.) from the image and uses these features for classification. During the production process, the machine will take images of the capsules and classify them in real time using the trained model. The model will automatically mark defective capsules and notify the staff to remove them. This allows accurate identification of defects on the capsule surface.
[0083] In summary, the present application uses image processing technology to collect images and pre-process the images. The images are divided into blocks according to the algorithm steps, and the target degree of each image is obtained according to the grayscale distribution characteristics. Then the grayscale histogram of each sub-image is obtained, and the importance of each grayscale level is obtained according to the change characteristics of the grayscale histogram. The target degree of each sub-image and the importance of each grayscale level are fused, and the part exceeding the contrast limit value parameter is adaptively allocated to each grayscale level. Then the CLAHE algorithm is used to continue to enhance the original capsule image currently collected, and the processed image is placed in a pre-trained defect recognition model to automatically filter out capsules containing stains.
[0084] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The above is a description of a specific embodiment of this specification. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0085] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0086] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An intelligent detection system for capsule appearance defect recognition, characterized in that: The system includes: An image segmentation module is used to collect capsule images and grayscale them to obtain grayscale images; the grayscale images are segmented to obtain sub-images; A grayscale distribution similarity acquisition module is used to calculate the grayscale distribution similarity of the sub-images based on the grayscale levels of the sub-images and the entropy values of the gradient directions of the pixels; The target degree acquisition module is used to obtain the similarity of the grayscale image change characteristics of the sub-image according to the change of the pixel points in each row of the sub-image; the target degree of the sub-image is obtained by multiplying the grayscale distribution similarity of the sub-image and the grayscale image change characteristic similarity and normalizing them; The importance calculation module is used to obtain the peak area and the trough area in the grayscale histogram curve corresponding to the sub-image, and divide the sub-image into important sub-images and unimportant sub-images according to the target degree; the importance of the peak area is obtained according to the peak value of the peak area corresponding to the important sub-image; A trend allocation part acquisition module is used to calculate the trend allocation part of each peak area according to the target degree of the non-important sub-image and the part exceeding the contrast limit value parameter; and calculate the trend allocation part of each peak area according to the target degree of the important sub-image, the part exceeding the contrast limit value parameter and the importance of each peak area; The defect detection module is used to enhance the capsule image based on the trend distribution part of each peak area in the non-important sub-image and the important sub-image combined with the CLAHE algorithm; and use the enhanced capsule image to identify the appearance defects of the capsule; The calculating of the grayscale distribution similarity of the sub-images based on the grayscale levels of the sub-images and the entropy values of the gradient directions of the pixels includes: The entropy value of the gradient direction of the pixel point in a sub-image is inverted and multiplied with the grayscale level of the sub-image to obtain the multiplication result, and the multiplication result is mapped using an exponential function with a natural constant as the base to obtain the grayscale distribution similarity of the sub-image; The obtaining of the similarity of grayscale image change characteristics of the sub-image according to the change of pixel points in each row of the sub-image includes: Map each row of pixels in the sub-image to a two-dimensional plane coordinate system to obtain the grayscale curve corresponding to each row of pixels, where the pixel position is the horizontal axis and the grayscale value is the vertical axis; obtain the standard deviation of the slope corresponding to each pixel on the grayscale curve, recorded as the grayscale standard deviation; obtain the number of peak points on the grayscale curve, recorded as the number of fluctuations; average the product of the grayscale standard deviation and the number of fluctuations of the grayscale curve corresponding to each row of pixels in the sub-image to obtain the grayscale change feature; use an exponential function with a natural constant as the base to map the inverse of the grayscale change feature to obtain the similarity of the grayscale image change features of the sub-image.
2. The intelligent detection system for capsule appearance defect recognition according to claim 1, characterized in that: The step of obtaining the peak area and the trough area in the grayscale histogram curve corresponding to the sub-image includes: Construct a grayscale histogram of the sub-image, perform Gaussian smoothing on the amplitude sequence corresponding to the grayscale histogram of the sub-image, and obtain a smoothed curve, which is recorded as a grayscale histogram curve; obtain each peak point and each trough point in the grayscale histogram curve; for a trough point, take the difference between the ordinate of the peak point with a smaller peak value among its adjacent peak points and the ordinate of the trough point to obtain a difference, and use the sum of the difference of a preset multiple and the ordinate of the trough point as the first distance; draw a straight line parallel to the horizontal axis at the first distance from the horizontal axis of the coordinate system, intersecting with the trough corresponding to the trough point respectively, and obtain two intersection points, which are recorded as boundary points; obtain the dividing point corresponding to each trough point, connect the two dividing points on the trough to obtain the trough area, and connect the two dividing points on the peak to obtain the peak area.
3. The intelligent detection system for capsule appearance defect recognition according to claim 1, characterized in that: The method of using the target degree to divide the subgraphs into important subgraphs and unimportant subgraphs includes: A subgraph whose target degree is greater than a first threshold is marked as an important subgraph, and a subgraph whose target degree is less than or equal to the first threshold is marked as a non-important subgraph.
4. The intelligent detection system for capsule appearance defect recognition according to claim 1, characterized in that: The obtaining the importance of the peak area according to the peak value of the peak area corresponding to the important sub-graph includes: The inverse of the peak value of the peak area corresponding to the important sub-image is obtained, and recorded as the importance of the peak area corresponding to the important sub-image.
5. The intelligent detection system for capsule appearance defect recognition according to claim 1, characterized in that: The step of calculating the trend allocation part of each peak area according to the target degree of the non-important sub-image and the parameter part exceeding the contrast limit value comprises: The parameter portion of the non-important sub-image that exceeds the contrast limit value, the target degree and the adjustment factor are multiplied and compared with the data of the peak area corresponding to the non-important sub-image to obtain the trend distribution portion of the peak area corresponding to the non-important sub-image.
6. The intelligent detection system for capsule appearance defect recognition according to claim 1, characterized in that: The step of calculating the trend allocation part of each peak region according to the target degree of the important sub-image, the part exceeding the contrast limit value parameter and the importance degree of each peak region comprises: The target degree of the important sub-image, the part exceeding the contrast limit parameter, the normalized result of the importance degree of a peak area corresponding to the important sub-image and the adjustment factor are multiplied together to obtain the trend allocation part of the peak area corresponding to the important sub-image.
7. The intelligent detection system for capsule appearance defect recognition according to claim 1, characterized in that: The method of using the enhanced capsule image to identify the appearance defects of the capsule includes: The enhanced capsule image is input into the defect recognition model to identify the defects on the capsule surface.
Citation Information
Patent Citations
Wire and cable defect detection method and system based on computer vision
CN114757949A
Steel pipe defect intelligent detection method based on image enhancement
CN117173180A