Drug production line remote monitoring method based on image processing

By analyzing the grayscale and gradient features of pixels within the blister pack area, iteratively optimizing the center position of the tablet, and constructing an edge intensity map for Hough circle detection, the detection accuracy problem caused by reflection and offset on the pharmaceutical production line is solved, thus improving the accuracy of tablet detection.

CN120876473AActive Publication Date: 2025-10-31SHANXI JIUZHOU PHARM CO LTD

Patent Information

Application Number
CN202511375843.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2025-10-31
Estimated Expiration
2045-09-25

AI Technical Summary

Technical Problem

The reflectivity of blister packaging and the misalignment of tablets on the pharmaceutical production line lead to unstable detection accuracy, which can easily result in missed or false detections. Existing technologies are not able to effectively identify missing, overfilled, or irregularly shaped tablets.

Method used

By analyzing the grayscale distribution and gradient change characteristics of pixels within the blister region, the reflection intensity score and grayscale validity weight are calculated. The center position of the pill is iteratively optimized, and an edge intensity map is constructed by combining the edge quality score and completion strategy to perform Hough circle detection.

Benefits of technology

It significantly improves the accuracy of tablet detection, reduces missed and false detections, and enhances the detection accuracy of missing, overfilled, and irregularly shaped tablets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120876473A_ABST
    Figure CN120876473A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of image processing, and particularly relates to a medicine production line remote monitoring method based on image processing, which comprises the following steps of: calculating a reflection intensity score according to a relative deviation and a gradient magnitude between a gray value of a pixel point in a bubble cap region and the overall gray of the region, and further determining a gray validity weight; initializing tablet center estimation, calculating an edge quality score in combination with a gray validity weight and an included angle between a gradient direction and a radial direction, and optimizing a tablet center position through an iteration gravity center; dividing a fan-shaped region by taking the optimized center as an original point, screening a reliable region and a region to be complemented according to the final edge quality score, and determining a complementation value by using the quality score interpolation of the reliable regions on the two sides; and synthesizing the gradient magnitude, the final edge score and the complementation value to construct an edge strength graph, and carrying out tablet defect detection according to a Hough circle detection result of the edge strength graph. The interference of light reflection and tablet deviation is eliminated, and the detection accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology. More specifically, this invention relates to a method for remote monitoring of pharmaceutical production lines based on image processing. Background Technology

[0002] In automated pharmaceutical production lines, blister packaging is the mainstream packaging method, and its quality is directly related to medication safety and production efficiency. To ensure that each blister pack is free from defects such as missing, overfilled, or mixed irregularly shaped tablets, industrial vision inspection systems need to perform real-time and accurate tablet identification on the high-speed moving blister packs.

[0003] However, due to the combined effects of the blister material and the lighting environment of the production line, the blister surface is prone to specular reflection under specific lighting angles, producing irregular bright spots. This causes the edges of the tablets to appear broken or blurred in the reflective area, and even some areas of the tablets to be covered by bright spots, making it impossible to effectively extract edge features. At the same time, during the packaging process, the tablets are often slightly offset within the blister cavity due to factors such as feeding deviation and blister forming error. Their geometric center does not coincide with the center of the blister cavity, which makes it easy for detection algorithms based on fixed areas to have positioning errors, further increasing the difficulty of defect identification.

[0004] Current mainstream technologies rely on Hough circle transform to identify tablets. This method achieves localization by detecting circular edges. However, Hough circle detection is highly sensitive to edge integrity. When the tablet edge is broken due to reflection, the algorithm is prone to missing detection. When the blister structure, reflective area, or tablet shadow forms a pseudo-arc edge, the algorithm is prone to false detection. In addition, traditional methods usually assume that the tablet center coincides with the blister center or use a global image processing strategy, which cannot adapt to the actual situation of tablet offset and uneven local illumination, resulting in unstable detection accuracy. Summary of the Invention

[0005] To address the technical problems of unstable detection accuracy and frequent false negatives / missed detections caused by blister surface reflection and tablet misalignment, this invention provides a remote monitoring method for pharmaceutical production lines based on image processing, comprising: For each blister region in the grayscale image of the pharmaceutical blister pack, the reflection intensity score of each pixel is determined based on the relative deviation between the grayscale value of the pixel within the blister region and the overall grayscale value of the blister region, as well as the gradient magnitude of the pixel. The grayscale effectiveness weight of the pixel is then determined based on the reflection intensity score. The center estimation of the tablet is initialized. Based on the grayscale effectiveness weight of the pixel, the angle between the gradient direction and the radial direction of the pixel under the current center estimation, the edge quality score of the pixel under the current center estimation is determined. The center position of the tablet is optimized by iteratively calculating the centroid of the edge quality score distribution. The edge quality score obtained after iterative convergence is then calculated. The final edge quality score is used as the final edge quality score. The blister pack area is evenly divided into multiple fan-shaped areas with the center of the tablet as the origin. Reliable areas and areas to be completed are selected based on the final edge quality score. The completion value of the area to be completed is determined based on the final edge quality score of the pixels in the reliable areas on both sides of the area to be completed. The edge intensity of the pixel is determined based on the gradient magnitude of the pixel, the final edge score, and the completion value of the area to be completed to which the pixel belongs. The edge intensity is used to construct an edge intensity map. Hough circle detection is performed on the edge intensity map. Based on the Hough circle detection results, it is determined whether there are missing, overfilled, or irregularly shaped tablets in the blister pack area.

