Tablet defect detection method and system based on machine vision

Through wavelet packet decomposition and multimodal matching degree optimization methods, the problem of insufficient sensitivity in the detection of tablet defects is solved, and higher detection accuracy and accuracy are achieved.

CN120088505AActive Publication Date: 2025-06-03SHANXI JIUZHOU PHARM CO LTD

Patent Information

Application Number
CN202510573149.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-06
Publication Date
2025-06-03
Estimated Expiration
2045-05-06

AI Technical Summary

Technical Problem

The traditional NCC image matching algorithm has insufficient local feature sensitivity in the detection of tablet surface defects, making it difficult to capture the edge defects and local shape distortion of the tablet, resulting in a high missed detection rate.

Method used

The wavelet packet decomposition method is used to perform multi-layer decomposition on the tablet image and template image, extract high-frequency subbands, calculate the shape fit coefficient and energy difference, and optimize the similarity of the NCC algorithm through these indicators to obtain multimodal matching degree to improve detection accuracy.

Benefits of technology

The sensitivity of the edge and geometric defect characteristics of the tablet is enhanced, and combined with multi-characteristics to suppress noise, significantly improving the accuracy and accuracy of the tablet defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120088505A_ABST
    Figure CN120088505A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to a tablet defect detection method and system based on machine vision. The method comprises the following steps: calculating a shape matching coefficient of each pixel point in a tablet image; performing multi-layer decomposition on the tablet image and the template image by using a wavelet packet decomposition method, extracting a high-frequency sub-band after each layer of decomposition, and calculating an energy difference degree of texture energy of each pixel point in the tablet image; and obtaining the initial similarity of each pixel point of the tablet image through an NCC algorithm, optimizing the initial similarity through the shape matching coefficient and the energy difference degree to obtain the multi-modal matching degree of the pixel point, and detecting the tablet based on the multi-modal matching degree. The tablet defect detection method has the effect of improving the tablet defect detection precision and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular, to a method and system for detecting tablet defects based on machine vision. Background Art

[0002] In recent years, driven by the dual promotion of technological progress and consumption upgrading, the public's health awareness and quality requirements have been continuously improved. As a special commodity related to life safety, the quality control of the production process of drugs has received attention. As a common form in pharmaceutical preparations, the integrity of the tablet surface not only directly affects the safety and effectiveness of drugs, but is also an important indicator of the quality control system of pharmaceutical enterprises. At present, the commonly used manual visual inspection method in the industry has limitations: the detection efficiency and accuracy are greatly affected by the state of the inspectors, and the missed detection rate is as high as 15% - 30%. Moreover, with the rising labor costs and the increasing demand for production capacity expansion, the traditional detection mode has been difficult to adapt to the trend of intelligent transformation of modern pharmaceutical industry. For the above reasons and the development and progress of image processing technology, some detection methods based on machine vision have gradually been applied to the field of tablet detection. The main detection steps include: collecting the image of the tablet, comparing the tablet image with a preset defect-free tablet image, and thus judging whether the tablet has defects to achieve the detection of the tablet.

[0003] The NCC (normalized cross correlation) matching algorithm is a common image processing method. Its core idea is to select the similarity (i.e., the NCC value) between the local regions of the template image (i.e., the standard image without defects) and the target image (i.e., the image to be detected), and finally generate a correlation matrix to record the matching scores at each position. The traditional NCC image matching algorithm has the problem of insufficient sensitivity to local features in the process of detecting tablet surface defects. That is, shape matching only depends on the global gray correlation, and it is difficult to capture the local shape distortion of the edge defect of the tablet. At the same time, when there is a local depression in the tablet but the overall gray distribution is similar, the NCC value may still be close to the value of 1, resulting in missed detection. In summary, the accuracy and precision of the traditional method for detecting tablets based on machine vision need to be further improved. Summary of the Invention

[0004] In order to solve the problem of insufficient detection accuracy and precision of the traditional NCC image matching algorithm for tablets, the present application provides a method and system for detecting tablet defects based on machine vision.

