Method for detecting heavy metals in food

By controlling the brightness of the scanner's light source, acquiring multiple scanned images, and correcting noise blocks, the problem of noise influence in the paper chip colorimetric method was solved, ensuring the accuracy of heavy metal detection in food.

CN121141635BActive Publication Date: 2026-02-03COMPREHENSIVE TESTING CENT OF CHINA ACAD OF INSPECTION & QUARANTINE SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511283035.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-09
Publication Date
2026-02-03
Estimated Expiration
2045-09-09

AI Technical Summary

Technical Problem

In existing technologies, the paper chip colorimetric method for detecting heavy metals in food suffers from incomplete noise processing of scanned images due to environmental factors and voltage instability, which affects the accuracy of colorimetric analysis.

Method used

By controlling the brightness change curve of the scanner light source, multiple scanned images are acquired, noise blocks are identified, a pixel value-time curve is generated, and the pixel value is corrected by the difference curve to ensure that the pixel value is similar to the brightness change curve and eliminate the influence of noise.

Benefits of technology

It enables accurate correction of scanned images, ensuring the precision of heavy metal concentration detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121141635B_ABST
    Figure CN121141635B_ABST
Patent Text Reader

Abstract

The present application relates to the field of detection, in particular to a heavy metal detection method in food, the light source brightness of the scanner is changed through the set brightness change curve, and multiple scanning images are collected at the same time, so that the accurate pixel value difference curve caused by noise is derived according to the change of the pixel value of each pixel in the scanning image with time, and the pixels affected by noise in the scanning image are corrected according to the difference curve, so that the scanning image with accurate pixels is obtained, and colorimetry is carried out according to the scanning image, so that the accurate heavy metal concentration can be obtained, and the accuracy of detection is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of detection, and in particular to a method for detecting heavy metals in food. Background Technology

[0002] Once food is contaminated with heavy metals such as lead, cadmium, and mercury, they will accumulate in the human body throughout life, gradually damaging nerves, liver, kidneys, and bones. This is especially dangerous for children and pregnant women. Therefore, it is particularly important to test food for heavy metals.

[0003] Currently, paper-based colorimetry is commonly used to detect heavy metals in food. The main process involves preparing a sample solution of the food, injecting it into a paper chip where a color reaction occurs, and then scanning the chip to obtain a scanned image. The color in the scanned image is compared with a pre-stored standard color to determine the heavy metal content in the sample. However, due to environmental factors and voltage instability, the acquired scanned images often contain noise. To ensure the accuracy of colorimetry, noise processing is necessary. Existing technologies generally use mean filtering and median filtering to handle noise. This method essentially blurs and smooths noisy pixels from surrounding pixels, which can only roughly remove noise but cannot restore the image, thus failing to produce accurate colors and significantly affecting the accuracy of colorimetry. Summary of the Invention

[0004] Therefore, it is necessary to provide a method for detecting heavy metals in food to address the above-mentioned problems.

[0005] The present invention is implemented as follows: a method for detecting heavy metals in food is provided, the method comprising:

[0006] S1: Take a food sample of a set mass, pre-treat it to make a sample solution, add the sample solution to the paper chip, and after the color reaction is complete, place the paper chip into the scanner.

[0007] S2: Control the light source of the scanner to change the brightness according to the set brightness change curve, and scan the paper chip during the brightness change process to obtain several scanned images of the paper chip, and identify all noise blocks in the display area of ​​each scanned image.

[0008] S3: Select a noise block as the target block on the first scanned image;

[0009] S4: In subsequent scanned images, noise blocks that partially overlap with the target block are identified as associated blocks, so as to identify overlapping blocks shared by the target block and associated blocks in the target block;

[0010] S5: Identify the pixel value of the center pixel of the overlapping block and the pixel value of the corresponding pixel in the associated block, and generate a pixel value-time curve;

[0011] S6: Compare the pixel value-time curve and the brightness change curve to correct the pixel value-time curve point by point, so that the corrected pixel value-time curve and the brightness change curve are similar curves, and generate a difference curve based on the correction difference at each point. The two curves that are similar to each other have the same trend, but their magnitudes are not necessarily the same.

[0012] S7: Determine whether the difference curve can correct the pixel value-time curves corresponding to all other pixels in the overlapping block to a curve similar to the brightness change curve. If yes, the difference curve is the target difference curve. If no, the pixel value-time curve of the center pixel is corrected point by point to obtain a new difference curve. Repeat this step until the target difference curve is obtained.

[0013] S8: Correct the pixels of the target block based on the target difference curve;

[0014] S9: Repeat steps S3 to S8 until all noise blocks on the first scan image are corrected. Use the scan image for colorimetric analysis to determine the concentration of heavy metals in the sample solution.