[0006] This invention accurately identifies and suppresses reflective interference areas by comprehensively analyzing the grayscale distribution characteristics and gradient change properties of pixels within the blister pack area, thus solving the problem of specular interference caused by the mirror reflection of the aluminum foil surface. Through iterative optimization of the tablet's center position, it overcomes the center positioning deviation caused by tablet offset within the blister pack, ensuring that subsequent analysis is based on the actual tablet position rather than the blister pack center. A targeted edge completion strategy based on edge quality assessment performs limited completion only in areas of edge loss caused by reflection, restoring broken tablet edges while avoiding misidentification of interfering edges as tablet edges, and preserving the original shape characteristics of irregularly shaped tablets. Hough circle detection of the edge intensity map significantly improves detection accuracy and anti-interference capability. This invention solves the problems of edge breakage, false edge generation, and tablet offset caused by reflective interference in traditional detection technologies, greatly improving the detection accuracy of missing, overfilled, and irregularly shaped tablets.

[0007] Preferably, the reflection intensity score satisfies the expression: In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels The score for reflectance intensity; Represents pixels grayscale value; This represents the average gray level of all pixels within the bubble area; This represents the standard deviation of the grayscale values ​​of all pixels within the blister area. Represents pixels The gradient magnitude; This represents the maximum gradient amplitude within the blister area.

[0008] Based on the characteristics that the gray values ​​of pixels in the reflective area are significantly higher than those in the normal area, and that the edges of the reflective area are blurred and the gradient amplitude is low, this invention calculates the reflection intensity score by combining the deviation of the gray values ​​of pixels in the bubble area from the overall gray value of the area and the gradient amplitude characteristics of the pixels. This allows the reflection intensity score to accurately reflect the reflectivity of the pixels, providing a basis for the subsequent gray value validity weighting of pixels.

[0009] Preferably, determining the grayscale validity weight of a pixel based on its reflection intensity score includes: determining a reflection suppression factor for the pixel based on its reflection intensity score. In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels Reflective inhibitory factor; The threshold for reflection intensity score; Represents the linear rectified function. Represents the hyperbolic tangent function; obtains the grayscale validity weight of pixels based on the reflection suppression factor: , Represents pixels Gray-scale validity weight, This is the reflection suppression weighting coefficient.

[0010] Preferably, the method for obtaining the reflection intensity score threshold is as follows: calculating the average reflection intensity score of all pixels within the bubble area. and standard deviation ,Will As a threshold for reflection intensity score.

[0011] Preferably, the initialization of the tablet's center estimation includes: using the blister center position as the initialization of the tablet's center estimation.

[0012] Preferably, the edge quality score of the pixel under the current center estimation satisfies the expression: In the formula, Represents the coordinates of any pixel within the bubble area; Iteration Next time pixel Edge quality score, Represents pixels Gray-scale validity weight; Represents pixels gradient direction and pixel The included angle in the radial direction, where the pixel point The radial direction is the current center estimate. To pixel The direction the line points to; It is a cosine function; It is the absolute value symbol.

[0013] This invention takes into account that the gradient direction of pixels at the edge of a pill usually points towards or away from the center of the pill. Therefore, it determines the edge quality score of a pixel based on the cosine of the angle between the gradient direction and the radial direction of the pixel, as well as the gray-level validity weight of the pixel. This eliminates the interference of pixels in reflective areas and can distinguish between real edge pixels and non-edge pixels of the pill. The edge quality score can accurately reflect the edge attributes of the pixel. The new center estimate calculated based on the edge quality score of the pixel will shift towards the real edge region of the edge quality score, gradually approaching the real center of the pill. This solves the problem of directional deviation caused by pill offset and provides a foundation for center localization for subsequent edge completion and Hough circle detection.

[0014] Preferably, the step of filtering reliable regions and regions to be completed based on the final edge quality score includes: for each sector region, pixels in the sector region whose final edge quality score is greater than a preset edge quality threshold are taken as reliable edge points, and the proportion of reliable edge points in the sector region to all pixels in the sector region is calculated. When the proportion is greater than a preset proportion threshold, the sector region is marked as a reliable region; for any sector region that is not a reliable region, if the interval between the nearest reliable region on the left and the nearest reliable region on the right of the sector region is less than 10 sector regions, then the sector region is taken as a region to be completed.

[0015] Preferably, determining the completion value of the region to be completed includes: weighting and summing the average final edge quality scores of all pixels in the nearest reliable region to the left of the region to be completed and the average final edge quality scores of all pixels in the nearest reliable region to the right of the region to be completed, to obtain the completion value of the region to be completed. In the weighted summation, the weight of the nearest reliable region to the left of the region to be completed is positively correlated with the distance from the region to the right of the region to be completed, and the weight of the nearest reliable region to the right of the region to be completed is positively correlated with the distance from the region to the left of the region to be completed.