[0005] In a first aspect, the present application provides a method for detecting tablet defects based on machine vision, adopting the following technical solutions: A method for detecting tablet defects based on machine vision, comprising the steps of: calculating the shape matching coefficient of each pixel point in the tablet image; using the wavelet packet decomposition method to perform multi-layer decomposition on the tablet image and the template image, extracting the high-frequency sub-bands after each layer of decomposition, and calculating the energy difference degree of the texture energy of each pixel point in the tablet image; obtaining the initial similarity of each pixel point in the tablet image through the NCC algorithm, optimizing the initial similarity through the shape matching coefficient and the energy difference degree to obtain the multi-modal matching degree of the pixel point, and detecting the tablet based on the multi-modal matching degree; Among them, the method for calculating the shape matching coefficient of each pixel in the tablet image includes the steps of: 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 to make the reference pixel point correspond to each pixel point in the tablet binary image, calculating the gray 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 gray value differences corresponding to each pixel point in the template binary image as the local distortion degree of the pixel point corresponding to the reference pixel point in the tablet image; adjusting the local distortion degree based on the standard tablet diameter to obtain the shape matching coefficient, where the standard tablet diameter is inversely proportional to the shape matching coefficient.

[0006] In this application, the local distortion degree is calculated through the difference in gray values between the template image and the tablet image, and then the local distortion degree is adjusted through the diameter of the tablet to obtain the shape matching coefficient. During the calculation of the shape matching coefficient, the standard tablet diameter is inversely proportional to the shape matching coefficient, that is, when the standard tablet diameter is larger, the more edge pixels the tablet has. When a single pixel changes, the changed pixel accounts for a relatively small proportion in the overall edge pixels, and the value of the shape matching coefficient can be appropriately reduced to reduce the impact on the calculation of the multi-modal matching degree. When the tablet is smaller, the change of a single pixel accounts for a relatively large proportion in the number of edge pixels. Therefore, in this case, the impact on the calculation of the multi-modal matching degree should be increased. If the number of edge pixel points of a tablet is 5, and one of the edge pixel points changes, it means that the tablet has already had a relatively large defect. When the number of pixel points of a tablet is 500, when one edge pixel point changes, the overall tablet has not changed significantly. At the same time, in this application, the image is also decomposed to obtain the high-frequency details in the image, and the energy difference degree between the tablet image and the template image is calculated. The initial similarity is adjusted synchronously by combining the energy difference degree and the shape matching coefficient, and the tablet defects are analyzed from multiple dimensions of data, so as to improve the accuracy of the final tablet detection and the accuracy of the final defect detection.

[0007] Optionally, the calculation formula of the shape matching coefficient is: ; In the formula, is the shape matching coefficient of the pixel point in the tablet image; denotes the exponential function with the natural constant as the base, is the local distortion degree of the pixel points in the tablet image, and

[0008] normalizes the value through the exponential function, which is used as the weight of When the standard tablet diameter increases, it decreases; when the standard tablet diameter decreases,

[0009] it increases, realizing the adjustment of the sensitivity of the shape matching coefficient during the defect detection process.

[0010] Optionally, the calculation steps of the multi-modal matching degree include: the shape matching coefficient is proportional to the multi-modal matching degree, and the energy difference degree is inversely proportional to the multi-modal matching degree.

[0011] For each decomposition, the template image and the tablet image both generate a high-frequency sub-band. The energy defect ratio is calculated through the difference of the same layer of high-frequency sub-bands, and then the energy defect ratio is compared with the preset standard defect ratio, so that the energy difference degree of the texture energy can be obtained.

[0012] Optionally, the calculation steps of the energy difference degree of any pixel point in the tablet image include: obtaining the energy defect ratio of any layer of high-frequency sub-bands of any pixel point in the tablet image; presetting the standard defect ratio, taking the absolute value of the difference between the energy defect ratio and the standard defect ratio as the texture energy deviation degree of the high-frequency sub-band, and taking the sum of the texture energy deviation degrees of multiple layers of high-frequency sub-bands as the energy difference degree of this pixel point.

[0013] In this method, different weight coefficients are set for the energy deviation degrees of each layer of high-frequency sub-bands, so that the final calculation result can focus on some textures of different sizes as needed.

[0014] Optionally, the template image and the tablet image are decomposed 3 times using the wavelet packet decomposition method, and the size of each layer of high-frequency sub-band is halved in turn; 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 that of the high-frequency sub-band with a smaller size.

[0015] The high-frequency subbands obtained through multiple decompositions can better reflect the details of the texture, and the defects of the tablets generally appear as fine textures such as scratches. Therefore, increasing the weight coefficient of this layer can improve the sensitivity of the final calculation result to fine textures.

