A drug detection image processing method and processing device

The drug images are obtained through industrial cameras and pre-processed, segmented and matched using image processing technology, and a geometric model is established to identify drug detection results, solving the problems of low efficiency and low accuracy of traditional manual detection, and achieving efficient and accurate drug detection.

CN119762470APending Publication Date: 2025-04-04WEIHAI HAMIKE BIOTECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411901778.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Traditional drug testing methods rely on manual testing, resulting in low detection efficiency, low accuracy and susceptible to subjective deviations.

Method used

Drug images are obtained through industrial cameras, and image preprocessing, segmentation and matching are used to pre-process, segmentation and matching using median filtering, iterative threshold segmentation and template matching algorithms. Finally, the drug detection results are obtained by establishing a geometric model.

Benefits of technology

It improves the efficiency and accuracy of drug testing, reduces artificial errors, realizes automated testing, and ensures the consistency and safety of drug quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119762470A_ABST
    Figure CN119762470A_ABST
Patent Text Reader

Abstract

The present application provides a method and device for processing drug detection images, which relate to the field of image processing technology. In this method, a computer device obtains a first image of a drug to be detected through an industrial camera; the first image is denoised through a median filtering algorithm to obtain a second image; the second image is segmented through an iterative threshold segmentation method to obtain a target image area in the second image, and the target image area is an image area whose grayscale value meets the threshold; a template matching algorithm is used to find a matching area with a drug template image in the target image area; a matching area is identified by establishing a geometric model to obtain a drug detection result. Through this solution, the image processing algorithm is applied to drug detection, which can complete drug surface detection more accurately and efficiently, thereby improving drug production efficiency and the strictness of quality control.
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 device for processing drug detection images. Background Art

[0002] In the production process of medicines, ensuring product quality is crucial. However, due to the complexity of the production process and the diversity of raw materials, defective and substandard products are inevitable. Traditional quality inspection methods mainly rely on manual inspection.

[0003] In manual testing, inspectors are usually required to check the appearance, size, color and other characteristics of the drug. Although this method is simple and intuitive, it has many problems: manual testing requires inspectors to check each drug one by one, which is cumbersome and time-consuming, and the testing efficiency is low. At the same time, the test results are also easily affected by the subjective bias of the inspectors, resulting in low detection accuracy.

[0004] Therefore, it is necessary to propose a new drug testing method to improve the accuracy and efficiency of drug testing. Summary of the invention

[0005] The present application provides a method and a device for processing drug detection images, which are used to improve the efficiency and accuracy of drug detection.

[0006] In a first aspect, the present application provides a method for processing a drug detection image, the method comprising: Acquire a first image of the drug to be inspected by an industrial camera; Performing denoising on the first image by using a median filtering algorithm to obtain a second image; The second image is segmented by an iterative threshold segmentation method to obtain a target image region in the second image, where the target image region is an image region whose gray value meets the threshold value; Using the template matching algorithm, a matching area with the drug template image is searched in the target image area; The matching area is identified by establishing a geometric model to obtain the drug detection results.

[0007] In a possible design of the first aspect, preprocessing the original image by a median filtering technique to obtain a denoised image includes: According to a preset filter window size, traverse the pixel points in the first image; For each pixel point in each preset filter window during the traversal process, obtain the grayscale value corresponding to each pixel point; Sort the grayscale values ​​corresponding to the pixels in the preset filter window to obtain a grayscale value sequence; The middle value in the gray value sequence is used as the gray value corresponding to the central pixel point in the preset filtering window to obtain a second image.

[0008] In a possible design of the first aspect, segmenting the second image by an iterative threshold segmentation method to obtain a target image area in the second image includes: Using an initial threshold, the second image is divided into a foreground sub-image and a background sub-image; Calculate a first threshold value according to the foreground sub-image and the background sub-image; When it is determined that the first threshold does not meet the preset convergence condition, the first threshold is used as a new initial threshold, and the second image is divided into a foreground sub-image and a background sub-image using the initial threshold until it is determined that the first threshold meets the preset convergence condition, and the target image area is output.