[0016] This invention uses a weighted summation of the final edge quality scores of the nearest reliable regions on the left and right sides of the area to be filled. This results in a completion value that matches the transition pattern of the reliable edges on both sides, avoiding the completion deviation caused by simple averaging. It can effectively connect the edges of the tablet that are broken due to interference such as reflection, ensuring the continuity and authenticity of the edges. At the same time, it can avoid introducing false edges that do not conform to the trend of the real edges, so that the subsequent Hough circle detection can more accurately identify the tablet outline and reduce the problems of missed detection and misjudgment caused by edge breakage.

[0017] Preferably, the edge strength satisfies the expression: ; In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels Edge strength; Represents pixels The final edge quality score; This represents the maximum value among the final edge quality scores of all pixels within the bubble area; Represents pixels The gradient magnitude; This represents the padding value of the region to be padded to the pixel. Represents the step function; This represents the set of pixels in the complete region.

[0018] This invention targets pixels in non-to-be-completed regions by combining their gradient magnitude, final edge quality score, and edge strength to highlight the real tablet edges and weaken the influence of non-edge pixels. For pixels in the to-be-completed regions, additional completion values ​​are added to match the real edge trend, effectively connecting edges broken by interference. This makes the real tablet edges clearer and more prominent in the edge strength map, while avoiding the introduction of false edges. This provides high-quality image input for subsequent Hough circle detection, reduces missed detections and misjudgments caused by unclear or broken edge features, and improves the accuracy of judging missing, overfilled, and irregularly shaped tablets.

[0019] Preferably, the step of determining whether there are missing, overfilled, or irregularly shaped tablets in the blister pack area based on the Hough circle detection results includes: for each blister pack area, if the number of detected circles is 0, it is determined to be a missing or irregularly shaped tablet; if the number of detected circles is greater than 1, it is determined to be an overfilled tablet; if the number of detected circles is equal to 1, it is determined to be a tablet present. In this case, the difference between the radius of the detected circle and the standard radius of the tablet is calculated, and if the difference is greater than 3 pixels, it is determined to be an irregularly shaped tablet.

[0020] The beneficial effects of this invention are as follows: By comprehensively analyzing the grayscale distribution characteristics and gradient change characteristics of pixels within the blister pack area, this invention accurately identifies and suppresses reflective interference areas, solving the problem of specular reflection interference caused by aluminum foil surface reflection; by iteratively optimizing the tablet center position, it overcomes the center positioning deviation caused by tablet offset within the blister pack, ensuring that subsequent analysis is based on the actual tablet position rather than the blister pack center; based on a targeted edge completion strategy using edge quality assessment, it only performs limited completion in edge loss areas caused by reflection, restoring broken tablet edges while avoiding misjudging interference edges as tablet edges, and preserving the original shape characteristics of irregularly shaped tablets; through Hough circle detection of the edge intensity map, it significantly improves detection accuracy and anti-interference capability. This invention solves the problems of edge breakage, false edge generation, and tablet offset caused by reflective interference in traditional detection technologies, greatly improving the detection accuracy of missing, overfilled, and irregularly shaped tablets. Attached Figure Description

[0021] Figure 1 This is a flowchart illustrating the image processing-based remote monitoring method for pharmaceutical production lines in this invention. Figure 2 This is a schematic representation of the original RGB image of a pharmaceutical blister pack. Figure 3 It is a schematic grayscale image showing a pharmaceutical blister pack. Figure 4 This is a schematic representation of a standard mask; Figure 5 This is a schematic diagram showing the image of the blister pack area; Figure 6 This is a schematic illustration of an image after contrast-limited adaptive histogram equalization of the bubble area; Figure 7 This is a schematic diagram showing the gradient image of the blister region; Figure 8 This is a schematic diagram illustrating the division of the sector area; Figure 9 This is a schematic diagram showing the edge intensity of the blister pack area; Figure 10 This schematically illustrates the results of Hough circle detection on the edge intensity map of the blister region; Figure 11 This schematically illustrates the results of Hough circle detection on the gradient image of the blister region. Detailed Implementation

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] Since transparent blister packs are the mainstream form of pharmaceutical blister packaging, and round tablets are a common form of tablet-type pharmaceuticals, this invention focuses on testing transparent blister packs and round tablets. The specific embodiments of this invention are described in detail below with reference to the accompanying drawings.

[0024] This invention discloses a remote monitoring method for pharmaceutical production lines based on image processing, referring to... Figure 1 This includes steps S1 to S6: S1: Collect grayscale images of blister packs for pharmaceutical products.

[0025] Specifically, an industrial CCD camera is used to capture images of blister packs on the pharmaceutical production line from a vertical, top-down angle, obtaining the original RGB image. The original RGB image is then converted to grayscale to obtain a grayscale image of the blister pack. For example, Figure 2 The original RGB image, Figure 3 This is a grayscale image of a pharmaceutical blister pack.

