Child accidental ingestion of suspicious drug image recognition assisted first aid method and system thereof
Patent Information
- Application Number
- CN202611160581.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-03
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2046-08-03
AI Technical Summary
[0024]1、本发明能够利用图像中天然存在的人体皮肤信息表征当前拍摄环境的颜色偏移情况,无需依赖标准色卡或专用颜色校准设备即可完成药物颜色校正,提高了复杂环境下药物图像识别的适用性,满足儿童误服药物等突发场景的快速使用需求;
Smart Images

Figure CN122676496B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition and assisted first aid technology, specifically to an image recognition-assisted first aid method and system for children who have accidentally ingested suspected drugs. Background Technology
[0002] With the development of mobile internet terminals and computer vision technology, image recognition-based drug identification technology is gradually being applied in scenarios such as home first aid, telemedicine, and health management. When a child accidentally ingests a suspected medication, parents typically use a mobile device to take a picture of the medication and upload it to the drug identification system. The system then identifies the medication based on its appearance characteristics, such as color, shape, size, and surface texture, and provides corresponding first aid suggestions, thus providing technical support for emergency treatment after a child has accidentally ingested medication.
[0003] However, most cases of children accidentally ingesting medication occur at night or indoors. The shooting conditions are often affected by factors such as warm lighting, low light, and automatic exposure of the camera equipment, leading to significant color shifts in the acquired drug images. For example, white tablets may appear yellow or orange, and pink capsules may appear dark orange or red. This causes a large deviation between the drug color characteristics in the image and the standard color characteristics in the drug database, thus affecting the accuracy of subsequent drug identification results.
[0004] Existing technologies typically employ fixed white balance, automatic white balance algorithms, or rely on standard color charts for color correction to reduce the impact of ambient light on image colors. However, fixed white balance and automatic white balance struggle to accurately reflect real-world lighting shifts in complex environments, while reference materials such as standard color charts require additional preparation by the user. This makes it difficult to meet the application needs for rapid shooting and immediate identification in emergency situations such as accidental ingestion of medication by children. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides an image recognition-assisted emergency rescue method and system for children who have accidentally ingested suspected drugs.
[0006] To achieve the above objectives, the technical solution of the present invention is as follows:
[0007] In a first aspect, the present invention discloses an image recognition-assisted first aid method for children who have accidentally ingested suspected drugs, comprising the following steps:
[0008] Acquire the original color image containing the drug entity area and the human skin area, and acquire the exposure control parameters of the camera device corresponding to the acquisition of the original color image;
[0009] Based on the pixel distribution characteristics in the original color image, the original color image is divided into regions to obtain drug candidate regions and human skin reference regions;
[0010] Extract the drug color features corresponding to the drug candidate region and the reference color features corresponding to the human skin reference region, respectively.
[0011] Obtain preset human body standard color reference data, and determine the ambient light offset parameter to characterize the degree of color offset in the current shooting environment based on the difference relationship between the reference color features and the human body standard color reference data for each color channel.
[0012] Based on the exposure control parameters of the camera device, the exposure response weights are extracted, and the ambient light offset parameters are scaled using the exposure response weights to generate a dynamic color correction matrix.
[0013] The dynamic color correction matrix is used to perform color compensation processing on the drug color features to obtain the true color features of the target drug.
[0014] The target drug's true color features are matched with a preset drug color feature library to determine the target drug's identity, and corresponding emergency assistance information is output based on the target drug's identity.
[0015] Secondly, this invention discloses an image recognition-assisted emergency rescue system for children who have accidentally ingested suspected drugs, comprising:
[0016] The image acquisition module is used to acquire original color images containing the drug entity area and the human skin area, and to acquire the exposure control parameters of the camera device corresponding to the acquisition of the original color images;
[0017] The region segmentation module is used to divide the original color image into regions based on the pixel distribution characteristics in the original color image to obtain drug candidate regions and human skin reference regions.
[0018] The region parsing module is used to extract the drug color features corresponding to the drug candidate region and the reference color features corresponding to the human skin reference region, respectively.
[0019] An ambient light offset calculation module is used to acquire preset human body standard color reference data and determine ambient light offset parameters to characterize the degree of color offset in the current shooting environment based on the difference relationship between the reference color features and the human body standard color reference data for each color channel.
[0020] The color correction module is used to extract exposure response weights based on the exposure control parameters of the camera device, use the exposure response weights to perform scale correction on the ambient light offset parameters, and generate a dynamic color correction matrix.
[0021] The color restoration module is used to perform color compensation processing on the color features of the drug using the dynamic color correction matrix to obtain the true color features of the target drug.
[0022] The drug identification and emergency output module is used to match the real color features of the target drug with a preset drug color feature library to determine the identity of the target drug, and output corresponding auxiliary emergency information according to the identity of the target drug.
[0023] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0024] 1. This invention can utilize the naturally existing human skin information in the image to characterize the color shift of the current shooting environment, and can complete the drug color correction without relying on standard color cards or special color calibration equipment, thereby improving the applicability of drug image recognition in complex environments and meeting the rapid use needs of emergency scenarios such as children accidentally ingesting drugs.
[0025] 2. This invention comprehensively considers changes in ambient light and exposure factors of the camera equipment to adaptively restore the color of the drug, making the color features involved in the identification closer to the true color of the drug. This reduces the impact of changes in ambient light and exposure on the drug identification results, improves the accuracy of drug identification, and provides a reliable data foundation for the output of subsequent emergency assistance information. Attached Figure Description
[0026] The disclosure of this invention is illustrated with reference to the accompanying drawings. It should be understood that the drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. In the drawings, the same reference numerals are used to refer to the same parts. Wherein:
[0027] Figure 1 This is a flowchart of the method of the present invention;
[0028] Figure 2 This is a data flow diagram of the present invention;
[0029] Figure 3 This is a system architecture diagram of the present invention. Detailed Implementation
[0030] It is readily understood that, based on the technical solution of this invention, those skilled in the art can propose various interchangeable structural methods and implementations without altering the essential spirit of the invention. Therefore, the following detailed embodiments and accompanying drawings are merely illustrative examples of the technical solution of this invention and should not be considered as the entirety of the invention or as limitations or restrictions on the technical solution of this invention.
[0031] This invention relates to the field of image recognition and assisted first aid technology, and proposes an image recognition-based assisted first aid method for children who have accidentally ingested suspected medications. It aims to solve the problem of color distortion in drug images caused by complex lighting environments in home emergency scenarios, affecting the accuracy of drug identification. Existing image recognition-based drug identification technologies mostly rely on the appearance features of drugs, such as color and shape, for identification. However, accidental drug ingestion by children often occurs at night or in low-light indoor environments. Warm-colored lighting and automatic exposure can easily cause color shifts in drugs, resulting in significant differences between the acquired image and the standard color characteristics of the drug. At the same time, traditional color correction methods usually require standard color charts or fixed lighting conditions, which are difficult to meet the practical needs of rapid shooting and immediate identification in home emergency scenarios. Therefore, how to accurately restore the true color of the drug without additional calibration equipment has become a key technical problem in improving the reliability of drug identification.
[0032] To address the aforementioned issues, this application uses raw color images captured by mobile phones or camera devices as a foundation. It analyzes both the drug entity region and the human skin region within the image, utilizing the naturally occurring biological reference information of human skin within the image. Combined with the camera device's exposure control parameters, a dynamic color correction mechanism is established to adaptively restore the drug color features affected by ambient light, obtaining target drug color features closer to their true color state. This is then matched against a drug color feature database to determine the target drug's identity, ultimately outputting corresponding auxiliary emergency information. Compared to traditional identification methods relying on standard color charts or fixed white balance, this invention emphasizes the reconstruction of true color information under complex shooting environments. By using the human skin reference region to reflect the current ambient light shift and employing exposure response weights to correct the color correction process, reliable drug color restoration and identification are achieved.
[0033] After implementation, this invention can effectively reduce the interference of ambient light and exposure changes on the color characteristics of drugs under complex lighting conditions, improve the stability of drug color recovery, and thus enhance the accuracy and reliability of drug identification. Since it does not rely on standard color charts or dedicated calibration devices, this solution is more suitable for rapid use in emergency situations such as accidental drug ingestion by children. It also helps improve the timeliness and practicality of emergency information output, providing more reliable data support for initial assessment and subsequent medical treatment at the home level.
[0034] like Figure 1 , Figure 2 As shown, this application discloses an image recognition-assisted first aid method for children who have accidentally ingested suspected drugs, including the following steps:
[0035] A1. Acquire the original color image containing the drug entity area and the human skin area, and acquire the exposure control parameters of the camera equipment corresponding to the acquisition of the original color image;
[0036] The original color image represents a two-dimensional visual mapping of the crime scene, representing the native digital pixel matrix (such as RGB data sequence) of the target object and background under the stimulated emission or reflection spectrum of the current light source, serving as the appearance basis for subsequent drug identification.
[0037] The exposure control parameters of a camera device mainly include ISO, exposure time, and aperture value. Physically, these parameters characterize the photoelectric gain amplification factor and integration time of the underlying photoelectric sensor of the camera device at the moment of capturing the image.
[0038] Since accidental drug ingestion by children often occurs at night or in low-light conditions (such as when only a bedside lamp is on), the terminal camera will automatically increase the ISO and extend the exposure time. This high gain will cause extremely severe non-linear gain drift and noise pollution in the image color channels. Relying solely on surface pixel values is insufficient to reproduce the true color of the target; it is necessary to combine the optical state data of the underlying hardware to perform inverse color compensation and restoration.
[0039] The original color image is obtained by directly capturing the pixel matrix through the camera component of the mobile terminal (such as smartphones and tablets) by calling the underlying image acquisition API of the operating system (such as the Camera2 API of Android or the AVFoundation framework of iOS); the exposure control parameters of the camera device are extracted in real time by reading the EXIF (Exchangeable ImageFileFormat) metadata of the image file at the moment of acquisition, or by synchronously calling the underlying system callback function of the camera hardware driver interface.
[0040] A2. Based on the pixel distribution characteristics in the original color image, the original color image is divided into regions to obtain the drug candidate region and the human skin reference region.
[0041] Pixel distribution features characterize the connectivity state in the image space topology and the clustering distribution attributes in the color space. The drug candidate region refers to the mask of the pixel set in the image that may contain suspicious target tablets or capsules. The human skin reference region refers to the mask of the pixel set in the image that belongs to human skin (such as the face, hands, or fingers of a child or parent). The human skin reference region acts as a biological benchmark reference target (i.e., a natural color card) under dynamic lighting conditions throughout the scheme.
[0042] In real emergency situations, the background is often extremely cluttered (e.g., containing vomit, patterned sheets, etc.). Directly processing the entire image for color would not only introduce massive amounts of noise but also significantly consume computational resources. By dividing the original color image into two independent regions, the target object to be corrected and the metering reference scale are decoupled from the cluttered background, completely eliminating interference from irrelevant background pixels. This improves the signal-to-noise ratio of subsequent color feature extraction and the real-time computational efficiency of the system.
[0043] At the machine execution level, the original color image is first subjected to color space conversion (e.g., from RGB space to YCbCr or HSV space). Discrete noise is filtered out using an edge detection operator combined with a preset morphological dilation and erosion algorithm. Next, the pixel distribution is analyzed using a connected component extraction algorithm. Connected components that conform to the preset biological skin color threshold spatial distribution are marked and bounded as human skin reference regions, while the remaining isolated foreground connected components are marked as drug candidate regions, generating spatial mask matrices for the corresponding regions.
[0044] A3. Extract the drug color features corresponding to the drug candidate region and the reference color features corresponding to the human skin reference region, respectively.
[0045] Drug color features and reference color features are high-dimensional statistical abstract data (such as multidimensional feature vectors or channel color distribution tensors) that, after mathematical dimensionality reduction, respectively characterize the macroscopic dominant color attributes of the drug candidate region and the human skin reference region under the current polluted light source.
[0046] The spatial mask matrix generated in the previous step is used to define the operation boundary, and statistical filtering algorithms are applied within the corresponding region. For example, a mean filtering mechanism after removing extreme points or a Gaussian weighted pooling algorithm is used to perform peak statistics or variance calculation on the pixel distribution histogram of each independent color channel, thereby reducing the dimensionality of the two-dimensional pixel space and outputting a set of color feature vectors composed of multi-dimensional floating-point numbers, namely drug color features and reference color features.
[0047] A4. Obtain preset human body standard color reference data, and determine the ambient light offset parameter used to characterize the degree of color offset in the current shooting environment based on the difference relationship between the reference color characteristics and the human body standard color reference data for each color channel.
[0048] The preset human body standard color reference data characterizes the stable spectral reflectance characteristic value base of healthy human skin under standard pollution-free white light (such as D65 light source or medical shadowless lamp). The difference relationship between the reference color features and the human body standard color reference data in each color channel characterizes the deviation of the extracted skin color features from the standard base in each color dimension. The ambient light offset parameter is a multi-dimensional correction vector, which physically represents the quantitative mapping of the spectral offset of the current non-standard light source (such as warm-colored bedside lamp) relative to standard white light.
[0049] Human body standard color reference data is retrieved from a locally stored knowledge base or a cloud-based medical color reference library. Subsequently, the vector difference, ratio, or multidimensional Euclidean distance distribution relationship between the extracted reference color features and the human body standard color reference data in the corresponding color channels (R, G, B) is calculated. After vector alignment and difference concatenation operations, ambient light offset parameters with directional and amplitude attributes are generated.
[0050] A5. Extract the exposure response weights based on the camera equipment's exposure control parameters, use the exposure response weights to perform scale correction on the ambient light offset parameters, and generate a dynamic color correction matrix.
[0051] Exposure response weights characterize the nonlinear coefficients (i.e., the optical signal-to-noise ratio state) of the current camera's photoelectric sensor in a high-gain extreme state in response to the degree of distortion of light of different wavelengths; the dynamic color correction matrix is a high-order algebraic operator (such as a diagonal matrix) that characterizes the transformation relationship system of inversely projecting the current distorted pixel color space and mapping it to the real standard color space.
[0052] The camera exposure control parameters obtained in step A1 are parsed and input into a preset photoelectric gain nonlinear response mapping table. Matching nonlinear weight coefficients (i.e., exposure response weights) are retrieved or fitted. Subsequently, tensor operations are performed internally, and the exposure response weights are used to perform dynamic limiting or smooth scaling corrections on each component of the ambient light offset parameters. Finally, the corrected offset components are filled into a predefined identity matrix, and a dynamic color correction matrix is output.
[0053] A6. Use a dynamic color correction matrix to perform color compensation processing on the color features of the drug to obtain the true color features of the target drug.
[0054] The true color feature of the target drug represents the intrinsic physical color vector exhibited by the target drug under an ideal medical-grade standard light source after successfully removing the influence of current complex physical light source pollution and hardware sensor gain distortion in mathematical space.
[0055] Existing medical emergency feature databases record only the absolute color data of drugs under standard ideal conditions. Only by cleaning and restoring the severely contaminated and distorted data collected on-site to a standard state can we ensure that the data from both sides are under the same physical measurement scale during the next step of database matching.
[0056] The generated dynamic color correction matrix is subjected to matrix multiplication or multidimensional affine mapping transformation with the original drug color feature vector. Adaptive anti-overflow truncation or smooth attenuation logic is introduced during the operation to accurately correct the color tensor without destroying the macroscopic geometric topology of the drug, so as to finally calculate and output the true color features of the target drug.
[0057] A7. Match the actual color characteristics of the target drug with the preset drug color characteristic library to determine the identity of the target drug, and output the corresponding auxiliary emergency information based on the identity of the target drug.
[0058] The preset drug color feature library is a standardized medical knowledge graph ontology. The target drug identity identifier refers to the system-level primary key or unique digital code representing a specific drug physical category (such as amoxicillin capsules or a specific type of antihypertensive drug). The auxiliary emergency information represents the medical operation instruction sequence (including but not limited to structured text and symbols such as contraindications to vomiting, toxicity classification, and detoxification plan guidance) that are forcibly bound to this code.
[0059] By transforming image features into identity identifiers, a reliable bridge is built from the visual image domain to the medical semantic domain. The output of structured emergency information can provide accurate, scientific and timely rescue operation guidelines to the families of sick children who are in a state of extreme panic and lack professional medical background during the most critical golden rescue time. This fundamentally reduces the probability of secondary fatal injuries caused by blind treatment (such as incorrectly inducing vomiting in children who have accidentally ingested strong acid or alkali drugs).
[0060] In the specific processing, the restored true color features of the target drug are used as input probes. A tolerance comparison engine is driven within a pre-defined drug color feature library to calculate the cosine similarity or Mahalanobis distance between the probe vector and each benchmark entry in the library. Through a multi-dimensional threshold verification mechanism, the matching object with the smallest spatial distance is identified, thereby extracting the corresponding target drug identifier. Subsequently, using this identifier as the query key, an asynchronous retrieval is initiated by calling the underlying medical rule knowledge base. A structured emergency response message is then assembled and generated, and finally transmitted to the front end for highlighted rendering on the user terminal interface.
[0061] This application further discloses the process of dividing the original color image into regions in step A2, as follows:
[0062] B1. Extract the spatial distribution connectivity data of each pixel in the original color image and the initial color threshold;
[0063] Spatial connectivity data refers to the topological clustering relationships and edge gradient parameters between adjacent pixel nodes in the image space matrix of the original color image. In machine logic, it reflects the continuous shape and geometric boundaries of objects in the physical world. The initial color threshold is a quantitative data benchmark used to initially distinguish the target foreground from large dark areas and solid color dead zones. By traversing the original image matrix, edge detection operators or region growing algorithms are used to statistically analyze the neighborhood states of pixels, thereby generating spatial connectivity data, and simultaneously reading the initial color threshold issued by the system.
[0064] By transforming isolated and disordered pixels into a topological set with macroscopic physical contours through spatially distributed connectivity data, fragmentation of recognition caused by single high-frequency noise is avoided. At the same time, the initial color threshold acts as a data gate to quickly strip away a large amount of invalid background redundant data at extremely low computational cost, providing a high signal-to-noise ratio initial screening data base for subsequent accurate spatial segmentation.
[0065] B2. Based on spatially distributed connectivity data and initial color thresholds, isolated connected domains in the foreground are separated as drug candidate regions.
[0066] The initial color threshold is used as the activation condition to filter out irrelevant background connected components. At the same time, based on the spatial distribution connectivity data, the geometric closure properties and boundary dispersion of each remaining connected component are calculated. Pixel blocks that satisfy the isolated and closed features are defined as foreground isolated connected components, and mask labels are applied to them. Finally, the drug candidate region is output.
[0067] Drug entities (such as tablets and capsules) in scattered scenes are usually isolated physical objects with clear closed boundaries. By introducing geometric topological properties for physical-level logical determination, spatial decoupling of the target drug is achieved. On the one hand, it eliminates the interference of complex clutter such as surrounding clothing textures and debris. On the other hand, it ensures the high purity of the extracted drug candidate region data and prevents it from being biased by erroneous features of the background when generating the color compensation matrix.
[0068] B3. After filtering out the drug candidate region in the original color image, the connected regions in the remaining connected regions that meet the preset biological skin color threshold are marked as human skin reference regions.
[0069] In the image space matrix of the original color image, the determined drug candidate region data is forcibly erased by inverse masking operation to form a hollow residual matrix. Then, the pre-loaded preset biological skin color threshold is called to traverse and compare the intersection of the connected components in the residual matrix one by one, and the set of pixels that meet the feature interval is locked and marked as the human skin reference region.
[0070] The preset biological skin color threshold characterizes the high-dimensional data envelopment boundary of healthy human skin in a specific color space (such as the YCbCr space or HSV space after removing luminance interference); its value calibration process is as follows:
[0071] First, batch images of human skin samples from multiple ethnic groups and age groups are acquired, and the lighting environment parameters of these samples under various controlled simulated light sources (including standard D65 white light, low color warm yellow light, and low illumination weak light) are acquired simultaneously to construct the original skin color sample dataset.
[0072] Subsequently, the original skin color sample dataset mentioned above is read, and the pixels of each sample are mapped from the original RGB physical color space to the target color space (preferably YCbCr color space) by linear algebraic matrix transformation. In this mapping process, the system forcibly discards or strips the luminance component (Y channel data) and retains only the chrominance component (Cb channel and Cr channel data) that characterizes the essence of color, thereby eliminating the physical interference caused by the fluctuation of light source illuminance to color calibration.
[0073] On the chromaticity plane of the target color space, the two-dimensional chromaticity distribution coordinates of each sample pixel are extracted, and machine learning clustering algorithms (such as Gaussian Mixture Model (GMM) or DBSCAN density clustering algorithm) are called to perform high-frequency feature clustering on the massive chromaticity two-dimensional distribution coordinates. Through iterative calculation, the machine finds the center coordinates of the densest sample distribution and sets them as the skin color cluster center.
[0074] Using the skin color cluster center as the mathematical origin and combining it with a preset statistical confidence interval (such as the distribution variance corresponding to 95% confidence), the geometric topological boundary extremum that can maximally enclose the high-frequency cluster set is calculated. The processor encapsulates this geometric topological boundary extremum data, which includes upper and lower bound coordinates, in a structured manner, and finally generates and solidifies it into a preset biological skin color threshold in the local knowledge base.
[0075] The above processing logic of first filtering out drug areas and then searching for skin areas fundamentally eliminates the fatal logical error of mistaking drugs with similar skin color (such as light yellow or flesh-colored tablets) for environmental reference rulers; in addition, by matching biological threshold features to lock in the real skin area, a highly reliable dynamic measuring ruler is found in the messy image without any human intervention.
[0076] This application further discloses the process for extracting the color characteristics of the drug in step A3, as follows:
[0077] C1. Identify the sequence of edge gradient extreme points within the drug candidate region, and based on the sequence of edge gradient extreme points, divide the drug candidate region into a central core region and an edge transition region.
[0078] The edge gradient extreme point sequence represents the set of curvature abrupt changes in the three-dimensional physical morphology of the target drug on the two-dimensional image projection. Since tablets or capsules typically have curved edges, these edges are prone to high-intensity specular reflection (white spots) or geometric shadows (dark corners) under ambient light. In terms of data processing, a difference operator (such as the Sobel or Canny operator) is applied to the pixel matrix of the decoupled drug candidate region image to calculate the abrupt derivatives of pixel chroma and brightness in various spatial directions. The coordinates of the points where the derivatives reach local maxima are extracted and combined into a sequence. Subsequently, using this sequence of extreme points as the geometric topological boundary, a preset pixel distance is shrunk inward, thereby forcibly dividing the single candidate region into two independent data subsets in the spatial domain: a central core region representing a flat and uniformly illuminated drug surface, and an edge transition region representing the three-dimensional edges of the drug and heavily polluted by ambient light.
[0079] C2. Extract the first color distribution tensor of the central core region and the second color distribution tensor of the edge transition region respectively;
[0080] The first and second color distribution tensors are high-order algebraic statistical structures (e.g., high-dimensional arrays containing channel mean, color histogram peaks, or spatial color co-occurrence matrices) representing the pixel value distribution of each color channel on two different physical light-receiving surfaces: the central core region and the edge transition region. In machine processing, statistical pooling operations are performed on the pixel matrices within these two independent spatial masks: the dominant chromaticity components of each channel in the central core region are extracted and aggregated into the first color distribution tensor; simultaneously, the chromaticity and gradient decay distribution features of the edge transition region are extracted and aggregated into the second color distribution tensor.
[0081] C3. Assign a preset extraction weight to the first color distribution tensor that is greater than that to the second color distribution tensor, calculate the weighted features of the two and use them as drug color features.
[0082] After extracting the first color distribution tensor and the second color distribution tensor, the core operation of feature fusion is performed: the first color distribution tensor is assigned a preset extraction weight greater than that of the second color distribution tensor, the weighted features of the two are calculated and used as drug color features;
[0083] At the data representation level, the first color distribution tensor in the central region mainly represents absolute chromaticity, while the second color distribution tensor in the edge region internally couples chromaticity and gradient decay features. In subsequent processing, these two tensors are concatenated to obtain the final drug color features.
[0084] The preset extraction weights are used as scale adjustment scalars to perform mandatory scaling on the two tensors respectively. Specifically, the large weight scalars assigned to the central core region are used to amplify the absolute value of the first color distribution tensor, while the small weight scalars assigned to the edge transition region are used to compress and smooth the gradient decay features in the second color distribution tensor.
[0085] After forced scaling, the scaled first color distribution tensor and the second color distribution tensor are subjected to high-dimensional vector concatenation in a multidimensional algebraic space to generate drug color features of a unified dimension.
[0086] Regarding the extraction process of the reference color features in step A3, this application further discloses the following:
[0087] C4. Extract multiple sets of local pixel block sequences within the human skin reference area and obtain the color statistical variance of each set of local pixel block sequences in each color channel;
[0088] Local pixel block sequences represent microscopic color topological slices at different spatial locations within the skin region, while color statistical variance is a discrete mathematical index that measures the degree of color fluctuation on local physical reflective surfaces. In machine processing, within the masked area of the human skin reference region, multiple fixed-dimensional pixel matrix fragments are extracted using a sliding window with a preset step size or a Poisson disk sampling algorithm. Subsequently, for each extracted fragment, discrete variance algebra operations are performed on independent red, green, and blue physical color channels to obtain the color statistical variance.
[0089] C5. Filter out local pixel block sequences whose color statistical variance is greater than the preset variance threshold to obtain a stable reference pixel set;
[0090] The preset variance threshold acts as a mandatory data filtering caliper, representing the maximum algebraic discrete extreme value of natural color fluctuations (such as normal color differences caused by pores and fine textures) in local micro-regions of healthy human skin under ideal uniform diffuse illumination conditions; while the stable reference pixel set is a pure physical background color data pool after removing high-frequency optical noise. The color statistical variance of all local pixel block sequences is traversed in memory, and a hardware logic comparison unit is used to conditionally compare it with the preset variance threshold.
[0091] Sequences with variance exceeding the threshold (i.e., distorted regions that physically correspond to high reflectivity or deep shadows) are forcibly blocked and their memory released; only sequences with variance below or equal to the threshold are retained, and all pixels contained within them are aggregated and recombined to obtain a stable reference pixel set.
[0092] The calibration process for the preset variance threshold is as follows:
[0093] First, multiple sets of local macro images of healthy human skin under standard controlled environments were acquired. During the acquisition process, the light source was strictly controlled to be a uniform diffuse reflection light source, and the oil and sweat on the skin surface were physically wiped away to ensure that the acquired image data were absolute pure intrinsic reference samples without any highlights or shadows.
[0094] The intrinsic baseline samples are read, and a preset step size, identical to that used in real emergency rescue scenarios, is employed to extract a massive sequence of local pixel blocks from the sample matrix using a sliding window mechanism. For each extracted local pixel block sequence, the mean is calculated on an independent color channel, and the color statistical variance of a single channel is calculated based on the sum of squared differences between each pixel and the mean.
[0095] Summarize the color statistical variance data of all intrinsic baseline samples and plot a one-dimensional data distribution histogram. Since the color fluctuation of pure skin is extremely small, this distribution usually exhibits a convergent unimodal state. Fit this unimodal data normally using a statistical probability model (such as a Gaussian distribution), and extract the upper confidence level coordinates covering 99.7% (i.e., 3 times the standard deviation range) of the vast majority of normal fluctuation data. Use these coordinates as the preset variance threshold for actual operation.
[0096] C6. Extract the channel mean features of the stable reference pixel set in each color channel, and use the vector sequence formed by concatenating the channel mean features as the reference color features.
[0097] The channel mean feature represents the average state of the physical basis energy accumulation of a pure skin sample in a single color dimension. The reference color feature, constructed by concatenating the channel mean features, is a structured low-dimensional algebraic vector, directly serving as the absolute operand for subsequent measurement scales. In terms of specific machine processing, for all valid pixels within the stable reference pixel set, scalar accumulation and mean calculation are performed on each independent color channel to obtain the high-confidence chromaticity mean for each channel. Subsequently, the processor calls a register concatenation instruction to perform high-dimensional vector concatenation of the means from different color channels according to a predetermined physical order, thereby generating a compact sequence of reference color feature vectors.
[0098] The process for determining the ambient light offset parameters mentioned in step A4 is further disclosed in this application as follows:
[0099] D1, the high-dimensional tensor sequence corresponding to the alignment reference color features and the human body standard color reference data;
[0100] Reference color features refer to low-dimensional chromaticity feature vectors extracted from human skin reference areas and contaminated by currently unknown non-standard light sources. Human standard color reference data refer to the absolute chromaticity standard vector of healthy human skin color under standard D65 light source, which is pre-stored in the system memory. The high-dimensional tensor sequence physically and logically represents a multi-dimensional algebraic matrix space with strict channel index alignment, used to carry and align color features from two independent sources, making them comparable under the same mathematical scale.
[0101] At the machine execution level, the tensor alignment operator is invoked to read the reference color features and human body standard color reference data. Based on the color channel identifier (ChannelID) and the preset spatial dimension specification, the two are written onto different component axes of the same high-order tensor space, thereby constructing a structured high-dimensional tensor sequence with one-to-one correspondence between channels.
[0102] The process of constructing human body standard color reference data is as follows:
[0103] We obtained healthy human skin samples from multiple races and age groups. In an absolutely dark room environment, we used a medical-grade standard shadowless lamp or a D65 standard white light source with an extremely high color rendering index (color temperature 6500K) to vertically and uniformly irradiate the skin samples. At the same time, we used a high-precision spectrophotometer or a calibrated reference camera sensor to collect the absolute spectral reflectance data of the skin samples.
[0104] Since the collected absolute spectral reflectance data is in the physical energy level dimension, it cannot be directly algebraically operated on with the channel mean features of the reference color features (such as 8-bit 0-255 color levels). Therefore, through a preset photoelectric conversion matrix and gamma correction algorithm, the absolute spectral reflectance data is forcibly mapped to a standard digital color space (such as sRGB color space) that is completely consistent with the target mobile terminal. And according to the same tensor dimension and bit depth, it is quantized and normalized into a multi-dimensional digital color vector.
[0105] A multidimensional Gaussian mixture model (GMM) clustering analysis is performed on the quantized multidimensional digital chromaticity vector to extract the cluster center feature vector that best represents the generalized human healthy skin tone. This cluster center feature vector is then structured and encapsulated according to a predetermined color channel order (such as the R, G, B channel sequence) to finally generate human standard color reference data. This data is then persistently stored in the system's non-volatile memory or in a cloud-based medical rule base for quick indexing and retrieval during real-time emergency identification.
[0106] D2. Calculate the relative offset ratio of the reference color features to each reference color channel in the high-dimensional tensor sequence;
[0107] Extract the corresponding elements of each color channel in the high-dimensional tensor sequence, drive the divider or vector element-level division instruction in the machine's native data layer, take the value of the reference color feature in a specific channel as the dividend, take the corresponding human body standard color reference data as the divisor to calculate the quotient, and output the relative offset ratio corresponding to each reference color channel in sequence.
[0108] The relative offset ratio physically characterizes the multiplicative gain contamination coefficient imposed by a non-standard light source on each independent color channel (such as the red, green, and blue wavelength bands). If the current shooting environment is under a warm-colored bedside lamp, the relative offset ratio corresponding to the red or green channel will deviate significantly from the reference axis.
[0109] D3. Extract the predetermined number of relative offset ratios as effective offset parameters;
[0110] In actual mobile terminal shooting, due to the underlying thermal noise, photoelectric quantization noise, and infinite repeating decimal problem caused by the division floating-point operation of the camera sensor, the directly calculated offset ratio will inevitably contain high-frequency numerical glitches.
[0111] Receive the relative offset ratio, perform bit-deep truncation or rounding to zero on the floating-point data of the relative offset ratio, discard low-order mantissa data exceeding the predetermined number of bits, and output the purified effective offset parameter.
[0112] The pre-defined number of decimal places represents the truncation boundary of significant digits retained when processing floating-point numbers (such as the preset number of significant digits after the decimal point), while the effective bias parameter refers to the channel distortion coefficient after numerical denoising and smoothing stabilization, which eliminates random small disturbances.
[0113] D4. Combine and merge the effective offset parameters corresponding to each reference color channel to generate ambient light offset parameters.
[0114] Ambient light offset parameter refers to a multidimensional feature control vector or matrix operator with a complete structure and uniform dimensions. Physically, it represents the comprehensive offset projection state caused by ambient light in the global color space under the current shooting scene.
[0115] Independent channel parameters (such as single R-channel bias and B-channel bias) are scattered scalar data and cannot be directly used as generators of the global color correction matrix. By re-encapsulating the effective bias parameters of each color channel in a multidimensional algebraic space, a dimensionality upgrade from scalar data to high-order vector / matrix data is achieved. This organically integrates discrete channel distortion data into a composite control operator capable of governing the color correction of the entire image, forming the ultimate data bridge for the entire emergency medical system from the environmental measurement stage to the drug feature correction stage.
[0116] According to the predetermined physical color channel arrangement order (such as RGB topology order), the effective offset parameters corresponding to each channel are linearly concatenated and merged on the vector axis, and finally the ambient light offset parameters in standard data format are generated and output in memory.
[0117] Regarding the extraction process of the exposure response weight mentioned in step A5, this application further discloses the following:
[0118] E1. Analyze the exposure control parameters of the camera equipment to separate the sensitivity parameters and exposure time parameters;
[0119] The ISO parameter, separated by machine analysis, physically characterizes the analog / digital gain amplification applied by the CMOS / CCD photoelectric sensor to the captured weak light signal, while the exposure time parameter physically characterizes the duration of photon integration when the sensor shutter is open.
[0120] In terms of machine processing, by calling the underlying Camera API interface or parsing the EXIF metadata header file of the original image, and using preset regular expressions or fixed offset addresses, these two orthogonal hardware working state variables are separated from the composite data stream.
[0121] E2. The sensitivity parameter and exposure time parameter are introduced into a preset nonlinear correlation mapping table for composite retrieval to obtain the noise drift coefficient that matches the current exposure state.
[0122] The pre-defined nonlinear correlation mapping table is a two-dimensional data structure calibrated offline and stored in memory. It not only records different photoelectric states but also internalizes the nonlinear physical attenuation law of color distortion under extreme conditions. The output noise drift coefficient is a scalar quantitatively representing the relative degradation degree of the color signal deviating from the true optical value under the current hardware operating extreme values. In terms of data processing, the separated photosensitivity parameter is used as a horizontal memory address index, and the exposure time parameter is used as a vertical memory address index for addressing within the two-dimensional correlation mapping table. If the parameter is not an integer or spans a step size, a bilinear interpolation algorithm is used to calculate the smooth transition value of the neighboring grid, thereby outputting the noise drift coefficient.
[0123] Because CMOS / CCD photoelectric sensors exhibit highly irregular thermal noise bursts and color crosstalk at extremely high gain (for example, the color deviation from ISO 100 to 200 is not proportionally amplified to the color deviation from ISO 3200 to 6400, and the attenuation rate of the red and blue channels is much greater than that of the green channel), it is difficult to accurately fit this physical phenomenon directly with mathematical formulas. Therefore, it is necessary to construct this table through offline calibration. The specific steps are as follows:
[0124] In a controlled darkroom environment, a standard color calibration target (such as a 24-color or 48-color ColorChecker standard color chart) is illuminated using a standard light source with multi-level illumination. Through an automated test script, all possible combinations of "sensitivity-exposure time" of the terminal camera device are forcibly traversed, and a massive amount of raw test images are collected.
[0125] Extract the actual chromaticity vector of each color block in each original test image, and calculate its three-dimensional Euclidean distance from the absolute standard chromaticity vector of the color card in the color space.
[0126] The average color difference calculated under different exposure combinations is used as the noise drift coefficient. For intermediate non-integer parameter levels that are not traversed, spline interpolation or polynomial nonlinear fitting algorithms are used to calculate the theoretical distortion value for smooth transition. Finally, all discrete and interpolated distortion data are filled into a two-dimensional grid of the corresponding dimension, structured, encapsulated, and persistently stored to form a nonlinear correlation mapping table.
[0127] E3. Calculate the ratio between the noise drift coefficient and the preset baseline coefficient, and use the preset logarithmic mapping relationship to perform scale conversion on the ratio data to obtain the exposure response weight.
[0128] The preset reference coefficient characterizes the inherent thermal noise and slight color deviation limits of a specific terminal photoelectric sensor (CMOS or CCD) under optimal physical optical excitation conditions (i.e., native reference sensitivity, such as ISO 100, and sufficient exposure time without overexposure). In other words, the preset reference coefficient is the physical ceiling of color fidelity that the camera device can achieve under ideal conditions. The exposure response weight is a purely mathematical dimensionless adjustment operator that has been completely removed from physical dimensions and can directly participate in matrix operations. The noise drift coefficient obtained is divided by the preset reference coefficient to obtain the ratio data representing the relative degradation rate. Subsequently, facing degradation ratios that may be hundreds or thousands of times higher, the underlying logarithmic function is called to perform nonlinear scaling with this ratio data as the independent variable. The compressed scalar value is then assigned and output as the final exposure response weight.
[0129] By introducing a logarithmic mapping relationship, a smooth "soft limiting" mechanism is mathematically implemented, ensuring that even under the most extreme exposure conditions, the converted weights are constrained within a reasonable algebraic range. This guarantees that color distortion will not occur due to overcorrection, and perfectly matches the natural law that human vision responds logarithmically to light intensity (Weber-Fechner law). Even in extreme emergency situations, it can still reproduce the intrinsic colors of the drug that best conform to the physiological cognitive habits of the human eye.
[0130] During the offline calibration phase of the association mapping table, when the camera's sensitivity and exposure time parameters are at the hardware's native optimal operating point (such as ISO 100 and reference shutter speed), the calculated basic background color geometric offset measure is forcibly registered and written into the initial zero-order coordinate node (i.e., the starting position of the two-dimensional grid) of the association mapping table as a preset reference coefficient.
[0131] Regarding the scaling process mentioned in step E3, this application further discloses the preset logarithmic mapping relationship:
[0132] The core formula for the nonlinear logarithmic mapping used in this scaling transformation is:
[0133] ;
[0134] in:
[0135] Weighting based on exposure response;
[0136] This is the ratio between the noise drift coefficient and the preset baseline coefficient.
[0137] The initial base weights represent the baseline mapping values without additional distortion, and are typically set to 1.0.
[0138] This is the logarithmic mapping scale gain coefficient, used to adjust the overall response sensitivity of the color compensation matrix; The value range is set as In this embodiment, the preferred value is Due to the natural logarithm The output value is usually small (e.g. The subsequent dynamic color correction matrix typically requires a control operator with a range of 1.0 to 3.5 when performing multiplication and addition operations on channel pixel values (0-255). It acts as a gear between the pure mathematical dimension and the RGB physical color dimension, ensuring the weight of the output exposure response. It can accurately map to the optimal color compensation working range of the image ISP (Image Signal Processor).
[0139] The limit physical signal-to-noise ratio safety threshold characterizes the maximum noise degradation rate that a photoelectric sensor can tolerate before signal truncation occurs. The value range is set as In this embodiment, the preferred value is . Characterizing the inflection point where sensor noise deteriorates from linear to exponential. Using native ISO 100 as a baseline, the calculated degradation ratio data is obtained when the ambient light is extremely dark, forcing the ISO to be artificially increased to 1600 or 3200 or higher. It usually exceeds 5.0. Setting it to 5.5 means that sufficient logarithmic gain compensation is allowed under normal low light conditions; however, once the degradation factor exceeds 5.5 times the baseline noise floor, it is determined that it is approaching the edge of hardware color degradation and immediately triggers the exponential soft limiting protection mechanism.
[0140] This is the extreme distortion suppression coefficient, used to control the curve smoothing decay rate after exceeding the threshold; The value range is set as In this embodiment, the preferred value is . It determines when the safety threshold is crossed. Afterwards, the matrix weight gain is forced to apply the brakes on its braking sensitivity. If A value that is too large will cause high ISO image compensation to suddenly stop (the image will darken instantly); a value that is too small will not suppress clipping. A value of 0.25 can construct an extremely smooth logarithmic decay envelope, which allows the correction weights generated under extremely poor exposure to gradually converge, perfectly preserving the microscopic texture of the drug's highlight areas.
[0141] In the formula It acts as a switch for the exponential term:
[0142] When ratio data At that time, the exponent term The formula completely degenerates into a standard smooth logarithmic compression, i.e. ;
[0143] when When the image is determined to be in a degraded state, the exponential decay term is activated.
[0144] If not Even with logarithmic attenuation, the resulting matrix weights can still be too large under extreme distortion, leading to color overflow when multiplied into the image (e.g., a red pill turning into a glaring, dead white). This formula forcibly suppresses the growth of the logarithmic argument through exponential attenuation, forming a soft saturation curve and firmly maintaining the physical boundaries of the color matrix.
[0145] At an emergency scene, parents might take photos in extremely dark corners using very high ISO settings. This adaptive composite logarithmic mapping mechanism can provide sufficiently sensitive color compensation when image degradation is within a controllable range; however, once noise and color cast reach catastrophic levels (i.e., exceeding the physical signal-to-noise ratio safety threshold), it will provide more sensitive color compensation. The nested exponential decay term within the algorithm forcibly lowers the growth slope of the logarithmic curve through feedforward suppression, forming a gradual soft saturation limiting boundary. This fundamentally eliminates matrix operation overflow caused by the unbounded divergence of compensation weights, ensuring that the final reconstructed drug image is both realistic and natural in color, without losing key surface geometric textures and text information.
[0146] Regarding the generation process of the dynamic color correction matrix mentioned in step A5, this application further discloses the following:
[0147] E4. The ambient light offset parameter is resolved into independent component sequences corresponding to different reference color channels;
[0148] The ambient light offset parameter is a multidimensional composite vector that represents the degree of overall distortion of the global ambient light on the overall color space. The resolved independent component sequence decouples this overall distortion in the physical spectrum dimension, corresponding to the offset scalars of individual physical color channels such as red, green, and blue. The high-dimensional ambient light offset parameter vector is decomposed and reduced in dimensionality according to the preset channel index address to obtain the independent component sequence.
[0149] E5. Generate the initial correction sequence by performing a mapping product operation between the exposure response weights and each independent component sequence;
[0150] The exposure response weights generated in step E3, which are combined with the underlying hardware state, are invoked. The arithmetic logic unit performs scalar multiplication operations on the exposure response weights and the separated independent component sequences, thereby outputting an initial correction sequence that includes hardware state feedback.
[0151] E6. Check whether the values of each channel in the initial calibration sequence exceed the preset correction boundary threshold.
[0152] The preset correction boundary threshold represents the maximum single-channel compensation limit that the image processor (ISP) can tolerate without color bit depth overflow (i.e., pixel values exceeding 255 leading to whiteouts or color banding). In terms of specific processing, the initial correction sequence is scanned channel by channel. When a channel value is found to exceed the limit, hardware-level limiting is immediately triggered, forcibly anchoring the exceeding value to the safe threshold boundary. Channels that do not exceed the limit retain their original values, ultimately outputting a safe target chromaticity deviation sequence.
[0153] The calibration process for the preset correction boundary threshold is as follows:
[0154] First, a reference drug entity with standard markings or embossed markings on its surface is acquired. Under simulated extremely dark controlled lighting conditions, the terminal camera is forced to acquire raw test images of the drug at its maximum ISO sensitivity, which are heavily contaminated by ambient light and accompanied by high-frequency noise.
[0155] A small initial compensation coefficient is injected into a single target color channel of the original test image, and incremental amplification is performed on this channel within the loop according to a preset micro-step size instruction. In each iteration of the numerical increment, a high-pass spatial filter (such as a Laplacian operator) is synchronously invoked to calculate and extract high-frequency spatial gradient feature data of the drug surface under the current compensated image in real time. This high-frequency data is physically equivalent to the edge sharpness of the microscopic characters on the drug.
[0156] As the compensation coefficient is continuously and forcibly increased, the pixel value of the target channel approaches the hardware's bit depth limit (e.g., the extreme value of 255 for an 8-bit image). When the compensation exceeds a certain physical critical point, the originally clear high-frequency spatial gradient feature data will experience a precipitous drop (the physical phenomenon is that the area of the pill text loses all contrast due to uniform pixel overflow, resulting in a completely white area and the texture disappearing completely). By taking the second derivative of the extracted gradient decay curve, this mathematical inflection point where irreversible texture truncation occurs is captured. Subsequently, the last compensation extreme value within the safe interval preceding this inflection point is extracted, structured, encapsulated, and persistently stored to obtain the preset correction boundary threshold.
[0157] E7. Fill the target chromaticity deviation sequence onto the diagonal of the preset unit matrix according to the predetermined matrix dimensions, and output the dynamic color correction matrix.
[0158] The dynamic color correction matrix is a diagonal matrix operator conforming to linear algebra. In machine processing, the processor initializes a standard identity matrix in memory (e.g., ...). The identity matrix (with 1s on the main diagonal and 0s elsewhere) is then used to replace the corresponding elements on the main diagonal of the purified and limited target chromaticity deviation sequence one by one according to the predetermined matrix dimension. Upscaling the discrete sequence data and filling it onto the diagonal of the identity matrix not only completes the standardized encapsulation from a scalar set to an algebraic operator, but more importantly, when the diagonal matrix participates in subsequent image pixel matrix multiplication transformations, it strictly ensures that each color channel undergoes only same-dimensional scaling, without causing any channel rotation or shearing deformation. This fundamental mathematical principle ensures that the final color compensation processing only changes the chromaticity values of the drug, without ever destroying the intrinsic image topology and physical spatial information of the target drug.
[0159] Regarding the process of obtaining the true color characteristics of the target drug mentioned in step A6, this application further discloses the following:
[0160] F1. Analyze the color features of the drug to obtain the chromaticity component and edge gradient component, and convert the chromaticity component into a color vector to be corrected with a predetermined dimension.
[0161] The drug color feature is a composite high-dimensional feature tensor containing absolute color and spatial structure features extracted in the previous step; the chromaticity component represents the intrinsic absolute color data of the drug core region (such as RGB color level values); the edge gradient component characterizes the gloss attenuation and spatial gradient change data of the drug edge due to the three-dimensional physical geometric curvature.
[0162] In terms of machine processing, the color features of the drug are decomposed in memory and the color intensity component and edge gradient component are separated by spatial address indexing and slice extraction instructions.
[0163] Subsequently, the chromaticity components are assembled according to a predetermined column array arrangement rule, reconstructing a standard column vector conforming to a predetermined algebraic dimension (e.g., (a column vector of dimensions) to obtain the color vector to be corrected.
[0164] F2. Perform matrix multiplication between the dynamic color correction matrix and the color vector to be corrected to generate an intermediate feature vector.
[0165] The intermediate feature vector physically represents the original color reconstruction vector that has been stripped of ambient light pollution but has not yet undergone underlying hardware display bit-depth security verification. In terms of processing methods, the dynamic color correction matrix generated earlier (such as...) (channel transformation matrix) and The intermediate feature vector is obtained by performing matrix multiplication on the color vector to be corrected.
[0166] F3. Extract the maximum value component from the intermediate feature vector and compare the maximum value component with the preset bit depth boundary threshold.
[0167] The maximum component refers to the scalar with the highest value in each color channel of the intermediate feature vector (e.g., the component with the largest absolute value after correction among the red, green, and blue channels); the preset bit depth boundary threshold represents the maximum numerical limit that the image signal processor or display hardware can resolve (e.g., the value 255 in an 8-bit bit depth system). In terms of processing, the processor extracts the maximum component through max pooling or sorting filtering mechanisms and calls a hardware-level logic comparator to compare its size with the preset bit depth boundary threshold.
[0168] F4. If the maximum value component is determined to be greater than the bit depth boundary threshold, calculate the dynamic scaling factor between the bit depth boundary threshold and the maximum value component; use the dynamic scaling factor to perform element-wise product mapping on each dimension component in the intermediate feature vector to obtain the target core chromaticity vector.
[0169] The dynamic scaling factor is an adjustment scalar generated due to overflow. After obtaining the dynamic scaling factor, the broadcast mechanism is used to apply the dynamic scaling factor to each dimension of the intermediate feature vector, perform element-wise multiplication, and calculate the safe target core chromaticity vector.
[0170] The scaling process described above avoids the color cast and white cast issues caused by hard-clipping when overflow occurs. Forcibly smoothing out excess values (e.g., smoothing the calculated red channel 300 to 255) would lead to an imbalance in the proportions of each channel, causing a hue shift in the pink pill. By calculating a dynamic factor and performing proportional global shrinkage, adaptive compression of the overall vector is achieved while maintaining absolute hue. This protects the color proportions of the drug itself, avoids detail loss in drug highlights due to hardware overflow, and improves the recognition stability of the emergency medical system in extreme exposure scenarios.
[0171] F5. If the maximum value component is determined to be less than or equal to the bit depth boundary threshold, then the intermediate feature vector is directly used as the target core chromaticity vector.
[0172] If the highest channel value (maximum component) does not exceed the safety threshold of 255 (bit depth boundary threshold), the subsequent division and multiplication scaling logic is bypassed, and the original intermediate feature vector is directly marked as the target core chromaticity vector. This avoids performing meaningless floating-point operations in a safe state, greatly saving the mobile terminal's precious computing clock cycles, and ensuring that the processing link can penetrate with extremely low latency under normal lighting conditions, thus gaining the most precious golden rescue time to save children's lives.
[0173] F6. Perform multi-dimensional vector concatenation and recombination on the target core chromaticity vector and edge gradient components to output the true color features of the target drug.
[0174] In terms of data representation, the resynthesized true color feature of the target drug is a structurally complete high-dimensional feature vector. Its initial segment perfectly preserves the restored true physical background color, while its subsequent segment fully carries the drug's three-dimensional physical geometric features unaffected by color correction distortion. In terms of processing, the initially decomposed edge gradient components are retrieved, and a multi-dimensional cascade operator is used to perform tail-end concatenation with the target core chromaticity vector in algebraic space, ultimately generating and outputting the true color feature of the target drug. In the final matching stage at the emergency scene, this process not only provides a cleaned, pure chemical background color but also simultaneously provides a spatial contour anti-counterfeiting label representing the drug's 3D physical morphology (such as edge markings, curvature gloss, etc.). This fundamentally avoids misjudgment of heterogeneous drugs with the same color due to relying solely on single chromaticity recognition, further improving the accuracy of emergency drug identification under complex low-light conditions.
[0175] The calculation process for the dynamic scaling factor mentioned in step F4 is further disclosed in this application, as follows:
[0176] F41. Perform a difference operation between the maximum value component and the preset bit depth boundary threshold to obtain the overflow deviation data;
[0177] The maximum value component is an abnormal absolute value that exceeds the physical limits of the hardware after matrix compensation (e.g., the red channel component soaring to 450 in 8-bit color depth). The overflow deviation data represents the pure out-of-bounds increment of this abnormal value exceeding the safety boundary (e.g., 255). Using the aforementioned maximum value component as the minuend and the preset bit depth boundary threshold as the subtrahend, difference truncation is performed to forcibly separate the safe data and the out-of-bounds data in mathematical space, obtaining the overflow deviation data for subsequent processing.
[0178] F42. Read the preset smoothing mapping base, and use the smoothing mapping base as the calculation basis to perform logarithmic decay operation on the overflow deviation data to generate decay leveling features;
[0179] The smoothing mapping base is a parameter calibrated offline and preset at the underlying level (such as a specific constant greater than 1). Its physical meaning is to control the damping coefficient of the compression curve of the overflow deviation data. The attenuation leveling feature is a smooth incremental scalar obtained by mathematically reducing the overflow difference, which originally showed a destructive linear surge.
[0180] In emergency nighttime shooting, extreme overload of a single channel (such as strong reflective spots) can lead to extremely large color discrepancies. Direct processing would trigger a global hard-clipping crush, where other normal color channels are compressed to near zero in order to suppress the single reflective spot, causing large areas of the pill to become completely black. By introducing logarithmic attenuation, the originally large and destructive overflow value is softened and compressed into a gradually smoothing parabola, perfectly absorbing the destructive energy of the highlight burst. This fundamentally protects the normal texture data of the midtones and shadows of the image from being dragged down by the distortion of a single channel.
[0181] F43. The preset bit depth boundary threshold and the attenuation leveling feature are scalar summed to obtain the smoothed maximum component.
[0182] The smoothed maximum component is a virtual extremum reassembled from a safety base (a preset bit depth boundary threshold) and a compressed safety highlight increment (attenuation leveling feature). Physically, the smoothed maximum component represents the optimal highlight limit that the current hardware can simulate without compromising global contrast. By scalarly concatenating the constant bit depth boundary threshold with the dynamically calculated attenuation leveling feature, and re-anchoring the logarithmically softened safety increment to the hardware boundary, a smooth virtual peak without precipitous drops is constructed. This ensures that the denominator does not exhibit abrupt numerical oscillations when calculating the scaling factor, thus guaranteeing the high mathematical stability of the final scaling factor.
[0183] F44. Calculate the relative quotient between the preset bit depth boundary threshold and the smoothed maximum component, and determine the relative quotient as the dynamic scaling factor.
[0184] The dynamic scaling factor is strictly located at... The dimensionless floating-point control operator within the interval uses a preset bit-depth boundary threshold as the dividend and the reconstructed smoothed maximum component as the divisor. Since the smoothed maximum component is necessarily greater than the bit-depth boundary threshold, the calculated quotient naturally constitutes a convergent decay multiplier, completing the transition from the chromaticity numerical space to the dimensionless proportional space. This division operation cancels out the absolute dimensions of the color space, condensing the complex nonlinear compression logic into a simple global scaling scale that can be directly used for full-channel broadcast mapping. Because the dynamic scaling factor is calculated based on the softened smoothed maximum component, it ensures that each color channel is reduced in dimensionality proportionally (maintaining absolute hue) while avoiding the excessive compression of other channels caused by conventional division, achieving the highest level of restoration of the intrinsic color and three-dimensional micro-texture of the target drug.
[0185] This application further discloses the process of generating the attenuation leveling feature using logarithmic attenuation operation in step F42, and its mathematical equation is as follows:
[0186] ;
[0187] in:
[0188] This is a decay leveling feature, i.e., a smooth incremental scalar output.
[0189] Overflow deviation data refers to the pure out-of-bounds increment of the input, which is the difference between the maximum value and the boundary threshold.
[0190] The preset smoothing mapping base is a constant used to determine the initial damping of the compression curve, with a value ranging from 1.5 to 3.0, and a preferred value being [value missing]. (or use the base of the natural logarithm) ). Characterized by the occurrence of small data overflows (i.e. When the value approaches 0, the initial static damping of logarithmic compression is performed. It is preferably 2.0, which on the one hand matches the basic shift operation characteristics of the underlying hardware binary register, so that the initial compression can provide sufficient softening kinetic energy, and on the other hand will not cause the tiny highlight details to be instantly flattened due to the excessively large base, thus preserving the linear transition of the faint luster on the drug surface.
[0191] This is the base asymptotic expansion coefficient, used to control the limit of the dynamic self-increment of the base as the overflow increases; its value range is limited to [value range missing]. In this embodiment, the preferred value is... Because of the arctangent function There exists a strict mathematical asymptote (the maximum value is...). This means that no matter how harsh the environmental exposure (i.e.) The maximum value of the dynamic base will be physically locked at [value]. .Pick Then the absolute physical ceiling of the dynamic base is strictly limited to approximately Nearby. This ensures that under extreme direct sunlight and reflection, the logarithmic base can expand to close to 10 (providing anti-overflow suppression capability), and fundamentally avoids the formula output directly returning to zero due to an infinitely large base (i.e., the image turning from pure white to pure black in a reverse flip).
[0192] A scalar for adjusting overflow sensitivity, used to map overflow values of physical dimensions to a normalization factor within the linear response range of the arctangent function; the value range is limited to... In this embodiment, the preferred value is... In 8-bit space, the overflow of a single color channel. It could potentially have up to hundreds of color levels (e.g., exceeding 400). Arctangent function The sensitive surge region is concentrated in the independent variable at a certain point. Within the range. Introducing scalars. It can force the overflow of tens to hundreds of physical pixels to be mapped to the optimal mathematical response range of the arctangent function (e.g., This ensures that the computational substrate's expansion protection mechanism can be triggered with the most sensitive slope when moderate to heavy overexposure occurs.
[0193] This is the bias response gain, used for linear gain compensation to prevent logarithmic calculation failure when the input is extremely small; its value range is limited to... In this embodiment, the preferred value is... This parameter primarily affects the argument of the logarithm, compensating for excessive decay of principal characteristics that may result from extremely strong base inflation. When set... At that time, the formula essentially allows for native overflow bias data. (and add measures to prevent overflow and underflow) The constant is directly entered into the logical operation domain. This 1:1 lossless pass-through ensures that the attenuation and leveling characteristics of the final output maintain an absolutely monotonically increasing mapping relationship with the original illumination distortion, and will not cause topological disorder of the color level.
[0194] It is a composite base that is dynamically calculated and changes in real time with the overflow deviation data.
[0195] overflow deviation data Simultaneously, the proper and base sides of the logarithmic function are introduced: when the overflow deviation data spikes rapidly, not only does the logarithmic operation itself decay, but its computational basis also changes in the arctangent function. Driven by this, synchronous expansion occurs (the base increases). The larger the base, the stronger the suppression of the logarithmic function; the dual-linkage feedback mechanism formed by the above process ensures that no matter how out of control the hardware exposure noise is, the output attenuation leveling characteristics can be firmly kept within a safe mathematical range.
[0196] The composite function of arctangent and logarithm used in the above formula is continuously differentiable in the entire positive real number domain, with perfect mathematical smoothness. This ensures that when the machine performs pixel reconstruction, the highlight fading and color transition on the drug surface are more natural, perfectly preserving the spatial gradient characteristics of the micro-printed characters.
[0197] The formula cleverly incorporates the arctangent function. To drive base inflation. Because... exist Time has extremely strict mathematical asymptotes This means that the dynamic base can only expand to a maximum of [number missing]. It will never increase indefinitely, causing the formula to collapse directly (output tends to 0); this setting simulates the physical intrinsic phenomenon of photoelectric sensors being fully saturated with electron wells under extreme overexposure but still having slight discrimination.
[0198] Under normal, small overflow conditions, the arctangent function term Approaching zero, the formula maintains the smooth mapping base. Normal smooth compression is performed; however, when faced with extreme overexposure such as direct light at an emergency scene, causing an exponential explosion in overflow data, the overflow deviation data... This mechanism inherently drives the synchronous expansion of the computational base. This adaptively increasing base mechanism endows the logarithmic function with increasingly strong nonlinear suppression, forcibly softening and converging catastrophic specular distortion data into gentle incremental features while maintaining the algorithm's infinitely continuous differentiability across the entire domain (never producing color banding). This mechanism, from the very bottom of mathematical logic, completely eliminates the potential hidden danger of global drug texture annihilation caused by arithmetic overflow of a single color channel.
[0199] like Figure 3 As shown, this application discloses an image recognition-assisted emergency rescue system for children who have accidentally ingested suspected drugs. The system includes an image acquisition module, a region segmentation module, a region resolution module, an ambient light offset calculation module, a color correction module, a color restoration module, and a drug recognition and emergency rescue output module.
[0200] The image acquisition module is used to acquire original color images containing the drug entity area and the human skin area, and to acquire the corresponding camera exposure control parameters when acquiring the original color images;
[0201] The region segmentation module is used to divide the original color image into regions based on the pixel distribution characteristics in the original color image, so as to obtain the drug candidate region and the human skin reference region.
[0202] The region parsing module is used to extract the drug color features corresponding to the drug candidate region and the reference color features corresponding to the human skin reference region, respectively.
[0203] The ambient light offset calculation module is used to obtain preset human body standard color reference data and determine the ambient light offset parameters to characterize the degree of color offset of the current shooting environment based on the difference relationship between the reference color features and the human body standard color reference data for each color channel.
[0204] The color correction module is used to extract exposure response weights based on the exposure control parameters of the camera equipment, use the exposure response weights to perform scale correction on the ambient light offset parameters, and generate a dynamic color correction matrix.
[0205] The color restoration module is used to perform color compensation processing on the color features of the drug using a dynamic color correction matrix to obtain the true color features of the target drug.
[0206] The drug identification and emergency output module is used to match the real color features of the target drug with a preset drug color feature library to determine the identity of the target drug, and output the corresponding auxiliary emergency information based on the identity of the target drug.
[0207] The technical scope of this invention is not limited to the content described above. Those skilled in the art can make various modifications and variations to the above embodiments without departing from the technical concept of this invention, and all such modifications and variations should fall within the protection scope of this invention.
Claims
1. An image recognition-assisted first aid method for children who have accidentally ingested suspected drugs, characterized by: Includes the following steps: Acquire the original color image containing the drug entity area and the human skin area, and acquire the exposure control parameters of the camera device corresponding to the acquisition of the original color image; Based on the pixel distribution characteristics in the original color image, the original color image is divided into regions to obtain drug candidate regions and human skin reference regions; Extract the drug color features corresponding to the drug candidate region and the reference color features corresponding to the human skin reference region, respectively. Obtain preset human body standard color reference data, and determine the ambient light offset parameter to characterize the degree of color offset in the current shooting environment based on the difference relationship between the reference color features and the human body standard color reference data for each color channel. Based on the exposure control parameters of the camera device, the exposure response weights are extracted, and the ambient light offset parameters are scaled using the exposure response weights to generate a dynamic color correction matrix. The dynamic color correction matrix is used to perform color compensation processing on the drug color features to obtain the true color features of the target drug. The target drug's true color features are matched with a preset drug color feature library to determine the target drug's identity identifier, and corresponding auxiliary emergency information is output based on the target drug's identity identifier. The process of extracting the exposure response weights is as follows: Analyze the exposure control parameters of the camera device to separate the sensitivity parameter and the exposure time parameter; The photosensitivity parameter and the exposure time parameter are introduced into a preset association mapping table for composite retrieval to obtain a noise drift coefficient that matches the current exposure state. Calculate the ratio between the noise drift coefficient and the preset reference coefficient, and use the preset logarithmic mapping relationship to perform a scale conversion on the ratio to obtain the exposure response weight. The generation process of the dynamic color correction matrix is as follows: The ambient light offset parameter is resolved into independent component sequences corresponding to different reference color channels; An initial correction sequence is generated by performing a mapping product operation between the exposure response weights and each of the independent component sequences; Detect whether the values of each channel in the initial correction sequence exceed a preset correction boundary threshold; If it is determined that the value of a target channel exceeds the preset correction boundary threshold, then the value of the target channel is subjected to amplitude limiting and truncation processing to obtain the target chromaticity deviation sequence. According to the predetermined matrix dimensions, the target chromaticity deviation sequence is filled into the diagonal of the preset identity matrix, and the dynamic color correction matrix is output.
2. The image recognition-assisted first aid method for children accidentally ingesting suspected drugs according to claim 1, characterized in that: The process of obtaining the true color characteristics of the target drug is as follows: The color features of the drug are analyzed to obtain the chromaticity component and the edge gradient component, and the chromaticity component is converted into a color vector to be corrected with a predetermined dimension. The dynamic color correction matrix is multiplied with the color vector to be corrected to generate an intermediate feature vector. Extract the maximum value component from the intermediate feature vector and compare the maximum value component with a preset bit depth boundary threshold; If it is determined that the maximum value component is greater than the bit depth boundary threshold, then the dynamic scaling factor between the bit depth boundary threshold and the maximum value component is calculated; The target core chromaticity vector is obtained by performing element-wise product mapping on each dimension component of the intermediate feature vector using the dynamic scaling factor. If the maximum value component is determined to be less than or equal to the bit depth boundary threshold, then the intermediate feature vector is directly used as the target core chromaticity vector. The edge gradient components and the target core chromaticity vector are concatenated and recombined in a multidimensional vector to output the true color features of the target drug.
3. The image recognition-assisted first aid method for children accidentally ingesting suspected drugs according to claim 2, characterized in that: The calculation process for the dynamic scaling factor is as follows: The difference between the maximum value component and the bit depth boundary threshold is calculated to obtain the overflow deviation data; Using a preset smoothing mapping base as the calculation basis, a logarithmic decay operation is performed on the overflow deviation data to generate decay leveling features; The bit depth boundary threshold and the attenuation leveling feature are scalar summed to obtain the smoothed maximum component. Calculate the relative quotient between the bit depth boundary threshold and the smoothed maximum component, and determine the relative quotient as the dynamic scaling factor.
4. The image recognition-assisted first aid method for children accidentally ingesting suspected drugs according to claim 1, characterized in that: The process of dividing the drug candidate region and the human skin reference region is as follows: Extract the spatial distribution connectivity data of each pixel in the original color image and the preset initial color threshold; Based on the spatial distribution connectivity data and the initial color threshold, the foreground isolated connected domains are separated as the drug candidate regions; After filtering out the drug candidate region from the original color image, the connected regions in the remaining connected regions that meet the preset biological skin color threshold are marked as the human skin reference region.
5. The image recognition-assisted first aid method for children accidentally ingesting suspected drugs according to claim 1, characterized in that: The extraction process of the drug color feature is as follows: Identify the sequence of edge gradient extreme points within the drug candidate region, and based on the sequence of edge gradient extreme points, divide the drug candidate region into a central core region and an edge transition region; Extract the first color distribution tensor of the central core region and the second color distribution tensor of the edge transition region respectively; Assign a preset extraction weight greater than that of the second color distribution tensor to the first color distribution tensor, calculate the weighted features of the two and use them as the color features of the drug.
6. The image recognition-assisted first aid method for children accidentally ingesting suspected drugs according to claim 1, characterized in that: The process for extracting the reference color features is as follows: Multiple sets of local pixel block sequences are extracted within the human skin reference area, and the color statistical variance of each set of local pixel block sequences in each color channel is obtained; By filtering out local pixel block sequences whose color statistical variance is greater than a preset variance threshold, a stable reference pixel set is obtained; Extract the channel mean features of the stable reference pixel set in each color channel, and use the vector sequence formed by concatenating the channel mean features as the reference color features.
7. The image recognition-assisted first aid method for children accidentally ingesting suspected drugs according to claim 1, characterized in that: The process for determining the ambient light offset parameter is as follows: Align the reference color features with the high-dimensional tensor sequences corresponding to the human body standard color reference data; Calculate the relative offset ratio of the reference color feature to each reference color channel on the high-dimensional tensor sequence; The first predetermined number of the relative offset ratio is used as the effective offset parameter; The effective offset parameters corresponding to each reference color channel are spliced and merged to generate the ambient light offset parameters.
8. An image recognition-assisted emergency rescue system for children who have accidentally ingested suspected drugs, characterized in that: include: The image acquisition module is used to acquire original color images containing the drug entity area and the human skin area, and to acquire the exposure control parameters of the camera device corresponding to the acquisition of the original color images; The region segmentation module is used to divide the original color image into regions based on the pixel distribution characteristics in the original color image to obtain drug candidate regions and human skin reference regions. The region parsing module is used to extract the drug color features corresponding to the drug candidate region and the reference color features corresponding to the human skin reference region, respectively. An ambient light offset calculation module is used to acquire preset human body standard color reference data and determine ambient light offset parameters to characterize the degree of color offset in the current shooting environment based on the difference relationship between the reference color features and the human body standard color reference data for each color channel. The color correction module is used to extract exposure response weights based on the exposure control parameters of the camera device, use the exposure response weights to perform scale correction on the ambient light offset parameters, and generate a dynamic color correction matrix. The color restoration module is used to perform color compensation processing on the color features of the drug using the dynamic color correction matrix to obtain the true color features of the target drug. The drug identification and emergency output module is used to match the true color features of the target drug with a preset drug color feature library to determine the identity of the target drug, and output corresponding auxiliary emergency information according to the identity of the target drug. The process of extracting the exposure response weights is as follows: Analyze the exposure control parameters of the camera device to separate the sensitivity parameter and the exposure time parameter; The photosensitivity parameter and the exposure time parameter are introduced into a preset association mapping table for composite retrieval to obtain a noise drift coefficient that matches the current exposure state. Calculate the ratio between the noise drift coefficient and the preset reference coefficient, and use the preset logarithmic mapping relationship to perform a scale conversion on the ratio to obtain the exposure response weight. The generation process of the dynamic color correction matrix is as follows: The ambient light offset parameter is resolved into independent component sequences corresponding to different reference color channels; An initial correction sequence is generated by performing a mapping product operation between the exposure response weights and each of the independent component sequences; Detect whether the values of each channel in the initial correction sequence exceed a preset correction boundary threshold; If it is determined that the value of a target channel exceeds the preset correction boundary threshold, then the value of the target channel is subjected to amplitude limiting and truncation processing to obtain the target chromaticity deviation sequence. According to the predetermined matrix dimensions, the target chromaticity deviation sequence is filled into the diagonal of the preset identity matrix, and the dynamic color correction matrix is output.
Citation Information
Patent Citations
Portrait automatic exposure white balance correction method and system based on skin color statistics
CN110381303A