[0009] In a possible design of the first aspect, searching for a matching area with a drug template image in a target image area by a template matching algorithm includes: According to the square difference matching algorithm, the square difference between the pixel points of the target image area and the pixel points of the drug template image is calculated; The matching area is determined based on the squared difference.

[0010] In a possible design of the first aspect, searching for a matching area with a drug template image in a target image area by a template matching algorithm includes: According to the normalized square difference matching algorithm, the normalized square difference between the pixel points of the target image area and the pixel points of the drug template image is calculated; The matching area is determined based on the normalized squared difference.

[0011] In a possible design of the first aspect, searching for a matching area with a drug template image in a target image area by a template matching algorithm includes: According to the correlation matching algorithm, the cross-correlation value between the pixel points of the target image area and the pixel points of the drug template image is calculated; The matching area is determined based on the cross-correlation value.

[0012] In a possible design of the first aspect, the process of establishing the geometric model includes: According to the outline of the drug template image, the minimum circumscribed rectangle of the drug template image is calculated and drawn through the center point coordinates, width, height, and rotation angle to establish a geometric model.

[0013] In a possible design of the first aspect, the process of establishing the geometric model includes: According to the contour of the drug template image, the minimum circumscribed circle of the drug template image is calculated and drawn through the center coordinates and radius to suggest a geometric model.

[0014] In a possible design of the first aspect, a matching area is identified by establishing a geometric model to obtain a drug detection result, including: The characteristic values ​​of the matching area are compared with the characteristic values ​​of the geometric model of the drug template image one by one to obtain the drug detection result.

[0015] In a second aspect, the present application provides a device for processing drug detection images, the device comprising: An acquisition module, used for acquiring a first image of the drug to be tested through an industrial camera; A filtering module, used for performing denoising on the first image by using a median filtering algorithm to obtain a second image; A segmentation module is used to segment the second image by an iterative threshold segmentation method to obtain a target image region in the second image, where the target image region is an image region whose gray value meets the threshold value; A matching module, used to find a matching area with a drug template image in a target image area through a template matching algorithm; The recognition module is used to identify the matching area by establishing a geometric model to obtain the drug detection result.

[0016] In a third aspect, the present application provides a computer device, comprising: a processor, and a memory communicatively connected to the processor; Memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method for processing drug detection images as described in any one of the first aspects of the present application.

[0017] The processing method and processing device of drug detection images provided in the present application relate to the field of image processing technology. In this scheme, a computer device obtains a first image of a drug to be detected through an industrial camera; the first image is denoised through a median filtering algorithm to obtain a second image; the second image is segmented through an iterative threshold segmentation method to obtain a target image area in the second image, and the target image area is an image area whose grayscale value meets the threshold; a template matching algorithm is used to find a matching area with a drug template image in the target image area; a matching area is identified by establishing a geometric model to obtain a drug detection result. Through this scheme, the image processing algorithm is applied to drug detection, which can complete drug surface detection more accurately and efficiently, thereby improving drug production efficiency and the strictness of quality control. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become readily understood. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, wherein: Figure 1 A schematic diagram of the process of the drug detection image processing method provided in this application; Figure 2 This is a schematic diagram of a specific implementation process of S120 in the drug detection image processing method provided in this application; Figure 3 This is a schematic diagram of a specific implementation process of S130 in the drug detection image processing method provided in this application; Figure 4 A schematic diagram of the structure of a drug detection image processing device is provided for this application; Figure 5 A schematic diagram of a computer device structure is provided for this application.

[0019] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0020] Here, exemplary embodiments are described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Instead, they are merely examples of methods and devices consistent with some aspects of the present application as detailed in the appended claims.

[0021] The quality inspection of drugs is crucial to ensure the safety and effectiveness of drugs. In the production process of drugs, it is crucial to ensure product quality. However, due to the complexity of the production process and the diversity of raw materials, defective and substandard products are inevitable. These problems not only affect the efficacy of drugs, but may also pose a threat to the health of patients. Therefore, effective quality inspection methods are an important means to ensure the quality of drugs.