[0026] Optionally, Gaussian filtering can be applied to the grayscale image for noise reduction. It should be noted that Gaussian filtering of the grayscale image can suppress some ambient light interference and random noise while preserving key edge details between the pill and the background. Other noise reduction algorithms can also be used.

[0027] S2: Obtain the bubble region in the grayscale image and perform image enhancement on the bubble region.

[0028] It should be noted that pharmaceutical blister packaging has standard specifications, and the blister area is fixed in position and regular in shape on the production line. Therefore, this invention obtains each blister area in the grayscale image of the pharmaceutical blister packaging plate through a standard mask of the blister area.

[0029] Specifically, a standard mask is read, in which each blister region is marked as an independent connected component. The standard mask is multiplied by the grayscale image of the pharmaceutical blister packaging plate to obtain a mask extraction image. The region corresponding to each connected component in the standard mask in the mask extraction image is a blister region. For example, Figure 4 For standard masks, Figure 5 Image of the blister pack area.

[0030] Optionally, image enhancement is performed separately for each blister region. This invention employs a Contrast-Limited Adaptive Histogram Equalization (CLAHE) algorithm to enhance each blister region; however, other image enhancement algorithms may also be used. For example, Figure 6 The image after contrast-limited adaptive histogram equalization of the bubble area.

[0031] It should be noted that the local illumination difference of the blister pack is large. Global histogram equalization of the grayscale image of the blister pack will destroy the original grayscale relationship and amplify noise. However, the present invention performs independent enhancement on each blister area, which can improve the local contrast of the edges of the tablets inside the blister and provide high-quality input for subsequent tablet detection.

[0032] S3: For each blister region, determine the reflection intensity score of the pixel based on the relative deviation between the gray value of the pixel in the blister region and the overall gray value of the blister region, as well as the gradient magnitude of the pixel. Then, determine the gray value validity weight of the pixel based on the reflection intensity score.

[0033] It should be noted that, due to the smooth surface of the blister pack, the blister pack area is prone to reflection, forming a reflective area. The gray value of the reflective area is usually much higher than that of the surrounding area, forming a bright spot. At the same time, the reflective area usually has blurred edges and gentle gradient changes. In contrast, the gray value of the tablet inside the blister pack area is lower than that of the reflective area, and the edges of the tablet have obvious gradient changes. Therefore, this invention determines the reflection intensity score of the pixel based on the gray value distribution characteristics and gradient change characteristics of the pixels within the blister pack area.

[0034] Specifically, for each bubble region, the Sobel operator is used to obtain the gradient magnitude and gradient direction of each pixel within the bubble region. For example, Figure 7 This is the gradient image of the bubble cap region.

[0035] For each pixel within the blister region, the pixel's reflection intensity score is determined based on the relative deviation between the pixel's grayscale value and the overall grayscale value of the blister region, as well as the pixel's gradient magnitude. ; In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels The score for reflectance intensity; Represents pixels grayscale value; This represents the average gray level of all pixels within the bubble area; This represents the standard deviation of the grayscale values ​​of all pixels within the blister area. Represents pixels The gradient magnitude; This represents the maximum gradient magnitude within the blister pack area, used for... Normalize.

[0036] Reflection intensity score This suggests that it may belong to a reflective area. Reflects pixels The relative deviation between the grayscale value and the overall grayscale value of the bubble area. Since the grayscale value of pixels in the reflective area is higher than that of the surrounding area, therefore, when... When the size is larger, the number of pixels The more likely it is to be located in a reflective area. At the same time, true reflective areas usually have blurred edges, therefore when... near hour, Approaching 0, thus avoiding misjudging sharp edges as reflections.

[0037] Furthermore, based on the reflection intensity scores of pixels within the bubble area, the reflection suppression factor of each pixel is determined: ; In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels Reflective inhibitory factor; The threshold for reflection intensity score; Represents a linear rectified function, in In the middle, when hour, ,when hour, ; This represents the hyperbolic tangent function, used to limit the reflection suppression factor of a pixel to a certain value. Within the range.

[0038] Among them, the reflection intensity score threshold The method for obtaining the value is as follows: calculate the average reflection intensity score of all pixels within the bubble area. and standard deviation ,Will This serves as the threshold for reflection intensity scoring. It should be noted that this invention uses a range of 2 standard deviations because, according to statistical principles, 95% of normal data distributions fall within the range of mean ± 2 standard deviations. Since reflective areas constitute a relatively small proportion of the bubble area, the reflection intensity scores of pixels in reflective areas typically exceed... Therefore, this invention sets the reflection intensity score threshold. Set as This is used to distinguish between reflective and normal areas. Implementers can also adjust the standard deviation multiple based on the proportion of reflective areas within the blister pack area during actual implementation. For example... .

