Drug sensitive paper sheet positioning detection method based on complex image background
Through custom convolution kernel and sliding window detection technology, the inaccuracy problem of drug-sensitive paper positioning in complex backgrounds is solved, and higher measurement accuracy and reduced errors are achieved, which is suitable for environments with poor imaging quality.
Patent Information
- Application Number
- CN202411125475.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-13
AI Technical Summary
In a complex context, traditional methods have difficulty accurately identifying and positioning drug-sensitive paper sheets, resulting in inaccuracy and detection errors in antibacterial circle measurements, especially in poor imaging quality.
Custom convolution kernel and sliding window detection technology are used to pre-process images, convolution operations, matrix multiplication and sliding window detection, gradually enhance local features and weaken background pseudo-targets, and ensure accurate positioning of drug-sensitive paper sheets.
It improves the positioning and measurement accuracy of drug-sensitive paper sheets in complex backgrounds, reduces missed and multi-tested cases, and is suitable for environments with poor imaging quality.
Smart Images

Figure CN119131132A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image detection, and in particular to a drug-sensitive paper positioning detection method based on complex image background. Background Art
[0002] With the development of medicine, new drugs are constantly being developed and marketed, bringing more options for fighting diseases. However, in the history of human disease treatment, the correct use of drugs has always been an important issue. Each type of disease and each drug has its own unique effects and side effects, and the most appropriate treatment plan needs to be selected according to the patient's specific situation; in this process, drug sensitivity testing becomes a key link.
[0003] Place drug-sensitive paper sheets containing different drug concentrations or different drug types on the culture medium, contact the colonies, and observe the size of the inhibition zone around the colonies to determine the sensitivity of the microorganism to the drug. The larger the inhibition zone, the stronger the inhibitory effect of the drug on the tested bacteria. If there is no inhibition zone, it means that the bacteria are resistant to the drug, such as Figure 1 Therefore, accurate measurement of the size of the inhibition zone is the key to achieving accurate measurement of antibiotic prices.
[0004] After the position of the culture dish is determined, since the antibacterial circle is a regular circle that expands outward with the drug-sensitive tablet as the center, the center of the antibacterial circle is exactly the center of the drug-sensitive tablet. Therefore, the general solution is to indirectly obtain the center of the antibacterial circle by detecting the position of the drug-sensitive tablet.
[0005] Therefore, the accurate identification and precise positioning of the drug-sensitive patch in the culture medium is a prerequisite for detecting the diameter of the inhibition zone. The drug sensitivity test takes a long time, generally 16 to 24 hours. During the experiment, considering the influence of the lighting conditions of the detection equipment and the temperature and humidity of the surrounding environment, there may be water vapor, reflections, and other conditions on the cover of the culture dish that are not conducive to detection. In the case of poor imaging quality, determining the position of the drug-sensitive patch by the traditional Hough transform method of detecting a circle will lead to multiple inspections or missed inspections. For example, the technical solution disclosed in the announcement number CN108053442B, the announcement date August 17, 2021, and the invention name "A method for measuring the size of the inhibition zone of a drug-sensitive patch based on an image" has the above-mentioned technical problems.
[0006] Therefore, how to improve the detection algorithm while maintaining the existing detection equipment to achieve the positioning measurement accuracy of drug-susceptible paper strips under complex backgrounds has become an urgent problem to be solved by the inhibition zone measurement mechanism. Summary of the invention
[0007] In order to solve the above problems, the present invention provides a method for locating and detecting drug-sensitive paper sheets based on complex image backgrounds.
[0008] The present invention aims to provide a method for locating and detecting drug-sensitive paper sheets based on a complex image background, comprising the following steps:
[0009] S1. Original image acquisition: Use a camera to capture the original image of the drug sensitivity test culture medium as the input image Src;
[0010] S2. Image preprocessing: preprocessing the input image Src to obtain a preprocessed image Src_pre;
[0011] S3. Image convolution operation: customizing the convolution kernel, using the convolution kernel to perform a convolution operation on the preprocessed image Src_pre, so as to enhance the local features and obtain the convolution image Src_con;
[0012] S4. Target secondary enhancement: performing matrix multiplication on the convolution image Src_con and the preprocessed image Src_pre to obtain an image Src_mul;
[0013] S5. Sliding window detection: define a sliding window, slide it on the image, detect the area where the image Src_mul has obvious gradient changes, and finally output the binary image Dst;
[0014] S6. Determine the position of the drug-sensitive paper according to the binary image Dst and mark it on the original image.
[0015] Preferably, step S3 includes the following sub-steps:
[0016] S301. Determine the radius pixel size of the drug-sensitive paper in the original image as r;
[0017] S302. Customize three convolution kernels of different sizes based on the pixel radius r;
[0018] S303. After the convolution kernel size is determined, a multi-scale filtering operation is performed on the pre-processed image Src_pre, and feature extraction is performed step by step.
[0019] Preferably, the convolution kernel size D i The expression is as follows:
[0020] D i =(4r×(2 / 3) i-1 )+1,i∈[1,3]
[0021] In the formula, i is the convolution kernel number, r is the radius pixel size of the drug-susceptibility paper in the original image;
[0022] The array value expression of the convolution kernel is as follows:
[0023]
[0024] b = 2r × (2 / 3), i∈[1, 3]
[0025] a=(x-x0) 2 +(y-y0) 2
[0026] Among them, x0 and y0 are the center pixel coordinates of the convolution kernel, a and b are the parameters for calculating the convolution kernel value, and r is the radius pixel size of the drug-susceptible paper in the original image.
[0027] Preferably, the sliding window size in step S5 is (2s+1, 2s+1), s is 2, and the sliding step is 1.
[0028] Preferably, the sliding detection in step S5 specifically includes the following operations:
[0029] Each time the sliding window moves one position, the pixels outside the eight neighborhoods are grouped in four directions based on the middle pixel point. Each set V contains 2s+1 pixel values. The set V is expressed as: V = [v1, ..., v s+1 , ..., v 2s+1 ];
[0030] Determine whether the center pixel value and the two end pixel values of each set satisfy the following formula:
[0031] max(|v1-v s+1 |,|v s+1 -v 2s+1 |)+|v1-v 2s+1 |>t0;
[0032] Among them, v s+1 is the center pixel value, v1 and v 2s+1 are the pixel values at both ends, t0 is the set threshold, and the threshold value is determined by combining the brightness of the image background and foreground;
[0033] Define a full-zero matrix of the same size as the input image Src. If the pixel value in a certain direction within the sliding window at the current position meets the formula conditions, the values of the coordinate points corresponding to this direction on the matrix are cumulatively added by 1.
[0034] After the sliding detection operation, a binary image Dst is obtained.
[0035] Preferably, after the sliding detection operation in step S5, an output image Src_out is obtained, and the roundness of the target in the output image Src_out is judged again to filter out the pseudo target, and finally a binary image Dst is obtained.
[0036] Preferably, the preprocessing in step S2 includes Gaussian filtering, image grayscale and scale transformation.
[0037] Preferably, the camera is an industrial camera.
[0038] Compared with the prior art, the present invention can achieve the following beneficial effects:
[0039] The detection method provided by the present invention achieves the positioning measurement accuracy of drug-sensitive paper sheets under complex backgrounds by improving the detection algorithm while maintaining the existing detection equipment. It is not easy to miss or over-detect, and is still applicable under conditions of poor imaging quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic diagram of the positions of culture medium, drug-sensitive paper and inhibition zone on a culture dish in the prior art.
[0041] Figure 2 This is an original image of a drug sensitivity test culture medium provided according to an embodiment of the present invention.
[0042] Figure 3 is a schematic diagram of a sliding window provided according to an embodiment of the present invention.
[0043] Figure 4 is a schematic diagram of a binary output image provided according to an embodiment of the present invention.
[0044] Figure 5 It is a schematic diagram of an output image of a drug-sensitive paper sheet positioning annotation provided according to an embodiment of the present invention.
[0045] Figure 6 It is a flow chart of a method for drug-sensitive paper location detection based on a complex image background provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the following description, the same modules are represented by the same reference numerals. In the case of the same reference numerals, their names and functions are also the same. Therefore, the detailed description thereof will not be repeated.
[0047] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and do not constitute a limitation of the present invention.
[0048] The present invention provides a method for locating and detecting drug-sensitive paper sheets based on a complex image background, which specifically comprises the following steps:
[0049] S1. Original image acquisition: Use a camera to capture the original image of the drug sensitivity test culture medium as the input image Src;
[0050] In a specific embodiment, the camera is an industrial camera.
[0051] S2. Image preprocessing: preprocess the input image Src to obtain a preprocessed image Src_pre;
[0052] Preprocessing includes Gaussian filtering, image grayscale, and scale transformation;
[0053] Gaussian filtering is used to suppress noise, smooth images, and remove irrelevant information in the input image Src; scaling can greatly simplify image data while retaining image position and scale information, thereby reducing the amount of algorithm calculation and shortening program operation time.
[0054] S3. Image convolution operation: Customize the convolution kernel, use the convolution kernel to perform convolution operation on the preprocessed image Src_pre, enhance the local features, and obtain the convolution image Src_con; specifically, it includes the following sub-steps:
[0055] S301. Approximately determine the radius pixel size of the drug-sensitive paper in the original image as r;
[0056] S302. Customize three convolution kernels of different sizes based on the pixel radius r;
[0057] The size of the convolution kernel K is D; the size of the convolution kernel D i The expression is as follows:
[0058] D i =(4r×(2 / 3) i-1 )+1,i∈[1,3]
[0059] In the formula, i is the convolution kernel number, r is the radius pixel size of the drug-susceptibility paper in the original image;
[0060] S303. After determining the convolution kernel size, perform a multi-scale filtering operation on the pre-processed image Src_pre and extract features one by one;
[0061] The array value expression of the convolution kernel is as follows:
[0062]
[0063] b=2r×(2 / 3) i , i∈[1,3]
[0064] a=(x-x0) 2 +(y-y0) 2
[0065] Among them, x0 and y0 are the central pixel coordinates of the convolution kernel, respectively; a and b are parameters for calculating the convolution kernel value (the specific values are as shown in the above formula, b is related to the pixel radius r in the original image, and a is related to the convolution kernel size), and r is the radius pixel size of the drug-susceptible paper in the original image.
[0066] S4. Secondary target enhancement: Perform matrix multiplication on the convolution image Src_con and the preprocessed image Src_pre to obtain the image Src_mul, which further weakens the background pseudo targets and enhances the foreground true targets.
[0067] S5. Sliding window detection: define a sliding window, slide it on the image, detect the area where the image Src_mul has obvious gradient changes, and finally output the binary image Dst according to the sliding window detection rules; specifically, the following operations are included:
[0068] According to the target size, a rectangular sliding window of size (2s+1, 2s+1) is defined with a value of 2 and a sliding step of 1, which slides sequentially on the image.
[0069] Each time the sliding window moves one position, the outer pixels of the eight neighborhoods are grouped in four directions based on the middle pixel point, and each set V contains 2s+1 pixel values;
[0070] V=[v1,...,v s+1 , ..., v 2s+1 ];
[0071] Determine whether the center pixel value and the two end pixel values of each set satisfy the following formula:
[0072] max(|v1-v s+1 |,|v s+1 -v 2s+1 |)+|v1-v 2s+1 |>t0;
[0073] Among them, v s+1 is the center pixel value, v1 and v 2s+1 are the pixel values at both ends, t0 is the set threshold, and the threshold value is determined by combining the brightness of the image background and foreground;
[0074] At the same time, define a full-zero matrix Src_out of the same size as the input image Src. If the pixel value in a certain direction within the sliding window at the current position meets the formula conditions, then the values of each coordinate point corresponding to this direction on the matrix are cumulatively added by 1.
[0075] After the sliding detection operation, the roundness of the target in the output image Src_out is judged again to filter out the pseudo target, and finally a binary image Dst is obtained.
[0076] S6. Determine the position of the drug-sensitive paper according to the output binary image Dst and mark it on the original image.
[0077] Example 1
[0078] like Figure 2-Figure 6 As shown, this embodiment provides a method for locating and detecting drug-sensitive paper sheets based on a complex image background, which specifically includes the following steps:
[0079] S1. Original image acquisition: Use an industrial camera to collect the original image of the drug sensitivity test culture medium as the input image Src ( Figure 2 ).
[0080] S2. Image preprocessing: preprocess the input image Src to obtain a preprocessed image Src_pre;
[0081] Preprocessing includes Gaussian filtering, image grayscale and scale transformation; Gaussian filtering is used to suppress noise, smooth images, and remove irrelevant information in the input image Src; scale transformation can greatly simplify image data while retaining image position and scale information, thereby reducing the amount of algorithm calculation and shortening program operation time.
[0082] S3. Image convolution operation: customize multiple convolution kernels, use the convolution kernels to perform continuous convolution operations on the preprocessed image Src_pre, extract features step by step, enhance local features, and obtain the convolution image Src_con;
[0083] Custom convolution kernel: The convolution operation can effectively capture local information of the image. By sliding the convolution kernel on the image and performing weighted summation on the covered area, it can enhance or remove certain features of the image. Different convolution kernels are suitable for extracting different image features.
[0084] In this embodiment, for the drug-sensitive paper detection scenario, a custom convolution kernel is designed based on the pixel size and shape characteristics of the target to be detected; the sub-steps are as follows:
[0085] S301. Approximately determine the radius pixel size of the drug-sensitive paper in the original image as r;
[0086] S302. Custom convolution kernel size: Design 3 convolution kernels of different sizes;
[0087] The size of the convolution kernel K is D; the size of the convolution kernel D i The expression is as follows:
[0088] D i =(4r×(2 / 3) i-1 )+1,i∈[1,3]
[0089] In the formula, i is the convolution kernel number, r is the radius pixel size of the drug-susceptibility paper in the original image;
[0090] S303. Determine the convolution kernel size, perform continuous convolution operations on the preprocessed image Src_pre, and extract features step by step;
[0091] The array value expression of the convolution kernel is as follows:
[0092]
[0093] b=2r×(2 / 3)i,i∈[1,3]
[0094] a=(x-x0) 2 +(y-y0) 2
[0095] Among them, x0 and y0 are the central pixel coordinates of the convolution kernel, respectively; a and b are parameters for calculating the convolution kernel value (the specific values are as shown in the above formula, b is related to the pixel radius r in the original image, and a is related to the convolution kernel size), and r is the radius pixel size of the drug-susceptible paper in the original image.
[0096] S4, secondary target enhancement: perform matrix multiplication on the convolution image Src_con and the pre-processed image Src_pre to obtain the image Src_mul, further weakening the background pseudo targets and enhancing the foreground true targets;
[0097] Since the convolved image contains all the characteristic information that meets the indicators, it needs to be further screened; the convolved image is dot-multiplied with the original image to weaken the background pseudo targets and enhance the foreground true targets.
[0098] S5, sliding window detection: define a sliding window, slide on the image, detect the area where the image Src_mul has obvious gradient changes, and finally output the binary image Dst according to the sliding window detection rules; specifically, the following operations are included:
[0099] A rectangular sliding window (s is 2) with a size of (2s+1, 2s+1) is defined according to the target size, and the sliding step is 1, which slides on the image in sequence. Unlike the convolution operation, the sliding window detection does not seek the weighted sum, but only detects edge features with obvious gradient changes.
[0100] Each time the sliding window moves one position, the outer pixels of the eight neighborhoods are grouped in four directions based on the middle pixel point ( Figure 3 ), since the frame size is 2s+1, each set V contains 2s+1 pixel values;
[0101] V=[v1,...,v s+1 , ..., v2s+1 ];
[0102] Determine whether the center pixel value and the two end pixel values of each set satisfy the following formula:
[0103] max(|v1-v s+1 |,|v s+1 -v 2s+1 |)+|v1-v 2s+1 |>t0;
[0104] Among them, v s+1 is the center pixel value, v1 and v 2s+1 are the pixel values at both ends, t0 is the set threshold, and the threshold value is determined by combining the brightness of the image background and foreground;
[0105] At the same time, define a full-zero matrix Src_out of the same size as the input image Src. If the pixel value in a certain direction within the sliding window at the current position meets the formula conditions, then the values of each coordinate point corresponding to this direction on the matrix are cumulatively added by 1.
[0106] After the sliding detection operation, the target in the output image Src_out is judged for roundness again to filter out pseudo targets, and finally a binary image Dst is obtained to determine the position of the drug-sensitive paper ( Figure 4 ).
[0107] S6. Determine the position of the drug-sensitive paper according to the output binary image Dst and mark it on the original image, such as Figure 5 shown.
[0108] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the disclosure of the present invention can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in the present invention can be achieved, and this document does not limit this.
[0109] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for locating and detecting drug-sensitive paper sheets based on complex image backgrounds, characterized in that: The steps include: S1. Original image acquisition: Use a camera to capture the original image of the drug sensitivity test culture medium as the input image Src; S2. Image preprocessing: preprocessing the input image Src to obtain a preprocessed image Src_pre; S3. Image convolution operation: customizing the convolution kernel, using the convolution kernel to perform a convolution operation on the preprocessed image Src_pre, so as to enhance the local features and obtain the convolution image Src_con; S4. Target secondary enhancement: performing matrix multiplication on the convolution image Src_con and the preprocessed image Src_pre to obtain an image Src_mul; S5. Sliding window detection: define a sliding window, slide it on the image, detect the area where the image Src_mul has obvious gradient changes, and finally output the binary image Dst; S6. Determine the position of the drug-sensitive paper according to the binary image Dst and mark it on the original image.
2. The method for locating and detecting drug-sensitive paper sheets based on complex image background according to claim 1, characterized in that: The step S3 includes the following sub-steps: S301. Determine the radius pixel size of the drug-sensitive paper in the original image as r; S302. Customize three convolution kernels of different sizes based on the pixel radius r; S303. After the convolution kernel size is determined, a multi-scale filtering operation is performed on the pre-processed image Src_pre, and feature extraction is performed step by step.
3. The method for locating and detecting drug-sensitive paper sheets based on complex image background according to claim 2, characterized in that: The convolution kernel size D i The expression is as follows: D i =(4r×(2 / 3) i-1 )+1,i∈[1,3] In the formula, i is the convolution kernel number, r is the radius pixel size of the drug-susceptibility paper in the original image; The array value expression of the convolution kernel is as follows: b=2r×(2 / 3) i ,i∈[1,3] a=(x-x0) 2 +(y-y0) 2 Among them, x0 and y0 are the center pixel coordinates of the convolution kernel, a and b are the parameters for calculating the convolution kernel value, and r is the radius pixel size of the drug-susceptible paper in the original image.
4. The method for locating and detecting drug-sensitive paper sheets based on complex image background according to claim 3, characterized in that: The sliding window size in step S5 is (2s+1, 2s+1), s is 2, and the sliding step is 1.
5. The method for locating and detecting drug-sensitive paper sheets based on complex image background according to claim 4, characterized in that: The sliding detection in step S5 specifically includes the following operations: Each time the sliding window moves one position, the pixels outside the eight neighborhoods are grouped in four directions based on the middle pixel point. Each set V contains 2s+1 pixel values. The set V is expressed as: V = [v1,…,v s+1 ,…,v 2s+1 ]; Determine whether the center pixel value and the two end pixel values of each set satisfy the following formula: max(|v1-v s+1 |,|v s+1 -v 2s+1 |)+|v1-v 2s+1 |>t0; Among them, v s+1 is the center pixel value, v1 and v 2s+1 are the pixel values at both ends, t0 is the set threshold, and the threshold value is determined by combining the brightness of the image background and foreground; Define a full-zero matrix of the same size as the input image Src. If the pixel value in a certain direction within the sliding window at the current position meets the formula conditions, the values of the coordinate points corresponding to this direction on the matrix are cumulatively added by 1. After the sliding detection operation, a binary image Dst is obtained.
6. The method for locating and detecting drug-sensitive paper sheets based on complex image background according to claim 5, characterized in that: After the sliding detection operation in step S5, an output image Src_out is obtained, and the objects in the output image Src_out are subjected to a roundness judgment again to filter out pseudo objects, and finally a binary image Dst is obtained.
7. The method for locating and detecting drug-sensitive paper sheets based on complex image background according to claim 6, characterized in that: The preprocessing in step S2 includes Gaussian filtering, image graying and scale transformation.
8. The method for locating and detecting drug-sensitive paper sheets based on complex image background according to claim 7, characterized in that: The camera is an industrial camera.