[0022] At present, the quality inspection of drugs mainly relies on manual inspection. The inspection process includes the following steps: First, prepare the inspection tools, equipment and standard documents. Second, check the label information of the packaging box, check whether the packaging box is damaged or contaminated, and take out the drugs from it to observe whether the color, shape and size are uniform, and whether there are cracks, spots or other defects on the surface. Third, measure the diameter, thickness, weight, hardness, etc. of the drugs to ensure that they meet the standards. Fourth, fill in a detailed inspection report, indicating the inspection date, inspection personnel, inspection results and other information. Fifth, judge whether the drugs are qualified based on the inspection results, isolate and mark the unqualified products, and notify the relevant departments to handle them.

[0023] Although the manual detection method is simple and intuitive, it also has many problems: the process is cumbersome and time-consuming, the detection efficiency is low, and the detection results are easily affected by the subjective judgment and experience of the testers. Different testers may have different detection standards and results. Long working hours will make the testers feel tired, further affecting the accuracy and consistency of the detection.

[0024] In order to solve the above problems, this application proposes a method for processing drug detection images. The method obtains drug images through industrial cameras, and uses image processing technologies such as median filtering technology, iterative threshold segmentation method and template matching algorithm to preprocess, segment and match drug images, and finally obtain drug detection results by establishing a geometric model for recognition. Thus, through automated image processing technology, a large number of images can be quickly processed, the detection efficiency can be significantly improved, human errors can be reduced, and the accuracy of the detection results can be improved.

[0025] In this application, the preparation of drug testing equipment must be completed first. The drug testing equipment may include a high-resolution camera, a conveyor belt (rotating table), a robotic arm, and other necessary sensors and controllers, such as photoelectric sensors, programmable logic controllers, etc. Installing sensors above or below the conveyor belt (rotating table) can ensure that each drug can be accurately captured. At the same time, a stable light source needs to be provided to obtain clear images under good lighting conditions.

[0026] In this application, a feature comparison method is used to apply drug testing equipment to distinguish different types of drugs. During testing, the drug testing equipment extracts relevant features according to specific tasks and analyzes the processed images to evaluate the quality of the drugs.

[0027] During the detection process, industrial cameras and other hardware equipment are selected to obtain high-resolution images to ensure that the images include as many subtle features on the surface of the drug as possible. Image preprocessing technology is used to remove or reduce image noise. Image segmentation method is used to obtain a set of pixels with specific attributes. Feature representation is determined using a geometric model algorithm. Among them, the image preprocessing technology used in this application may include median filtering; the image segmentation method may include iterative threshold segmentation method; the geometric model algorithm may include a connected component labeling algorithm. In practical applications, image preprocessing technologies such as mean filtering, Gaussian filtering, and bilateral filtering can also be used according to needs; image segmentation methods such as region growing and watershed algorithm are used, and this application does not make specific limitations on this.

[0028] The following specific embodiments are used to describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0029] Figure 1 The following is a flow chart of the method for processing drug detection images provided in this application. Figure 1 As shown, the drug detection image processing method of the present application may include the following S110 to S160: S110: Acquire a first image of the drug to be inspected through an industrial camera.

[0030] Among them, industrial cameras refer to devices that use high-quality sensors and lenses to capture images with sufficient clarity and color. The main features of industrial cameras are reliability and durability, and the ability to shoot at high frame rates and output high-resolution images.

[0031] Therefore, in this embodiment, an industrial camera is used to photograph the drugs to be tested on the production line, which can quickly and continuously obtain high-resolution images and evaluate their quality based on the captured subtle surface features of the drugs.

[0032] S120: Perform denoising on the first image using a median filtering algorithm to obtain a second image.

[0033] Among them, median filtering is a nonlinear filtering technology that is effective in removing black and white point noise randomly distributed in an image. While removing noise, median filtering can well preserve edge and detail information, and its calculation is simple and easy to integrate into the existing image processing process.