[0016] Optionally, the steps of obtaining the energy defect ratio of any high-frequency subband of any pixel point in the tablet image include: obtaining the sum of squares of the coefficient matrix of any high-frequency subband in the template image; obtaining the sum of squares of the corresponding elements in the coefficient matrix of the corresponding high-frequency subband in the tablet image compared with the template image; taking the ratio of the sum of squares corresponding to the template image to the sum of squares corresponding to the tablet image as the energy defect ratio of the pixel point corresponding to the reference pixel point in the tablet image.

[0017] For any decomposed high-frequency subband of the template image and the tablet image, there is a matrix composed of coefficients, that is, the coefficient matrix. Comparing the corresponding elements of the coefficient matrix in the template image with the coefficient matrix in the tablet image can reflect the difference in texture energy between the template image and the tablet image. The closer the ratio of the sum of squares corresponding to the template image to the sum of squares corresponding to the tablet image is to 1, the more similar the textures of the template image and the tablet image are.

[0018] Optionally, the calculation formula for the multi-modal matching degree is: ; where The multi-modal matching degree of the pixel point in the tablet image; The initial similarity of the pixel point in the tablet image; represents the shape matching coefficient of the pixel point in the tablet image; represents the energy difference degree of the pixel point in the tablet image; is the first adjustment coefficient; is the second adjustment coefficient; is the third adjustment coefficient.

[0019] Optionally, the steps of detecting the tablet based on the multi-modal matching degree include: the multi-modal matching degrees of each pixel point in the tablet image form 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.

[0020] In a second aspect, the present application provides a tablet defect detection system based on machine vision, adopting the following technical solution: A tablet defect detection system based on machine vision includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a tablet defect detection method based on machine vision as described above.

[0021] Generate a computer program for the above-mentioned tablet defect detection method based on machine vision and store it in the memory to be loaded and executed by the processor. Thus, making a system according to the memory and the processor is convenient for use.

[0022] The present application has the following technical effects: In the present application, in order to enhance the sensitivity of edges and geometric edges, a shape matching coefficient is constructed based on the gray value difference between the tablet image and the template image, as well as the size of the tablet. Further, in order to jointly suppress noise with multiple features, an energy difference degree is constructed based on the difference between the texture energy of the high-frequency sub-band of the tablet image and the texture energy of the high-frequency sub-band of the template image. Finally, based on the shape matching coefficient and the energy difference degree, the similarity of the traditional NCC image matching algorithm is improved and optimized to obtain a multi-modal matching degree, which enhances the sensitivity of edges and geometric defect features while jointly suppressing noise with multiple features and improves the accuracy of tablet defect detection. Description of the Drawings

[0023] Figure 1 It is a method flow chart of a tablet defect detection method based on machine vision in the present application. Detailed Embodiments

[0024] The embodiments of the present application disclose a tablet defect detection method based on machine vision, which obtains a template image and a tablet image, and calculates the shape matching coefficient between each pixel point in the tablet image and the template image. Decompose the template image and the tablet image, and calculate the energy difference degree between each pixel point in the tablet image and the template. Obtain the initial similarity of each pixel point in the tablet image, optimize the initial similarity through the shape matching coefficient and the energy difference degree to obtain a multi-modal matching degree, and complete the detection of the tablet based on the optimized multi-modal matching degree.

[0025] Refer to Figure 1 , a tablet defect detection method based on machine vision includes steps S1 - step S3.

[0026] S1: Calculate the shape matching coefficient of each pixel point in the tablet image.

[0027] Obtain the template binary image and the pill binary image. Set a reference pixel point in the template binary image. Slide the template binary image to make the reference pixel point correspond to each pixel point in the pill binary image. Calculate the gray value difference between each pixel point in the template binary image and the corresponding pixel point in the pill binary image. Take the sum of the gray value differences corresponding to each pixel point in the template binary image as the local distortion degree of the pixel point corresponding to the reference pixel point in the pill image. Select defect-free pills as template samples during the production process, and use an industrial camera to collect the images of the template samples as template images. Use an industrial camera to collect the images of the pills to be detected, and then process the images of the pills through Gaussian denoising to obtain the pill images.

