Color identification method and system for pH test paper detection
By obtaining standard color card data and processing pH test strip images, the problem of indistinguishable color difference in pH test strip detection is solved, the detection accuracy is improved, it is suitable for microcontroller applications, and the cost-effective pH test strip detection is achieved.
Patent Information
- Application Number
- CN202411647660.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2024-12-20
AI Technical Summary
In pH test strip testing, tiny color difference is difficult to accurately distinguish, ordinary cameras or sensors cannot provide sufficient resolution and color accuracy, and dirt, reflective substances and other interfering substances on the test strip affect the accuracy of color detection.
By obtaining standard color card data, defining the identification area, obtaining the position information of the pH test paper color block, and calculating the color information of the pH test paper color block based on the standard color card data, using white balance, mean filtering, grayscale processing, convolution processing and two-dimensional Value-based processing and other steps improve recognition accuracy.
It improves the color recognition accuracy of pH test strip detection, is suitable for color recognition based on microcontrollers, has a high cost performance and can measure pH more accurately.
Smart Images

Figure CN119169109A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a color recognition method and system for pH test paper detection. Background Art
[0002] In the color recognition of pH test paper detection, the color change of pH test paper may be very subtle and difficult to distinguish accurately. Minor color differences may lead to inaccurate measurements. Ordinary cameras or sensors may not provide sufficient resolution and color accuracy, affecting the accuracy of the test results. Different color models (such as RGB, HSV) represent colors differently, and conversion and interpretation may introduce errors.
[0003] Dirt, reflective materials or other interfering materials on the test paper may affect the accurate detection of color. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to provide a color recognition method and system for pH test paper detection.
[0005] The technical solution adopted by the present invention is: In one aspect, an embodiment of the present invention provides a color recognition method for pH test paper detection, the method comprising the following steps: Get standard color card data; Define the identification area; According to the identified area, obtaining the pH test paper color block position information; The pH test paper color block color information is obtained according to the pH test paper color block position information and the standard color card data.
[0006] Furthermore, the obtaining of standard color card data comprises the following steps: Collect standard color card images; Establishing the relationship information between color and pH value according to the standard color card image; According to the relationship information between the color and the pH value, standard color card data is obtained.
[0007] Furthermore, the defining of the identification area comprises the following steps: Get the original image of pH test paper; According to the original image of the pH test paper, an identification area is obtained.
[0008] Furthermore, the step of obtaining the pH test paper color block position information according to the identification area includes the following steps: Performing white balance processing on the original image of the pH test paper to obtain a first image; Performing mean filtering on the first picture to obtain a second picture; Performing grayscale processing on the second image to obtain a third image; Performing convolution processing on the third image to obtain a fourth image; Binarizing the fourth image to obtain a fifth image; The pH test paper color block position information is obtained according to the identification area and the fifth picture.
[0009] Further, obtaining the pH test paper color block color information according to the pH test paper color block position information and the standard color card data comprises the following steps: According to the pH test paper color block position information, the overlapping color blocks are removed to obtain the first color data; According to the first color data, remove the color block data at the detection edge to obtain second color data; According to the second color data, remove the color block data that does not meet the preset size to obtain third color data; sorting the third color data according to the coordinates to obtain fourth color data; Calculating an average RGB value of the fourth color data to obtain fifth color data; The pH test paper color block color information is obtained according to the fifth color data and the standard color card data.
[0010] Further, the calculating the average RGB value of the fourth color data to obtain the fifth color data comprises the following steps: According to the fourth color data, 64 groups of cache space are provided for each color block, data is accessed in the form of circular cache, and the standard deviation of the color block is calculated; The average RGB value of the fourth color data is calculated according to the standard deviation to obtain fifth color data.
[0011] Furthermore, the color recognition method for pH test paper detection also includes the following steps: Traverse the color information of the pH test paper color block to obtain each RGB data; The RGB data is measured to obtain a pH value.
[0012] On the other hand, an embodiment of the present invention further provides a color recognition system for pH test paper detection, the system comprising: The first module is used to obtain standard color card data; The second module is used to define the recognition area; The third module is used to obtain the pH test paper color block position information according to the identification area; The fourth module is used to obtain the color information of the pH test paper color block according to the pH test paper color block position information and the standard color card data.
[0013] On the other hand, an embodiment of the present invention also provides a color recognition device for pH test paper detection, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the color recognition method for pH test paper detection as described above is implemented.
[0014] On the other hand, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method described above.
[0015] The embodiments of the present application include at least the following beneficial effects: The present application provides a color recognition method and system for pH test paper detection. The present invention obtains standard color card data; defines a recognition area; obtains pH test paper color block position information according to the recognition area; obtains pH test paper color block color information according to the pH test paper color block position information and the standard color card data. The present invention can improve recognition accuracy, is more suitable for improving the accuracy of color recognition based on a single-chip microcomputer, and is cost-effective. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a flow chart of a color recognition method for pH test paper detection provided by an embodiment of the present invention; Figure 2 is a schematic diagram of an identification area for positioning identification provided by an embodiment of the present invention; Figure 3 is a schematic diagram of the positioning recognition after executing the white balance algorithm provided by an embodiment of the present invention; Figure 4 is a schematic diagram of the positioning identification after mean filtering is performed according to an embodiment of the present invention; Figure 5 is a schematic diagram of the positioning recognition after grayscale processing provided by an embodiment of the present invention; Figure 6 is a schematic diagram of the positioning recognition after performing the convolution operation provided by the embodiment of the present invention; Figure 7 is a schematic diagram of the binarization of the positioning identification provided by an embodiment of the present invention; Figure 8 is a schematic diagram of the positioning identification after setting the center point provided by an embodiment of the present invention; Fig. 9 is a schematic diagram of positioning identification provided by an embodiment of the present invention after removing smaller blocks; Fig.10is a schematic diagram of edge detection after positioning and identification provided by an embodiment of the present invention; Fig.11 is a schematic diagram of positioning identification including coordinate color information provided by an embodiment of the present invention; Fig.12 is a flow chart of a color recognition method for pH test paper detection provided by an embodiment of the present invention; Fig.13 is a schematic diagram of a color recognition system provided by an embodiment of the present invention; Fig.14 It is a schematic diagram of color calculation provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0018] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0019] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0021] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0022] 1) pH: The full name is "potential hydrogen", which is used to measure the concentration of hydrogen ions in a solution and is a measurement scale used to indicate the acidity or alkalinity of a solution.
[0023] 2) Roberts operator: It is an edge detection operator in image processing, used to identify edge features in images.
[0024] 3) KNN algorithm: KNN (K-Nearest Neighbors), KNN algorithm is a simple supervised learning method for classification and regression tasks.
[0025] 4) Grayworld white balance algorithm: is an image processing technique used to adjust the color balance of an image so that the gray areas in the image appear close to a true neutral gray.
[0026] 5) RGB: RGB represents the three basic colors of red, green and blue. The RGB color model is a widely used color representation method, mainly used in electronic display devices and digital image processing.
[0027] The present invention takes into account that in the field of pH test paper detection, the recognition accuracy can be improved by combining calculation with positioning recognition; standard color card comparison is provided in advance, and the pH is calculated by traversing the samples, which significantly improves the recognition accuracy compared with the method of relying on existing database comparison; compared with the neural network algorithm, the present invention is more suitable for improving the accuracy of color recognition based on a single-chip microcomputer, and has a high cost-effectiveness.
[0028] The embodiments of the present invention are further described below in conjunction with the accompanying drawings.
[0029] On the one hand, the embodiment of the present invention provides a color recognition method for pH test paper detection, specifically, referring to Figure 1 , the method comprises the following steps: S100, obtaining standard color card data; S200, defining an identification area; S300, obtaining pH test paper color block position information according to the identification area; S400, obtaining pH test paper color block color information according to pH test paper color block position information and standard color card data.
[0030] The embodiment of the present invention discloses step S100 of acquiring standard color card data, including the following steps: S110, collecting standard color card images; S120, establishing the relationship information between color and pH value according to the standard color card image; S130, obtaining standard color card data according to the relationship information between color and pH value.
[0031] As an optional implementation manner, step S100 of the embodiment of the present invention includes: Prepare standard color cards: Prepare standard color cards with known pH values and ensure that these color cards are consistent with the actual usage conditions under lighting conditions.
[0032] Photographing a standard color chart: Photographing a standard color chart with a high-resolution camera ensures clear images and even lighting.
[0033] Image processing: Perform white balance, denoising and color correction on the captured images to obtain accurate color information.
[0034] Data extraction: Extract the color data of each standard color card from the processed image, including RGB values and corresponding pH values.
[0035] Sample storage: Store the extracted color data and pH value into a database for subsequent comparison and analysis.
[0036] The embodiment of the present invention discloses that step S200 defines the identification area, including the following steps: S210, obtaining the original image of the pH test paper; S220, obtaining a recognition area according to the original image of the pH test paper.
[0037] As an optional implementation manner, step S200 of the embodiment of the present invention includes: Image acquisition: Acquire the image of the pH test paper to be tested from the camera.
[0038] Region localization: Locate the area of the test strip in the image through algorithms (such as edge detection) and define the bounding box of the area to be tested.
[0039] Area adjustment: Adjust the size and position of the bounding box according to the actual situation of the test paper to ensure that it covers all the color block areas to be tested.
[0040] Area confirmation: Ensure that the defined identification area is accurate and covers all the color blocks that need to be detected on the test paper.
[0041] The embodiment of the present invention discloses that step S300 obtains the pH test paper color block position information according to the identification area, including the following steps: S310, performing white balance processing on the original image of the pH test paper to obtain a first image; S320, performing mean filtering on the first image to obtain a second image; S330, performing grayscale processing on the second image to obtain a third image; S340, performing convolution processing on the third image to obtain a fourth image; S350, performing binarization processing on the fourth picture to obtain a fifth picture; S360: Obtain pH test paper color block position information according to the identification area and the fifth image.
[0042] As an optional implementation manner, step S300 of the embodiment of the present invention includes: Image preprocessing: Perform white balance and noise processing on the defined recognition area to improve the subsequent processing accuracy.
[0043] Color block detection: Use positioning recognition algorithms (such as center edge diffusion detection) to identify the position and edges of color blocks to ensure that the coordinates of each color block can be accurately found.
[0044] Position confirmation: Confirm the position of each color block and store the position information in a data structure to prepare for subsequent color information extraction.
[0045] The embodiment of the present invention discloses step S400 of obtaining the color information of the pH test paper color block according to the pH test paper color block position information and the standard color card data, including the following steps: S410, according to the pH test paper color block position information, remove the overlapping color blocks to obtain first color data; S420, removing the color block data at the detection edge according to the first color data to obtain second color data; S430, according to the second color data, removing the color block data that does not meet the preset size to obtain third color data; S440, sorting the third color data according to the coordinates to obtain fourth color data; S450, calculating an average RGB value of the fourth color data to obtain fifth color data; S460, obtaining pH test paper color block color information according to the fifth color data and the standard color card data.
[0046] As an optional implementation manner, step S400 of the embodiment of the present invention includes: Extract color data: Extract the average RGB value from the area of each color block, and obtain the average RGB value of this area by calculating the mean of a group of color data that are closest to each other.
[0047] Data comparison: The extracted RGB values are compared with the data in the standard color card database, and the closest pH value is determined using the KNN algorithm.
[0048] pH value calculation: Calculate the pH value of each color block on the test paper based on the comparison results and the color information of the standard color card.
[0049] Result return: The pH value and color information of each color block are sorted and returned for users to view and analyze.
[0050] In S410 of the embodiment of the present invention, overlapping color blocks are removed according to the color block position information of the pH test paper to obtain the first color data: 1. Obtain pH test paper color block position information: Extract all color block boundary coordinates and their corresponding color data from the color block coordinate information obtained in the previous step.
[0051] 2. Identify overlapping color blocks: Use overlap detection algorithms (such as calculating the intersection of color block boundaries) to identify those color blocks that overlap at the same location. Overlap detection can use different techniques, such as: Geometric overlap detection: Determine whether there is overlap by calculating the intersection of the color block bounding boxes.
[0052] Color consistency detection: Compare the colors of overlapping areas. If the colors are very close, it is considered that these color blocks may be the same.
[0053] 3. Clear overlapping color blocks: For the detected overlapping areas, retain a main color block (which can be selected based on the color mean or other criteria) and remove other overlapping color blocks. The final color block data is the "first color data".
[0054] In S420 of the embodiment of the present invention, the color block data at the detection edge is removed according to the first color data to obtain the second color data: 1. Edge detection: By judging whether the coordinate color of the first color data and the color of the surrounding area are similar, determine whether the color block is located at the edge of the detection area. Detecting the edge can help avoid errors caused by edge effects.
[0055] 2. Edge color block removal: Remove color blocks located at the edge based on the detected edge information. Usually, these color blocks may produce inaccurate color values because they are not completely covered in the target area.
[0056] Finally, the data obtained after the edge color blocks are removed from the first color data is the “second color data”.
[0057] In S430 of the embodiment of the present invention, the color block data that does not meet the preset size is removed according to the second color data to obtain the third color data: 1. Determine the preset size: Set the size range of the color block according to actual needs. For example, the width and height of the color block should be within a certain range to ensure the representativeness of the color block.
[0058] 2. Filter out color blocks that do not meet the size requirements: traverse the "second color data" and filter out those color blocks that do not meet the size requirements according to the preset size range. This can be done by calculating the area of each color block (such as width * height). After the filtering operation, the retained data is the "third color data".
[0059] In S440 of the embodiment of the present invention: the third color data is sorted according to the coordinates to obtain fourth color data: 1. Define the sorting criteria: Determine the sorting criteria, such as sorting by the coordinate position, size or color value of the color block. The sorting methods of the present invention are: Sort by coordinates: Sort all color blocks in ascending or descending order according to the center coordinates (x, y) of the color block.
[0060] Sort by color value: Sort by the average color value of the color blocks.
[0061] 2. Perform sorting operation: Sort the "third color data" according to the defined sorting criteria. Standard sorting algorithms such as quick sorting, merge sorting, etc. can be used. The overall data obtained after sorting is the "fourth color data".
[0062] In S450 of the embodiment of the present invention: average RGB values are calculated for the fourth color data to obtain fifth color data: 1. Calculate RGB values: For each pixel in a color block, calculate the average RGB value. By traversing the distance from each pixel to all other pixels, selecting the most concentrated part of the points as the typical value, and then calculating the average of this part of the points, color differences caused by uneven coloring can be effectively avoided.
[0063] 2. Use statistical methods: Use statistical methods such as standard deviation calculation to ensure the stability of RGB values. For the calculation process, the stability parameters of the final calculation results will be output. If the stability is poor, the subsequent processing will comprehensively determine whether to discard the re-measurement data. The data obtained after the statistics are completed is the "fifth color data".
[0064] In S460 of the embodiment of the present invention: according to the fifth color data and the standard color card data, the color information of the pH test paper color block is obtained: 1. Load standard color card data: Load standard color card data from storage, which includes the RGB value and corresponding pH value of each standard color.
[0065] 2. Color matching: Use a color matching algorithm (such as the KNN algorithm) to compare the RGB value of the "fifth color data" with the standard color card data. For the average RGB value of each color block, find the closest standard color and its corresponding pH value.
[0066] 3. Calculate pH value: Based on the color matching results, determine the pH value of each color block. This step includes calculating a distance metric (such as Euclidean distance) to select the closest standard color.
[0067] 4. Result output: Returns the color information of the pH test paper color blocks, including the position, color and corresponding pH value of each color block.
[0068] The embodiment of the present invention discloses that step S450 calculates the average RGB value of the fourth color data to obtain the fifth color data, including the following steps: S451, providing 64 groups of cache space for each color block according to the fourth color data, accessing data in the form of circular cache, and calculating the standard deviation of the color block; S452: Calculate the average RGB value of the fourth color data according to the standard deviation to obtain fifth color data.
[0069] In step S451 of the present invention, 64 groups of buffer space are provided for each color block according to the fourth color data, and data is accessed in the form of circular buffer to calculate the standard deviation of the color block: 1. Define cache space: Purpose: To provide enough buffer space for storing and processing color data for each color channel (red, green, blue) of the processed color block.
[0070] Operation: Each color block is allocated 64 groups of cache space. Here, "64 groups of cache space" can be understood as 64 independent storage units, each unit is used to store the color information of a color block. This cache space uses the form of circular cache, that is, data is updated in the cache space in a circular manner to facilitate the processing of different data blocks.
[0071] 2. Access data: Action: The fourth color data is stored in these buffer spaces in blocks. This means that as the color blocks are processed, the data is written to the buffer and can be accessed in a loop to calculate statistics.
[0072] 3. Calculate the standard deviation: Purpose: Standard deviation is used to measure the degree of dispersion of color data, that is, the range of color variation. A larger standard deviation indicates a larger color variation, and a smaller standard deviation indicates a smaller color variation.
[0073] operate: Data collection: Extract stored color data from the cache.
[0074] Calculation process: For each color channel (RGB) of a color patch, calculate the standard deviation of these color values. This involves the following steps: ① Calculate the average value of each color channel.
[0075] ②Calculate the deviation of each color value from the average value.
[0076] ③Square these deviations.
[0077] ④Find the average of these squared deviations.
[0078] ⑤ Take the square root of the mean to get the standard deviation.
[0079] In step S452 of the present invention, the average RGB value of the fourth color data is calculated according to the standard deviation to obtain the fifth color data: 1. Calculation based on standard deviation: Purpose: Using the standard deviation calculated in step S451, the color data of the color block is averaged. This can help smooth the color data and reduce errors due to noise or unevenness.
[0080] operate: Data Integration: Apply the calculated standard deviation to the fourth color data. The color data can be adjusted based on the standard deviation by weighted average. Color blocks with larger standard deviations receive more smoothing, while color blocks with smaller standard deviations remain the same.
[0081] 2. Calculate the average RGB value: operate: Data Extraction: Extracts adjusted color data from each patch.
[0082] Average calculation: For all color patches, calculate the average of their red, green, and blue channels. This will give the average RGB value for each color channel.
[0083] Generate fifth color data: Generate fifth color data according to the calculated average RGB value. This is optimized color data that can more accurately represent the overall color characteristics of the fourth color data.
[0084] The color recognition method for pH test paper detection disclosed in the embodiment of the present invention further includes the following steps: S500, traverse the color information of the pH test paper color block to obtain each RGB data; S600: Calculate the RGB data to obtain a pH value.
[0085] As an optional implementation manner, the embodiment of the present invention includes: S1. Sampling In addition to the conventional sampling operation, the data collection of the standard color card to be compared in S4 can be increased.
[0086] S2. Positioning and identification (single time is about 10ms) Center edge diffusion detection is to diffuse from the center point to the surrounding areas (spiral outward) to find the edges of the four sides. After finding one side, continue to find the next side until all four sides are found to determine the color block.
[0087] The specific steps are as follows: 1. Get the original input image a from the camera, the positioning area, and the size range of the blocks to be identified, refer to Figure 2 , Figure 2 The middle blue box is the recognition area; 2. Perform white balance processing on the localized area of input image a, use the surrounding color as the reference color, and use the GrayworldWB white balance algorithm to obtain image b. Figure 3 ; 3. Perform 3*3 mean filtering on image b to obtain image c, refer to Figure 4 ; 4. Perform grayscale processing on image c and determine the RGB color weighting ratio according to the specific situation. Figure 5 ; 5. Use the Roberts operator to perform convolution operation on image c to obtain image d, such as Figure 6 ,The Roberts operator of the present invention is an edge detection operator, which highlights the edge part in the image and finds the edge by calculating the gradient of the image; 6. Judge each point in image d one by one, set the points with values greater than the threshold to 0, and set the others to 1, complete the binarization, and save it as image e, as shown in Figure 7 ; 7. According to the size range in 1, determine the center point interval. In picture e, set a center point at a certain interval, and judge whether the surrounding color is the same as the center in turn. If it is the same, continue. If it is different, stop judging in this direction until all four directions are judged. And store the judged data of each center point in f, such as Figure 8 ; 8. Traverse the data in f, and determine whether there are overlapping blocks according to the coordinate range of each color block. Use the area or bounding box size as a basis to remove the smaller data in the overlapping area. Determine which block is smaller by comparing the area of the overlapping area and remove it, such as Fig. 9 ; 9. Traverse the color blocks in list f and check whether they are in the detection edge area. If so, remove these data, such as Fig.10 ,Edge data refers to those color blocks close to the edge of the image, which usually affect the recognition accuracy due to noise or other reasons; 10. Traverse the data in f, and determine whether the size does not meet the setting in 1 according to the coordinate range of each color block, and check whether the size of each color block meets the range set before (previous step 1). Remove the color blocks that do not meet the size range to ensure that all detected color blocks are within the predetermined size range, such as Fig.10 ; 11. Sort the data according to the coordinates to get g; 12. Traverse the data in g, take the data of about 1 / 4 of the pixels in image a for each data center, calculate the average RGB value, and push it into the cache space corresponding to g; 13. Traverse the data in g, and determine whether the color block is a target detection block or a reference color block according to the coordinate range of each color block, and mark it, for example, the left column is the reference color block, and the right column is the target color block; 14. Return the data in g, including the coordinate and color information of all valid blocks, such as Fig.11 ; S3. Calculation (single time takes several hundred us) The calculation mode omits the image processing in the detection mode, improves the sampling speed and increases the sampling accuracy.
[0088] The specific steps are as follows: 1. Get the original input image a from the camera and get the final result g of the most recent detection mode, where g can also be read from the storage. g contains the previous detection results, such as the location of the color block and other related information.
[0089] 2. Traverse the data in g, take the data of approximately 1 / 4 of the pixels in image a for each data center, calculate the average RGB value, and push it into the corresponding cache space of g.
[0090] Each color block in 3.g has 64 groups of cache space, and data is accessed in the form of circular cache. The average value of all stored data is calculated. The average value is calculated by first calculating the standard deviation and then using the data within the standard deviation range to find the average.
[0091] 4. Return the data in g, which contains the coordinate and color information of all valid blocks.
[0092] S4. pH display When traversing the samples, the KNN algorithm is performed based on the data collected from the previous standard color cards (100-200 data are collected for each pH value).
[0093] The specific steps are as follows: 1. For the same batch of test papers, the database is measured by using standard solutions to measure the actual color. For each standard solution, more than 100 sets of data are measured.
[0094] 2. Data screening: remove obviously erroneous data from the data. These abnormal data may be caused by factors such as equipment failure, environmental interference or human operation errors. The overall data should satisfy the normal distribution, and the RGB data values and PH values are combined into a sample set. The sample set is used for simulation calculations, and the error of the sample set is reduced to the required value by continuously removing abnormal points.
[0095] 3. Add the sample data to the MCU code. At the end of S3.4, traverse each RGB data in g and use the same algorithm as S4.2 to perform actual calculations to obtain the final result.
[0096] The steps of the above implementation method are as follows Fig.12 .
[0097] On the other hand, an embodiment of the present invention further provides a color recognition system for pH test paper detection, the system comprising: The first module is used to obtain standard color card data; The second module is used to define the recognition area; The third module is used to obtain the pH test paper color block position information according to the identification area; The fourth module is used to obtain the color information of the pH test paper color block according to the pH test paper color block position information and the standard color card data.
[0098] As an optional implementation, refer to Fig.13 and Fig.14 The embodiment of the present invention includes a sampling module, a recognition module, a color calculation module, and a pH display module.
[0099] On the other hand, an embodiment of the present invention also provides a color recognition device for pH test paper detection, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the color recognition method for pH test paper detection as described above is implemented.
[0100] The color recognition device for pH test paper detection according to the embodiment of the present invention includes a memory and a processor.
[0101] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0102] The memory may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage. Among them, ROM can store static data or instructions required by the processor or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at run time. In addition, the memory may include any combination of computer-readable storage media, including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (such as a DVD-ROM, a double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (such as an SD card, a mini SD card, a Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and transient electronic signals transmitted wirelessly or wired.
[0103] The memory stores executable codes, and when the executable codes are processed by the processor, the processor can execute part or all of the methods described above.
[0104] On the other hand, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above method.
[0105] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0106] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A color recognition method for pH test paper detection, characterized in that, The method comprises the following steps: Get standard color card data; Define the identification area; According to the identified area, obtaining the pH test paper color block position information; The pH test paper color block color information is obtained according to the pH test paper color block position information and the standard color card data.
2. The method according to claim 1, characterized in that The step of obtaining the standard color card data comprises the following steps: Collect standard color card images; Establishing the relationship information between color and pH value according to the standard color card image; According to the relationship information between the color and the pH value, standard color card data is obtained.
3. The method according to claim 1, characterized in that Defining the identification area comprises the following steps: Get the original image of pH test paper; According to the original image of the pH test paper, an identification area is obtained.
4. The method according to claim 3, characterized in that The step of obtaining the pH test paper color block position information according to the identification area includes the following steps: Performing white balance processing on the original image of the pH test paper to obtain a first image; Performing mean filtering on the first picture to obtain a second picture; Performing grayscale processing on the second image to obtain a third image; Performing convolution processing on the third image to obtain a fourth image; Binarizing the fourth image to obtain a fifth image; The pH test paper color block position information is obtained according to the identification area and the fifth picture.
5. The method according to claim 1, characterized in that The method of obtaining the color information of the pH test paper color block according to the pH test paper color block position information and the standard color card data comprises the following steps: According to the pH test paper color block position information, the overlapping color blocks are removed to obtain the first color data; According to the first color data, remove the color block data at the detection edge to obtain second color data; According to the second color data, remove the color block data that does not meet the preset size to obtain third color data; sorting the third color data according to the coordinates to obtain fourth color data; Calculating an average RGB value of the fourth color data to obtain fifth color data; The pH test paper color block color information is obtained according to the fifth color data and the standard color card data.
6. The method according to claim 5, characterized in that The step of calculating the average RGB value of the fourth color data to obtain the fifth color data comprises the following steps: According to the fourth color data, 64 groups of cache space are provided for each color block, data is accessed in the form of circular cache, and the standard deviation of the color block is calculated; The average RGB value of the fourth color data is calculated according to the standard deviation to obtain fifth color data.
7. The method according to claim 1, characterized in that The color recognition method for pH test paper detection also includes the following steps: Traverse the color information of the pH test paper color block to obtain each RGB data; The RGB data is measured to obtain a pH value.
8. A color recognition system for pH test paper detection, characterized in that: The system comprises: The first module is used to obtain standard color card data; The second module is used to define the recognition area; The third module is used to obtain the pH test paper color block position information according to the identification area; The fourth module is used to obtain the color information of the pH test paper color block according to the pH test paper color block position information and the standard color card data.
9. A color recognition device for pH test paper detection, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the color recognition method for pH test paper detection as claimed in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Substance content detection method, system and device based oncolordata analysis
CN107144531A
PH test paper detection method based on computer vision
CN110599552A
General dry chemical test paper interpretation system and method
CN112014387A
Color Detection Method and Terminal
US20200374447A1
Cited By
PH test paper reading scoring method, system and equipment and readable storage medium
CN120356196A
A method, system, device, and readable storage medium for scoring a pH test strip reading
CN120356196B