[0034] Figure 2 This is a schematic diagram of the specific implementation process of S120 in the drug detection image processing method provided in this application. Figure 2As shown, in S120, when the original image is preprocessed by the median filtering technology to obtain the denoised image, the following S121 to S124 may be specifically included: S121: Traverse the pixel points in the first image according to a preset filter window size.

[0035] The preset filter window size is usually an odd number, such as 3x3, 5x5, etc., to ensure a clear center pixel point.

[0036] S122: For each pixel point in each preset filter window during the traversal process, obtain the grayscale value corresponding to each pixel point.

[0037] S123: Sort the grayscale values ​​corresponding to the pixels in the preset filter window to obtain a grayscale value sequence.

[0038] The grayscale values ​​corresponding to the pixels may be sorted in ascending order or in descending order, which is not specifically limited here.

[0039] S124: Taking the grayscale value in the middle of the grayscale value sequence as the grayscale value corresponding to the central pixel point in the preset filtering window to obtain a second image.

[0040] Specifically, the center pixel value of the window is replaced by the grayscale value in the middle of the grayscale value sequence. For example, if the preset filter window size is 3x3, the grayscale value in the middle of the grayscale value sequence is the 5th value; if the preset filter window size is 5x5, the grayscale value in the middle of the grayscale value sequence is the 13th value.

[0041] In the case where the preset filtering window exceeds the edge of the first image, these boundary pixels can be ignored, and the edge of the first image can be extended by using mirror filling, copy filling or other methods.

[0042] After obtaining the second image, enter S130: In S130 : the second image is segmented by an iterative threshold segmentation method to obtain a target image region in the second image, where the target image region is an image region whose grayscale value meets the threshold.

[0043] Among them, iterative threshold segmentation is an adaptive image segmentation technique that segments an image into foreground and background by iteratively adjusting the threshold. Iterative threshold segmentation does not require prior knowledge of the specific information of the image, but adaptively determines the optimal threshold based on the grayscale distribution of the image itself.

[0044] Figure 3 This is a schematic diagram of the specific implementation process of S130 in the drug detection image processing method provided in this application. Figure 3As shown, the process of segmenting the second image in S130 to obtain the target image area in the second image may specifically include: S131: Using an initial threshold, divide the second image into a foreground sub-image and a background sub-image.

[0045] Specifically, pixels in the second image whose grayscale values ​​are greater than or equal to the initial threshold are determined as pixels of the foreground sub-image, and pixels in the second image whose grayscale values ​​are less than the initial threshold are determined as pixels of the background sub-image.

[0046] S132: Calculate a first threshold according to the foreground sub-image and the background sub-image.

[0047] In this step, the average gray value m1 of the pixels in the foreground sub-image and the average gray value m2 of the pixels in the background sub-image are calculated respectively; and the first threshold value Tn is calculated according to the formula Tn=(m1+m2) / 2.

[0048] S133: When it is determined that the first threshold does not meet the preset convergence condition, the first threshold is used as a new initial threshold, and the second image is divided into a foreground sub-image and a background sub-image using the initial threshold until it is determined that the first threshold meets the preset convergence condition, and the target image area is output.

[0049] In this step, it is checked whether the first threshold Tn meets the preset convergence condition. If so, the iteration is stopped; if not, the process returns to execute S131 until the first threshold meets the preset convergence condition.

[0050] Specifically, the preset convergence condition is that the difference between the first threshold and the initial threshold is less than a set value, or the number of iterations reaches a preset number of iterations.

[0051] After obtaining the target image area in the second image, execute S140: At S140: using a template matching algorithm, a matching area with the drug template image is searched in the target image area.

[0052] The template matching algorithm compares a smaller template image (known target) with a larger target image by sliding, calculates the similarity score of each possible position, and finally finds the best matching position. Template matching is used to identify specific patterns or objects in an image. Commonly used template matching algorithms include square difference matching, normalized square difference matching, and correlation matching. The following is an explanation of the use of different template matching algorithms.