[0028] To quantify the geometric differences between the pill contours in the pill images and the pill contours in the template images and enhance the sensitivity of edge defect detection. Use an edge detection algorithm to obtain the binary images of the template image and the pill image. In the binary images of the template image and the pill image, the gray value of the pixel points on the edge of the pill is 255, and the pixel points in the non-edge area are 0.

[0029] In this embodiment, the size of the pill image is larger than that of the template image. Determine any pixel point in the template binary image as the reference pixel point. Place the template binary image on the pill binary image and then slide it pixel by pixel. During the sliding process, the reference pixel point can correspond to different pixel points in the pill binary image.

[0030] For any pixel point in the pill binary image, there is a local distortion degree.

[0031] Specifically, when the reference pixel point of the template binary image corresponds to any pixel point in the pill binary image, for any pixel point in the template binary image, there is a corresponding pixel point in the pill binary image.

[0032] Calculating the gray value difference between the pixel points in the template binary image and the corresponding pixel points in the pill binary image and summing up multiple gray value differences can reflect the local distortion degree of the template at this position and a certain pixel point in the pill image.

[0033] Specifically, the calculation formula for the local distortion degree is: ; In the formula, is the local distortion degree of the pixel point in the pill image; is the pixel value of the pixel point in the template binary image, is the pixel value at the pixel point in the pill binary image, The coordinate range of the template image.

[0034] In this formula, the differences between the template binary image and the tablet binary image are compared when the template binary image is in different positions. The greater the difference between the template binary image and the tablet binary image, the greater the local distortion degree of the tablet binary image relative to the template binary image at this position.

[0035] Represents the position of the pixel point in the tablet binary image. Indicates the position of any pixel point in the template binary image in the template image. Represents the pixel point in the template binary image The position in the tablet binary image, which is mainly used to map the pixel point coordinates in the template binary image to the coordinate system where the tablet binary image is located.

[0036] For example, the coordinate of any pixel point in the tablet binary image is . The coordinate of the reference pixel point in the template binary image is , then the position of the reference pixel point in the tablet binary image is ; if there is a pixel point coordinate in the template binary image is .

[0037] The shape matching coefficient is obtained by adjusting the local distortion degree based on the standard tablet diameter, where the standard tablet diameter is inversely proportional to the shape matching coefficient; The specific calculation formula of the shape matching coefficient is: ; in the formula, is the shape matching coefficient of the pixel point in the tablet image; represents the exponential function with the natural constant as the base, is the local distortion degree of the pixel point in the tablet binary image, is the preset standard tablet diameter.

[0038] In the formula, the shape matching coefficient is normalized to between 0 and 1 through the exponential function. When the value of the local distortion degree is 0, that is, there is no difference between the template binary image and the tablet binary image; the value of the shape matching coefficient is 1, and the tablet binary image completely matches the template binary image. When the value of the local distortion degree increases, the shape matching coefficient decays, sensitively reflecting the shape defect.

[0039] At the same time Represents the adjustment coefficient for defect sensitivity. If the diameter of a tablet is small, the number of edge pixels is small, and the defect of a single pixel occupies a relatively large proportion among the edge pixels. Therefore, the sensitivity of defect detection should be appropriately increased, that is, increase the value of.

[0040] S2: Use the method of wavelet packet decomposition to perform multi-layer decomposition on the tablet image and the template image, extract the high-frequency sub-bands after each layer of decomposition, and calculate the energy difference degree of the texture energy of each pixel point in the tablet image.

[0041] The traditional NCC image matching algorithm only depends on the gray-scale matching of pixel sets and cannot distinguish texture changes of different frequencies. Therefore, wavelet packet decomposition is used to perform multi-layer decomposition on the tablet image and the template image. In this embodiment, three-layer decomposition is performed in total. The image texture is separated into different frequency bands (including low-frequency approximation and high-frequency details, where the high-frequency details include horizontal details, vertical details, and diagonal details). Among them, the basis function of wavelet packet decomposition in this application selects the Daubechies4 basis function, and the implementer can select other basis functions based on actual situations. Since the surface defects of the tablet (such as scratches and spots) are mainly manifested as high-frequency energy changes, high-frequency sub-bands are selected for subsequent analysis in this application.