[0039] It should be noted that the reflection intensity score threshold reflects the statistical boundary of normal brightness variation within the bubble area, while the reflection suppression factor reflects the degree to which the reflection intensity score of a pixel exceeds the normal range. The more a pixel's reflection intensity score exceeds the reflection intensity score threshold, the more likely the pixel is to be in a reflective area, and the larger the reflection suppression factor is. When a pixel's reflection intensity score does not exceed the reflection intensity score threshold, the pixel is more likely to be in a normal area, and the reflection suppression factor is 0.

[0040] Furthermore, the grayscale validity weight of each pixel is obtained based on the reflection suppression factor: ; In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels Gray-scale validity weight; Represents pixels The reflection suppression factor. The grayscale effectiveness weight reflects the probability that a pixel is in a non-reflective area. When the reflection suppression factor is larger, the pixel is more likely to be in a reflective area. At this time, the grayscale effectiveness weight is smaller, which reduces the contribution of this area in subsequent processing and avoids the reflection area from interfering with the detection of the tablet. When the reflection suppression factor is 0, the grayscale effectiveness weight is 1, indicating that the pixel is not affected by reflection interference.

[0041] in, This is the reflection suppression weight coefficient, used to control the degree of influence of the reflection suppression factor on the grayscale effectiveness weight. It represents the system's sensitivity to reflection interference. The higher the value, the stronger the system's reflection suppression. The smaller the value, the less sensitive the system is to reflective interference, and the system exhibits weak reflective suppression. The value range of is set to (0,1]. In this invention, Set it to 0.6.

[0042] S4: Initialize the center estimation of the pill. Based on the gray-level validity weight of the pixel, the angle between the gradient direction and the radial direction of the pixel under the current center estimation, determine the edge quality score of the pixel under the current center estimation. Optimize the center position of the pill by iteratively calculating the centroid of the edge quality score distribution. The edge quality score after iterative convergence is taken as the final edge quality score.

[0043] It should be noted that tablets are usually offset within the blister pack, and their geometric center does not coincide with the blister center. Directly using the blister center for radial analysis will lead to directional deviation. Furthermore, the gradient direction of the tablet edge usually points towards or away from the center, either consistent with or opposite to the radial direction. Therefore, this invention estimates the tablet center position based on the angle between the gradient direction of the pixel and the radial direction, as well as the grayscale validity weight of the pixel.

[0044] Specifically, 1. For any blister region, initialize the center estimation of the tablet. 1. Determine the center coordinates of the blister pack; 2. Determine the edge quality score of each pixel under the current center estimate based on the angle between the gradient direction of the pixel and the radial direction of the pixel under the center estimate, as well as the gray-level validity weight of the pixel; 3. Calculate a new center estimate based on the edge quality scores of all pixels in the blister pack area under the current center estimate; 4. Repeat steps 2 to 3 until the convergence condition is met and the iteration stops. The edge quality score of each pixel under the latest center estimate at the time of iteration stop is taken as the final edge quality score of the pixel, and the latest center estimate is taken as the center of the pill.

[0045] In one embodiment, the number of iterations is denoted as The current central estimate is denoted as Determine the current central estimate Edge quality scores for each pixel: ; In the formula, Represents the coordinates of any pixel within the bubble area; Iteration Next time pixel Edge quality score, Represents pixels Gray-scale validity weight; Represents pixels gradient direction and pixel The included angle in the radial direction, where the pixel point The radial direction is the current center estimate. To pixel The direction the line points to; It is a cosine function; It is the absolute value symbol.

[0046] For pixels within the pill region or background pixels, the gradient direction is randomly distributed, and the angle between it and the radial direction of the pixel is uncertain; while for pixels at the edge of the pill, the gradient direction points towards or away from the center of the circle, and is consistent with or opposite to the radial direction, making... Approaching 0° or 180°, making The value approaches 1, and the grayscale effectiveness weight of pixels at the edge of the tablet is relatively large, resulting in a higher edge quality score for the pixels. The gradient direction is relatively large for pixels in reflective areas, and the grayscale effectiveness weight is small, resulting in a lower edge quality score for the pixels. The edge quality score is relatively small. Therefore, the higher the edge quality score, the more likely the pixel is to be a pixel on the edge of a pill.

[0047] Furthermore, based on the estimation of all pixels within the blister region at the current center... The edge quality score is used to calculate a new center estimate. : ; ; In the formula, Iteration The center coordinates of the next pill; Iteration The x-coordinate of the center coordinate of the next pill; Iteration The ordinate of the center coordinate of the next pill; Represents iterated pixels In iteration The edge quality score under the next time pill center estimation; Indicates the blister area. This represents the pixels within the blister pack area. Represents pixels x-coordinate Represents pixels The ordinate.

[0048] It should be noted that, For the centroid of the high edge quality region, when As the value increases, the point is estimated to be central. The increased contribution causes the center to shift towards the area concentrated at the edge of the actual pill; when As the value decreases, the contribution of that point to the center estimation decreases. This invention updates the center estimation based on the distribution of pixel edge quality scores in each iteration, making the center estimation gradually approach the actual pill center, thereby solving the pill offset problem. When the pill shifts to the right, the edge quality scores of pixels on the right are high, and the center estimation shifts to the right; when the pill shifts to the left, the edge quality scores of pixels on the left are high, and the center estimation shifts to the left, so that subsequent radial analysis is based on the actual pill position rather than the blister center.