[0015] Preferably, the scanned image is a grayscale processed image; identifying the pixel value of the center pixel of the overlapping block and the pixel value of the corresponding pixel in the associated block, and generating a pixel value-time curve includes:

[0016] S51: Identify the coordinates of the center pixel in the scanned image where the overlapping block is located as the target coordinates;

[0017] S52: Establish a pixel value-time coordinate system and set n=1;

[0018] S53: Take the nth scanned image, identify the pixel value of the pixel corresponding to the target coordinate, and determine the time when the scanned image was acquired. Obtain a pixel value coordinate and mark the coordinate point of the pixel value coordinate in the pixel value-time coordinate system, where the horizontal axis of the pixel value coordinate is the time and the vertical axis is the pixel value.

[0019] S54: Let n = n + 1, execute steps S53 to S54 until n is greater than m, where m is the number of associated images;

[0020] S55: Connect the points in the pixel value-time coordinate system with a smooth curve to obtain the pixel value-time curve.

[0021] Preferably, comparing the pixel value-time curve and the brightness change curve to perform point-by-point correction on the pixel value-time curve includes:

[0022] S61: Determine the range of pixel values ​​of the center pixel of the target block under the condition of no noise based on the brightness change curve;

[0023] S62: Determine the ratio of the brightness at each point in the brightness variation curve to the brightness at the first point;

[0024] S63: Select the first pixel value in the pixel value range as the base pixel value;

[0025] S64: Using the first moment corresponding to the pixel value-time curve as the horizontal axis and the basic pixel value as the vertical axis, obtain the coordinate point corresponding to the basic pixel value, and mark the coordinate point on the coordinate system where the pixel value-time curve is located.

[0026] S65: For each associated block, retrieve the ratio corresponding to the time of the associated block, and multiply the ratio by the base pixel value to obtain the estimated pixel value of the center pixel corresponding to the time. This yields a coordinate point with the time as the horizontal axis and the estimated pixel value as the vertical axis, and the coordinate point is marked on the coordinate system where the pixel value-time curve is located.

[0027] S66: Connect the newly labeled coordinate points with a smooth curve on the coordinate system where the pixel value-time curve is located to obtain the first estimated curve.

[0028] Preferably, generating a difference curve based on the correction difference at each point includes:

[0029] For each point on the pixel value-time curve, determine the corresponding point on the first estimated curve for the x-coordinate of that point. Subtract the y-coordinate of the corresponding point from the y-coordinate of the point to obtain the correction difference for that point. Thus, obtain the correction difference coordinate point with the correction difference as the y-coordinate and the x-coordinate of the point as the x-coordinate, and mark it on the pixel value-time coordinate system.

[0030] Connect the coordinate points of each correction difference with a smooth curve to obtain the difference curve.

[0031] Preferably, determining the pixel value range of the center pixel of the target block under noise-free conditions based on the brightness variation curve includes:

[0032] Set the minimum value in the pixel value range to 1;

[0033] Retrieve the initial brightness and maximum brightness from the brightness change curve;

[0034] The maximum ratio is obtained by dividing the maximum brightness by the initial brightness. The maximum value in the pixel value range is calculated. The obtained pixel value range is .

[0035] Preferably, determining whether the difference curve can correct the pixel value-time curves corresponding to all other pixels in the overlapping block to a curve similar to the brightness change curve includes:

[0036] S71: For each other pixel in the overlapping block, identify the pixel value of that pixel and the pixel value of the corresponding pixel in the associated block, and generate the corresponding pixel value-time curve;

[0037] S72: Retrieve the difference curve in the coordinate system of the generated pixel value-time curve, and align the two curves;

[0038] S73: For the ordinate value of each point on the pixel value-time curve, subtract the correction difference of the corresponding point on the difference curve from the ordinate value to obtain a coordinate point;

[0039] S74: Connect the actual coordinate points to obtain the second estimated curve corresponding to the pixel value-time curve;

[0040] S75: For each point on the second estimated curve, calculate the ratio of the ordinate of that point to the ordinate of the first point on the second estimated curve;

[0041] S76: Compare the calculated ratio with the corresponding ratio on the brightness change curve to determine the overall deviation of the ratio;

[0042] S77: Calculate the proportion of points with a ratio deviation less than the set deviation to the total number of points on the second estimated curve, and determine whether this proportion is greater than the set proportion. If so, the difference curve can correct the pixel value-time curves corresponding to other pixels in the overlapping block to a curve similar to the brightness change curve. If not, the difference curve cannot correct the pixel value-time curves corresponding to other pixels in the overlapping block to a curve similar to the brightness change curve.

