Multi-stage image enhancement method and system for anesthetic drug identification
By employing a multi-stage image enhancement method, including Gaussian filtering, weighted grayscale conversion, and single-scale Retinex processing, the image quality degradation problem in the identification of anesthetic and psychotropic drugs in complex hospital environments was solved, improving recognition accuracy and real-time processing capabilities while reducing hardware costs.
Patent Information
- Application Number
- CN202511551403.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-28
- Publication Date
- 2026-02-06
AI Technical Summary
In the complex environment of hospitals, the image recognition of anesthetic and psychotropic drugs is affected by complex lighting conditions and various interference factors, resulting in image quality degradation. Existing preprocessing technologies cannot effectively address this issue, leading to insufficient recognition accuracy of the model in actual deployment.
A multi-stage image enhancement method is adopted, including Gaussian filtering, weighted grayscale conversion and single-scale Retinex processing, combined with image flipping and histogram equalization, to improve image quality by suppressing noise, correcting uneven illumination and suppressing reflection interference.
It significantly improves the recognition accuracy of the target detection model, meets clinical application standards, achieves stable performance and real-time processing in complex environments, and reduces hardware costs.
Smart Images

Figure CN121481854A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision and digital image processing, and particularly relates to a multi-stage image enhancement method and system for narcotic and psychotropic drug identification. BACKGROUND
[0002] Accurate identification and supervision of narcotic and psychotropic drugs is a core link of medical safety management, and is directly related to patient medication safety and public health order. In recent years, target detection technology based on deep learning (such as YOLO series) has been gradually applied to drug automatic management system, but in the complex environment of hospital, the serious degradation of original image quality has restricted the algorithm performance: Complex lighting conditions: there are large differences in lighting in pharmacy, operating room, warehouse and other scenes, and there are problems such as local overexposure, backlight shadow, etc., resulting in low image contrast and loss of details; Many interference factors: the mirror reflection of drug packaging materials (glass, plastic, metal, etc.) easily produces mirror reflection, and superimposes environmental noise (such as sensor interference and background clutter texture), resulting in feature information being submerged; Limitations of existing preprocessing technology: single enhancement method (such as histogram equalization which easily amplifies noise, traditional Retinex which easily produces halos when processing low signal-to-noise ratio images, and simple grayscale which loses key brightness information) cannot solve multiple degradation problems, resulting in mAP50 (average precision) less than 85% in actual deployment of the model, which is difficult to meet the clinical high-precision identification demand.
[0003] Therefore, a systematic image enhancement scheme for complex medical scenes is urgently needed, which eliminates noise, corrects uneven lighting and suppresses reflection interference through multi-stage collaborative processing, provides high-quality input for subsequent identification model, and guarantees the reliability and real-time performance of narcotic and psychotropic drug supervision. SUMMARY
[0004] The technical problem solved by the present application is to provide a solution to one or more of the above-mentioned problems in the prior art.
[0005] To solve the above technical problems, one technical solution adopted by the present application is: a multi-stage image enhancement method for narcotic and psychotropic drug identification, the innovation of which lies in: comprising the following steps: S1: obtaining an original narcotic and psychotropic drug color image under a complex scene; S2: performing Gaussian filtering processing on the original image to suppress image noise, to obtain a filtered image; S3: performing weighted grayscale conversion processing on the filtered image, using a weight coefficient based on human eye visual characteristics to convert the color image into a grayscale image; S4: Perform single-scale Retinex processing on the grayscale image to correct uneven illumination and suppress reflection interference by estimating and separating the illumination components, thereby obtaining the final enhanced image; S5: Output the final enhanced image for subsequent target detection model recognition.
[0006] In some implementations, in step S2, the Gaussian filter uses a 3×3 convolution kernel with a standard deviation σ of 1.5.
[0007] In some implementations, in step S3, the weighting coefficients based on human visual characteristics are: R channel 0.299, G channel 0.587, and B channel 0.114.
[0008] In some implementations, step S4, the single-scale Retinex processing includes: performing Gaussian low-pass filtering on the grayscale image to estimate the illumination component, separating the illumination component and the reflection component through logarithmic domain transformation, and performing a linear transformation on the reflection component to obtain an enhanced image.
[0009] In some implementations, after step S1 and before step S2, step S0 is included: performing image flipping enhancement on the original image, wherein the image flipping enhancement includes horizontal flipping, vertical flipping, or horizontal-vertical flipping.
[0010] In some implementations, before or after step S2, step S2a is included: performing histogram equalization on the image to enhance the global contrast of the image.
[0011] A multi-stage image enhancement system for identifying narcotic and psychotropic drugs includes: The image acquisition module is used to acquire images of anesthetic and psychotropic drugs in complex scenes; The image preprocessing module is configured to perform Gaussian filtering, weighted grayscale conversion, and single-scale Retinex processing. The control module is used to schedule and execute the algorithm combination process in the preprocessing module; The output module is used to output the enhanced image to the display unit or the target detection model.
[0012] In some implementations, the system is integrated into an embedded AI processing board based on the HiSilicon Hi3519AV100 chip.
[0013] In some implementations, the algorithm of the image preprocessing module is executed by a DSP processor in an embedded AI processing board.
[0014] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the method as described in any one of claims 1-6.
[0015] The beneficial effects of this invention are: significantly improved recognition accuracy: after multi-stage enhancement, the mAP50 (average accuracy) of the target detection model (such as YOLOv8) is improved from 82.09% of the original image to 99.31%, and the recognition accuracy of 36 types of drugs such as propofol and fentanyl reaches the clinically practical standard.
[0016] Strong environmental robustness: Simultaneously solves three core problems: noise interference (Gaussian filtering), uneven illumination (SSR), and reflection suppression (component separation), maintaining stable performance even in complex scenarios such as backlight, low light, and high reflectivity (such as ampoule bottles and syringe surfaces).
[0017] High-efficiency real-time processing: The algorithm is integrated into the HiSilicon Hi3519AV100 embedded AI processing board, which realizes real-time processing of 30fps high-definition video stream (1920×1080 resolution) through the DSP processor, with an average latency of less than 80ms, meeting the real-time monitoring needs of operating rooms, pharmacies and other scenarios.
[0018] Flexible scenario adaptation: Supports multiple preprocessing combinations such as "basic three-stage", "equalization enhancement" and "lightweight two-stage", which can be dynamically switched through the control module to adapt to different scenarios such as drug storage (mainly noisy), operating room (variable lighting) and mobile inspection (portable equipment).
[0019] Hardware cost optimization: The algorithm is deployed in a lightweight manner based on an embedded platform, without relying on high-performance GPUs, which reduces the hardware cost and power consumption of medical devices and is suitable for integration into miniaturized devices such as smart medicine cabinets and portable testing terminals. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein: Figure 1 : A schematic diagram of the multi-stage image enhancement method according to an embodiment of the present invention; Figure 2 Example of an original image of anesthetic or psychotropic drugs; Figure 3 Image after Gaussian filtering; Figure 4 :right Figure 3The image after weighted grayscale conversion; Figure 5 :right Figure 4 The final enhanced image after single-scale Retinex (SSR) processing; Figure 6 : Drug detection results image with other preprocessing combinations (such as histogram equalization, arithmetic mean grayscale, etc.); Figure 7 : Structural block diagram of the hardware core board (Hi3519AV100) of the present invention. Detailed Implementation
[0021] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] The embodiments of the present invention include: I. Implementation of Multi-Stage Image Enhancement Method This embodiment, based on the method described in claims 1-6, achieves image enhancement processing of anesthetic and psychotropic drugs in complex scenes through the following steps, the specific process of which is as follows: Figure 1 As shown: Step S1: Obtain the original image Color images of anesthetic and psychotropic drugs in complex scenarios are captured using image acquisition devices (such as built-in cameras in smart medicine cabinets, high-definition PTZ cameras, or portable cameras). The original image resolution is 1920×1080, covering real environments such as pharmacies, operating rooms, and warehouses. The images include different packaging forms (such as glass bottles, ampoules, syringes, etc.) for 36 drugs including propofol and fentanyl, and are subject to interference from uneven lighting, reflections, and noise. Figure 2 (As shown).
[0023] Step S0 (optional): Image flipping enhancement After step S1 and before step S2, the original image is enhanced by image flipping, including horizontal flipping, vertical flipping, or horizontal-vertical flipping, to expand the training dataset. For example, it can be achieved by using the cv2.flip() function of OpenCV, with the horizontal flipping parameter set to 1, the vertical flipping parameter set to 0, and the horizontal-vertical flipping parameter set to -1, which can improve the robustness of the model to changes in the angle of drug placement.
[0024] Step S2: Gaussian filtering for noise reduction Apply Gaussian filtering to the original image (or the image after inversion and enhancement) to suppress image noise. Specific parameters are: Kernel size: 3×3; Standard deviation σ: 1.5.
[0025] This is achieved using OpenCV's cv2.GaussianBlur(I, (3,3), 1.5) function. The filtered image effectively preserves the edge details of the medicine while removing salt-and-pepper noise (such as...) in highly reflective areas. Figure 3 (As shown).
[0026] Step S2a (optional): Histogram equalization Before or after step S2, the image can be processed by histogram equalization to enhance global contrast; for example, the grayscale image (or a channel of the color image) can be processed by the cv2.equalizeHist() function, which is suitable for scenarios with extremely uneven lighting (such as drug labels in backlit environments).
[0027] Step S3: Weighted Grayscale Conversion The filtered image is then subjected to weighted grayscale conversion. Weighting coefficients based on human visual characteristics are used to compress the color image into a grayscale image, as shown in the following formula: Where R, G, and B are the pixel values of the red, green, and blue channels of the color image, respectively. This is achieved using OpenCV's cv2.cvtColor() function combined with a custom weight matrix, preserving key brightness features such as drug label text and packaging textures (e.g., ...). Figure 4 (As shown).
[0028] Step S4: Single-scale Retinex (SSR) illumination correction The specific steps for performing SSR processing on grayscale images to correct uneven illumination and suppress reflection interference are as follows: Estimating illumination components: Apply a Gaussian low-pass filter to the grayscale image, with a Gaussian kernel standard deviation σ=80 (implemented using cv2.GaussianBlur(I_gray, (0,0), 80)). Logarithmic domain transformation: Convert the original grayscale image and illumination components to the logarithmic domain respectively, using the following formula: 3. Separate the reflection component: Subtract the illumination component from the logarithmic domain to obtain the reflection component: 4. Linear Transformation: The reflection components are normalized to the range of 0-255 using the cv2.normalize() function, converted to 8-bit unsigned integers, and the final enhanced image is obtained (e.g., ...). Figure 5 (As shown).
[0029] Step S5: Output enhanced image The final enhanced image is output to a display unit (such as a monitoring screen) or a target detection model (such as YOLOv8) for drug identification. Experiments show that after processing with this method, the model's mAP50 is improved from 82.09% to 99.31% of the original image.
[0030] II. Implementation of a Multi-Stage Image Enhancement System This embodiment is based on the system described in claims 7-9, integrated into an embedded AI processing board with a HiSilicon Hi3519AV100 chip, and the hardware structure is as follows. Figure 7 As shown, the functions of each module are as follows: 1. Image Acquisition Module The smart medicine cabinet has a built-in camera: 5 megapixels, F2.0 aperture, supports macro shooting, and can capture detailed images of the medicines inside the cabinet. High-definition PTZ camera: 20x optical zoom, 360° rotation, capturing images of drug distribution over a wide monitoring area; Portable camera: 1080P wireless transmission, 6-hour battery life, used for image acquisition in mobile scenarios (such as operating room medicine carts).
[0031] 2. Image preprocessing module The following algorithm is executed by the Tensilica Vision P6 DSP processor (710MHz) on the embedded AI processing board: Gaussian filtering: noise suppression based on 3×3 convolution kernels; Weighted grayscale conversion: Real-time conversion from color to grayscale is achieved through hardware-accelerated matrix operations; Single-scale Retinex: Integrates logarithmic transform and Gaussian filter IP cores, with processing latency of less than 20ms / frame.
[0032] 3. Control Module Through the ARM Cortex-A53 core scheduling algorithm of the embedded system, dynamic selection of preprocessing combinations is supported: In scenarios with severe noise: enable a two-stage process of "filtering-weighted grayscale"; For scenes with extremely uneven lighting: enable a three-stage process of "histogram equalization - filtering - Retinex".
[0033] 4. Output Module The enhanced image is transmitted via gigabit Ethernet to the YOLOv8 object detection model (running on the onboard 0.3 Tops neural network computing unit) or directly displayed on a 1080P monitoring screen, with an average detection latency of less than 80ms.
[0034] III. Implementation of Computer-Readable Storage Media The computer-readable storage medium of claim 10 is an eMMC flash memory (capacity 64GB) of an embedded AI processing board, storing the following program code: Image acquisition driver (supports simultaneous acquisition from multiple cameras); Preprocessing algorithm library (Gaussian filtering, Retinex, etc., optimized based on OpenCV 4.5); Model inference interface (linked with the weight file of the YOLOv8 model). When the program is executed by the DSP processor, it implements the steps of the method described in any one of claims 1-6, and can be updated via JTAG interface.
[0035] IV. Verification of Experimental Results On a dataset containing 510 complex scene images (covering 36 classes of narcotic and psychotropic drugs), after processing using the "filtering-weighted grayscale-Retinex" three-stage workflow of this implementation, the detection performance of the input YOLOv8 model is as follows: Evaluation Index Original Image After Processing by the Method Precision 82.66% 98.35% Recall 82.71% 98.71% mAP50 82.09% 99.31% The results show that this implementation method can effectively solve the problems of uneven illumination, reflection and noise, and significantly improve the accuracy of drug identification.
[0036] This technical solution optimizes the image quality of anesthetic and psychotropic drugs in complex scenes through a multi-stage collaborative enhancement mechanism. The core principle is as follows: Noise suppression and feature preservation: A Gaussian filter with a 3×3 convolution kernel and a standard deviation σ=1.5 is used to suppress high-frequency noise (such as sensor noise and environmental interference) while preserving low-frequency details such as drug packaging edges and label text through the smoothing properties of the Gaussian function, laying a clear foundation for subsequent processing.
[0037] Human visual characteristics adaptation: By using weighted grayscale conversion with R:0.299, G:0.587, and B:0.114, the human eye's visual characteristics of being most sensitive to green and least sensitive to blue are simulated. When compressing color images into grayscale images, brightness information is preserved to the maximum extent, and the interference of redundant color channels on feature extraction is reduced.
[0038] Illumination and Reflection Separation Correction: The single-scale Retinex (SSR) algorithm estimates the illumination component through Gaussian low-pass filtering and separates the illumination and reflection components in the logarithmic domain. This effectively corrects common lighting unevenness problems in hospital environments, such as local overexposure and backlighting, and suppresses specular reflection interference from glass / plastic packaging, thereby enhancing the structural contrast of drug textures and labels.
[0039] Modular process scheduling: The control module dynamically selects preprocessing combinations (such as "filtering-Retinex", "equalization-filtering-Retinex", etc.) according to the scenario to achieve adaptive matching between the algorithm and complex scenarios and improve the system's generalization ability.
[0040] The advantages of this technical solution are: Significantly improved recognition accuracy: After multi-stage enhancement, the mAP50 (mean accuracy) of the target detection model (such as YOLOv8) increased from 82.09% of the original image to 99.31%, and the recognition accuracy of 36 types of drugs such as propofol and fentanyl reached the clinically practical standard.
[0041] Strong environmental robustness: Simultaneously solves three core problems: noise interference (Gaussian filtering), uneven illumination (SSR), and reflection suppression (component separation), maintaining stable performance even in complex scenarios such as backlight, low light, and high reflectivity (such as ampoule bottles and syringe surfaces).
[0042] High-efficiency real-time processing: The algorithm is integrated into the HiSilicon Hi3519AV100 embedded AI processing board, which realizes real-time processing of 30fps high-definition video stream (1920×1080 resolution) through the DSP processor, with an average latency of less than 80ms, meeting the real-time monitoring needs of operating rooms, pharmacies and other scenarios.
[0043] Flexible scenario adaptation: Supports multiple preprocessing combinations such as "basic three-stage", "equalization enhancement" and "lightweight two-stage", which can be dynamically switched through the control module to adapt to different scenarios such as drug storage (mainly noisy), operating room (variable lighting) and mobile inspection (portable equipment).
[0044] Hardware cost optimization: The algorithm is deployed in a lightweight manner based on an embedded platform, without relying on high-performance GPUs, which reduces the hardware cost and power consumption of medical devices and is suitable for integration into miniaturized devices such as smart medicine cabinets and portable testing terminals.
[0045] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention specification, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A multi-stage image enhancement method for identifying narcotic and psychotropic drugs, characterized in that: Includes the following steps: S1: Acquire raw color images of anesthetic and psychotropic drugs in complex scenes; S2: Perform Gaussian filtering on the original image to suppress image noise, and obtain the filtered image; S3: Perform weighted grayscale conversion processing on the filtered image, and use weight coefficients based on the characteristics of human visual perception to convert the color image into a grayscale image; S4: Perform single-scale Retinex processing on the grayscale image to correct uneven illumination and suppress reflection interference by estimating and separating the illumination components, thereby obtaining the final enhanced image; S5: Output the final enhanced image for subsequent target detection model recognition.
2. The multi-stage image enhancement method for identifying narcotic and psychotropic drugs according to claim 1, characterized in that: In step S2, the Gaussian filter uses a 3×3 convolution kernel with a standard deviation σ of 1.
5.
3. The multi-stage image enhancement method for identifying narcotic psychotropic drugs according to claim 1, characterized in that: In step S3, the weighting coefficients based on human visual characteristics are: R channel 0.299, G channel 0.587, and B channel 0.
114.
4. The multi-stage image enhancement method for identifying narcotic and psychotropic drugs according to claim 1, characterized in that: In step S4, the single-scale Retinex processing includes: performing Gaussian low-pass filtering on the grayscale image to estimate the illumination component, separating the illumination component and the reflection component through logarithmic domain transformation, and performing linear transformation on the reflection component to obtain an enhanced image.
5. The multi-stage image enhancement method for identifying narcotic and psychotropic drugs according to claim 1, characterized in that: After step S1 and before step S2, step S0 is also included: performing image flipping enhancement on the original image, wherein the image flipping enhancement includes horizontal flipping, vertical flipping, or horizontal-vertical flipping.
6. The multi-stage image enhancement method for identifying narcotic and psychotropic drugs according to claim 1, characterized in that: Before or after step S2, step S2a is also included: performing histogram equalization on the image to enhance the global contrast of the image.
7. A multi-stage image enhancement system for identifying narcotic and psychotropic drugs, characterized in that: include: The image acquisition module is used to acquire images of anesthetic and psychotropic drugs in complex scenes; The image preprocessing module is configured to perform Gaussian filtering, weighted grayscale conversion, and single-scale Retinex processing. The control module is used to schedule and execute the algorithm combination process in the preprocessing module; The output module is used to output the enhanced image to the display unit or the target detection model.
8. A multi-stage image enhancement system for identifying narcotic and psychotropic drugs according to claim 1, characterized in that: The system is integrated into an embedded AI processing board based on the HiSilicon Hi3519AV100 chip.
9. A multi-stage image enhancement system for identifying narcotic and psychotropic drugs according to claim 1, characterized in that: The algorithm of the image preprocessing module is executed by the DSP processor in the embedded AI processing board.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by the processor, it implements the steps of the method as described in any one of claims 1-6.