[0049] It should be noted that when the edge quality score of all pixels within the blister area is 0, it results in... When the value is 0, the denominator in the center estimation expression will be zero, making center estimation impossible. This situation typically occurs when the blister region is completely covered by reflection, the tablet is completely missing, or the image quality is so poor that no effective edges can be extracted. Therefore, this invention first checks the denominator before each iteration. If the value is 0, the iteration process is terminated immediately, and the blister area is marked as having missing edge features. No further steps are performed, and the blister area is directly determined to have a serious defect. Manual re-inspection or removal is then requested.

[0050] Furthermore, let's define the convergence condition: when and The iteration stops when the distance between them is less than a preset distance threshold or when the maximum number of iterations is reached.

[0051] It should be noted that this iterative process converges quickly, typically obtaining a stable result in 2-3 iterations. Therefore, this invention sets the maximum number of iterations to 3. In other embodiments, implementers can set the maximum number of iterations according to the actual implementation situation. The distance threshold is used to control the convergence accuracy of the center estimation, representing the acceptable range of center position variation. When the distance threshold is set larger, the iteration convergence is faster but the accuracy is lower; when the distance threshold is set smaller, the iteration convergence is slower but the accuracy is higher. In this invention, the distance threshold is set to 3 pixels. In other embodiments, implementers can set the distance threshold according to the actual implementation situation, but to ensure the accuracy of the center estimation, the distance threshold cannot exceed 5 pixels.

[0052] S5: Divide the blister pack area into multiple fan-shaped regions at an angle with the center of the tablet as the origin. Filter reliable regions and regions to be completed based on the final edge quality score. Determine the completion value of the region to be completed based on the final edge quality score of the pixels in the reliable regions on both sides of the region to be completed. Determine the edge intensity of the pixel based on the gradient magnitude of the pixel, the final edge score, and the completion value of the region to be completed to which the pixel belongs. Construct an edge intensity map from the edge intensity.

[0053] It should be noted that due to reflective interference, the edge of the tablet may be broken or missing in a certain direction, leading to misjudgment in Hough circle detection. Therefore, this invention combines the edge quality score of the pixel and the angular continuity to perform limited completion of high-reliability areas, thereby improving the accuracy of subsequent Hough circle detection.

[0054] Specifically, for each blister pack area, with the center of the tablet as the center point, the blister pack area is divided into 72 angles. A sector-shaped region. For example, Figure 8 This is a schematic diagram of the sector-shaped region division.

[0055] Furthermore, for each sector region, pixels in the sector region whose final edge quality score is greater than a preset edge quality threshold are taken as reliable edge points. The proportion of reliable edge points in the sector region to all pixels in the sector region is calculated. When the proportion is greater than a preset proportion threshold, the sector region is marked as a reliable region.

[0056] It should be noted that a reliable region represents a high degree of integrity of the tablet's edge along that angle. The edge quality threshold is used to control the selection criteria for reliable edge points, representing the required edge quality. A larger edge quality threshold results in fewer selected reliable edge points and a higher requirement for edge integrity; conversely, a smaller edge quality threshold results in more selected reliable edge points and a lower requirement for edge integrity. In this invention, the edge quality threshold is set to 0.4. , This represents the maximum value among the final edge quality scores of all pixels within the blister region. In other embodiments, implementers can set the edge quality threshold according to the actual implementation situation, but to ensure the accuracy of edge completion, the edge quality threshold should not be less than 0.2. And it should not exceed 0.6 The ratio threshold is used to control the screening criteria for reliable regions. The larger the ratio threshold is set, the higher the proportion of reliable edge points in the sector area is required, and the more stringent the screening of reliable regions is. The smaller the ratio threshold is set, the more lenient the screening of reliable regions is. In this invention, the ratio threshold is set to 0.3. In other embodiments, implementers can set the ratio threshold according to the actual implementation situation, but in order to ensure the reliability of edge completion, the ratio threshold should not be less than 0.2.

[0057] It should be noted that the proportion of reliable edge points within a sector to all pixels within that sector reflects the edge integrity in the corresponding angular direction for each sector.

[0058] Furthermore, for any sector of an unreliable region, if the interval between the nearest reliable region to the left and the nearest reliable region to the right of the sector is less than 10 sector regions, then the sector is regarded as a region to be completed.

[0059] For any region to be completed, the completion value of the region is calculated based on the average of the final edge quality scores of all pixels in the nearest reliable region to the left and the average of the final edge quality scores of all pixels in the nearest reliable region to the right. ; In the formula, This represents the completion value for the region to be completed; This represents the average of the final edge quality scores of all pixels in the nearest reliable region to the left of the region to be filled. This represents the average of the final edge quality scores of all pixels in the nearest reliable region to the right of the region to be filled. This represents the distance from the region to be completed to the nearest reliable region to its right; This represents the distance from the region to be completed to the nearest reliable region to its left. In this invention, the distance between the region to be completed and the reliable region is the number of fan-shaped regions between the region to be completed and the reliable region plus 1. For example, if there are 3 fan-shaped regions between a region to be completed and a reliable region, then the distance between the region to be completed and the reliable region is 3+1=4.