[0043] Preferably, the ratio corresponding to each point on the second estimated curve is taken as the first ratio, and the ratio corresponding to each point on the brightness change curve is taken as the second ratio; the calculated ratio is compared with the corresponding ratio on the brightness change curve to determine the overall deviation of the ratio, including:

[0044] S761: Let i=1;

[0045] S762: Take the first ratio corresponding to the i-th point on the second estimated curve. Take the second ratio corresponding to the i-th point on the brightness change curve. ;

[0046] S763: Calculate the deviation between the first ratio and the second ratio ;

[0047] S764: Let i = i + 1, execute steps S762 to S764 until i is greater than j, where j is the estimated number of points on the curve;

[0048] S765: The overall deviation of the ratio is calculated using the following formula:

[0049]

[0050] in, This represents the overall deviation of the ratio.

[0051] Preferably, correcting the pixels of the target block based on the target difference curve includes:

[0052] Determine the correction difference corresponding to the acquisition time of the scanned image where the target block is located on the target difference curve;

[0053] For each pixel in the target block, subtract the determined correction difference from the pixel value of that pixel; thus completing the pixel correction of the target block.

[0054] This invention provides a method for detecting heavy metals in food, including taking a set mass of food sample, pre-treating it to prepare a sample solution, adding the sample solution to a paper chip, and placing the paper chip into a scanner after the colorimetric reaction is complete. The scanner's light source is controlled to change brightness according to a set brightness change curve, and the paper chip is scanned during the brightness change process to obtain several scanned images of the paper chip. All noise blocks in the display area of ​​each scanned image are identified. A noise block is selected as the target block in the first scanned image. In subsequent scanned images, noise blocks that partially overlap with the target block are identified as associated blocks, thus identifying overlapping blocks shared by the target block and associated blocks within the target block. The pixel value of the center pixel of the overlapping block and the pixel value of the corresponding pixel in the associated block are identified to generate a pixel value-time curve. The pixel value-time curve and the brightness change curve are compared to perform point-by-point correction on the pixel value-time curve, making the corrected pixel value-time curve similar to the brightness change curve, and a difference curve is generated based on the correction difference at each point. The difference curve is then judged. If the line can correct the pixel value-time curve corresponding to all other pixels in the overlapping block to a curve similar to the brightness change curve, then the difference curve is the target difference curve. If not, the pixel value-time curve of the center pixel is corrected point by point to obtain a new difference curve. This step is repeated until the target difference curve is obtained. The pixels of the target block are corrected according to the target difference curve. The above steps are repeated until all noise blocks on the first scan image are corrected. The scan image is used for colorimetry to determine the concentration of heavy metals in the sample solution. In this application, the brightness of the scanner light source is changed by setting the brightness change curve, and multiple scan images are acquired simultaneously. The pixel value of each pixel in the scan image is derived from its change over time to obtain an accurate pixel value difference curve caused by noise. The pixels affected by noise in the scan image are corrected according to the difference curve to obtain a scan image with accurate pixels. The scan image is used for colorimetry to obtain an accurate heavy metal concentration, ensuring the accuracy of the detection. Attached Figure Description

[0055] Figure 1 This is a flowchart of a method for detecting heavy metals in food provided in one embodiment;

[0056] Figure 2 This is an application environment diagram of a method for detecting heavy metals in food provided in one embodiment.

[0057] Figure 3 This is a schematic diagram of a scanning image of a method for detecting heavy metals in food provided in one embodiment;

[0058] Figure 4This is a schematic diagram of the overlapping area of ​​a method for detecting heavy metals in food provided in one embodiment;

[0059] Figure 5 This is a schematic diagram of the brightness change curve of a method for detecting heavy metals in food provided in one embodiment;

[0060] Figure 6 This is a schematic diagram illustrating the determination of the difference curve for a method for detecting heavy metals in food provided in one embodiment. Detailed Implementation

[0061] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0062] It is understood that the terms "first," "second," etc., used in this invention may be used to describe various elements herein, but unless specifically stated otherwise, these elements are not limited by these terms. These terms are used only to distinguish one element from another. For example, without departing from the scope of this invention, a first script may be referred to as a second script, and similarly, a second script may be referred to as a first script.

[0063] like Figure 1 As shown, in one embodiment, a method for detecting heavy metals in food is proposed, the method comprising:

[0064] S1: Take a food sample of a set mass, pre-treat it to make a sample solution, add the sample solution to the paper chip, and after the color reaction is complete, place the paper chip into the scanner.

[0065] S2: Control the light source of the scanner to change the brightness according to the set brightness change curve, and scan the paper chip during the brightness change process to obtain several scanned images of the paper chip, and identify all noise blocks in the display area of ​​each scanned image.