[0053] In one implementation, when the template matching algorithm is a square difference matching algorithm, the matching area is determined by calculating the square difference between the pixel points of the drug template image and the pixel points of the target image area. The smaller the square difference, the higher the similarity between the drug template image and the target image area.

[0054] In one implementation, when the template matching algorithm is based on a normalized square difference matching algorithm, the matching area is determined by calculating the normalized square difference between the pixel points of the drug template image and the pixel points of the target image area. The normalized square difference matching can normalize the result to a range of 0-1, so that images of different scales can be compared.

[0055] In one implementation, when the template matching algorithm is a correlation matching algorithm, the drug template image is slid on the target image area, and the matching area is determined by calculating the cross-correlation value of the pixel values ​​at each position. The larger the cross-correlation value, the higher the similarity between the drug template image and the target image area.

[0056] S150: Identify the matching area by establishing a geometric model to obtain the drug detection result.

[0057] Among them, building a geometric model is an important step in extracting feature representation to achieve automated quality control, which can be achieved by fitting contours. The geometric model can help identify key attributes such as drug shape, size, and color.

[0058] Common geometric models include the minimum circumscribed rectangle, the minimum circumscribed circle, and the fitted ellipse. The following is an explanation of how to establish a geometric model.

[0059] If the geometric model is based on the minimum circumscribed rectangle, the minimum circumscribed rectangle of the drug template image is calculated and drawn according to the outline of the drug template image through the center point coordinates, width and height, and rotation angle. If the geometric model is based on the minimum circumscribed circle, the minimum circumscribed circle of the drug template image is calculated and drawn according to the outline of the drug template image through the center point coordinates and radius. If the geometric model is based on the fitted ellipse, the fitted ellipse of the drug template image is calculated and drawn according to the outline of the drug template image through the center point coordinates, major axis and minor axis, and rotation angle.

[0060] Afterwards, the feature values ​​of the matching area are compared with the feature values ​​of the geometric model of the drug template image one by one to check whether they are within the threshold range. If all features meet the threshold range, the test result of the drug to be tested is judged to be qualified; otherwise, the test result of the drug to be tested is judged to be unqualified.

[0061] In summary, the use of image processing technology can provide an efficient, accurate and reliable method for drug detection to ensure drug quality and safety. Compared with the traditional manual detection method, the advantages of this embodiment are mainly reflected in the following aspects: First, image processing technology can automatically detect and reduce the impact of human factors, effectively improving the consistency and accuracy of detection. In particular, modern cameras and scanning equipment can provide high-resolution images, so that even small defects or differences can be accurately captured.

[0062] Second, image processing technology is a non-contact detection method, which not only does not cause any physical damage to the drugs, but also reduces the risk of contamination.

[0063] Third, image processing technology can complete large amounts of data processing in a short period of time, immediately identify unqualified products, and take timely measures to reduce waste and improve production efficiency.

[0064] Fourth, image processing technology can extract multiple features from images, such as color, shape, texture, size, etc., to comprehensively evaluate the quality of drugs. At the same time, it is also applicable to drugs of different types and forms, including tablets, capsules, liquids, etc.

[0065] Fifth, image processing technology can reduce labor costs. Although it may require a certain amount of hardware and software investment in the initial stage, in the long run, automated inspection can significantly improve production efficiency and reduce scrap rates, thereby bringing higher returns on investment.

[0066] Sixth, image processing technology can ensure that each batch of drugs meets preset standards and improve product quality consistency.

[0067] In the processing method of the drug detection image of this embodiment, a first image of the drug to be detected is obtained by an industrial camera; the first image is denoised by a median filtering algorithm to obtain a second image; the second image is segmented by an iterative threshold segmentation method to obtain a target image area in the second image, and the target image area is an image area whose grayscale value meets the threshold; a template matching algorithm is used to find a matching area with the drug template image in the target image area; a geometric model is established to identify the matching area to obtain the drug detection result. According to the technical solution of the embodiment of the present application, the image processing algorithm is applied to drug detection, which can complete the drug surface detection more accurately and efficiently, thereby improving the drug production efficiency and the strictness of quality control.