[0060] The completion value is an interpolation based on the edge quality scores of the nearest reliable regions on both sides of the region to be completed, reflecting the true edge trend. When the value is smaller, the completion value is closer to the edge quality of the reliable region on the left. When the value is smaller, the completion value is closer to the edge quality of the reliable region on the right, thus ensuring that the completion value is consistent with the true edge trend.

[0061] It should be noted that the present invention strictly limits the completion range. Only when there are reliable edges on both sides of the unreliable region and the interval is small will the unreliable region be used as the region to be completed. This can prevent interference edges from being mistakenly identified as the edge of the tablet for completion. When the interval between the nearest reliable region on the left and the nearest reliable region on the right of the unreliable region is greater than or equal to 10, the edge of the unreliable region is kept broken to avoid introducing false edges.

[0062] Furthermore, for each pixel within the blister region, in response to a pixel not belonging to the region to be completed, the edge intensity of the pixel is determined based on the pixel's gradient magnitude and final edge quality score. In response to a pixel belonging to the region to be completed, the edge intensity of the pixel is determined based on the pixel's gradient magnitude, final edge score, and the completion value of the region to be completed to which the pixel belongs. Specifically: ; In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels Edge strength; Represents pixels The final edge quality score; This represents the maximum value among the final edge quality scores of all pixels within the bubble area; Represents pixels The gradient magnitude; This represents the padding value of the region to be padded to the pixel. Represents the step function, when hour, Preserve the original final edge quality score of each pixel. hour, ; This represents the set of pixels in the complete region.

[0063] When a pixel does not belong to the region to be filled, if the gradient magnitude of the pixel is larger, the final edge quality score of the pixel is also larger, and the final edge quality score is greater than... When a pixel is more likely to be a real pill edge, its edge strength is greater; when the final edge quality score of a pixel is smaller, and less than or equal to... When the pixel is less likely to be the edge of a real pill, the edge intensity of the pixel is smaller.

[0064] When a pixel belongs to the region to be completed, its edge strength is obtained based on its final edge quality score and the completed value. The larger the pixel's gradient magnitude, the higher its final edge quality score, or the larger the completed value of its region, the more likely the pixel is to be a real pill edge, and thus the stronger its edge strength. Conversely, the smaller the pixel's gradient magnitude, the lower its final edge quality score, and the smaller the completed value of its region, the less likely the pixel is to be a real pill edge, and thus the weaker its edge strength.

[0065] Furthermore, the edge intensity of all pixels within the blister region is used to construct an edge intensity map of the blister region. For example, Figure 9 This is the edge intensity map of the blister region.

[0066] S6. Perform Hough circle detection on the edge intensity map. Based on the Hough circle detection results, determine whether there are missing, overfilled, or irregularly shaped tablets in the blister pack area.

[0067] Specifically, Hough circle detection is performed on the edge intensity map of the blister region. During the Hough circle detection process, the search range for the center of the circle is set to be centered on the tablet. Centered on A circular region with a defined boundary, wherein, The radius of the blister area.

[0068] For each blister pack area, check the number of detected circles. If the number is 0, it is determined to be a missing or irregularly shaped tablet; if the number is greater than 1, it is determined to be an overfill; if the number is equal to 1, it is determined to be a tablet. At this time, calculate the difference between the radius of the detected circle and the standard radius of the tablet. If the difference is greater than 3 pixels, it is determined to be an irregularly shaped tablet.

[0069] For example, Figure 10 The results of Hough circle detection are shown for the edge intensity map of the blister region. Figure 11 To directly Figure 7 The results of Hough circle detection on the gradient image of the blister pack region shown are as follows: Directly performing Hough circle detection on the gradient image is affected by reflective areas and missing edges. In some blister pack regions, tablets are present but no circle is detected; in others, a circle is detected, but it does not coincide with the edge, resulting in offset. However, using the method of this invention to perform Hough circle detection on the edge intensity map can detect the position of all tablets, and the detected circle basically coincides with the edge of the tablet, effectively avoiding missed and false detections.

[0070] This enables the detection of missing, overfilled, and irregularly shaped tablets in blister packaging for pharmaceuticals.

Claims

