A tablet defect detection method and system based on machine vision
Through the methods of wavelet packet decomposition and multimodal matching degree optimization, the problems of insufficient precision and accuracy in traditional tablet detection methods are solved, and efficient detection of tablet defects is achieved.
Patent Information
- Application Number
- CN202510573149.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2045-05-06
AI Technical Summary
Traditional machine vision-based tablet inspection methods have problems with insufficient precision and accuracy when detecting tablet defects, especially for detecting tablet edge defects and local depressions, which are difficult to accurately identify.
The wavelet packet decomposition method is used to perform multi-layer decomposition of the tablet image and the template image. Combined with the shape matching coefficient and energy difference, the multimodal matching degree is optimized through the NCC algorithm to enhance the detection accuracy of tablet defects.
The precision and accuracy of tablet defect detection are improved, the sensitivity to edge and geometric defects is enhanced, and noise interference is suppressed.
Smart Images

Figure CN120088505B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a tablet defect detection method and system based on machine vision. Background Art
[0002] In recent years, driven by both technological advancements and consumer upgrades, public health awareness and quality requirements have continued to rise. As a crucial commodity, pharmaceuticals, which are crucial for life safety, have garnered increasing attention for quality control during the production process. As a common form factor in pharmaceutical preparations, the surface integrity of tablets not only directly impacts drug safety and efficacy but is also a crucial indicator of pharmaceutical companies' quality control systems. Currently, manual visual inspection, a widely used method in the industry, has limitations: inspection efficiency and accuracy are significantly affected by the inspector's condition, resulting in a high miss rate of 15% to 30%. Furthermore, with rising labor costs and the need for expanded production capacity, traditional inspection models are no longer adapting to the intelligent transformation of the modern pharmaceutical industry. Due to these factors and the advancement of image processing technology, several machine vision-based inspection methods have been gradually applied to tablet inspection. These inspection steps primarily involve capturing tablet images and comparing them with pre-set, non-destructive images to determine if the tablets are defective, ultimately enabling accurate tablet inspection.
[0003] The normalized cross correlation (NCC) matching algorithm is a common image processing method. Its core concept is to select the similarity (i.e., NCC value) of local regions between a template image (a standard image without defects) and a target image (the image to be inspected). This ultimately generates a correlation matrix that records the matching score at each location. Traditional NCC image matching algorithms suffer from insufficient sensitivity to local features when inspecting tablet surface defects. Specifically, shape matching relies solely on global grayscale correlation, making it difficult to capture localized shape distortions such as edge defects. Furthermore, when a tablet has a localized depression but a similar overall grayscale distribution, the NCC value may still be close to 1, leading to missed detections. In summary, the accuracy and precision of traditional machine vision-based tablet inspection methods need to be further improved. Summary of the Invention
[0004] In order to solve the problem of insufficient precision and accuracy of traditional NCC image matching algorithms for tablet detection, the present application provides a tablet defect detection method and system based on machine vision.
[0005] In a first aspect, the present application provides a method for detecting tablet defects based on machine vision, which adopts the following technical solutions:
[0006] A method for detecting tablet defects based on machine vision comprises the following steps: calculating a shape fit coefficient for each pixel in a tablet image; performing multi-layer decomposition of the tablet image and a template image using a wavelet packet decomposition method, extracting high-frequency subbands from each decomposition layer, and calculating energy differences in texture energy for each pixel in the tablet image; obtaining initial similarities for each pixel in the tablet image using an NCC algorithm, optimizing the initial similarities using the shape fit coefficient and the energy difference to obtain a multimodal matching degree for the pixel, and detecting the tablet based on the multimodal matching degree.
[0007] Among them, the method for calculating the shape fitting coefficient of each pixel in the tablet image includes the steps of: obtaining a template binary image and a tablet binary image, setting a reference pixel point in the template binary image, sliding the template binary image so that the reference pixel point corresponds to each pixel point in the tablet binary image, calculating the grayscale value difference between each pixel point in the template binary image and the corresponding pixel point in the tablet binary image, and taking the sum of the grayscale value differences corresponding to each pixel point in the template binary image as the local distortion degree of the pixel point in the tablet image corresponding to the reference pixel point; adjusting the local distortion degree based on the standard tablet diameter to obtain the shape fitting coefficient, wherein the standard tablet diameter is inversely proportional to the shape fitting coefficient.
[0008] In this application, the local distortion is calculated by the difference in grayscale values between the template image and the tablet image, and then the local distortion is adjusted by the diameter of the tablet to obtain the shape matching coefficient. In the process of calculating the shape matching coefficient, the diameter of the standard tablet is inversely proportional to the shape matching coefficient, that is, when the diameter of the standard tablet is larger, the tablet has more edge pixels. When a single pixel changes, the changed pixel accounts for a small proportion of the overall edge pixels, and the value of the shape matching coefficient can be appropriately reduced, thereby reducing the impact on the calculation of the multimodal matching degree. When the tablet is small, the change of a single pixel accounts for a large proportion of the number of edge pixels, so in this case the impact on the calculation of the multimodal matching degree should be increased. If the number of edge pixels of a tablet is 5, when one of the edge pixels changes, it means that the tablet has a large defect. When the number of pixels of a tablet is 500, when one edge pixel changes, the overall tablet still does not change significantly. At the same time, this application also decomposes the image to obtain high-frequency details in the image, and calculates the energy difference between the tablet image and the template image. The initial similarity is adjusted synchronously based on the energy difference and shape matching coefficient, and the tablet defects are analyzed from data in multiple dimensions, thereby improving the final accuracy of tablet detection and improving the accuracy of final defect detection.
[0009] Optionally, the shape fit coefficient is calculated as:
[0010] Where, is the pixel point in the pill image The shape fit coefficient of Expressed as a natural constant The exponential function with base , is the pixel point in the pill image The local distortion of The preset standard tablet diameter.
[0011] Normalize the values by the exponential function, As The weight of the standard tablet increases when the diameter of the tablet increases Get smaller, as the diameter of the standard tablet decreases becomes larger, realizing the adjustment of the sensitivity of the shape matching coefficient during the defect detection process.
[0012] Optionally, the step of calculating the multimodal matching degree includes: the shape matching coefficient is proportional to the multimodal matching degree, and the energy difference is inversely proportional to the multimodal matching degree.
[0013] Optionally, the steps for calculating the energy difference of any pixel point in the pill image include: obtaining the energy defect ratio of any layer of high-frequency sub-band of any pixel point in the pill image; presetting a standard defect ratio, taking the absolute value of the difference between the energy defect ratio and the standard defect ratio as the texture energy offset of the high-frequency sub-band, and taking the sum of the texture energy offsets of multiple layers of high-frequency sub-bands as the energy difference of the pixel point.
[0014] For each decomposition, the template image and the tablet image generate a high-frequency sub-band. The energy defect ratio is calculated by the difference of the high-frequency sub-bands in the same layer, and then the energy defect ratio is compared with the preset standard defect ratio to obtain the energy difference of the texture energy.
[0015] Optionally, the steps for calculating the energy difference of any pixel point in the pill image include: obtaining the energy defect ratio of any layer of high-frequency sub-band of any pixel point in the pill image; setting the weight coefficient of the energy defect ratio of each layer of high-frequency sub-band, presetting the standard defect ratio, taking the absolute value of the difference between the energy defect ratio and the standard defect ratio as the energy deviation, and taking the product of the energy deviation and the corresponding weight coefficient as the texture energy offset of the high-frequency sub-band; and taking the sum of the texture energy offsets of multiple layers of high-frequency sub-bands as the energy difference of the pixel point.
[0016] In this method, different weight coefficients are set for the energy deviation of the high-frequency sub-band of each layer, so that the final calculation result can focus on textures of different sizes as needed.
[0017] Optionally, the template image and the pill image are decomposed three times using a wavelet packet decomposition method, and the size of each high-frequency sub-band is halved successively; for any two layers of high-frequency sub-bands, the weight coefficient of the high-frequency sub-band with a larger size is smaller than the weight coefficient of the high-frequency sub-band with a smaller size.
[0018] The high-frequency sub-bands obtained after multiple decompositions can better reflect the details of the texture. The defects of the tablets are generally manifested as subtle textures such as scratches. Therefore, increasing the weight coefficient of this layer will increase the sensitivity of the final calculation results to subtle textures.
[0019] Optionally, the step of obtaining the energy defect ratio of any layer of high-frequency sub-band of any pixel point in the pill image includes: obtaining the sum of the squares of the coefficient matrix of any layer of high-frequency sub-band in the template image; obtaining the sum of the squares of the elements corresponding to the template image in the coefficient matrix of the corresponding high-frequency sub-band in the pill image; and taking the ratio of the sum of squares corresponding to the template image to the sum of squares corresponding to the pill image as the energy defect ratio of the pixel point corresponding to the reference pixel point in the pill image.
[0020] For each high-frequency subband decomposed at any level of the template image and the pill image, there exists a matrix of coefficients, known as the coefficient matrix. Comparing the corresponding elements of the coefficient matrix in the template image with those in the pill image reveals the difference in texture energy between the two images. The closer the ratio of the sum of squares corresponding to the template image to the sum of squares corresponding to the pill image is to 1, the more similar the textures of the template image and the pill image are.
[0021] Optionally, the calculation formula for multimodal matching is:
[0022] Where, Pixels in the pill image Multimodal matching degree; Pixels in the pill image The initial similarity of Represents the pixel points in the pill image The shape fit coefficient of Represents the pixel points in the pill image The energy difference of is the first adjustment coefficient; is the second adjustment coefficient; is the third adjustment coefficient.
[0023] Optionally, the step of detecting tablets based on multimodal matching includes: the multimodal matching degree of each pixel point in the tablet image forms an optimal NCC matrix; setting a defect threshold and obtaining the maximum element value in the optimal NCC matrix; in response to the maximum element value being greater than the defect threshold, determining that the tablet has a defect.
[0024] In a second aspect, the present application provides a tablet defect detection system based on machine vision, which adopts the following technical solutions:
[0025] A tablet defect detection system based on machine vision includes a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, the tablet defect detection method based on machine vision is implemented.
[0026] The above-mentioned tablet defect detection method based on machine vision is generated into a computer program and stored in a memory so as to be loaded and executed by a processor. Thus, a system is made based on the memory and the processor for easy use.
[0027] This application has the following technical effects:
[0028] In this application, to enhance the sensitivity to edges and geometric edges, a shape fit coefficient is constructed based on the grayscale value difference between the tablet image and the template image, as well as the size of the tablet. Furthermore, to suppress noise using multiple features, an energy difference is constructed based on the difference between the texture energy of the high-frequency subband of the tablet image and the texture energy of the high-frequency subband of the template image. Finally, based on the shape fit coefficient and energy difference, the similarity of the traditional NCC image matching algorithm is improved and optimized to obtain a multimodal matching degree. This enhances the sensitivity to edge and geometric defect features while also combining multiple features to suppress noise, thereby improving the accuracy of tablet defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 This is a flow chart of a method for detecting tablet defects based on machine vision in this application. DETAILED DESCRIPTION
[0030] The present invention discloses a machine vision-based tablet defect detection method. A template image and a tablet image are acquired, and the shape fit coefficient between each pixel in the tablet image and the template image is calculated. The template image and tablet image are decomposed, and the energy difference between each pixel in the tablet image and the template is calculated. Initial similarities are obtained for each pixel in the tablet image, and these initial similarities are optimized using the shape fit coefficient and energy difference to obtain a multimodal matching degree. Tablet detection is then completed based on the optimized multimodal matching degree.
[0031] Reference Figure 1 A tablet defect detection method based on machine vision includes steps S1 to S3.
[0032] S1: Calculate the shape matching coefficient of each pixel in the tablet image.
[0033] Obtain a template binary image and a tablet binary image, set a reference pixel in the template binary image, slide the template binary image so that the reference pixel corresponds to each pixel in the tablet binary image, calculate the grayscale value difference between each pixel in the template binary image and the corresponding pixel in the tablet binary image, and use the sum of the grayscale value differences corresponding to each pixel in the template binary image as the local distortion degree of the pixel in the tablet image corresponding to the reference pixel;
[0034] During the production process, defect-free tablets are selected as template samples. An industrial camera is used to capture images of the template samples as template images. The images of the tablets to be inspected are then processed using Gaussian denoising to produce tablet images.
[0035] To quantify the geometric differences between the tablet outlines in the tablet image and the template image and enhance the sensitivity of edge defect detection, an edge detection algorithm is used to obtain binary images of the template and tablet images. In these binary images, the grayscale value of pixels at the edge of the tablet is 255, while the grayscale value of pixels in non-edge areas is 0.
[0036] In this embodiment, the size of the tablet image is larger than that of the template image. An arbitrary pixel in the template binary image is determined as a reference pixel. The template binary image is placed on the tablet binary image and then slid pixel by pixel. During the sliding process, the reference pixel can correspond to different pixels in the tablet binary image.
[0037] For any pixel in the binary image of the tablet, there is a local distortion degree.
[0038] Specifically, when the reference pixel point of the template binary image corresponds to any pixel point in the tablet binary image, there is a pixel point in the tablet binary image that corresponds to any pixel point in the template binary image.
[0039] Calculating the grayscale value difference between the pixel point in the template binary image and the corresponding pixel point in the tablet binary image, and summing up multiple grayscale value differences can reflect the local distortion degree of a certain pixel point in the tablet image at that position.
[0040] Specifically, the calculation formula of local distortion is:
[0041] ;
[0042] Where, is the pixel point in the pill image The local distortion degree; is the pixel point in the template binary image The pixel value of is the pixel point in the binary image of the pill The pixel value at is the coordinate range of the template image.
[0043] This formula compares the difference between the template binary image and the tablet binary image at different positions. The greater the difference between the template binary image and the tablet binary image, the greater the local distortion of the tablet binary image relative to the template binary image at that position.
[0044] Represents the position of the pixel in the binary image of the tablet. Indicates the position of any pixel in the template binary image in the template image. Represents the pixel points in the template binary image The position in the binary image of the tablet is mainly used to map the pixel coordinates in the template binary image to the coordinate system of the tablet binary image.
[0045] For example, the coordinates of any pixel in the binary image of the pill for The coordinates of the reference pixel in the template binary image are , then the position of the reference pixel in the binary image of the tablet is ; If there is a pixel coordinate in the template binary image for , then the coordinates of the pixel in the binary image of the tablet are .
[0046] The shape fit coefficient is obtained by adjusting the local distortion degree based on the standard tablet diameter, wherein the standard tablet diameter is inversely proportional to the shape fit coefficient;
[0047] The specific calculation formula of the shape matching coefficient is:
[0048] Where, is the pixel point in the pill image The shape fit coefficient of Expressed as a natural constant The exponential function with base , is the pixel point in the binary image of the pill The local distortion of The preset standard tablet diameter.
[0049] Here, the shape fit coefficient is normalized to a value between 0 and 1 using an exponential function. When the local distortion is 0, there is no difference between the template binary image and the tablet binary image. When the shape fit coefficient is 1, the tablet binary image and the template binary image are completely matched. As the local distortion increases, the shape fit coefficient decreases, sensitively reflecting shape defects.
[0050] at the same time Indicates the adjustment coefficient for defect sensitivity. If the diameter of a tablet is small, the number of its edge pixels is small, and the defect of a single pixel occupies a large proportion of the edge pixels. Therefore, the sensitivity of defect detection should be appropriately increased, that is, increasing The value of .
[0051] S2: Use the wavelet packet decomposition method to perform multi-layer decomposition on the pill image and the template image, extract the high-frequency sub-band after each decomposition layer, and calculate the energy difference of the texture energy of each pixel in the pill image.
[0052] Traditional NCC image matching algorithms rely solely on grayscale matching of pixel sets and are unable to distinguish texture variations at different frequencies. Therefore, wavelet packet decomposition is used to perform multi-layer decomposition of the tablet image and template image. In this embodiment, three layers of decomposition are performed. The image texture is separated into different frequency bands (including low-frequency approximations and high-frequency details, where high-frequency details include horizontal details, vertical details, and diagonal details). The Daubechies4 basis function is used as the basis function for the wavelet packet decomposition in this application. Implementers may select other basis functions based on actual circumstances. Because tablet surface defects (such as scratches and spots) primarily manifest as high-frequency energy variations, this application selects high-frequency subbands for subsequent analysis.
[0053] The template image is slid pixel by pixel, and the energy defect ratio of any high-frequency sub-band of any pixel in the tablet image is obtained during the sliding process.
[0054] Obtain the square sum of the coefficient matrix of any layer of high-frequency subband in the template image; obtain the square sum of the elements corresponding to the template image in the coefficient matrix of the corresponding high-frequency subband in the pill image; and use the ratio of the square sum corresponding to the pill image to the square sum corresponding to the template image as the energy defect ratio of the pixel point corresponding to the reference pixel point in the pill image.
[0055] Specifically, the energy defect ratio of any pixel in the tablet image is calculated as:
[0056] ; is the pixel point in the pill image In the Energy defect ratio of high frequency sub-band of the layer; The corresponding pixel in the coefficient matrix of the k-th layer high frequency subband after the template image is decomposed by wavelet packet Elements, is the corresponding pixel point in the coefficient matrix of the k-th high-frequency subband after the pill image is decomposed by wavelet packet Elements, is the preset parameter adjustment factor; Indicates the value range of the template image.
[0057] In this application, the template image and the tablet image are decomposed three times. The size of the high-frequency sub-band obtained in the first layer is half of the original image. Similarly, the high-frequency sub-bands of the second and third layers are obtained. For example, the original image size is , then the size of the first layer high frequency subband is , the size of the second-layer high-frequency sub-band is , the size of the third layer high frequency sub-band is .
[0058] The template image is represented by The square sum of multiple elements in the coefficient matrix of the high-frequency subband of the layer eliminates the directionality of the coefficients through the square operation and only retains the energy intensity; at the same time, the square sum is more sensitive to large-value coefficients and is easier to capture significant texture changes.
[0059] During the calculation process, if the final calculated energy defect ratio is close to 1, it means that the texture energy of the template image and the tablet image are consistent and there are no significant defects. If the final energy defect ratio is greater than 1, it means that there is texture energy anomaly in the template image, possibly due to high-frequency noise. If the final energy defect ratio is less than 1, it means that there is texture loss in the tablet image.
[0060] In one embodiment, the energy difference calculation step includes: presetting a standard defect ratio, taking the absolute value of the difference between the energy defect ratio and the standard defect ratio as the texture energy offset of the high-frequency sub-band, and taking the sum of the texture energy offsets of multiple layers of high-frequency sub-bands as the energy difference of the pixel point.
[0061] In this embodiment, the standard defect ratio is 1. When the energy defect ratio approaches 1, it indicates that the texture energy of the template image and the tablet image is similar.
[0062] Specifically, the calculation formula for energy difference is:
[0063] Where, is the pixel point in the pill image The energy difference of is the pixel point in the pill image Energy defect ratio of high frequency sub-band in the kth layer.
[0064] Where, It reflects the degree to which the energy defect ratio deviates from the normal value. Whether the defect ratio is enhanced or weakened, it is considered abnormal.
[0065] In another embodiment, the steps of calculating the energy difference include: setting the weight coefficient of the energy defect ratio of each layer of high-frequency sub-band, presetting the standard defect ratio, taking the absolute value of the difference between the energy defect ratio and the standard defect ratio as the energy deviation, and taking the product of the energy deviation and the corresponding weight coefficient as the texture energy deviation of the high-frequency sub-band; and taking the sum of the texture energy deviations of multiple layers of high-frequency sub-bands as the energy difference of the pixel point.
[0066] Specifically, the calculation formula for energy difference is:
[0067] Where, is the pixel point in the pill image The energy difference of is the pixel point in the pill image In the Energy defect ratio of high frequency sub-band of the layer; No. The weight coefficient of the energy defect ratio corresponding to the high-frequency sub-band; Indicates the number of high-frequency sub-bands.
[0068] The weight of the high frequency sub-band decomposed in the first layer is greater than the weight of the high frequency sub-band decomposed in the second layer. Similarly, the weight of the high frequency sub-band in the second layer is greater than the weight corresponding to the high frequency sub-band in the third layer. ; In other embodiments, it can be adjusted automatically.
[0069] The high-frequency subbands generated by the first decomposition correspond to subtle textures and major defects of the tablets, and are therefore assigned a greater weight in this application.
[0070] S3: The initial similarity of each pixel in the pill image is obtained through the NCC algorithm. The initial similarity is optimized through the shape matching coefficient and energy difference to obtain the multimodal matching degree of the pixel. The pills are then detected based on the multimodal matching degree.
[0071] The calculation of the initial similarity is a conventional technical means in this field and will not be described in detail here.
[0072] The calculation formula for the multimodal matching degree of any pixel in the pill image is: Where, is the pixel point in the pill image Multimodal matching degree; is the pixel point in the pill image The shape fit coefficient, is the pixel point in the pill image The energy difference, is the initial similarity calculated using the NCC matching algorithm; is the first adjustment coefficient; is the second adjustment coefficient; is the third adjustment coefficient. 、 、 .
[0073] As the template image slides, the multimodal matching degree of each pixel in the tablet image is calculated to obtain the optimal NCC matrix. The maximum multimodal matching degree within the optimal NCC matrix is selected and used to inspect the tablets based on this maximum multimodal matching degree. A higher multimodal matching degree indicates a closer correspondence between the template image and the tablet image at that location, and therefore the multimodal matching degree at that location is used to determine tablet defects.
[0074] A defect threshold is set, and in response to a maximum value of the multimodal matching degree being less than the defect threshold, it is determined that a defect exists in the tablet in the tablet image.
[0075] In this embodiment, the defect threshold is set to 0.95, and in other embodiments, it can be adjusted according to production requirements.
[0076] An embodiment of the present application also discloses a tablet defect detection system based on machine vision, including a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, a tablet defect detection method based on machine vision according to the present application is implemented.
[0077] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface. The configuration and functions of these components are known in the art and will not be described in detail here.
[0078] The above are all preferred embodiments of the present application, and are not intended to limit the scope of protection of the present application. Therefore, any equivalent changes made based on the structure, shape, and principle of the present application should be included in the scope of protection of the present application.
Claims
1. A tablet defect detection method based on machine vision, characterized in that: Including steps: Calculate the shape matching coefficient of each pixel in the tablet image; The wavelet packet decomposition method is used to perform multi-layer decomposition on the pill image and the template image, extract the high-frequency sub-band after each decomposition layer, and calculate the energy difference of the texture energy of each pixel in the pill image, including: Obtaining the energy defect ratio of any high-frequency subband of any pixel in the pill image, specifically: obtaining the square sum of the coefficient matrix of any high-frequency subband in the template image; obtaining the square sum of the elements corresponding to the template image in the coefficient matrix of the corresponding high-frequency subband in the pill image; and using the ratio of the square sum corresponding to the template image to the square sum corresponding to the pill image as the energy defect ratio of the pixel corresponding to the reference pixel in the pill image; Set the weight coefficient of the energy defect ratio of each high-frequency sub-band, preset the standard defect ratio, take the absolute value of the difference between the energy defect ratio and the standard defect ratio as the energy deviation, and take the product of the energy deviation and the corresponding weight coefficient as the texture energy deviation of the high-frequency sub-band; The sum of the texture energy offsets of multiple layers of high-frequency sub-bands is used as the energy difference of the pixel; The NCC algorithm is used to obtain the initial similarity of each pixel in the tablet image. The initial similarity is optimized using the shape matching coefficient and energy difference to obtain the multimodal matching degree of the pixel. The tablets are then detected based on the multimodal matching degree. Among them, the method for calculating the shape fitting coefficient of each pixel in the tablet image includes the following steps: in order to enhance the sensitivity of edge defect detection, using an edge detection algorithm to obtain a template image and a binary image of the tablet image, obtaining the template binary image and the tablet binary image, setting a reference pixel point in the template binary image, sliding the template binary image so that the reference pixel point corresponds to each pixel point in the tablet binary image, calculating the grayscale value difference between each pixel point in the template binary image and the corresponding pixel point in the tablet binary image, and taking the sum of the grayscale value differences corresponding to each pixel point in the template binary image as the local distortion degree of the pixel point in the tablet image corresponding to the reference pixel point; adjusting the local distortion degree based on the standard tablet diameter to obtain the shape fitting coefficient, wherein the standard tablet diameter is inversely proportional to the shape fitting coefficient.
2. The method for tablet defect detection based on machine vision according to claim 1, characterized in that: The calculation formula of the shape fit coefficient is: Where, is the pixel point in the pill image The shape fit coefficient of Expressed as a natural constant The exponential function with base , is the pixel point in the pill image The local distortion of The preset standard tablet diameter.
3. The tablet defect detection method based on machine vision according to claim 1, characterized in that: The shape matching coefficient is proportional to the multimodal matching degree, and the energy difference is inversely proportional to the multimodal matching degree.
4. The tablet defect detection method based on machine vision according to claim 1, characterized in that: The template image and pill image are decomposed three times using the wavelet packet decomposition method, and the size of each high-frequency sub-band is halved successively; for any two high-frequency sub-bands, the weight coefficient of the high-frequency sub-band with a larger size is smaller than the weight coefficient of the high-frequency sub-band with a smaller size.
5. The method for tablet defect detection based on machine vision according to claim 2, characterized in that: The calculation formula of multimodal matching degree is: Where, Pixels in the pill image Multimodal matching degree; Pixels in the pill image The initial similarity of Represents the pixel points in the pill image The shape fit coefficient of Represents the pixel points in the pill image The energy difference of is the first adjustment coefficient; is the second adjustment coefficient; is the third adjustment coefficient.
6. The tablet defect detection method based on machine vision according to claim 1, characterized in that: The steps of detecting tablets based on multimodal matching include: forming an optimal NCC matrix based on the multimodal matching degree of each pixel point in the tablet image; setting a defect threshold and obtaining the maximum element value in the optimal NCC matrix; and determining that the tablet has a defect in response to the maximum element value being greater than the defect threshold.
7. A tablet defect detection system based on machine vision, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a tablet defect detection method based on machine vision according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Glass fiber surface oil stain detection method and device, storage medium and electronic equipment
CN113781446A
Engine cylinder surface defect detection method and system
CN119290761A
Video sharpness assessment method, apparatus and device, storage medium, and product
WO2024255617A1