[0042] Slide the template image pixel by pixel, and obtain the energy defect ratio of any high-frequency sub-band of any pixel point in the tablet image during the sliding process; Obtain the sum of squares of the coefficient matrix of any high-frequency sub-band in the template image; obtain the sum of squares of the elements corresponding to the template image in the coefficient matrix of the corresponding high-frequency sub-band in the tablet image; use the ratio of the sum of squares corresponding to the tablet image to the sum of squares corresponding to the template image as the energy defect ratio of the pixel point corresponding to the reference pixel point in the tablet image.

[0043] Specifically, the calculation formula for the energy defect ratio of any pixel point in the tablet image is: ; is the pixel point in the tablet image at the layer high-frequency sub-band energy defect ratio; is the element corresponding to the pixel point in the coefficient matrix of the k-th layer high-frequency sub-band after wavelet packet decomposition of the template image, is the element corresponding to the pixel point in the coefficient matrix of the k-th layer high-frequency sub-band after wavelet packet decomposition of the tablet image, is the preset tuning factor; represents the value range of the template image.

[0044] 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 one-half of the original image. Similarly, the high-frequency sub-bands of the second and third layers are obtained. For example, if the size of the original image is , then the size of the high-frequency sub-band in the first layer is , the size of the high-frequency sub-band in the second layer is , and the size of the high-frequency sub-band in the third layer is .

[0045] represents the sum of the squares of multiple elements in the coefficient matrix of the -layer high-frequency sub-band of the template image. By performing the square operation, the directionality of the coefficients is eliminated, and only the energy intensity is retained; at the same time, the sum of squares is more sensitive to large-magnitude coefficients and is more likely to capture significant texture changes.

[0046] During the calculation process, if the finally calculated energy defect ratio is close to 1, it indicates that the texture energy of the template image and the tablet image is consistent and there are no significant defects. If the value of the finally calculated energy defect ratio is greater than 1, it indicates that there is an abnormal texture energy in the template image and there may be high-frequency noise. If the result of the finally calculated energy defect ratio is less than 1, it indicates that there is a texture deficiency in the tablet image.

[0047] In one embodiment, the calculation steps of the energy difference degree include: 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 degree of the high-frequency sub-band, and taking the sum of the texture energy offset degrees of the multi-layer high-frequency sub-bands as the energy difference degree of this pixel point.

[0048] 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.

[0049] Specifically, the calculation formula of the energy difference degree is: ; in the formula, is the energy difference degree of the pixel point in the tablet image; is the energy defect ratio of the pixel point in the k-th layer high-frequency sub-band of the tablet image.

[0050] In the formula, reflects the degree to which the energy defect ratio deviates from the normal value, and both an increase or a decrease in the defect ratio is regarded as an abnormality.

[0051] In another embodiment, the calculation steps of the energy difference degree include: setting the weight coefficients of the energy defect ratios of each layer of high-frequency subbands, 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 degree, and taking the product of the energy deviation degree and the corresponding weight coefficient as the texture energy deviation degree of the high-frequency subband; taking the sum of the texture energy deviation degrees of multiple layers of high-frequency subbands as the energy difference degree of the pixel point.

[0052] Specifically, the calculation formula of the energy difference degree is: ; where is the energy difference degree of the pixel point in the tablet image; is the energy defect ratio of the pixel point in the th layer of high-frequency subband; The th weight coefficient corresponding to the energy defect ratio of the high-frequency subband; represents the number of high-frequency subbands.

[0053] The weight of the high-frequency subband decomposed in the first layer is greater than the weight of the high-frequency subband decomposed in the second layer. Similarly, the weight of the second-layer high-frequency subband is greater than the weight corresponding to the third-layer high-frequency subband. In this embodiment ; in other embodiments, it can be adjusted by itself.

[0054] The high-frequency subband generated by the first decomposition corresponds to fine textures and the main defects of the tablet. Therefore, a larger weight is assigned in this application.

[0055] S3: Obtain the initial similarity of each pixel point of the tablet image through the NCC algorithm, optimize the initial similarity through the shape matching coefficient and the energy difference degree to obtain the multi-modal matching degree of the pixel point, and detect the tablet based on the multi-modal matching degree.

[0056] The calculation of the initial similarity is a conventional technical means in the art and will not be elaborated here.

[0057] For the multi-modal matching degree of any pixel point in the tablet image, its calculation formula is: ; where is the multi-modal matching degree of the pixel point in the tablet image; is the shape matching coefficient of the pixel point in the tablet image, is the energy difference degree of the pixel point in the tablet image, 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. In this embodiment , , .