[0066] S3: Select a noise block as the target block on the first scanned image;

[0067] S4: In subsequent scanned images, noise blocks that partially overlap with the target block are identified as associated blocks, so as to identify overlapping blocks shared by the target block and associated blocks in the target block;

[0068] S5: Identify the pixel value of the center pixel of the overlapping block and the pixel value of the corresponding pixel in the associated block, and generate a pixel value-time curve;

[0069] S6: Compare the pixel value-time curve and the brightness change curve to correct the pixel value-time curve point by point, so that the corrected pixel value-time curve and the brightness change curve are similar curves, and generate a difference curve based on the correction difference at each point. The two curves that are similar to each other have the same trend, but their magnitudes are not necessarily the same.

[0070] S7: Determine whether the difference curve can correct the pixel value-time curves corresponding to all other pixels in the overlapping block to a curve similar to the brightness change curve. If yes, the difference curve is the target difference curve. If no, the pixel value-time curve of the center pixel is corrected point by point to obtain a new difference curve. Repeat this step until the target difference curve is obtained.

[0071] S8: Correct the pixels of the target block based on the target difference curve;

[0072] S9: Repeat steps S3 to S8 until all noise blocks on the first scan image are corrected. Use the scan image for colorimetric analysis to determine the concentration of heavy metals in the sample solution.

[0073] In this embodiment, step S1 is performed manually by staff; steps S2 to S9 are performed by computer equipment. The computer equipment can be an independent physical server or terminal, or a server cluster consisting of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud servers, cloud databases, cloud storage, and CDN. Figure 2 As shown, the computer device is connected to the scanner, enabling the computer device to control the scanner to adjust the brightness of the light source and acquire scanned images;

[0074] In this embodiment, the set mass range can be 50~100g; the pretreatment process includes: taking the edible part of the food sample (e.g., peeling an apple, removing the roots of spinach), homogenizing it with a tissue homogenizer, accurately weighing 5~10g (accurate to 0.001g) and placing it in a 50mL centrifuge tube; adding 20~30mL of 0.5% acetic acid solution to the centrifuge tube (the ratio of extractant volume to sample mass is usually 4:1~5:1 to ensure sufficient extraction), tightening the cap, and vortexing for 1min to allow the sample and extractant to fully interact. Mixing; Room temperature extraction: suitable for easily soluble free heavy metals, shake and let stand for 2-4 hours (vortex once every 30 minutes during this period); Low temperature heating extraction: suitable for weakly bound heavy metals, place in a constant temperature water bath (40-60℃), shake and extract for 1-2 hours (the temperature should not be too high to avoid dissolution of organic matrix and interference with subsequent detection), put the centrifuge tube after extraction into a high-speed centrifuge (4000-6000rpm), centrifuge for 10-15 minutes to separate the organic residue from the extract, and extract the supernatant as the sample solution;

[0075] In this embodiment, the heavy metals detected include lead, cadmium, mercury, etc. For each heavy metal, a special paper chip (containing a colorimetric reagent for the heavy metal to be detected) can be used to display the reaction, and then the concentration can be analyzed using this method.