[0068] Figure 4 A schematic diagram of a device structure for processing drug detection images is provided for this application. Figure 4As shown, the drug detection image processing device 400 of the present application may include: an acquisition module 410 , a filtering module 420 , a segmentation module 430 , a matching module 440 , and a recognition module 450 .

[0069] The acquisition module 410 is used to acquire a first image of the drug to be inspected through an industrial camera.

[0070] The filtering module 420 is used to perform denoising on the first image by using a median filtering algorithm to obtain a second image.

[0071] The segmentation module 430 is used to perform segmentation processing on the second image by an iterative threshold segmentation method to obtain a target image region in the second image, where the target image region is an image region whose grayscale value meets the threshold.

[0072] The matching module 440 is used to find a matching area with the drug template image in the target image area through a template matching algorithm.

[0073] The identification module 450 is used to identify the matching area by establishing a geometric model to obtain the drug detection result.

[0074] In one implementation, the filtering module 420 can be specifically used to traverse the pixel points in the first image according to the preset filtering window size; for the pixel points in each preset filtering window during the traversal process, obtain the grayscale value corresponding to each pixel point; sort the grayscale values ​​corresponding to the pixel points in the preset filtering window to obtain a grayscale value sequence; use the middle value in the grayscale value sequence as the grayscale value corresponding to the center pixel point in the preset filtering window to obtain a second image.

[0075] In one implementation, the segmentation module 430 can be specifically used to use an initial threshold to divide the second image into a foreground sub-image and a background sub-image; calculate a first threshold based on the foreground sub-image and the background sub-image; when it is determined that the first threshold does not meet the preset convergence condition, use the first threshold as a new initial threshold, and execute the processing of dividing the second image into a foreground sub-image and a background sub-image using the initial threshold until it is determined that the first threshold meets the preset convergence condition, and output the target image area.

[0076] In one implementation, the matching module 440 may be specifically configured to calculate the square difference between the pixel points of the target image area and the pixel points of the drug template image according to a square difference matching algorithm; and determine the matching area according to the square difference.

[0077] In one implementation, the matching module 440 may be specifically used to calculate the normalized square difference between the pixel points of the target image area and the pixel points of the drug template image according to the normalized square difference matching algorithm; and determine the matching area according to the normalized square difference.

[0078] In one implementation, the matching module 440 may be specifically configured to calculate the cross-correlation value between the pixel points of the target image area and the pixel points of the drug template image according to a correlation matching algorithm; and determine the matching area according to the cross-correlation value.

[0079] In one implementation, when establishing the geometric model, the matching module 440 may calculate and draw the minimum circumscribed rectangle of the drug template image based on the contour of the drug template image through the center point coordinates, width and height, and rotation angle to establish the geometric model.

[0080] In one implementation, when establishing the geometric model, the matching module 440 may specifically calculate and draw the minimum circumscribed circle of the drug template image based on the contour of the drug template image through the coordinates of the circle center and the radius to suggest the geometric model.

[0081] In one implementation, the identification module 450 may be specifically used to compare the feature values ​​of the matching area with the feature values ​​of the geometric model of the drug template image one by one to obtain the drug detection result.

[0082] This embodiment provides a drug detection image processing device, which can be used to execute the drug detection image processing method in any of the aforementioned method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.

[0083] Figure 5 A schematic diagram of a computer device structure is provided for this application. Figure 5 As shown, the computer device 500 may specifically include a processor 520 and a memory 530. The memory 530 is used to store computer-executable instructions, and the processor 520 is used to execute the computer-executable instructions stored in the memory 530 to implement the above-mentioned drug detection image processing method.

[0084] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

[0085] In the description of the present application, it should be noted that the terms "first", "second" and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0086] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, equipment and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0087] In the embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0088] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0089] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0090] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of each embodiment of the present application.

[0091] Finally, it should be noted that the above embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solution of the present application, rather than to limit it. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solution recorded in the above embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solution deviate from the spirit and scope of the technical solution of the embodiment of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