1. A remote monitoring method for pharmaceutical production lines based on image processing, characterized in that, include: For each blister region in the grayscale image of a pharmaceutical blister packaging plate, the reflection intensity score of the pixel is determined based on the relative deviation between the grayscale value of the pixel in the blister region and the overall grayscale of the blister region, as well as the gradient magnitude of the pixel. The grayscale validity weight of the pixel is then determined based on the reflection intensity score. Initialize the center estimation of the pill. Based on the gray-level validity weight of the pixel, the angle between the gradient direction and the radial direction of the pixel under the current center estimation, determine the edge quality score of the pixel under the current center estimation. Optimize the center position of the pill by iteratively calculating the centroid of the edge quality score distribution. The edge quality score after iterative convergence is taken as the final edge quality score. The blister area is evenly divided into multiple fan-shaped areas with the center of the tablet as the origin. Reliable areas and areas to be completed are selected based on the final edge quality score. The completion value of the area to be completed is determined based on the final edge quality score of the pixels in the reliable areas on both sides of the area to be completed. The edge intensity of a pixel is determined based on its gradient magnitude, final edge score, and the completion value of the region to be completed to which the pixel belongs. The edge intensity is then used to construct an edge intensity map. Perform Hough circle detection on the edge intensity map, and determine whether there are missing, overfilled, or irregularly shaped tablets in the blister pack area based on the Hough circle detection results.

2. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The reflection intensity score satisfies the expression: ; In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels The score for reflectance intensity; Represents pixels grayscale value; This represents the average gray level of all pixels within the bubble area; This represents the standard deviation of the grayscale values ​​of all pixels within the blister area. Represents pixels The gradient magnitude; This represents the maximum gradient amplitude within the blister area.

3. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The determination of the grayscale validity weight of a pixel based on its reflection intensity score includes: The reflection suppression factor of a pixel is determined based on the reflection intensity score: In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels Reflective inhibitory factor; The threshold for reflection intensity score; Represents the linear rectified function. Represents the hyperbolic tangent function; obtains the grayscale validity weight of pixels based on the reflection suppression factor: , Represents pixels Gray-scale validity weight, This is the reflection suppression weighting coefficient.

4. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 3, characterized in that, The method for obtaining the reflection intensity score threshold is as follows: Calculate the mean of the reflection intensity scores of all pixels within the bubble area. and standard deviation ,Will As a threshold for reflection intensity score.

5. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The initialization of the tablet's center estimation includes: The center position of the blister is used as the center estimate of the initial tablet.

6. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The edge quality score of the pixel under the current center estimation satisfies the expression: ; In the formula, Represents the coordinates of any pixel within the bubble area; Iteration Next time pixel Edge quality score, Represents pixels Gray-scale validity weight; Represents pixels gradient direction and pixel The included angle in the radial direction, where the pixel point The radial direction is the current center estimate. To pixel The direction the line points to; It is a cosine function; It is the absolute value symbol.

7. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The process of filtering reliable regions and regions to be completed based on the final edge quality score includes: For each sector region, pixels whose final edge quality score is greater than a preset edge quality threshold are considered reliable edge points. The proportion of reliable edge points to all pixels in the sector region is calculated. When the proportion is greater than a preset proportion threshold, the sector region is marked as a reliable region. For any sector region that is not a reliable region, if the interval between the nearest reliable region on the left and the nearest reliable region on the right is less than 10 sector regions, then the sector region is considered as a region to be completed.

8. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The determination of the completion value for the region to be completed includes: The completion value of the region to be completed is obtained by weighted summing the average final edge quality scores of all pixels in the nearest reliable region to the left of the region to be completed and the average final edge quality scores of all pixels in the nearest reliable region to the right of the region to be completed. When performing the weighted summation, the weight of the nearest reliable region to the left of the region to be completed is positively correlated with the distance from the region to the right of the region to be completed, and the weight of the nearest reliable region to the right of the region to be completed is positively correlated with the distance from the region to the left of the region to be completed.

9. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The edge strength satisfies the expression: ; In the formula, Represents the coordinates of any pixel within the bubble area; Represents pixels Edge strength; Represents pixels The final edge quality score; This represents the maximum value among the final edge quality scores of all pixels within the bubble area; Represents pixels The gradient magnitude; This represents the padding value of the region to be padded to the pixel. Represents the step function; This represents the set of pixels in the complete region.

10. The remote monitoring method for pharmaceutical production lines based on image processing according to claim 1, characterized in that, The determination of whether there are missing, overfilled, or irregularly shaped tablets in the blister pack area based on the Hough circle detection results includes: For each blister pack area, if the number of detected circles is 0, it is determined to be a missing or irregularly shaped tablet; if the number of detected circles is greater than 1, it is determined to be an overfill; if the number of detected circles is equal to 1, it is determined to be a tablet present. At this time, the difference between the radius of the detected circle and the standard radius of the tablet is calculated. If the difference is greater than 3 pixels, it is determined to be an irregularly shaped tablet.

Citation Information

Patent Citations

  • Workpiece edge extraction method based on improved Canny operator

    CN108022233A

  • Image completion method, device and equipment and computer readable storage medium

    CN111242871A

  • Road construction quality detection method and system based on artificial intelligence

    CN117173184A

  • Packaging tin appearance defect detection method

    CN119228800A

  • Image segmentation system for medical diagnosis

    CN120563823A

Cited By

  • Pole adaptive positioning method and system based on image processing

    CN121414848A

  • An image processing-based polar adaptive localization method and system

    CN121414848B