[0076] In this embodiment, the computer device has a built-in noise recognition algorithm, such as a supervised classification model based on dense convolutional networks (DenseNet-NoiseID), which enables the identification of noise in scanned images (e.g., Figure 3 (as shown)

[0077] In this embodiment, as Figure 5 As shown, the shape of the set brightness change curve can be a symmetrical semi-circular arch. Due to the change in brightness of the light emitted by the light source, the brightness of the reflected light reflected by the paper chip surface also changes accordingly. Therefore, under ideal conditions (i.e., without image noise), the pixel value change trend of the acquired scanned image corresponds to the change trend of the brightness change curve.

[0078] In this embodiment, the center pixel is the pixel located at the geometric center of the target block;

[0079] In this embodiment, the horizontal axis of the brightness change curve represents time, and the vertical axis represents brightness. The computer device controls the scanner to continuously acquire multiple scan images by controlling the brightness change of the light source of the scanner, so that the time period for acquiring the scan images matches the time period corresponding to the brightness change curve. The acquisition time of each scan image is a moment in that time period.

[0080] In this embodiment, in a scanned image, noise often randomly affects multiple locations, generating multiple image noises. Each image noise has a certain area, forming a noise block on the scanned image. Since they are affected by the same noise, pixels in the same noise block are affected by the same noise, and their pixel change values ​​are also the same. Each scanned image has an image coordinate system set at the same location (e.g., the lower left corner of the image), so that the coordinates of each pixel in the image can be located. Subsequent scanned images have partial overlap with the target block, that is, there are noise blocks in subsequent scanned images where the pixel coordinates of some pixels are consistent with the pixel coordinates of the target block (e.g., when any subsequent scanned image is overlapped with the first scanned image, there are noise blocks in the subsequent scanned image that partially overlap with the target block in the first scanned image). The overlapping blocks shared by the target block and associated blocks are blocks contained in the target block and all associated blocks. For example, if the target block is A and the associated blocks are B and C, then the shared overlapping block E = A∩B∩C. Figure 4As shown; based on the above principle, it can be deduced that the pixel value change of each pixel in the overlapping region in the first scanned image and each associated image (i.e., the difference between the pixel value identified by scanning and the actual pixel value, where the pixel value identified by scanning is the sum of the actual pixel value and the noise pixels) is approximately consistent. Therefore, it can be inferred that the pixel value-time curve corresponding to each pixel in the overlapping region is applicable to the same difference curve (i.e., the target difference curve). That is, the curve obtained by subtracting the difference curve from the pixel value-time curve of each pixel in the overlapping region is the change curve of the actual color of the pixel (not affected by noise) (the change trend of this change curve is consistent with the brightness change curve, i.e., the two are similar curves). Therefore, in this embodiment, by finding the target difference curve, the pixel change difference of each pixel in the target block can be determined. Thus, by subtracting the change difference from the pixel value identified by scanning, the accurate pixel value of the pixel can be obtained. By performing this method on each noise block in the first scanned image, pixel correction of the entire range of the image can be achieved.

[0081] In this embodiment, the computer device has a pre-stored pixel value-concentration correspondence table for each heavy metal, including the concentration of the heavy metal corresponding to each pixel value. After the scanned image is corrected, the pixel values ​​in the corrected scanned image can be used in real time, so as to infer the concentration of heavy metals in the sample based on the pixel value-concentration correspondence table.

[0082] In this application, the brightness of the scanner's light source is changed by setting a brightness change curve, and multiple scanned images are acquired simultaneously. The pixel value of each pixel in the scanned image is then used to derive an accurate pixel value difference curve caused by noise based on its change over time. The pixels in the scanned image affected by noise are then corrected based on this difference curve, thereby obtaining a scanned image with accurate pixels. Colorimetry is then performed based on this scanned image to obtain an accurate heavy metal concentration, ensuring the accuracy of the detection.

[0083] In a preferred embodiment, the scanned image is a grayscale image; identifying the pixel value of the center pixel of the overlapping block and the pixel value of the corresponding pixel in the associated block, and generating a pixel value-time curve includes:

[0084] S51: Identify the coordinates of the center pixel in the scanned image where the overlapping block is located as the target coordinates;

[0085] S52: Establish a pixel value-time coordinate system and set n=1;

[0086] S53: Take the nth scanned image, identify the pixel value of the pixel corresponding to the target coordinate, and determine the time when the scanned image was acquired. Obtain a pixel value coordinate and mark the coordinate point of the pixel value coordinate in the pixel value-time coordinate system, where the horizontal axis of the pixel value coordinate is the time and the vertical axis is the pixel value.

[0087] S54: Let n = n + 1, execute steps S53 to S54 until n is greater than m, where m is the number of associated images;

[0088] S55: Connect the points in the pixel value-time coordinate system with a smooth curve to obtain the pixel value-time curve.

[0089] In this embodiment, the scanned image is a grayscale image, so that the pixel value is a single channel (range of 0~255), which makes it easier to compare and facilitates the quantification of concentration.

[0090] In a preferred embodiment, comparing the pixel value-time curve and the brightness change curve to perform point-by-point correction on the pixel value-time curve includes:

[0091] S61: Determine the range of pixel values ​​of the center pixel of the target block under the condition of no noise based on the brightness change curve;

[0092] S62: Determine the ratio of the brightness at each point in the brightness variation curve to the brightness at the first point;

[0093] S63: Select the first pixel value in the pixel value range as the base pixel value;

[0094] S64: Using the first moment corresponding to the pixel value-time curve as the horizontal axis and the basic pixel value as the vertical axis, obtain the coordinate point corresponding to the basic pixel value, and mark the coordinate point on the coordinate system where the pixel value-time curve is located.

[0095] S65: For each associated block, retrieve the ratio corresponding to the time of the associated block, and multiply the ratio by the base pixel value to obtain the estimated pixel value of the center pixel corresponding to the time. This yields a coordinate point with the time as the horizontal axis and the estimated pixel value as the vertical axis, and the coordinate point is marked on the coordinate system where the pixel value-time curve is located.

[0096] S66: Connect the newly labeled coordinate points with a smooth curve on the coordinate system where the pixel value-time curve is located to obtain the first estimated curve.

[0097] In this implementation, the first estimated curve is the curve after correcting the pixel value-time curve of the center pixel; the pixel value without noise is the actual pixel value of the pixel, and the pixel value range is the range that the actual pixel value may take; in the process of determining the target difference curve in the first round, the pixel value with the smallest pixel value range (e.g., 1) is selected as the base pixel value. If the target difference curve is not successfully determined, the pixel value-time curve of the center pixel needs to be corrected point by point again. Then, the next pixel value in the pixel value range (e.g., 2) is taken as the base pixel value, and so on, until the target difference curve is determined.

[0098] In this embodiment, the two curves are considered similar curves, meaning that the corresponding horizontal coordinate spans of the two curves are the same, and the ratio of the height of a point with the same horizontal coordinate to the height of the initial point of its respective curve is consistent. For example, for two curves with the same horizontal coordinate span, if the ratio of the vertical coordinate of any point 'a' in one curve to the vertical coordinate of the initial point of that curve is 'a', and the ratio of the vertical coordinate of point 'b' in the other curve with the same horizontal coordinate as point 'a' to the vertical coordinate of the initial point of that curve is 'b', and the ratios 'a' and 'b' are the same, then the two curves are considered similar curves. Therefore, since the actual pixel value of a pixel is directly affected by the brightness change of the light source, and its change pattern is consistent with the brightness change curve, the first estimated curve and the brightness change curve are similar curves. The first estimated curve can be determined based on the basic pixel value and the ratio of the brightness of each point in the determined brightness change curve to the brightness of the first point.

[0099] As a preferred embodiment, such as Figure 6 As shown, the difference curve generated based on the correction difference at each point includes:

[0100] For each point on the pixel value-time curve, determine the corresponding point on the first estimated curve for the x-coordinate of that point. Subtract the y-coordinate of the corresponding point from the y-coordinate of the point to obtain the correction difference for that point. Thus, obtain the correction difference coordinate point with the correction difference as the y-coordinate and the x-coordinate of the point as the x-coordinate, and mark it on the pixel value-time coordinate system.

[0101] Connect the coordinate points of each correction difference with a smooth curve to obtain the difference curve.

[0102] In this embodiment, the difference curve is the difference between the uncorrected pixel value-time curve and the first estimated curve, which characterizes the change of noise on pixel value over time.

[0103] As a preferred embodiment, determining the pixel value range of the center pixel of the target block under noise-free conditions based on the brightness variation curve includes:

[0104] Set the minimum value in the pixel value range to 1;

[0105] Retrieve the initial brightness and maximum brightness from the brightness change curve;

[0106] The maximum ratio is obtained by dividing the maximum brightness by the initial brightness. The maximum value in the pixel value range is calculated. The obtained pixel value range is .

[0107] In this embodiment, since the estimated curve is obtained by multiplying the ratio by the base pixel value, the minimum value of the pixel value range is 1, which is very different from the 0 pixel value, and the resulting difference can be ignored.

[0108] As a preferred embodiment, determining whether the difference curve can correct the pixel value-time curves corresponding to all other pixels in the overlapping block to a curve similar to the brightness change curve includes:

[0109] S71: For each other pixel in the overlapping block, identify the pixel value of that pixel and the pixel value of the corresponding pixel in the associated block, and generate the corresponding pixel value-time curve;

[0110] S72: Retrieve the difference curve in the coordinate system of the generated pixel value-time curve, and align the two curves;

[0111] S73: For the ordinate value of each point on the pixel value-time curve, subtract the correction difference of the corresponding point on the difference curve from the ordinate value to obtain a coordinate point;

[0112] S74: Connect the actual coordinate points to obtain the second estimated curve corresponding to the pixel value-time curve;

[0113] S75: For each point on the second estimated curve, calculate the ratio of the ordinate of that point to the ordinate of the first point on the second estimated curve;

[0114] S76: Compare the calculated ratio with the corresponding ratio on the brightness change curve to determine the overall deviation of the ratio;

[0115] S77: Calculate the proportion of points with a ratio deviation less than the set deviation to the total number of points on the second estimated curve, and determine whether this proportion is greater than the set proportion. If so, the difference curve can correct the pixel value-time curves corresponding to other pixels in the overlapping block to a curve similar to the brightness change curve. If not, the difference curve cannot correct the pixel value-time curves corresponding to other pixels in the overlapping block to a curve similar to the brightness change curve.

[0116] The ratio corresponding to each point on the second estimated curve is taken as the first ratio, and the ratio corresponding to each point on the brightness change curve is taken as the second ratio. The calculated ratio is compared with the corresponding ratio on the brightness change curve to determine the overall deviation of the ratio, including:

[0117] S761: Let i=1;

[0118] S762: Take the first ratio corresponding to the i-th point on the second estimated curve. Take the second ratio corresponding to the i-th point on the brightness change curve. ;

[0119] S763: Calculate the deviation between the first ratio and the second ratio ;

[0120] S764: Let i = i + 1, execute steps S762 to S764 until i is greater than j, where j is the estimated number of points on the curve;

[0121] S765: The overall deviation of the ratio is calculated using the following formula:

[0122]

[0123] in, This represents the overall deviation of the ratio.

[0124] In this embodiment, the deviation range is set to 0.02~0.05; the ratio can be set to 0.9; for each other pixel in the overlapping block, the method of generating the corresponding pixel value-time curve is the same as the method of generating the corresponding pixel value-time curve for the center pixel, which will not be described again here; the second estimated curve is the curve after the pixel value-time curve of the other pixels in the overlapping block has been corrected.

[0125] In this embodiment, for each other pixel in the overlapping block, if the set conditions (set deviation, set ratio) are met, the difference curve can be considered to be applicable to the difference curve; if all other pixels in the overlapping block are applicable to the difference curve, then the difference curve is the target difference curve, which can be used for correction.

[0126] As a preferred embodiment, correcting the pixels of the target block based on the target difference curve includes:

[0127] Determine the correction difference corresponding to the acquisition time of the scanned image where the target block is located on the target difference curve;

[0128] For each pixel in the target block, subtract the determined correction difference from the pixel value of that pixel; thus completing the pixel correction of the target block.

[0129] In this embodiment, since the overlapping block is located within the target block, the pixels in the target block and the pixels in the overlapping block are affected by the same noise, and the pixel change is approximately the same. This embodiment allows for a relatively accurate estimation of the actual pixel values ​​of all pixels in the target block.

[0130] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0131] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.