[0092] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

Claims

1. A method for processing drug detection images, characterized in that: The method comprises: Acquire a first image of the drug to be inspected by an industrial camera; Performing denoising on the first image by using a median filtering algorithm to obtain a second image; Segmenting the second image by an iterative threshold segmentation method to obtain a target image region in the second image, wherein the target image region is an image region whose grayscale value meets a threshold; Using a template matching algorithm, searching for a matching area with a drug template image in the target image area; The matching area is identified by establishing a geometric model to obtain the drug detection result.

2. The method according to claim 1, characterized in that The method of preprocessing the original image by using the median filtering technology to obtain the denoised image includes: According to a preset filter window size, traverse the pixel points in the first image; For each pixel point in the preset filter window during the traversal process, obtaining the grayscale value corresponding to each pixel point; Sorting the grayscale values ​​corresponding to the pixel points in the preset filter window to obtain a grayscale value sequence; The middle value in the gray value sequence is used as the gray value corresponding to the central pixel point in the preset filtering window to obtain a second image.

3. The method according to claim 1, characterized in that The step of segmenting the second image by an iterative threshold segmentation method to obtain a target image region in the second image includes: Using an initial threshold, dividing the second image into a foreground sub-image and a background sub-image; Calculating a first threshold value according to the foreground sub-image and the background sub-image; When it is determined that the first threshold does not meet the preset convergence condition, the first threshold is used as the new initial threshold, and the process of using the initial threshold to divide the second image into a foreground sub-image and a background sub-image is performed until it is determined that the first threshold meets the preset convergence condition, and the target image area is output.

4. The method according to claim 1, characterized in that: The method of searching for a matching area with the drug template image in the target image area by using a template matching algorithm includes: Calculating the square difference between the pixel points of the target image area and the pixel points of the drug template image according to the square difference matching algorithm; The matching area is determined according to the square difference.

5. The method according to claim 1, characterized in that The method of searching for a matching area with the drug template image in the target image area by using a template matching algorithm includes: Calculating the normalized square difference between the pixel points of the target image area and the pixel points of the drug template image according to the normalized square difference matching algorithm; The matching area is determined according to the normalized square difference.

6. The method according to claim 1, characterized in that The method of searching for a matching area with the drug template image in the target image area by using a template matching algorithm includes: Calculating the cross-correlation value between the pixel points of the target image area and the pixel points of the drug template image according to the correlation matching algorithm; The matching area is determined according to the mutual correlation value.

7. The method according to claim 1, characterized in that The process of building a geometric model includes: According to the outline of the drug template image, the minimum circumscribed rectangle of the drug template image is calculated and drawn through the center point coordinates, width and height, and rotation angle to establish the geometric model.

8. The method according to claim 1, characterized in that The process of building a geometric model includes: According to the outline of the drug template image, the minimum circumscribed circle of the drug template image is calculated and drawn through the center coordinates and radius to suggest the geometric model.

9. The method according to claim 1, characterized in that: The step of identifying the matching area by establishing a geometric model to obtain a drug detection result includes: The characteristic values ​​of the matching area are compared with the characteristic values ​​of the geometric model of the drug template image one by one to obtain the drug detection result.

10. A drug detection image processing device, characterized in that: The device comprises: An acquisition module, used for acquiring a first image of the drug to be tested through an industrial camera; A filtering module, configured to perform denoising on the first image by using a median filtering algorithm to obtain a second image; a segmentation module, configured to perform segmentation processing on the second image by an iterative threshold segmentation method to obtain a target image region in the second image, wherein the target image region is an image region whose grayscale value meets a threshold; A matching module, used to search for a matching area with a drug template image in the target image area by using a template matching algorithm; The identification module is used to identify the matching area by establishing a geometric model to obtain the drug detection result.

Citation Information

Cited By

  • Associated imaging impurity detection method and system for drug production

    CN120971448A

  • Visual detection method and system for stepped shaft

    CN121639763A