Color constancy distribution matching intelligent identification system and method
Through standard color cards and color processing technology, the problem of color errors caused by equipment and lighting environment in biochemical reaction test paper color comparison is solved, the accuracy and applicability of test paper testing are improved, and more accurate color matching is achieved.
Patent Information
- Application Number
- CN202410711134.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, there are color errors caused by different shooting equipment and lighting environments in biochemical reaction test paper colorimetry, which limits the accuracy and applicability of the test paper test.
Using the standard color card as a reference, through device identification, color gamut conversion, color constancy processing and automatic white balance, combined with the Lab three-channel color gamut and KL divergence algorithm, the impact of the equipment and lighting environment on the test paper image is reduced, and the calculation is The color closest to the standard color card.
It greatly improves the colorimetric accuracy of biochemical reaction test paper, reduces the color difference caused by equipment and lighting environment, and enhances the reliability and applicability of test paper testing.
Smart Images

Figure CN118730302A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer image processing, and in particular to a color constancy distribution matching intelligent recognition system and method. Background Art
[0002] In recent years, with the advancement of science and technology and the development of society, biochemical reaction test paper colorimetric experiments have gradually moved from the professional field of professional laboratories to various production application tests in people's daily lives. In daily production and life, common test paper biochemical experiments include: urine test paper experiments, swimming pool water quality test paper experiments, pregnancy test paper experiments, HIV virus test paper experiments, etc. Compared with high-precision laboratory inspection and analysis, test paper tests have higher portability and timeliness, and are low-cost and more suitable for personal self-testing. For example, the water quality test of swimming pools has multiple indicators such as pH, urea, and free residual oxygen. If the samples are collected and brought back to the laboratory for monitoring and analysis item by item, it will consume a lot of time. With test paper testing, you only need to take a small amount of sample, put the test paper in for a few seconds, take it out and wait for about a minute to get the result by comparing the color. However, the accuracy of test paper testing is not as good as laboratory measurement, and there will be errors caused by the human eye and the environment.
[0003] The invention patent "A method for detecting and analyzing urine test strip mobile phone images" (application number: CN202210360996.1) discloses a method for detecting and analyzing urine test strip mobile phone images. The method first collects urine test strip JPEG images under a variety of light sources under a standard light source box, and takes the test strip image under the D65 light source as the standard image. The test strip images under other light source environments converge to the RGB color performance of the test strip block in the corresponding area of the test strip image under the standard light source, that is, the compensation model is trained and obtained. The model feature parameters fully consider the color characteristics of the test strip and the characteristics of the mobile phone camera. The features are pre-processed through maximum, minimum and variance analysis to ensure the accuracy of the color correction model. Multiple regression models are established and trained to optimize the color correction effect, and an enhanced compensation model is realized. The color of the test strip image is corrected by the compensation model to reduce the error caused by the ambient light affecting the color performance of the urine test strip image. However, the patent limits the shooting environment to a standard light source box, and does not consider the error caused by different shooting equipment. It is suitable for laboratory use and lacks applicability and adaptability in real scenes.
[0004] Therefore, technicians in this field are committed to developing a color constancy distribution matching intelligent recognition system and method. Summary of the invention
[0005] In view of the above-mentioned defects of the prior art, the technical problem to be solved by the present invention is how to reduce the error caused by different shooting equipment and different lighting environments in the colorimetry of biochemical reaction test strips.
[0006] The inventor analyzed the factors that affect color errors in the prior art, mainly the color difference caused by different shooting equipment, the color difference caused by light in different shooting environments, and the differences caused by different computer algorithms for matching colors. The inventor used a standard color card with different color blocks as a reference, and reduced the influence of the shooting equipment by identifying different shooting equipment; reduced the influence of light in the shooting environment through color constancy processing and automatic white balance (Auto White Balance) in image processing, so that the image presents its own color; obtained the Lab three-channel color gamut distribution through computer processing, and calculated the distribution distance to obtain the color closest to the standard color card.
[0007] In one embodiment of the present invention, a color constancy distribution matching intelligent recognition system is provided, comprising:
[0008] Comparative color card module, providing standard color card reference for color constancy processing;
[0009] The client module takes a photo of the biochemical reaction test paper placed at the specified position of the comparison color card module, sends it to the server module, and receives the color closest to the standard color card returned by the server for display;
[0010] The server module receives the photos sent by the client module, and performs device identification, color gamut conversion, color constancy processing, automatic white balance and distribution distance calculation to obtain the color closest to the standard color card and send it to the client module;
[0011] Communication module, used for communication between client module and server module;
[0012] The comparison color card module, the client module, the communication module, and the server module are connected in communication in sequence; the client module takes a photo of the biochemical reaction test paper placed at the specified position of the comparison color card module, and sends it to the server module through the communication module. In response to the photo sent by the client module, the server module performs device identification, color gamut conversion, color constancy processing, automatic white balance and distribution distance calculation to obtain the color closest to the standard color card, and sends it to the client module through the communication module for display.
[0013] Optionally, in the color constancy distribution matching intelligent recognition system in the above embodiment, the client module selects a smart phone.
[0014] Optionally, in the color constancy distribution matching intelligent recognition system in any of the above embodiments, the server module selects a computer.
[0015] Optionally, in the color constancy distribution matching intelligent recognition system in any of the above embodiments, the communication module adopts a RocketMQ queue model, and uses RocketMQ to deploy a remote procedure call protocol (RPC).
[0016] Optionally, in the color constancy distribution matching intelligent recognition system in any of the above embodiments, the server module includes:
[0017] The device identification submodule identifies the type of the client module and reduces the impact of the client module on color difference;
[0018] The color gamut conversion submodule converts the color gamut of the photos transmitted by the client module so that the server can process the image;
[0019] The color constancy submodule removes the influence of lighting on the color difference of photos through color constancy processing and automatic white balance processing;
[0020] The color block positioning and cropping submodule locates and crops color blocks in photos that have been processed for color constancy and automatic white balance. It uses grayscale and binarization algorithms to extract the edge areas of color blocks and obtain the coordinates of the four vertices of each color block.
[0021] The distribution distance calculation submodule extracts the distribution of the three Lab channels for the photos that have been positioned and cropped, and uses the KL divergence algorithm to calculate the distance to obtain the color closest to the standard color card; the Lab color gamut contains three channels, L, a, and b, and each channel represents a different attribute of the color;
[0022] The device identification submodule, color gamut conversion submodule, color constancy submodule, color block positioning and cropping submodule, and distribution distance calculation submodule are connected in communication in sequence. The device identification submodule receives photos sent by the mobile client, reduces the color difference after processing for different mobile devices, and sends them to the color gamut conversion module, converts the RGB color gamut image into three-dimensional color gamut information of HSV and Lab color gamut, and then sends it to the color constancy module to eliminate the influence of ambient light, and then sends it to the color block positioning and cropping submodule, outputs the position information of each color block in the color card, sends it to the distribution distance calculation module, and finally outputs the color closest to the standard color card.
[0023] Optionally, in the color constancy distribution matching intelligent recognition system in any of the above embodiments, the color gamut conversion includes: conversion from the RGB color gamut to the HSV color gamut and conversion from the RGB color gamut to the Lab color gamut.
[0024] Furthermore, in the color constancy distribution matching intelligent recognition system in the above embodiment, the algorithm used for converting from the RGB color gamut to the HSV color gamut is as follows:
[0025]
[0026] v=max
[0027] Among them, r, g, b represent the r channel data, g channel data, and b channel data in the RGB color gamut respectively, h, s, v represent the h channel data, s channel data, and v channel data in the HSV color gamut respectively, max represents the maximum value of r, g, and b, and min represents the minimum value of r, g, and b.
[0028] Furthermore, in the color constancy distribution matching intelligent recognition system in the above embodiment, the method of converting from the RGB color gamut to the Lab color gamut includes:
[0029] S1000, convert from RGB color gamut to XYZ color gamut, the formula is as follows:
[0030]
[0031] Among them, X, Y, Z represent the X channel data, Y channel data, and Z channel data in the XYZ color space, respectively; R, G, and B represent the R channel data, G channel data, and B channel data in the RGB color space, respectively;
[0032] S2000, convert from XYZ color gamut to Lab color gamut, the formula is as follows:
[0033]
[0034] Among them, X n ,Y n ,Z n are constants, X n =0.950456, Y n =1.0, Z n =1.088754, the L channel represents the brightness of the color, ranging from 0 to 100; the a channel represents the position of the color between red and green, ranging from -128 to 127; the b channel represents the position of the color between yellow and blue, ranging from -128 to 127.
[0035] Optionally, in the color constancy distribution matching intelligent recognition system in any of the above embodiments, the KL divergence algorithm formula is as follows:
[0036]
[0037] Where D(p||q) represents the KL divergence of the p distribution relative to the q distribution, and p(x) and q(x) represent the p distribution and q distribution of sample x, respectively.
[0038] Based on the above embodiment, in another embodiment of the present invention, a color constancy distribution matching intelligent recognition method is provided, comprising:
[0039] S100, taking a photo of the biochemical reaction test paper. The client module takes a photo of the biochemical reaction test paper placed at a designated position of the comparison color card module;
[0040] S200, photo sending, the client module sends the taken photos to the server module through the communication module;
[0041] S300, device identification, in response to the photo sent by the client module, the server module identifies the device type of the client module and removes the color difference generated by the client module on the photo;
[0042] S400, color gamut conversion, converts the color gamut of the photo without the influence of the device, including conversion from RGB color gamut to HSV color gamut and from RGB color gamut to Lab color gamut;
[0043] S500, color constancy processing, performs color constancy processing and automatic white balance on the photos after color gamut conversion to remove the influence of ambient light on color difference;
[0044] S600, vertex coordinate calculation, extracting the edge area of the color block through the grayscale algorithm and the binarization algorithm for the photo without the influence of ambient light, and obtaining the four vertex coordinates of each color block in the standard color card;
[0045] S700, distribution distance calculation, using KL divergence algorithm to calculate the distance and obtain the color closest to the standard color card;
[0046] S800, result display: the server module sends the color closest to the standard color card to the client module through the communication module for display.
[0047] Optionally, in the color constancy distribution matching intelligent recognition method in any of the above embodiments, step S700 includes:
[0048] S710, calculating the coordinates of the four vertices, using the grayscale algorithm and the binarization algorithm to extract the edge area of each color block, and obtaining the coordinates of the four vertices of each color block;
[0049] S720, calculating characteristic values, calculating the Lab three-color gamut distribution of each color block and a plurality of characteristic values of each color gamut;
[0050] S730, calculating the distribution distance, using the KL divergence algorithm to calculate the distance between the contrasting colors, the smaller the distance, the closer the contrasting colors are;
[0051] S740, calculating the color closest to the standard color card, and taking the color card color with the smallest distance between contrasting colors as the color closest to the standard color card.
[0052] Furthermore, in the color constancy distribution matching intelligent recognition method in the above embodiment, the KL divergence algorithm formula is as follows:
[0053]
[0054] The present invention reduces the color difference of different devices on the biochemical reaction test paper photos by identifying the device type of the client module, removes the color difference influence of the lighting environment on the biochemical reaction test paper through color constancy processing, and then obtains the color closest to the standard color card through distribution distance calculation, solves the problem of the influence of the device and the lighting environment on the color difference in the colorimetric identification of the biochemical reaction test paper, and greatly improves the accuracy of the colorimetric of the biochemical reaction test paper.
[0055] The concept, specific structure and technical effects of the present invention will be further described below in conjunction with the accompanying drawings to fully understand the purpose, characteristics and effects of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 is a structural diagram illustrating a color constancy distribution matching intelligent recognition system according to an exemplary embodiment;
[0057] Figure 2 is a flowchart illustrating a color constancy distribution matching intelligent recognition method according to an exemplary embodiment. DETAILED DESCRIPTION
[0058] The following describes several preferred embodiments of the present invention with reference to the drawings in the specification, so that the technical content is clearer and easier to understand. The present invention can be embodied in many different forms of embodiments, and the protection scope of the present invention is not limited to the embodiments mentioned in the text.
[0059] In the drawings, components with the same structure are indicated by the same numerical reference numerals, and components with similar structures or functions are indicated by similar numerical reference numerals. The size and thickness of each component shown in the drawings are arbitrarily shown, and the present invention does not limit the size and thickness of each component. In order to make the illustration clearer, the thickness of the components is schematically exaggerated in some places in the drawings.
[0060] The inventors have designed a color constancy distribution matching intelligent recognition system, such as Figure 1 As shown, including:
[0061] Comparative color card module, providing standard color card reference for color constancy processing;
[0062] The client module takes a photo of the biochemical reaction test paper placed at the specified position of the comparison color card module, sends it to the server module, and receives the color closest to the standard color card returned by the server for display. The client module selects a smart phone;
[0063] The server module receives the photos sent by the client module, and performs device identification, color gamut conversion, color constancy processing, automatic white balance and distribution distance calculation to obtain the color closest to the standard color card and send it to the client module. The server module selects the computer; including:
[0064] The device identification submodule identifies the type of the client module and reduces the impact of the client module on color difference;
[0065] The color gamut conversion submodule converts the color gamut of the photos transmitted by the client module so that the server can process the image;
[0066] The color constancy submodule removes the influence of lighting on the color difference of photos through color constancy processing and automatic white balance processing;
[0067] The color block positioning and cropping submodule locates and crops color blocks in photos that have been processed for color constancy and automatic white balance. It uses grayscale and binarization algorithms to extract the edge areas of color blocks and obtain the coordinates of the four vertices of each color block.
[0068] The distribution distance calculation submodule extracts the distribution of the three Lab channels for the photos that have been positioned and cropped, and uses the KL divergence algorithm to calculate the distance to obtain the color closest to the standard color card; the Lab color gamut contains three channels, L, a, and b, and each channel represents a different attribute of the color. The KL divergence algorithm formula is as follows:
[0069]
[0070] Where D(p||q) represents the KL divergence of p distribution relative to q distribution, p(x) and q(x) represent the p distribution and q distribution of sample x respectively;
[0071] The device identification submodule, the color gamut conversion submodule, the color constancy submodule, the color block positioning and cutting submodule, and the distribution distance calculation submodule are sequentially communicated and connected;
[0072] Color gamut conversion includes: conversion from RGB color gamut to HSV color gamut and conversion from RGB color gamut to Lab color gamut;
[0073] The algorithm used to convert from RGB color gamut to HSV color gamut is as follows:
[0074]
[0075] v=max
[0076] Among them, r, g, b represent the r channel data, g channel data, and b channel data in the RGB color domain, respectively; h, s, v represent the h channel data, s channel data, and v channel data in the HSV color domain, respectively; max represents the maximum value of r, g, and b; min represents the minimum value of r, g, and b;
[0077] The methods for converting from RGB color space to Lab color space include:
[0078] S1000, convert from RGB color gamut to XYZ color gamut, the formula is as follows:
[0079]
[0080] Among them, X, Y, Z represent the X channel data, Y channel data, and Z channel data in the XYZ color space, respectively; R, G, and B represent the R channel data, G channel data, and B channel data in the RGB color space, respectively;
[0081] S2000, convert from XYZ color gamut to Lab color gamut, the formula is as follows:
[0082]
[0083] Among them, X n ,Y n ,Z n are constants, X n =0.950456, Y n =1.0, Z n =1.088754, the L channel represents the brightness of the color, ranging from 0 to 100; the a channel represents the position of the color between red and green, ranging from -128 to 127; the b channel represents the position of the color between yellow and blue, ranging from -128 to 127.
[0084] The communication module is used for communication between the client module and the server module. The communication module adopts the RocketMQ queue model and uses RocketMQ to deploy the remote procedure call protocol (RPC);
[0085] The comparison color card module, the client module, the communication module, and the server module are connected in communication in sequence; the client module takes a photo of the biochemical reaction test paper placed at the specified position of the comparison color card module, and sends it to the server module through the communication module. In response to the photo sent by the client module, the server module performs device identification, color gamut conversion, color constancy processing, automatic white balance and distribution distance calculation to obtain the color closest to the standard color card, and sends it to the client module through the communication module for display.
[0086] Based on the above embodiments, the inventors have designed a color constancy distribution matching intelligent recognition method, such as Figure 2 As shown, including:
[0087] S100, taking a photo of the biochemical reaction test paper. The client module takes a photo of the biochemical reaction test paper placed at a designated position of the comparison color card module;
[0088] S200, photo sending, the client module sends the taken photos to the server module through the communication module;
[0089] S300, device identification, in response to the photo sent by the client module, the server module identifies the device type of the client module and removes the color difference generated by the client module on the photo;
[0090] S400, color gamut conversion, converts the color gamut of the photo without the influence of the device, including conversion from RGB color gamut to HSV color gamut and from RGB color gamut to Lab color gamut;
[0091] S500, color constancy processing, performs color constancy processing and automatic white balance on the photos after color gamut conversion to remove the influence of ambient light on color difference;
[0092] S600, vertex coordinate calculation, extracting the edge area of the color block through the grayscale algorithm and the binarization algorithm for the photo without the influence of ambient light, and obtaining the four vertex coordinates of each color block in the standard color card;
[0093] S700, distribution distance calculation, using KL divergence algorithm to calculate the distance and obtain the color closest to the standard color card, including:
[0094] S710, calculate the coordinates of the four vertices, and use the grayscale algorithm and the binarization algorithm to extract each vertex.
[0095] The edge area of the color block, obtains the coordinates of the four vertices of each color block;
[0096] S720, calculating characteristic values, calculating the Lab three-color gamut distribution of each color block and a plurality of characteristic values of each color gamut;
[0097] S730, calculate the distribution distance, use the KL divergence algorithm to calculate the distance between the contrasting colors, the smaller the distance, the closer the contrasting colors are, the KL divergence algorithm formula is as follows:
[0098]
[0099] S740, calculating the color closest to the standard color card, and taking the color card color with the smallest distance between contrasting colors as the color closest to the standard color card.
[0100] S800, result display: the server module sends the color closest to the standard color card to the client module through the communication module for display.
[0101] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A color constancy distribution matching intelligent recognition system, characterized in that: include: Comparative color card module, providing standard color card reference for color constancy processing; The client module takes a photo of the biochemical reaction test paper placed at the specified position of the comparison color card module, sends it to the server module, and receives the color closest to the standard color card returned by the server for display; The server module receives the photo sent by the client module, performs device identification, color gamut conversion, color constancy processing, automatic white balance and distribution distance calculation, obtains the color closest to the standard color card, and sends it to the client module; A communication module, used for communication between the client module and the server module; The contrast color card module, the client module, the communication module, and the server module are communicatively connected in sequence.
2. The color constancy distribution matching intelligent recognition system according to claim 1, characterized in that: The client module selects a smart phone.
3. The color constancy distribution matching intelligent recognition system according to claim 1, characterized in that: The communication module adopts the RocketMQ queue model and uses RocketMQ to deploy the remote procedure call protocol (RPC).
4. The color constancy distribution matching intelligent recognition system according to claim 1, characterized in that: The server module includes: A device identification submodule, which identifies the type of the client module and reduces the impact of the client module on color difference; A color gamut conversion submodule converts the color gamut of the photo transmitted by the client module so that the server can perform image processing; The color constancy submodule removes the influence of lighting on the color difference of photos through color constancy processing and automatic white balance processing; The color block positioning and cropping submodule locates and crops color blocks in photos that have been processed for color constancy and automatic white balance. It uses grayscale and binarization algorithms to extract the edge areas of color blocks and obtain the coordinates of the four vertices of each color block. The distribution distance calculation submodule extracts the distribution of the three Lab channels from the photos that have been positioned and cropped, and uses the KL divergence algorithm to calculate the distance to obtain the color that is closest to the standard color card. The device identification submodule, the color gamut conversion submodule, the color constancy submodule, the color block positioning and cutting submodule, and the distribution distance calculation submodule are communicatively connected in sequence.
5. The color constancy distribution matching intelligent recognition system according to claim 1, characterized in that: The color gamut conversion includes: converting from the RGB color gamut to the HSV color gamut and converting from the RGB color gamut to the Lab color gamut.
6. The color constancy distribution matching intelligent recognition system according to claim 5, characterized in that: The algorithm used to convert from RGB color gamut to HSV color gamut is as follows: v=max.
7. The color constancy distribution matching intelligent recognition system according to claim 5, characterized in that: The methods for converting from RGB color space to Lab color space include: S1000, convert from RGB color gamut to XYZ color gamut, the formula is as follows: S2000, convert from XYZ color gamut to Lab color gamut, the formula is as follows:
8. The color constancy distribution matching intelligent recognition system according to claim 4, characterized in that: The KL divergence algorithm formula is as follows:
9. A color constancy distribution matching intelligent recognition method, using the color constancy distribution matching intelligent recognition system as described in any one of claims 1 to 8, characterized in that: The steps include: S100, taking a photo of the biochemical reaction test paper, the client module taking a photo of the biochemical reaction test paper placed at a designated position of the comparison color card module; S200, sending photos, the client module sends the taken photos to the server module through the communication module; S300, device identification: in response to the photo sent by the client module, the server module identifies the device type of the client module and removes the color difference of the photo caused by the client module; S400, color gamut conversion, converts the color gamut of the photo without the influence of the device, including conversion from RGB color gamut to HSV color gamut and from RGB color gamut to Lab color gamut; S500, color constancy processing, performs color constancy processing and automatic white balance on the photos after color gamut conversion to remove the influence of ambient light on color difference; S600, vertex coordinate calculation, extracting the edge area of the color block through the grayscale algorithm and the binarization algorithm for the photo without the influence of ambient light, and obtaining the four vertex coordinates of each color block in the standard color card; S700, distribution distance calculation, using KL divergence algorithm to calculate the distance and obtain the color closest to the standard color card; S800, result display: the server module sends the color closest to the standard color card to the client module through the communication module for display.
10. The method according to claim 9, wherein: The step S700 includes: S710, calculating the coordinates of the four vertices, using the grayscale algorithm and the binarization algorithm to extract the edge area of each color block, and obtaining the coordinates of the four vertices of each color block; S720, calculating characteristic values, calculating the Lab three-color gamut distribution of each color block and a plurality of characteristic values of each color gamut; S730, calculating the distribution distance, using the KL divergence algorithm to calculate the distance between the contrasting colors, the smaller the distance, the closer the contrasting colors are; S740, calculating the color closest to the standard color card, and taking the color card color with the smallest distance between contrasting colors as the color closest to the standard color card.