Claims

1. A method for detecting heavy metals in food, characterized in that, The method includes: S1: Take a food sample of a set mass, pre-treat it to make a sample solution, add the sample solution to the paper chip, and after the color reaction is complete, place the paper chip into the scanner. S2: Control the light source of the scanner to change the brightness according to the set brightness change curve, and scan the paper chip during the brightness change process to obtain several scanned images of the paper chip, and identify all noise blocks in the display area of ​​each scanned image. S3: Select a noise block as the target block on the first scanned image; S4: In subsequent scanned images, noise blocks that partially overlap with the target block are identified as associated blocks, so as to identify overlapping blocks shared by the target block and associated blocks in the target block; S5: Identify the pixel value of the center pixel of the overlapping block and the pixel value of the corresponding pixel in the associated block, and generate a pixel value-time curve; S6: Compare the pixel value-time curve and the brightness change curve to correct the pixel value-time curve point by point, so that the corrected pixel value-time curve and the brightness change curve are similar to each other, and generate a difference curve based on the correction difference at each point. S7: Determine whether the difference curve can correct the pixel value-time curves corresponding to all other pixels in the overlapping block to a curve similar to the brightness change curve. If yes, the difference curve is the target difference curve. If no, the pixel value-time curve of the center pixel is corrected point by point to obtain a new difference curve. Repeat this step until the target difference curve is obtained. S8: Correct the pixels of the target block based on the target difference curve; S9: Repeat steps S3 to S8 until all noise blocks on the first scan image are corrected. Use the scan image for colorimetric analysis to determine the concentration of heavy metals in the sample solution.