[0058] As the template image slides, calculate the multimodal matching degree of each pixel in the tablet image, so as to obtain the optimal NCC matrix. Select the maximum value of the multimodal matching degree in the optimal NCC matrix, and detect the tablet based on the maximum value of the multimodal matching degree. The larger the multimodal matching degree, the more corresponding the position of the template image is to the position of the tablet image at this position. Therefore, select the multimodal matching degree at this position to judge the tablet defect.

[0059] Set a defect threshold. When the maximum value of the multimodal matching degree is less than the defect threshold, it is determined that the tablet in the tablet image has a defect.

[0060] In this embodiment, the defect threshold is set to 0.95, and in other embodiments, it can be adjusted according to production requirements.

[0061] The embodiment of the present application also discloses a tablet defect detection system based on machine vision, including a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, a tablet defect detection method based on the present application is implemented.

[0062] The above system also includes other components well known to those skilled in the art such as a communication bus and a communication interface. Their settings and functions are known in the art, so they will not be described in detail here.

[0063] The above are all the preferred embodiments of the present application. The protection scope of the present application is not limited accordingly. Therefore, all equivalent changes made according to the structure, shape, and principle of the present application should be covered within the protection scope of the present application.

Claims

1. A tablet defect detection method based on machine vision, characterized in that: The method comprises the following steps: calculating the shape matching coefficient of each pixel in a pill image; performing multi-layer decomposition on the pill image and the template image by using a wavelet packet decomposition method, extracting the high-frequency subband after each decomposition, and calculating the energy difference of the texture energy of each pixel in the pill image; obtaining the initial similarity of each pixel in the pill image by using an NCC algorithm, optimizing the initial similarity by using the shape matching coefficient and the energy difference to obtain the multi-modal matching degree of the pixel, and detecting the pill based on the multi-modal matching degree; The method for calculating the shape matching 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 to make the reference pixel point correspond to each pixel point in the tablet binary image, calculating the gray value difference between each pixel point in the template binary image and each corresponding pixel point in the tablet binary image, and taking the sum of the gray 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; and adjusting the local distortion degree based on the standard tablet diameter to obtain the shape matching coefficient, wherein the standard tablet diameter is inversely proportional to the shape matching 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: ; In the formula, is the pixel point in the pill image The shape fit coefficient of Indicated by natural constant The exponential function with base , is the pixel point in the pill image The local distortion of It is the preset standard tablet diameter.

3. The method for tablet defect detection 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 method for tablet defect detection based on machine vision according to claim 1, characterized in that: 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.

5. The method for tablet defect detection based on machine vision according to claim 1, characterized in that: The steps for calculating the energy difference of any pixel in the pill image include: obtaining the energy defect ratio of any layer of high-frequency sub-band of any pixel 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 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.

6. The method for tablet defect detection 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 layers of high-frequency sub-bands, the weight coefficient of the large-sized high-frequency sub-band is smaller than the weight coefficient of the small-sized high-frequency sub-band.

7. A tablet defect detection method based on machine vision according to claim 4 or 5, characterized in that: The step of obtaining the energy defect ratio of any layer of high-frequency subband of any pixel point in the pill image includes: obtaining the sum of squares of the coefficient matrix of any layer of high-frequency subband in the template image; obtaining the sum of squares of the elements corresponding to the template image in the coefficient matrix of the corresponding high-frequency subband 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.

8. 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: ; In the formula, Pixels in the pill image The multimodal matching degree of 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.

9. The method for tablet defect detection based on machine vision according to claim 1, characterized in that: The steps of detecting tablets based on multimodal matching include: 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, judging that the tablet has a defect.

10. 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 method for detecting tablet defects based on machine vision according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Glass fiber surface oil stain detection method and device, storage medium and electronic equipment

    CN113781446A

  • Sensor packaging curing adhesive defect identification method based on visual identification

    CN114943738A

  • Textile printing defect detection method and system

    CN115311263A

  • Digital printing quality visual detection method and system for high-weather-resistance printed cloth

    CN119251227A

  • Engine cylinder surface defect detection method and system

    CN119290761A

Cited By

  • Distributed data processing method and system for color sorting equipment

    CN121166384A

  • A distributed data processing method and system for color sorting equipment

    CN121166384B