Solution color detection device and system thereof
Through the red positioning marking line and Euclidean distance comparison technology, the automated and structured detection of solution color is achieved, and the problems of strong artificial subjectivity and expensive equipment in the existing technology are solved, the accuracy and consistency of the detection are improved, and it is suitable for drug quality control.
Patent Information
- Application Number
- CN202510419739.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-07-18
Smart Images

Figure CN120334142A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of image processing and colorimetric detection, and particularly to a solution color detection device and system thereof. Background Art
[0002] In the current fields of pharmaceutical colorimetric detection and image recognition technologies, how to achieve intelligent recognition and automatic determination of solution colors has become an important technical issue in quality control, pharmaceutical detection, production supervision and other links. Traditional colorimetric methods generally rely on manual visual observation and visual comparison with reference to a standard colorimetric card or standard colorimetric solution. Although this method was relatively common in early detection means, its results highly depend on the operator's visual perception ability, such as factors like color vision normality, judgment experience, and lighting environment. This makes this method have significant deficiencies in terms of human subjectivity, repeatability, and stability. Especially in the context of the increasingly strict supervision of pharmaceutical quality at present, the method relying solely on manual judgment is increasingly difficult to meet the detection requirements of high precision and high consistency.
[0003] On the other hand, although there are professional colorimeters and colorimetric analysis devices on the market, such devices are expensive, have complex structures, usually require professional training before use, and their volume, operation process, and maintenance cost are not suitable for wide deployment in grass-roots drug inspection institutions or production workshops. In addition, traditional colorimetric instruments are highly sensitive to the sample shape, container material, and ambient light conditions. Once the sample form changes (such as liquid position, bottle body reflection, background stray light), it may cause unpredictable deviations in the results, further limiting the scope of application of such devices.
[0004] With the development of image processing and mobile terminal technologies, some studies have attempted to use smartphone cameras combined with image algorithms to achieve the recognition of solution colors. This colorimetric technology based on mobile device image recognition theoretically has advantages such as portability, low cost, and scalability, and is particularly suitable for rapid detection of drug solution colors by medical institutions, community pharmacies, and end users. However, existing image colorimetric technologies still have technical bottlenecks in multiple key links in practice and are difficult to meet actual detection requirements.
[0005] First of all, in terms of image acquisition, existing methods mostly rely on users to manually align and take pictures manually, lacking a unified acquisition environment and positioning device. Due to the different camera parameters, optical systems, and automatic exposure strategies of different devices, combined with changes in factors such as lighting environment, shooting angle, distance, and focus, there are huge differences in the color reproduction effect of the final image, resulting in difficult standardization of color recognition results. At the same time, many current solutions do not perform positioning recognition and image cropping for the multi-sample structure in the tray, and users need to manually mark or position the target area, increasing the operation complexity and also reducing the degree of automation.
[0006] Secondly, in terms of color feature extraction, most existing systems use the average RGB value of a certain area in the image as the color representation, but lack an effective area determination mechanism and anti-interference ability. If there are bubbles, reflections, background noise, or image noise on the solution surface, it is easy to cause the pixels in the extraction area to deviate from the true color distribution, affecting the accuracy of subsequent comparison. At the same time, due to the lack of image preprocessing (such as white balance correction, background removal, and standardized brightness) steps, the RGB data itself may be distorted, resulting in insufficient robustness in subsequent comparison.
[0007] In terms of color matching, although some methods attempt to introduce the Euclidean distance as a similarity criterion, they often simply calculate the distance between the RGB values to be measured and several standard RGB values, lacking functions such as RGB channel weighting, structured management of standard values, and joint modeling of hue and color level. At the same time, the sources of standard color data are diverse, the formats are not unified, and they are not bound or maintained with the database, lacking scalability and update capabilities. In large-scale color level recognition tasks, such "unstructured and non-systematic" comparison schemes are difficult to meet the industry requirements in terms of accuracy and practicality.
[0008] In terms of colorimetric result output, most existing systems only return the hue number or RGB difference of the comparison result, lacking the structural binding of the detection position and the visual expression of the image space. It is difficult for users to understand the "color deviation position", "abnormal area distribution", or "overall color level risk" through the system, which is not conducive to result interpretation and the expansion of usage scenarios. At the same time, the system cannot generate a structured colorimetric diagram, color level heat map, or abnormal risk level map based on the colorimetric data of multiple slots, restricting the application of such systems in more complex scenarios such as scientific research, teaching, and quality traceability.
[0009] In addition, in the actual detection process, most existing image colorimetric schemes rarely involve spatial modeling and multi-region fusion analysis. The colorimetric slots are regularly distributed in space, but traditional methods usually only perform single-point recognition, ignoring the correlation, change trend, and gradient information between detection structures. For example, if there is an obvious color level jump in a certain area of the colorimetric slot, it may imply detection abnormalities or sample configuration errors in that area. However, existing systems are difficult to capture and quantify such potential risks and do not have the ability to generate a "colorimetric risk map".
[0010] In terms of data structure and output, most current image colorimetric systems only support the return of image screenshots or pure text results, lacking a structured and parsable data format and not supporting batch export, system integration, or database update of the results. In industrial applications such as pharmaceutical production lines, laboratory management systems, and detection report generation platforms, a standardized and structured data output form is required to achieve functions such as automatic archiving, comparison of historical records, and auxiliary decision-making. Existing systems are significantly lacking in this regard.
[0011] Therefore, how to provide a solution color detection device and its system is an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0012] An object of the present invention is to provide a solution color detection device and its system. The present invention realizes automatic image cropping through a red positioning identification line, establishes color features by extracting the RGB channel means of the central pixels of the standard area and the area to be measured, and performs Euclidean distance comparison with a structured standard color feature library to automatically output the closest hue and color level labels. At the same time, the present invention constructs a slot space mapping relationship, uses a Gaussian weighted model to generate continuous hue maps, color level maps and risk response maps, and realizes the structured and visual output of detection results. The present invention has the advantages of simple structure, accurate recognition, high calculation efficiency, strong scalability, etc., and is particularly suitable for low-cost deployment and multi-sample colorimetric detection tasks of mobile devices, providing an innovative solution for intelligent colorimetric systems.
[0013] A solution color detection method according to an embodiment of the present invention includes the following steps:
[0014] S1. Collect an image of a tray loaded with a standard colorimetric solution through an image acquisition device to obtain standard image data;
[0015] S2. According to the red positioning identification line on the tray in the standard image data, extract the image area corresponding to each standard colorimetric bottle to obtain a standard area image set;
[0016] S3. For each image area in the standard area image set, extract the RGB channel values of the central pixel point and calculate the average value of the RGB channels to obtain standard RGB mean data;
[0017] S4. Associate the standard RGB mean data with the corresponding hue and color level, construct a standard color feature library, and save the standard color feature library to a local database;
[0018] S5. Place the solution to be measured in the specified detection slot of the tray, collect the image data to be measured through the image acquisition device, and extract the image area where the solution to be measured is located according to the red positioning identification line in the image data to be measured to obtain an image area to be measured;
[0019] S6. Extract the RGB channel values of the central pixel point from the image area to be measured, calculate the average value of the RGB channels to obtain the RGB mean data to be measured, and perform Euclidean distance comparison between the RGB mean data to be measured and each item of the standard RGB mean data in the standard color feature library to determine the standard RGB mean data with the smallest Euclidean distance;
[0020] S7. Output the hue and color level corresponding to the standard RGB mean data with the smallest Euclidean distance as the detection result, and save the detection result to the local record database.
[0021] Optionally, the S2 specifically includes:
[0022] S21. Perform differential enhancement processing on the red channel of the standard image data I to construct a red response map:
[0023]
[0024] where, I r is the red response map, x is the horizontal coordinate of the pixel point, y is the vertical coordinate of the pixel point, R(x, y) is the red channel pixel value of the original image at the pixel coordinate (x, y), G(x, y) is the green channel pixel value of the original image at the pixel coordinate (x, y), B(x, y) is the blue channel pixel value of the original image at the pixel coordinate (x, y), ∈ is the regularization term, and τ is the response threshold;
[0025] S22. Perform adaptive threshold segmentation and edge detection on the red response map, extract the contours of all high-response red regions, and obtain a contour set:
[0026] C = FindContours(Canny(Open(Close(I r *K c )*K o ), θ1, θ2));
[0027] where, C is the contour set, * is the convolution operation of the image and the structural element, K c , K o are the structural element kernels of the closing operation and the opening operation respectively, θ1, θ2 are the double threshold parameters of the Canny edge detection, Close(·) is the morphological closing operation, Open(·) is the morphological opening operation, Canny(·, θ1, θ2) is the edge detection operator, and FindContours(·) is the contour extraction function;
[0028] S23. Perform the minimum bounding quadrilateral fitting operation on each contour, extract its vertex set, and calculate the affine transformation matrix T i ;
[0029] S24. Perform an image transformation operation on the standard image data I and the affine transformation matrix T i to generate a standardized image region, and integrate all the standardized image regions to obtain the standard region image set I s .
[0030] Optionally, the S3 specifically includes:
[0031] S31. For each standard image region in the standard region image set I s ={I1, I2, …, I n}, extract the pixel sub-region P i at its central position;
[0032] S32. Represent each pixel point in the pixel sub-region as a three-dimensional color vector, the components of which are the pixel values of the pixel in the three channels of red, green, and blue respectively. The color information of each pixel point is composed of a column vector with a dimension of 3, forming the sampling pixel vector set V i of the i-th image region;
[0033] S33. Organize all the pixel points in the sampling pixel vector set V i in sequential order to construct a standard color data matrix M with 3 rows and i columns;
[0034] S34. Based on the standard color data matrix M i , jointly calculate the color mean vector and covariance matrix of the i-th image region to form a color statistical feature pair:
[0035]
[0036] where f i is the color statistical feature pair, μ i is the standard RGB mean vector, m is the total number of pixels in the color sampling region, i is the index number of the standard image region, j is the index number of the pixel point in the sampling region, p ij is the color vector of the j-th pixel point in the i-th image region, and T is the transpose operation of the matrix;
[0037] S35. Organize the standard RGB mean vectors corresponding to all the standard image regions in order to form a standard RGB mean data set D.
[0038] Optionally, the specific steps of S4 include:
[0039] S41. Based on the standard RGB mean data set D, bind each standard color mean vector μ i with the corresponding affine transformation matrix T i and color level label L i of its source image region to form a ternary association data record γ i ;
[0040] S42. Based on the ternary association data record γ i , the ternary association data record γ iEach triple in it is mapped to a structured color record data item, and all the record data items are summarized to form a structured color record set R;
[0041] S43. Based on the structured color record set R, construct a standard color feature index table Standard color feature index table It is defined that when any RGB mean vector to be compared is input, the system will search for the record item with the smallest Euclidean distance from this vector in the structured color record set, and return the hue label and color level label corresponding to this record item;
[0042] S44. The structured color record set R and the standard color feature index table are written into the local database to form a standard color feature library.
[0043] Optionally, the S6 specifically includes:
[0044] S61. Extract the red channel of the image to be measured from the image to be measured, and construct an enhanced gradient response map by calculating the sum of squares of the horizontal and vertical gradients:
[0045]
[0046] Among them, G' R is the enhanced gradient response map, R' is the red channel of the image to be measured, x is the horizontal coordinate of the pixel point, y is the vertical coordinate of the pixel point, and λ is the weighting coefficient;
[0047] S62. Perform contour extraction and morphological screening on the enhanced gradient response map to obtain a set of target contours, calculate the minimum circumscribed rectangle bounding box for each contour, and screen out the bounding box of the solution to be measured according to the area and aspect ratio threshold;
[0048] S63. Construct an affine transformation matrix, map the bounding box of the solution to be measured to the standard region template, and use this matrix to perform geometric alignment transformation on the original image to obtain the region of the image to be measured;
[0049] S64. Extract the central pixel window in the region of the image to be measured to form a set of pixels to be measured, and organize them into a color matrix to be measured;
[0050] S65. Calculate the RGB mean vector to be measured, the covariance matrix to be measured, and the weighted color intensity vector to be measured for the color matrix to be measured at the same time, and define it as the RGB mean data μ' to be measured;
[0051] S66. Perform weighted Euclidean distance calculation on the RGB mean data to be measured and each item of the standard RGB mean data in the standard color feature library:
[0052]
[0053] Among them, i * is the standard RGB mean data with the smallest Euclidean distance, μ' is the RGB mean vector to be measured, and μ i is the standard RGB mean vector, i is the number index of the standard image area, T is the transpose operation of the matrix, W is the weighting matrix, and argmin is the variable value corresponding to when the objective function obtains the minimum value.
[0054] Optionally, the S7 specifically includes:
[0055] S71. Based on the bounding box of the solution to be measured, calculate the geometric center coordinate point of the solution to be measured in the tray image and map it to the slot number in the standard template coordinate system. Based on the standard RGB mean data i with the smallest Euclidean distance * , construct a colorimetric space matching table M;
[0056] S72. According to the colorimetric space matching table M, construct a hue label function and a color level label function in the standard image coordinate domain:
[0057]
[0058] Among them, T is the hue label function, L is the color level label function, K is the total number of colorimetric slots, k is the slot index number, T k is the hue label matched by the k-th slot, and L k is the color level label matched by the k-th slot, x is the horizontal coordinate of the pixel point, y is the vertical coordinate of the pixel point, x k is the horizontal center coordinate of the k-th slot, and y k is the vertical center coordinate of the k-th slot, and σ is the spatial scale coefficient of the Gaussian kernel;
[0059] S73. Based on the hue label function, construct a hue change intensity map, and define a structured colorimetric risk response function:
[0060]
[0061] Among them, F is the colorimetric risk response function, α is the weighting coefficient of the color level factor, β is the weighting coefficient of the hue change factor, and L max is the maximum possible value of the standard color level, Ω is the image domain, and λ T is the hue self-response weighting coefficient;
[0062] S74. Map the hue label function, the color level label function, and the colorimetric risk response function to a pseudo-color image for output, generate corresponding: colorimetric structure diagram, color scale distribution diagram, and risk level diagram, and structurally bind the image results with the slot number, standard coordinates, and detection results, and save the results to the local record database.
[0063] A solution color detection device according to an embodiment of the present invention includes the following units:
[0064] An image acquisition unit, configured to collect images of a tray loaded with a standard colorimetric solution and a solution to be measured, and generate standard image data and to-be-measured image data including a plurality of slots;
[0065] A region positioning unit, configured to identify red positioning identification information in the image, and extract the image regions of the corresponding slots accordingly, to obtain a standard image region set and a to-be-measured image region respectively;
[0066] A color analysis unit, configured to perform statistical processing on the central pixel set of the extracted image region, construct an RGB mean vector, and extract color covariance features;
[0067] A color registration unit, configured to establish a mapping relationship between the standard RGB mean vector and the corresponding hue label and color level label, and generate a standard color record item;
[0068] A comparison and identification unit, configured to perform a weighted Euclidean distance comparison between the to-be-measured RGB mean vector and the standard color record item, and output the hue and color level information with the smallest matching degree as the detection result;
[0069] A position mapping unit, configured to associate the detection result with the slot center point in the tray image coordinate system, to achieve spatial binding of the slot numbers;
[0070] An image expression unit, configured to construct a colorimetric function model according to the detection label information, and generate a colorimetric image output corresponding to the tray structure, including a hue map, a color level map, and a risk map;
[0071] A data storage unit, configured to perform local persistent storage on the detection result, comparison data, image output file, and related information.
[0072] A solution color detection system according to an embodiment of the present invention includes the following modules:
[0073] An image acquisition module, configured to collect an image of a standard colorimetric solution tray and an image of a solution to be measured through a mobile phone camera, and obtain overall view image data including a plurality of colorimetric slots;
[0074] An image positioning and cropping module, configured to automatically identify the position of the image region according to the red identification line at the edge of the tray, crop and extract the slot image regions where the standard solution and the to-be-measured solution are located, and output a standard region image set and a to-be-measured region image;
[0075] A color feature extraction module, configured to extract the RGB channel values of a fixed number of pixel points at the central position of the image region, and calculate the mean of the RGB channels, and output standard RGB mean data and to-be-measured RGB mean data;
[0076] A standard color registration module, which is used to receive standard RGB mean data, bind hue labels and color level labels, construct a set of color triples, generate a structured color record set and save it to the local standard color feature library;
[0077] A color matching and determination module, which is used to receive the RGB mean data to be measured, compare it with all records in the standard color feature library by weighted Euclidean distance, determine the minimum distance index, and output the hue label and color level label of the matching item as the detection result;
[0078] A spatial position mapping module, which is used to map the center coordinates of the boundary box of the solution to be measured to the slot number in the standard tray coordinate system to construct a colorimetric space matching table;
[0079] A hue and color level distribution modeling module, which is used to construct a two-dimensional hue distribution function and a color level distribution function, and generate a hue map and a color level map by spatially diffusing each slot label;
[0080] A risk response function generation module, which is used to calculate the colorimetric risk response function by combining the color level distribution map and the hue gradient response map;
[0081] A structure diagram generation module, which is used to map the hue label function, the color level label function and the colorimetric risk response function to a pseudo-color image, output a colorimetric structure diagram, a color scale distribution diagram and a risk level diagram, and bind them with the slot number and coordinates to form structured image data;
[0082] A local data management module, which is used to save the standard color feature library, the detection history record, the structure image data and the user information;
[0083] A user interaction and prompt module, which is used to interact with the user on the App side, including registration guidance, detection process prompt, error feedback, and detection result display.
[0084] The beneficial effects of the present invention are:
[0085] The present invention can stably complete the automatic positioning and regional cropping of the solution tray image through a hardware device with a fixed structure and the red positioning identification line in the image acquisition area, effectively solving the problems of image skew, inaccurate framing and inconsistent acquisition area in the existing colorimetric detection process. Through the central area pixel mean extraction method, the system can stably obtain the RGB characteristics of each solution bottle area and avoid local interference caused by factors such as bubbles, reflections and color spots, thus significantly improving the stability and accuracy of color extraction. In the colorimetric matching link, the present invention introduces an Euclidean distance comparison mechanism based on a structured color feature library, which can automatically determine the closest standard hue and color level, replacing the subjective judgment of traditional manual visual colorimetry, and significantly improving the consistency and automation level of detection.
[0086] Furthermore, through the modeling of the color comparison slot space structure, the present invention binds the color matching results to specific slot numbers and image coordinates, realizes the fusion of colorimetric data and spatial information, and then constructs structured output results such as a hue distribution map, a color level map, and a risk response map. This two-dimensional image expression method not only improves the intuitiveness and interpretability of the detection results, but also helps users quickly identify potential color deviation areas and abnormal slots, providing a more visual-assisted decision-making basis for drug quality control, teaching demonstration, and experimental management. In addition, by constructing a standard RGB database, an image cropping template, and a unified shooting environment, the system is replicable and scalable, and supports rapid deployment to different detection scenarios.
[0087] The system of the present invention is simple in design, convenient to use, accurate in detection, and low in cost, and is particularly suitable for replacing manual operation for rapid colorimetric detection in scenarios lacking professional colorimeter equipment. The entire system realizes a complete process of "image acquisition - feature extraction - intelligent comparison - structure mapping - result output", and can support both mobile deployment and subsequent expansion capabilities such as white balance correction, exposure control, and HSV space analysis. Through the deep combination of hardware design and image algorithms, the present invention realizes a structural replacement of traditional colorimetric methods, and has broad application and promotion prospects and engineering practical value in the field of drug colorimetric detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] The drawings are used to provide a further understanding of the present invention, and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the present invention, and do not constitute a limitation to the present invention. In the drawings:
[0089] Figure 1 is the overall flowchart of a solution color detection method proposed by the present invention;
[0090] Figure 2 is the unit display diagram of a solution color detection device proposed by the present invention;
[0091] Figure 3 is the structural schematic diagram of a solution color detection system proposed by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0092] Now, the present invention will be further described in detail with reference to the drawings. These drawings are all simplified schematic diagrams, only showing the basic structure of the present invention in a schematic manner, so they only show the components related to the present invention.
[0093] Refer to Figure 1 , a solution color detection method, comprising the following steps:
[0094] S1. Collect the image of the tray loaded with the standard colorimetric solution through an image acquisition device to obtain standard image data;
[0095] S2. According to the red positioning identification line on the tray in the standard image data, extract the image area corresponding to each standard colorimetric bottle to obtain a standard area image set;
[0096] S3. For each image area in the standard area image set, extract the RGB channel values of the central pixel point and calculate the average value of the RGB channels to obtain standard RGB mean data;
[0097] S4. Associate the standard RGB mean data with the corresponding hue and color level, construct a standard color feature library, and save the standard color feature library to the local database;
[0098] S5. Place the solution to be tested in the specified detection slot of the tray, collect the image data to be tested through the image acquisition device, and extract the image area where the solution to be tested is located according to the red positioning identification line in the image data to be tested to obtain the image area to be tested;
[0099] S6. Extract the RGB channel values of the central pixel point from the image area to be tested, calculate the average value of the RGB channels to obtain the RGB mean data to be tested, and compare the RGB mean data to be tested with each item of the standard RGB mean data in the standard color feature library to determine the standard RGB mean data with the smallest Euclidean distance;
[0100] S7. Output the hue and color level corresponding to the standard RGB mean data with the smallest Euclidean distance as the detection result, and save the detection result to the local record database.
[0101] A solution color detection method provided by the present invention can significantly improve the automation degree and recognition accuracy of solution colorimetric detection. By using an image acquisition device to obtain the standard tray image, combined with the red positioning identification line, precise cropping of the standard colorimetric area is realized, ensuring that the extracted image areas are unified and standardized. The central pixel statistical strategy is adopted to calculate the RGB channel mean value, construct a stable color feature expression form, and structurally bind it with the preset hue and color level labels to generate a standard color feature library. For the image area to be tested, the same operations of positioning, cropping, and RGB mean value extraction are also performed, and compared with each item in the standard library through the weighted Euclidean distance to accurately match the most similar standard color. The system finally outputs the corresponding hue and color level labels, and completes the structured result recording and saving. Compared with the traditional manual visual judgment or unstructured image comparison method, the present invention has significant advantages such as simple operation, high calculation accuracy, flexible system deployment, and standardized recognition process, and is particularly suitable for mobile fast colorimetric detection, visual management of pharmaceutical solutions, and on-site quality control scenarios, and has broad prospects for engineering promotion and industrial application.
[0102] In this embodiment, S2 specifically includes:
[0103] S21. Perform differential enhancement processing on the red channel of the standard image data I to construct a red response map:
[0104]
[0105] where I r is the red response map, x is the horizontal coordinate of the pixel point, y is the vertical coordinate of the pixel point, R(x, y) is the red channel pixel value of the original image at the pixel coordinate (x, y), G(x, y) is the green channel pixel value of the original image at the pixel coordinate (x, y), B(x, y) is the blue channel pixel value of the original image at the pixel coordinate (x, y), ∈ is the regularization term, and τ is the response threshold;
[0106] S22. Perform adaptive threshold segmentation and edge detection on the red response map, extract the contours of all high-response red regions, and obtain a contour set:
[0107] C = FindContours(Canny(Open(Close(I r *K c )*K o ), θ1, θ2));
[0108] where C is the contour set, * is the convolution operation of the image and the structural element, K c , K o are the structural element kernels of the closing operation and the opening operation respectively, θ1, θ2 are the double threshold parameters of the Canny edge detection, Close(·) is the morphological closing operation, Open(·) is the morphological opening operation, Canny(·, θ1, θ2) is the edge detection operator, and FindContours(·) is the contour extraction function;
[0109] S23. Perform the minimum circumscribed quadrilateral fitting operation on each contour, extract its vertex set, and calculate the affine transformation matrix T i ;
[0110] S24. Perform an image transformation operation on the standard image data I and the affine transformation matrix T i to generate a standardized image region, and integrate all the standardized image regions to obtain the standard region image set I s .
[0111] In the process of positioning the colorimetric slot, the present invention introduces a method for constructing a red response map and affine geometric transformation, which significantly improves the automatic recognition accuracy of the red positioning identification line in the colorimetric tray image and the standardization ability of image area cropping. By performing differential enhancement processing on the red channel in the standard image data, combining a regularization term and a non-linear response function, a red response map with local saliency is generated. On this basis, adaptive threshold segmentation, edge detection, and morphological operator operations are applied to effectively extract the boundary contours of all high-response red regions and construct a contour set. For each candidate contour region, the minimum circumscribed quadrilateral fitting is performed, its vertex positions are extracted, and an affine transformation matrix is constructed to achieve geometric standard alignment processing of the colorimetric slot region in the image captured at any angle. After unified cropping of all standardized regions, a standard region image set is formed to ensure the spatial consistency and the robustness of pixel statistics in the subsequent color extraction and comparison processes. This method overcomes the dependence problems of traditional image cropping methods on angles, lighting, and shooting postures, and has the advantages of high automation, good image geometric stability, and accurate extraction of feature regions. It can provide high-quality basic image data support for standard color modeling and colorimetric region positioning in solution color detection.
[0112] In this embodiment, step S3 specifically includes:
[0113] S31. For each standard image region in the standard region image set I s ={I1, I2, …, I n}, extract the pixel sub-region P i at its central position;
[0114] S32. Represent each pixel point in the pixel sub-region as a three-dimensional color vector, whose components are the pixel values of the pixel in the red, green, and blue channels respectively. The color information of each pixel point is composed of a column vector with a dimension of 3, forming the sampling pixel vector set V i of the i-th image region;
[0115] S33. Organize all pixel points in the sampling pixel vector set V i in the order of their numbers, and construct a standard color data matrix M i with 3 rows and columns;
[0116] S34. Based on the standard color data matrix M i , jointly calculate the color mean vector and covariance matrix of the i-th image region, and form a color statistical feature pair:
[0117]
[0118] where f i is the color statistical feature pair, and μ iis the standard RGB mean vector, m is the total number of pixels in the color sampling area, i is the index number of the standard image area, j is the index number of the pixel in the sampling area, and p ij is the color vector of the j-th pixel in the i-th image area, and T is the transpose operation of the matrix;
[0119] S35. Compose the standard color mean vectors corresponding to all standard image areas in order to form a standard RGB mean data set D.
[0120] In the construction process of the standard color feature of the present invention, the central pixel sub-region modeling and matrix statistical method are introduced, effectively improving the accuracy and stability of color expression. By extracting the pixel blocks in the central area of the image, each pixel is represented as a three-dimensional color vector, and a standard color data matrix is constructed. On this basis, the color mean vector and covariance matrix are jointly calculated to form a complete color statistical feature pair. This method can comprehensively reflect the main color information and color distribution characteristics of the standard area, and enhance the robustness to local noise, uneven illumination and image deviation. The mean vectors of all standard image areas form a unified standard RGB mean data set, providing a reliable basis for subsequent comparison. The invention realizes the upgrade of color features from the pixel layer to the structure layer, and has the advantages of simple expression, strong anti-interference ability and good scalability, providing a solid foundation for the high-quality construction of the standard color feature library.
[0121] In this embodiment, the S4 specifically includes:
[0122] S41. Based on the standard RGB mean data set D, bind each standard color mean vector μ i with the affine transformation matrix T i corresponding to its source image area and the color level label L i to form a ternary association data record γ i ;
[0123] S42. Based on the ternary association data record γ i , map each triple in the ternary association data record γ i to a structured color record data item, and summarize all record data items to form a structured color record set R;
[0124] S43. Based on the structured color record set R, construct a standard color feature index table The standard color feature index table is defined as: when any RGB mean vector to be compared is input, the system will search for the record item with the smallest Euclidean distance from this vector in the structured color record set, and return the hue label and color level label corresponding to this record item;
[0125] S44. Write the structured color record set R and the standard color feature index table to the local database to form a standard color feature library.
[0126] In the management process of standard color features, the present invention introduces a ternary binding structure and an index matching mechanism, significantly improving the organization efficiency and comparison accuracy of standard color data. By binding each standard RGB mean vector with the affine transformation matrix and color level label of its source image, a complete ternary association record is formed, and it is uniformly mapped into a structured color record data item to form an indexable and extensible standard color record set. On this basis, a standard color feature index table is constructed to achieve the minimum Euclidean distance retrieval and matching between any input RGB vector and the structured color record set, and return the corresponding hue and color level label, greatly improving the accuracy and automation of colorimetric judgment. Finally, the index table and the record set are written to the local database to form a highly reliable standard color feature library, providing unified data support for color matching. This method has the advantages of complete structure, efficient retrieval, flexible management, etc., significantly improving the adaptability and engineering practical value of the color comparison system in complex scenarios.
[0127] In this embodiment, the S6 specifically includes:
[0128] S61. Extract the red channel of the image to be measured from the image data to be measured. By calculating the sum of the squares of the horizontal and vertical gradients, construct an enhanced gradient response map:
[0129]
[0130] where G' R is the enhanced gradient response map, R' is the red channel of the image to be measured, x is the horizontal coordinate of the pixel point, y is the vertical coordinate of the pixel point, and λ is the weighting coefficient;
[0131] S62. Perform contour extraction and morphological screening on the enhanced gradient response map to obtain a set of target contours. Calculate the minimum circumscribed rectangle bounding box for each contour, and screen out the bounding box of the solution to be measured according to the area and aspect ratio thresholds;
[0132] S63. Construct an affine transformation matrix to map the bounding box of the solution to be measured to the standard region template, and use this matrix to perform a geometric alignment transformation on the original image to obtain the region of the image to be measured;
[0133] S64. Extract the central pixel window in the region of the image to be measured to form a set of pixels to be measured, and organize them into a color matrix to be measured;
[0134] S65. Simultaneously calculate the mean RGB vector to be measured, the covariance matrix to be measured, and the weighted color intensity vector to be measured for the color matrix to be measured, and define them as the mean RGB data μ' to be measured;
[0135] S66. Calculate the weighted Euclidean distance between the RGB mean data to be measured and each standard RGB mean data in the standard color feature library:
[0136]
[0137] where i * is the standard RGB mean data with the smallest Euclidean distance, μ' is the RGB mean vector to be measured, μ i is the standard RGB mean vector, i is the index number of the standard image area, T is the transpose operation of the matrix, W is the weighted matrix, and argmin is the variable value corresponding to the minimum value of the objective function.
[0138] In the process of analyzing the image of the solution to be measured, the present invention introduces an enhanced red gradient response map and a weighted Euclidean distance matching algorithm, significantly improving the robustness and accuracy of solution boundary location and color matching. By extracting the red channel of the image to be measured and constructing a response map in combination with the sum of the squares of the horizontal and vertical gradients, a weighting coefficient is introduced to enhance the boundary sensitivity, and further combined with contour extraction and morphological constraints to accurately obtain the boundary box where the solution to be measured is located. After completing the regional geometric alignment through affine transformation, the central pixels are extracted in the standardized area to construct a color matrix, and the RGB mean vector, covariance matrix, and weighted color intensity vector are jointly calculated to form the complete RGB mean data to be measured. In the color comparison stage, a channel-weighted Euclidean distance measurement mechanism is adopted to perform matching calculations with all records in the standard color feature library, and finally the minimum distance matching item is determined as the output result. This method effectively overcomes the influence brought by image offset, noise interference, and solution morphology changes, and has the advantages of accurate positioning, stable features, and high matching accuracy, providing reliable support for intelligent colorimetric detection in complex environments on mobile devices.
[0139] In this embodiment, the S7 specifically includes:
[0140] S71. Based on the boundary box of the solution to be measured, calculate the geometric center coordinate point of the solution to be measured in the tray image and map it to the slot number in the standard template coordinate system. Based on the standard RGB mean data i * with the smallest Euclidean distance, construct a colorimetric space matching table M;
[0141] S72. According to the colorimetric space matching table M, construct a hue label function and a color level label function in the standard image coordinate domain:
[0142]
[0143] where T is the hue label function, L is the color level label function, K is the total number of colorimetric slots, k is the slot index number, T kThe hue label matched for the k-th slot, L k The color level label matched for the k-th slot, x is the horizontal coordinate of the pixel, y is the vertical coordinate of the pixel, x k The horizontal center coordinate of the k-th slot, y k The vertical center coordinate of the k-th slot, σ is the spatial scale coefficient of the Gaussian kernel;
[0144] S73. Construct a hue change intensity map based on the hue label function. Define a structured colorimetric risk response function:
[0145]
[0146] where F is the colorimetric risk response function, α is the weighting coefficient of the color level factor, β is the weighting coefficient of the hue change factor, L max is the maximum possible value of the standard color level, Ω is the image domain, λ T is the hue self-response weighting coefficient;
[0147] S74. Map the hue label function, color level label function and colorimetric risk response function to a pseudo-color image for output, and generate the corresponding colorimetric structure diagram, color scale distribution diagram and risk level diagram. Structurally bind the image results with the slot number, standard coordinates and detection results, and save the results to the local record database.
[0148] In the process of colorimetric result modeling and visualization expression, the present invention introduces a spatial matching mapping mechanism and a functional risk modeling method, which significantly improves the expression level of the detection results and the image interpretation ability. By calculating the mapping relationship between the geometric center coordinates based on the boundary box to be measured and the standard template, a colorimetric space matching table is constructed, and the hue and color level labels corresponding to the item with the minimum Euclidean distance match are bound to the specific slot. On this basis, continuous hue label functions and color level label functions are constructed, and the Gaussian kernel is used to perform spatial diffusion modeling on the slot labels to realize the functional expression of the colorimetric labels in the image coordinate domain. Further, a hue gradient change response and a color level intensity weighting mechanism are introduced to construct a structured colorimetric risk response function to realize the joint characterization of color change and risk factors. Finally, the colorimetric function is mapped to a pseudo-color image, and the colorimetric structure diagram, color scale distribution diagram and risk level diagram are output, and are structurally bound and saved with the slot coordinates, numbers and label information. This method effectively breaks through the limitation that the traditional detection results are limited to numerical or single-label output, realizes the atlas-level expression and spatial distribution visualization of the color recognition results, and provides high-dimensional support for the comprehensive application of solution detection in multiple scenarios such as display, analysis and comparison.
[0149] Reference Figure 2 , a solution color detection device, includes the following units:
[0150] An image acquisition unit for collecting images of a tray loaded with a standard colorimetric solution and a solution to be measured, and generating standard image data and to-be-measured image data including multiple slots;
[0151] A region positioning unit for identifying red positioning identification information in the image, and extracting the image regions of the corresponding slots accordingly, to obtain a standard image region set and a to-be-measured image region respectively;
[0152] A color analysis unit for performing statistical processing on the central pixel set of the extracted image region, constructing an RGB mean vector, and extracting color covariance features;
[0153] A color registration unit for establishing a mapping relationship between the standard RGB mean vector and the corresponding hue label and color level label, and generating a standard color record item;
[0154] A comparison and identification unit for performing a weighted Euclidean distance comparison between the to-be-measured RGB mean vector and the standard color record item, and outputting the hue and color level information with the minimum matching degree as the detection result;
[0155] A position mapping unit for associating the detection result with the slot center point in the tray image coordinate system to achieve spatial binding of the slot numbers;
[0156] An image expression unit for constructing a colorimetric function model according to the detection label information and generating a colorimetric image output corresponding to the tray structure, including a hue map, a color level map and a risk map;
[0157] A data storage unit for locally and persistently saving the detection result, comparison data, image output file and related information.
[0158] A solution color detection device provided by the present invention constructs a closed-loop colorimetric detection process from image acquisition, color extraction to result output by integrating an image acquisition unit, a region positioning unit, a color analysis unit, a comparison and recognition unit, and an image expression and data storage function module, so as to comprehensively realize the automatic recognition and structured presentation of the solution color. The image acquisition unit takes pictures of the standard tray based on the mobile phone camera or an external imaging module, and automatically generates standard and to-be-tested image data; the region positioning unit realizes the automatic extraction of multi-slot regions through the red positioning identification line to ensure the consistency of image input; the color analysis unit performs statistical modeling on the central pixel region, extracts the RGB mean value and covariance features, and enhances the robustness of color expression; the comparison and recognition unit quickly completes the label matching of hue and color level based on the weighted Euclidean distance algorithm; the image expression unit combines colorimetric function modeling to output a color scale map and a risk map, improving the interpretability and visualization level of the results; the data storage unit supports the local archiving of all detection records, facilitating traceability and system integration. Compared with the traditional naked-eye comparison or high-cost colorimeter detection methods, this device has the advantages of convenient operation, fast calculation, stable detection, and controllable cost. It is especially suitable for deployment on mobile devices, in pharmaceutical testing laboratories or on-site liquid quality control sites, and can effectively improve the efficiency and standardization level of colorimetric detection, providing reliable support for daily detection and data management.
[0159] Reference Figure 3 , a solution color detection system, includes the following modules:
[0160] An image acquisition module, which is used to collect images of a standard colorimetric solution tray and a to-be-tested solution through a mobile phone camera, and obtain overall view image data including multiple colorimetric slots;
[0161] An image positioning and cropping module, which is used to automatically identify the position of the image area according to the red identification line on the tray edge, crop and extract the slot image areas where the standard solution and the to-be-tested solution are located, and output a standard area image set and a to-be-tested area image;
[0162] A color feature extraction module, which is used to extract the RGB channel values of a fixed number of pixel points at the central position of the image area, and calculate the mean value of the RGB channels, and output standard RGB mean value data and to-be-tested RGB mean value data;
[0163] A standard color registration module, which is used to receive the standard RGB mean value data, bind hue labels and color level labels, construct a set of color triples, generate a structured color record set and save it to the local standard color feature library;
[0164] A color matching and determination module, which is used to receive the to-be-tested RGB mean value data, perform a weighted Euclidean distance comparison with all records in the standard color feature library, determine the minimum distance index, and output the hue label and color level label of the matching item as the detection result;
[0165] A spatial position mapping module, which is used to map the center coordinates of the boundary box of the solution to be measured to the slot number in the standard tray coordinate system, and construct a colorimetric space matching table;
[0166] A hue and color level distribution modeling module, which is used to construct a two-dimensional hue distribution function and a color level distribution function, and generate a hue map and a color level map by performing spatial diffusion on each slot label;
[0167] A risk response function generation module, which is used to calculate a colorimetric risk response function by combining the color level distribution map and the hue gradient response map;
[0168] A structure diagram generation module, which is used to map the hue label function, the color level label function and the colorimetric risk response function to a pseudo-color image, output a colorimetric structure diagram, a color scale distribution diagram and a risk level diagram, and bind them with the slot number and coordinates to form structured image data;
[0169] A local data management module, which is used to save the standard color feature library, the detection history record, the structure image data and the user information;
[0170] A user interaction and prompt module, which is used to interact with the user on the App side, including registration guidance, detection process prompt, error feedback, and detection result display.
[0171] A solution color detection system provided by the present invention realizes automatic recognition, spatial mapping and structured visualization expression of the solution color by constructing an integrated system architecture of "acquisition - positioning - extraction - comparison - modeling - output". The system uses an image acquisition module to obtain images of the standard colorimetric tray and the solution to be measured, ensuring the real-time performance and consistency of the detection data; the image positioning and cropping module combines the red identification line for automatic image area positioning and accurately extracts the image area of each colorimetric slot; the color feature extraction module outputs robust RGB color features based on central pixel extraction and mean calculation. The system constructs a structured color feature library through the standard color registration module, and realizes high-precision hue and color level recognition based on the weighted Euclidean distance through the color matching and determination module. Further combining the spatial position mapping module and the diffusion modeling module, the system can generate a hue map, a color level map and a colorimetric risk response map, improving the intuitiveness and depth of the result expression. The structure diagram generation module realizes the visual output at the atlas level, and the results are simultaneously written into the local data management module for easy user call and historical traceability. The system guides the operation and displays the detection results on the App side through the user interaction module, realizing a complete closed loop of the detection process. The present invention effectively solves the problems of traditional manual colorimetry such as non-standardization, high equipment cost, and inability to process in batches, and has the advantages of simple operation, high precision, low cost, and strong adaptability, and is applicable to various scenarios such as drug quality detection, experimental teaching, and portable on-site detection.
[0172] Example 1:
[0173] To verify the feasibility of the present invention in implementation, the present invention was applied to a rapid drug quality detection project carried out by a provincial drug inspection and research institute in December 2024. The purpose of this project was to conduct a consistency detection of the solution color of a batch of vitamin B6 injection samples provided by a pharmaceutical factory. A total of 83 batches of samples were involved, and the detection objective was to determine whether they met the specified colorimetric standards to ensure that the appearance quality of the drugs met the requirements for market circulation.
[0174] In this project, the detection environment was selected in a laboratory standard lighting space, and the portable solution color detection device and the supporting App system proposed by the present invention were used. The detection equipment included a metal light-shielding box (26×26×18 cm), a standard colorimetric tray, a 30W adjustable LED lamp (color temperature 4000K), and a mobile phone as an image acquisition terminal. First, 66 standard colorimetric solutions (6 hues × 11 color levels for each hue) provided by the official were used for registration. One image was collected for each hue separately, with a total of 6 photos. The system automatically identified the red positioning line, cropped the images of 11 slot areas, extracted the central 200 pixel points, calculated the RGB mean value, formed a standard color feature library, and stored it locally.
[0175] In the formal detection stage, the staff placed the solution to be detected in the central slot of the tray, used the App to take an image and automatically identify the area. After the system extracted the central color features, it executed the Euclidean distance comparison algorithm, matched the closest hue and color level labels from the standard library, and the results were displayed in real time on the App interface and saved into the detection record form.
[0176] In terms of operation convenience, the detection time for each sample was about 8 seconds on average. Compared with the traditional manual colorimetry, which took about 35 seconds per sample on average, the efficiency of this system was increased by more than 4 times. In terms of consistency, the detection results were compared and verified with a professional colorimeter (Minolta CR-400). Among the 83 batches, 78 batches had exactly the same matched hue, and the color level deviation was controlled within ±1 level, with a matching rate of 93.98%. Further, a satisfaction survey was conducted on the operators. 4 out of 5 inspectors said that "the operation is simple and the automatic recognition is accurate", and 1 person feedback that "a schematic diagram prompt can be added to the hue interface".
[0177] Especially in dealing with typical problems of manual colorimetry, the system showed significant advantages. For example, in a sample numbered B6-20241235, the manual judgment was "orange-yellow level 5", while the system matched it as "orange-yellow level 4". After subsequent confirmation by professional instruments, the actual color level of this sample was 4.3, further verifying that the system output was closer to the objective color information.
[0178] During this implementation, some room for device optimization was also found. For example, when the ambient light is strong (the upper cover is not closed), the recognition accuracy decreases slightly, indicating that the subsequent version needs to introduce an automatic exposure control and an ambient light sensing module.
[0179] Table 1 Data table of on-site test results of the intelligent solution color detection system
[0180]
[0181]
[0182] Based on this embodiment, it can be seen that the solution color detection system proposed by the present invention effectively solves the problems of subjective misjudgment, low detection efficiency, and poor standardization existing in traditional colorimetric methods. It has the advantages of simple structure, low cost, strong result consistency, and high automation degree, and can be widely applied in scenarios such as drug quality inspection, teaching training, and rapid screening.
[0183] The experimental results show that with the support of the solution color detection system proposed by the present invention based on the RGB color mean extraction and weighted Euclidean distance comparison algorithm, both the accuracy and efficiency of solution colorimetric detection have been significantly improved. Taking the sampling task of the appearance quality of vitamin B6 injection carried out by the Shandong Institute for Drug Control in December 2024 as the application scenario, this system was used for the color consistency determination of 83 batches of samples, effectively replacing the traditional manual visual inspection and high-cost colorimeter detection.
[0184] In the experiment, the testers first used this system to complete the registration and database building of 66 standard colorimetric solutions. On average, 1 image was collected for each color tone and 11 color levels were extracted, generating a total of 396 structured color record items. In the detection stage, the staff sequentially placed the solution to be tested into the designated slots of the tray, used a mobile phone to collect images, and the system automatically identified the area. After extracting the RGB data of the central pixel, it was compared with the standard library. The average detection time per batch was 8.1 seconds, saving about 75% or more time compared to manual comparison, greatly improving the detection efficiency.
[0185] In terms of recognition accuracy, the color tone and color level output by the system are highly consistent with the results of the professional colorimeter CR-400. Among the 83 batches, 78 batches have the same color tone, and the color level deviation is controlled within ±1 level, with an overall accuracy rate of 93.98%. For example, for the sample of batch B6-20241235, the system determined it as orange-yellow level 4, the manual judgment was level 5, and the instrument detection was 4.3 levels. The system result is closer to the true value. It can be seen that the system has significant advantages in subjective color difference control.
[0186] In addition, the system also generates a color scale distribution map and a colorimetric risk map, visually annotating the edge abnormal areas, which improves the interpretability of the results. User feedback also shows that the system is easy to operate and has stable recognition, and is suitable for the daily detection scenarios of drug testing laboratories. In summary, the present invention significantly improves the efficiency and objectivity of colorimetric detection, providing an efficient and intelligent solution for the quality control of drug appearance.
[0187] The above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution and inventive concept of the present invention, making equivalent replacements or changes, should be covered within the protection scope of the present invention.
Claims
1. A method for detecting the color of a solution, characterized in that, It includes the following steps: S1. Collect the image of the tray loaded with the standard colorimetric solution through an image acquisition device to obtain standard image data; S2. According to the red positioning identification lines on the tray in the standard image data, extract the image area corresponding to each standard colorimetric bottle to obtain a standard area image set; S3. For each image area in the standard area image set, extract the RGB channel values of the central pixel point and calculate the average value of the RGB channels to obtain standard RGB mean data; S4. Associate the standard RGB mean data with the corresponding hue and color level, construct a standard color feature library, and save the standard color feature library to the local database; S5. Place the solution to be tested in the specified detection slot of the tray, collect the image data to be tested through the image acquisition device, and extract the image area where the solution to be tested is located according to the red positioning identification lines in the image data to be tested to obtain the image area to be tested; S6. Extract the RGB channel values of the central pixel point from the image area to be tested, calculate the average value of the RGB channels to obtain the RGB mean data to be tested, and perform an Euclidean distance comparison between the RGB mean data to be tested and each item of the standard RGB mean data in the standard color feature library to determine the standard RGB mean data with the minimum Euclidean distance; S7. Output the hue and color level corresponding to the standard RGB mean data with the minimum Euclidean distance as the detection result, and save the detection result to the local record database; 2. The method for detecting the color of a solution according to claim 1, wherein The specific content of S2 includes: S21. Perform differential enhancement processing on the red channel of the standard image data I to construct a red response map; Among them, I r is the red response map, x is the horizontal coordinate of the pixel point, y is the vertical coordinate of the pixel point, R(x, y) is the red channel pixel value of the original image at the pixel coordinates (x, y), G(x, y) is the green channel pixel value of the original image at the pixel coordinates (x, y), B(x, y) is the blue channel pixel value of the original image at the pixel coordinates (x, y), ∈ is the regularization term, and τ is the response threshold; S22. Perform adaptive threshold segmentation and edge detection on the red response map, and extract the contours of all high-response red areas to obtain a contour set; C = FindContours(Canny(Open(Close(I r *K c )*K o ), θ1, θ2)); Among them, C is a set of contours, * is the convolution operation between the image and the structural element, K c , K o are the structural element kernels of closing operation and opening operation respectively, θ1 and θ2 are the double threshold parameters of Canny edge detection, Close(·) is the morphological closing operation, Open(·) is the morphological opening operation, Canny(·, θ1, θ2) is the edge detection operator, and FindContours(·) is the contour extraction function; S23. Perform the minimum circumscribed quadrilateral fitting operation on each contour, extract its vertex set, and calculate the affine transformation matrix T i ; S24. Perform an image transformation operation on the standard image data I and the affine transformation matrix T i to generate a standardized image region, and integrate all the standardized image regions to obtain a standard region image set I s .
3. The method for detecting the color of a solution according to claim 1, characterized in that, The specific content of S3 includes: S31. For each standard image region in the standard region image set I s ={I1, I2, …, I n}, extract the pixel sub-region P i at its central position; S32. Represent each pixel point in the pixel sub-region as a three-dimensional color vector, the components of which are the pixel values of the pixel in the three channels of red, green, and blue respectively. The color information of each pixel point is composed of a column vector with a dimension of 3, forming the sampling pixel vector set V of the i-th image region i ; S33. Organize all pixel points in the sampled pixel vector set V i in the order of their numbers to construct a standard color data matrix M with 3 rows and 1 column i ; S34. Based on the standard color data matrix M i , jointly calculate the color mean vector and covariance matrix of the i-th image region to form a color statistical feature pair: where f i is the color statistical feature pair, μ i is the standard RGB mean vector, m is the total number of pixels in the color sampling area, i is the number index of the standard image area, j is the number index of the pixel point in the sampling area, p ij is the color vector of the j-th pixel point in the i-th image area, and T is the transpose operation of the matrix; S35. Organize the standard color mean vectors corresponding to all standard image areas in order to form a standard RGB mean data set D.
4. A method for detecting the color of a solution according to claim 1, characterized in that, The specific content of S4 includes: S41. Based on the standard RGB mean data set D, for each standard color mean vector μ i bind it with the affine transformation matrix T i corresponding to its source image region i and the color level label L i to form a ternary association data record γ S42. Record γ based on triple association data i , map each triple in the triple association data record γ i to a structured color record data item, and summarize all the record data items to form a structured color record set R; S43. Construct a standard color feature index table based on the structured color record set R Standard color feature index table It is defined that when any RGB mean vector to be compared is input, the system will search for the record item with the smallest Euclidean distance from this vector in the structured color record set and return the hue label and color level label corresponding to this record item; S44. Write the structured color record set R and the standard color feature index table into the local database to form a standard color feature library.
5. A method for detecting the color of a solution according to claim 1, characterized in that The specific content of S6 includes: S61. Extract the red channel of the image data to be tested from the image data to be tested, and construct an enhanced gradient response map by calculating the sum of the squares of the horizontal and vertical gradients; Among them, G' R is the enhanced gradient response map, R' is the red channel of the image to be measured, x is the horizontal coordinate of the pixel, y is the vertical coordinate of the pixel, and λ is the weighting coefficient; S62. Perform contour extraction and morphological screening on the enhanced gradient response map, obtain a target contour set, calculate the minimum circumscribed rectangle bounding box for each contour, and screen out the bounding box of the solution to be tested according to the area and width-to-height ratio threshold; S63. Construct an affine transformation matrix, map the bounding box of the solution to be tested to the standard area template, and use this matrix to perform a geometric alignment transformation on the original image to obtain the image area to be tested; S64. Extract the central pixel window in the image area to be tested to form a set of pixels to be tested, and organize it into a color matrix to be tested; S65. Calculate the RGB mean vector to be tested, the covariance matrix to be tested, and the weighted color intensity vector to be tested for the color matrix to be tested, and define them as the RGB mean data μ' to be tested; S66. Perform a weighted Euclidean distance calculation between the RGB mean data to be tested and each item of the standard RGB mean data in the standard color feature library; where i * is the standard RGB mean data with the smallest Euclidean distance, μ' is the RGB mean vector to be measured, and μ i is the standard RGB mean vector, i is the number index of the standard image area, T is the transpose operation of the matrix, W is the weighted matrix, and argmin is the variable value corresponding to the minimum value of the objective function.
6. The method for detecting the color of a solution according to claim 1, wherein, The specific content of S7 includes: S71. Calculate the geometric center coordinate point of the solution to be measured in the tray image based on the bounding box of the solution to be measured, map it to the slot number in the standard template coordinate system, and construct a colorimetric space matching table M based on the standard RGB mean data i with the minimum Euclidean distance. * , and construct a colorimetric space matching table M; S72. According to the colorimetric space matching table M, construct a hue label function and a color level label function in the standard image coordinate domain; Among them, T is the hue label function, L is the color level label function, K is the total number of colorimetric slots, k is the slot index number, and T k is the hue label matched by the k-th slot, and L k is the color level label matched by the k-th slot, x is the horizontal coordinate of the pixel point, y is the vertical coordinate of the pixel point, and x k is the horizontal center coordinate of the k-th slot, and y k is the vertical center coordinate of the k-th slot, and σ is the spatial scale coefficient of the Gaussian kernel; S73. Construct a hue change intensity map based on the hue label function, and define a structured colorimetric risk response function: where F is the colorimetric risk response function, α is the weighting coefficient of the color level factor, β is the weighting coefficient of the hue change factor, L max is the maximum possible value of the standard color level, Ω is the image domain, λ T is the self-response weighting coefficient of the hue; S74. Map the hue label function, color level label function, and colorimetric risk response function to a pseudo-color image output, generate corresponding colorimetric structure diagrams, color scale distribution diagrams, and risk level diagrams, and structurally bind the image results with the slot number, standard coordinates, and detection results, and save the results to the local record database.
7. A solution color detection device that executes a solution color detection method according to any one of claims 1 to 6, characterized in that, It includes the following units: An image acquisition unit for collecting images of the tray loaded with the standard colorimetric solution and the solution to be tested, generating standard image data and to-be-tested image data containing multiple slots; A region positioning unit for identifying the red positioning identification information in the image and extracting the image regions corresponding to the slots accordingly, obtaining a standard image region set and a to-be-tested image region respectively; A color analysis unit for statistically processing the central pixel set of the extracted image regions, constructing an RGB mean vector, and extracting color covariance features; A color registration unit for establishing a mapping relationship between the standard RGB mean vector and the corresponding hue label and color level label, and generating a standard color record item; A comparison and identification unit for performing a weighted Euclidean distance comparison between the to-be-tested RGB mean vector and the standard color record item, and outputting the hue and color level information with the minimum matching degree as the detection result; A position mapping unit for associating the detection result with the slot center point in the tray image coordinate system to achieve spatial binding of the slot number; An image expression unit for constructing a colorimetric function model according to the detection label information and generating a colorimetric image output corresponding to the tray structure, including a hue map, a color level map, and a risk map; A data storage unit for locally persistently saving the detection results, comparison data, image output files, and related information.
8. A solution color detection system that executes a solution color detection method according to any one of claims 1 to 6, characterized in that, It includes the following modules: An image acquisition module for collecting images of the standard colorimetric solution tray and the solution to be tested through a mobile phone camera, and obtaining overall view image data containing multiple colorimetric slots; An image positioning and cropping module for automatically identifying the position of the image region according to the red identification line at the edge of the tray, cropping and extracting the slot image regions where the standard solution and the to-be-tested solution are located, and outputting a standard region image set and a to-be-tested region image; A color feature extraction module for extracting the RGB channel values of a fixed number of pixel points at the central position of the image region and calculating the mean of the RGB channels, and outputting standard RGB mean data and to-be-tested RGB mean data; A standard color registration module for receiving the standard RGB mean data, binding the hue label and color level label, constructing a set of color triples, generating a structured color record set, and saving it to the local standard color feature library; A color matching and determination module for receiving the to-be-tested RGB mean data, performing a weighted Euclidean distance comparison with all records in the standard color feature library, determining the minimum distance index, and outputting the hue label and color level label of the matching item as the detection result; A spatial position mapping module for mapping the center coordinates of the boundary box of the to-be-tested solution to the slot number in the standard tray coordinate system to construct a colorimetric space matching table; The hue and color level distribution modeling module is used to construct a two-dimensional hue distribution function and a color level distribution function, and generate a hue map and a color level map by spatially diffusing each slot label; The risk response function generation module is used to calculate the colorimetric risk response function by combining the color level distribution map and the hue gradient response map; The structure diagram generation module is used to map the hue label function, the color level label function and the colorimetric risk response function into a pseudo-color image, output the colorimetric structure diagram, the color level distribution diagram and the risk level diagram, and bind them with the slot number and coordinates to form structured image data; The local data management module is used to save the standard color feature library, the detection history record, the structure image data and the user information; The user interaction and prompt module is used to interact with the user on the App side, including registration guidance, detection process prompt, error feedback, and detection result display.