2. The method according to claim 1, characterized in that, The scanned image is a grayscale image; the pixel value of the center pixel of the overlapping block and the pixel value of the corresponding pixel in the associated block are identified, and a pixel value-time curve is generated, including: S51: Identify the coordinates of the center pixel in the scanned image where the overlapping block is located as the target coordinates; S52: Establish a pixel value-time coordinate system, and let n=1; S53: Take the nth scanned image, identify the pixel value of the pixel corresponding to the target coordinate, and determine the time when the scanned image was acquired. Obtain a pixel value coordinate and mark the coordinate point of the pixel value coordinate in the pixel value-time coordinate system, where the horizontal axis of the pixel value coordinate is the time and the vertical axis is the pixel value. S54: Let n = n + 1, execute steps S53 to S54 until n is greater than m, where m is the number of associated images; S55: Connect the points in the pixel value-time coordinate system with a smooth curve to obtain the pixel value-time curve.

3. The method according to claim 1, characterized in that, Comparing the pixel value-time curve with the brightness change curve to perform point-by-point correction on the pixel value-time curve includes: S61: Determine the range of pixel values ​​of the center pixel of the target block under the condition of no noise based on the brightness change curve; S62: Determine the ratio of the brightness at each point in the brightness variation curve to the brightness at the first point; S63: Select the first pixel value in the pixel value range as the base pixel value; S64: Using the first moment corresponding to the pixel value-time curve as the horizontal axis and the basic pixel value as the vertical axis, obtain the coordinate point corresponding to the basic pixel value, and mark the coordinate point on the coordinate system where the pixel value-time curve is located. S65: For each associated block, retrieve the ratio corresponding to the time of the associated block, and multiply the ratio by the base pixel value to obtain the estimated pixel value of the center pixel corresponding to the time. This yields a coordinate point with the time as the horizontal axis and the estimated pixel value as the vertical axis, and the coordinate point is marked on the coordinate system where the pixel value-time curve is located. S66: Connect the newly labeled coordinate points with a smooth curve on the coordinate system where the pixel value-time curve is located to obtain the first estimated curve.

4. The method according to claim 3, characterized in that, The difference curve is generated based on the correction difference at each point, including: For each point on the pixel value-time curve, determine the corresponding point on the first estimated curve for the x-coordinate of that point. Subtract the y-coordinate of the corresponding point from the y-coordinate of the point to obtain the correction difference for that point. Thus, obtain the correction difference coordinate point with the correction difference as the y-coordinate and the x-coordinate of the point as the x-coordinate, and mark it on the pixel value-time coordinate system. Connect the coordinate points of each correction difference with a smooth curve to obtain the difference curve.

5. The method according to claim 3, characterized in that, The range of pixel values ​​for the center pixel of the target block, determined based on the brightness variation curve, under noise-free conditions includes: Set the minimum value in the pixel value range to 1; Retrieve the initial brightness and maximum brightness from the brightness change curve; The maximum ratio is obtained by dividing the maximum brightness by the initial brightness. The maximum value in the pixel value range is calculated. The obtained pixel value range is .

6. The method according to claim 3, characterized in that, The criteria for determining whether the difference curve can correct the pixel value-time curves corresponding to all other pixels in the overlapping block to a curve similar to the brightness change curve include: S71: For each other pixel in the overlapping block, identify the pixel value of that pixel and the pixel value of the corresponding pixel in the associated block, and generate the corresponding pixel value-time curve; S72: Retrieve the difference curve in the coordinate system of the generated pixel value-time curve, and align the two curves; S73: For the ordinate value of each point on the pixel value-time curve, subtract the correction difference of the corresponding point on the difference curve from the ordinate value to obtain a coordinate point; S74: Connect the actual coordinate points to obtain the second estimated curve corresponding to the pixel value-time curve; S75: For each point on the second estimated curve, calculate the ratio of the ordinate of that point to the ordinate of the first point on the second estimated curve; S76: Compare the calculated ratio with the corresponding ratio on the brightness change curve to determine the overall deviation of the ratio; S77: Calculate the proportion of points with a ratio deviation less than the set deviation to the total number of points on the second estimated curve, and determine whether this proportion is greater than the set proportion. If so, the difference curve can correct the pixel value-time curves corresponding to other pixels in the overlapping block to a curve similar to the brightness change curve. If not, the difference curve cannot correct the pixel value-time curves corresponding to other pixels in the overlapping block to a curve similar to the brightness change curve.

7. The method according to claim 6, characterized in that, The ratio corresponding to each point on the second estimation curve is taken as the first ratio, and the ratio corresponding to each point on the brightness change curve is taken as the second ratio. The calculated ratio is compared with the corresponding ratio on the brightness change curve to determine the overall deviation of the ratio, including: S761: Let i=1; S762: Take the first ratio corresponding to the i-th point on the second estimated curve. Take the second ratio corresponding to the i-th point on the brightness change curve. ; S763: Calculate the deviation between the first ratio and the second ratio ; S764: Let i = i + 1, execute steps S762 to S764 until i is greater than j, where j is the estimated number of points on the curve; S765: Calculate the overall deviation of the ratio using the following formula: in, This represents the overall deviation of the ratio.

8. The method according to claim 1, characterized in that, The pixels of the target block corrected based on the target difference curve include: Determine the correction difference corresponding to the acquisition time of the scanned image where the target block is located on the target difference curve; For each pixel in the target block, subtract the determined correction difference from the pixel value of that pixel; thus completing the pixel correction of the target block.

Citation Information

Patent Citations

  • Cardiovascular and cerebrovascular disease multi-index combined diagnosis method based on combination of portable scanner and microfluidic control filter paper chip

    CN110646410A

  • Method and system for detecting component content of substance to be detected based on colorimetric quantification

    CN117848963A