Colloidal gold test paper cmos imaging detection method based on global gradient gray field reconstruction

By constructing a global gradient grayscale field and imaging correction parameter set, the problems of uneven illumination and weak signal acquisition in agricultural product detection were solved, realizing high-precision colloidal gold test paper CMOS imaging detection, which is suitable for rapid on-site screening of agricultural products.

CN123176239APending Publication Date: 2026-11-27SUZHOU CHENGJIAN BIOTECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611403475.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-10
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing agricultural product testing equipment suffers from insufficient accuracy and stability in areas such as uneven lighting, weak signal acquisition, and image processing, leading to frequent false positive or false negative results and failing to meet the high-precision requirements for large-scale and rapid on-site screening of agricultural products.

Method used

By acquiring images with multiple levels of exposure, a global gradient grayscale field is constructed. Combined with CMOS imaging parameters and LED light source operating parameters, an imaging correction parameter set is built. The T/C line feature area is located, the grayscale discrimination threshold is iteratively optimized, and effective pixel grayscale data is extracted frame by frame to achieve accurate calculation of the T/C line grayscale ratio.

Benefits of technology

It improves the imaging consistency and detection accuracy of colloidal gold test strips, making them suitable for rapid qualitative and quantitative screening of agricultural products on-site, and achieving highly robust detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123176239A_ABST
    Figure CN123176239A_ABST
Patent Text Reader

Abstract

The application discloses a colloidal gold test paper CMOS imaging detection method based on global gradient gray field reconstruction and belongs to the technical field of agricultural product detection. The method comprises the following steps: collecting multi-grade graded exposure images, CMOS imaging and LED light source working condition parameters, and constructing an original imaging data set; fusing multi-exposure images to generate a global gradient gray field and construct an imaging correction parameter set; preprocessing images by using the imaging correction parameter set and positioning a T / C line feature area, combining base noise iterative optimization gray and stain bubble threshold value, and obtaining a solidified gray discrimination threshold group; frame by frame extracting effective pixel gray data to calculate T / C line gray ratio, completing sample negative / positive / critical qualitative discrimination according to multi-frame ratio median value, realizing quantitative detection, and simultaneously updating the original data set; and the method can correct light source unevenness, strengthen weak detection signals, inhibit stain bubble interference, improve colloidal gold test paper strip imaging consistency and detection precision, and is suitable for on-site rapid qualitative and quantitative screening of agricultural products.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of agricultural product testing technology, specifically a colloidal gold test paper CMOS imaging detection method based on global gradient grayscale field reconstruction. Background Technology

[0002] In the rapid screening of agricultural products for safety, colloidal gold immunochromatography is widely used due to its ease of operation and rapid response. Its core principle is to determine the qualitative or quantitative nature of the target analyte by measuring the gray ratio of the T line and C line on the test card. However, existing detection equipment and methods have revealed certain defects in practical applications, affecting the accuracy and stability of the detection. First, regarding imaging illumination, current systems mostly use LED light sources with fixed parameters, lacking effective control over the uniformity of the light spot. This results in a noticeable phenomenon of bright center and hazy edges in the light field illuminating the test card surface, leading to significant differences in substrate grayscale across different areas of the same test card. This directly affects the accuracy and quantitative repeatability of the T / C line grayscale ratio calculation. Second, in the signal acquisition stage, CMOS image sensors typically use fixed exposure parameters, failing to adapt to the wide dynamic range of the colorimetric signal of colloidal gold immunochromatographic test strips and the extremely weak T-line reflection signal of weak positive samples. In addition, the sensor exhibits significant dark current noise under low illumination conditions, making it easy for weak effective signals to be submerged by noise, further reducing the detection capability of low-concentration samples. Third, quality defects in the test strip itself, such as stains, scratches, bubbles, or impurities on the membrane surface, can create grayscale features similar to the true colorimetric lines during imaging. Existing image processing algorithms lack effective interference suppression and feature discrimination mechanisms, easily misjudging these artifacts as detection lines, leading to frequent false positive or false negative results. Furthermore, existing methods lack a systematic modeling and dynamic optimization mechanism for the correlation between imaging parameters, light source conditions, and image grayscale field. They cannot adaptively adjust the CMOS exposure gain according to the actual imaging environment, nor can they establish a global grayscale field gradient information feedback. Therefore, it is difficult to correct systematic deviations introduced by factors such as light source aging, ambient temperature fluctuations, and differences in substrates between different batches of test strips. Ultimately, this results in insufficient consistency and long-term stability of the test results between batches, making it difficult to meet the actual needs of high precision and high robustness for large-scale rapid screening of agricultural products on-site. Summary of the Invention

[0003] To address the shortcomings of existing technologies, this invention proposes a CMOS imaging detection method for colloidal gold test strips based on global gradient grayscale field reconstruction. The method involves acquiring multiple levels of graded exposure images, CMOS imaging parameters, and LED light source operating parameters to construct an original imaging dataset. Multi-exposure images are fused to generate a global gradient grayscale field, constructing an imaging correction parameter set. Images are preprocessed using the imaging correction parameter set, and the T / C line feature region is located. Grayscale discrimination thresholds and stain / bubble anomaly thresholds are iteratively optimized based on the substrate noise to obtain a solidified grayscale discrimination threshold set. Effective pixel grayscale data is extracted frame by frame to calculate the T / C line grayscale ratio. Based on the median value of the multi-frame ratio, the sample is qualitatively judged as negative / positive / critical, achieving quantitative detection, while simultaneously updating the original imaging dataset. This invention can correct for uneven light sources, enhance weak detection signals, suppress stain / bubble interference, and improve the imaging consistency and detection accuracy of colloidal gold test strips, making it suitable for rapid qualitative and quantitative screening of agricultural products on-site.

[0004] To achieve the above objectives, the present invention provides the following technical solution:

[0005] A CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction includes:

[0006] S1: Simultaneously acquire the raw imaging dataset of the colloidal gold card;

[0007] S2: Reconstruct the global gradient grayscale field of the colloidal gold card using the original imaging dataset. Based on the global gradient grayscale field, construct the LED spot homogenization correction model and the weak signal enhancement curve respectively. At the same time, generate the effective area segmentation mask of the card surface and integrate them to form an imaging correction parameter set.

[0008] S3: Call the imaging correction parameter set, apply the LED spot homogenization correction model and weak signal enhancement curve to preprocess the colloidal gold card test paper image, and combine the effective area segmentation mask of the card surface to locate the T-line feature area and C-line feature area;

[0009] S4: Based on the preprocessed colloidal gold card test strip image and the global gradient gray field, set the gray level discrimination threshold, extract the gray level noise standard deviation of the blank substrate of the test strip and set the stain bubble abnormality threshold, iteratively optimize the gray level discrimination threshold and the stain bubble abnormality threshold until the absolute value of the difference between the extracted mark edge signal-to-noise ratio and 1 is less than the preset convergence threshold, and output the solidified gray level discrimination threshold group.

[0010] S5: Collect real-time colloidal gold card images based on the solidified grayscale discrimination threshold group, lock effective pixels by relying on the effective area segmentation mask of the card surface, extract pixel-level grayscale distribution data frame by frame and calculate the grayscale ratio of T / C line;

[0011] S6: Based on the grayscale ratio of the T / C line in each frame, complete the qualitative and quantitative interpretation of colloidal gold samples of agricultural products, simultaneously archive pixel-level grayscale distribution data and update the original imaging dataset.

[0012] Specifically, the steps of S1 include:

[0013] The CMOS image sensor is controlled by a timestamp synchronous triggering method to sequentially acquire images of colloidal gold cards under LED light source according to the preset first exposure time, second exposure time and third exposure time, generating a graded exposure image sequence composed of the first exposure image, the second exposure image and the third exposure image, wherein the first exposure time is shorter than the second exposure time, and the second exposure time is shorter than the third exposure time.

[0014] At each frame of image acquisition time, the integration time and analog gain corresponding to each frame of image are obtained by reading the status register inside the CMOS image sensor as CMOS imaging parameters; the LED light source driving current value at each frame of image acquisition time is obtained by monitoring the sampling resistor voltage of the LED light source driving circuit, and the current duty cycle value of the pulse width modulation controller is read as LED light source operating condition parameters.

[0015] Each frame of graded exposure image is associated with its corresponding CMOS imaging parameters and LED light source operating parameters according to the acquisition timestamp, forming multiple image-parameter association units. All image-parameter association units are then aggregated and stored as the original imaging dataset.

[0016] Specifically, the steps of S2 include:

[0017] A weighted fusion-based exposure fusion algorithm is used to synthesize the first exposure image, the second exposure image, and the third exposure image into a single global grayscale image.

[0018] Taking each pixel in the global grayscale image as the center, extract the grayscale difference between adjacent pixels in the horizontal and vertical directions for each pixel, combine the grayscale differences in the horizontal and vertical directions to form the gradient vector of the corresponding pixel, and the gradient vectors of all pixels constitute the global gradient grayscale field.

[0019] Using the grayscale value and coordinate position of each pixel in the global gradient grayscale field as input data, a second-order polynomial surface fitting algorithm is used to fit the illuminance distribution fitting surface of the LED light source on the card surface. The illuminance distribution fitting surface is compared pixel by pixel with the standard uniform illuminance plane to generate a pixel-by-pixel gain coefficient matrix composed of illuminance compensation coefficients at each pixel position, which serves as the LED spot homogenization correction model.

[0020] Specifically, the steps of S2 further include:

[0021] The cumulative grayscale distribution of all pixels in the global gradient grayscale field is statistically analyzed. Based on the cumulative grayscale distribution, the lower stretching reference point and the upper stretching reference point are determined at the first percentile and the second percentile. In the grayscale interval between the lower stretching reference point and the upper stretching reference point, a logarithmic mapping curve is used to stretch the grayscale to form a grayscale remapping curve as a weak signal enhancement curve, wherein the first percentile is smaller than the second percentile.

[0022] Based on the global gradient gray field, pixels with gray values ​​greater than the global gray average are selected as seed points. Region growth is performed from the seed points to the neighboring pixels. Then, morphological closing operations are performed on the region growth results to close the edges, generating a binary mask image of the effective reaction area of ​​the card surface as the effective area segmentation mask of the card surface.

[0023] The LED spot homogenization correction model, weak signal enhancement curve, and card surface effective region segmentation mask are packaged into an imaging correction parameter set.

[0024] Specifically, the step of fitting the illuminance distribution of the LED light source on the card surface using a second-order polynomial surface fitting algorithm includes:

[0025] Using the horizontal and vertical coordinates of each pixel in the global grayscale image as independent variables and the grayscale value of each pixel as the dependent variable, a second-order polynomial fitting equation is constructed.

[0026] The coefficient matrix of the second-order polynomial fitting equation is solved using the least squares method. The obtained coefficient matrix is ​​then substituted into the second-order polynomial fitting equation to obtain the illuminance distribution fitting surface.

[0027] The fitted gray value at each pixel position on the illuminance distribution fitting surface is compared pixel by pixel with the actual gray value at the corresponding pixel position in the global grayscale image, and the ratio of the fitted gray value to the actual gray value is calculated as the illuminance compensation coefficient for the corresponding pixel position.

[0028] Traverse all pixel positions and arrange the illumination compensation coefficients of all pixel positions according to pixel coordinates to form a pixel-wise gain coefficient matrix with the same resolution as the original image.

[0029] Specifically, the steps of S3 include:

[0030] Extract the pixel-wise gain coefficient matrix from the LED spot homogenization correction model and the gray-level remapping curve from the weak signal enhancement curve from the imaging correction parameter set;

[0031] The gray value of each pixel in the acquired original colloidal gold card test strip image is multiplied by the illuminance compensation coefficient of the corresponding pixel position in the pixel-by-pixel gain coefficient matrix to obtain the homogenized corrected image.

[0032] Based on the gray value of each pixel in the homogenized image, gray value conversion is performed according to the gray-level remapping curve to obtain the preprocessed colloidal gold card test paper image.

[0033] Extract the effective area segmentation mask from the imaging correction parameter set, perform a pixel-by-pixel AND operation between the preprocessed colloidal gold test paper image and the effective area segmentation mask, and mask out pixels outside the effective area to obtain the effective area image.

[0034] Specifically, the steps of S3 further include:

[0035] On the effective area image, based on the preset vertical position intervals of the T-line and C-line on the colloidal gold card, the horizontal gray-scale projection integration is performed on the pixels within the preset vertical position interval of the T-line to obtain the horizontal projection curve of the T-line, and the horizontal gray-scale projection integration is performed on the pixels within the preset vertical position interval of the C-line to obtain the horizontal projection curve of the C-line.

[0036] Search for the trough positions of the horizontal projection curves of the T-line and the C-line respectively, and determine the horizontal coordinates corresponding to the trough positions as the center column coordinates of the T-line and the center column coordinates of the C-line;

[0037] The column coordinate range of the T-line feature area is determined by taking the center column coordinates of the T-line as the center and the preset width threshold as the radius. The column coordinate range of the C-line feature area is determined by taking the center column coordinates of the C-line as the center and the preset width threshold as the radius. The pixel coordinate range of the T-line feature area and the C-line feature area on the image is finally determined by combining the preset row coordinate range.

[0038] Specifically, the step of performing horizontal grayscale projection integration on pixels within a preset vertical position interval of the T-line to obtain the horizontal projection curve of the T-line, and performing horizontal grayscale projection integration on pixels within a preset vertical position interval of the C-line to obtain the horizontal projection curve of the C-line, includes:

[0039] On the effective area image, determine the preset vertical start row coordinates and preset vertical end row coordinates of the T-line. From the preset vertical start row coordinates to the preset vertical end row coordinates, extract the gray values ​​of all pixels in each row within the effective area and sum them to obtain the horizontal projection integral value of each row. Then, take the row coordinates of each row and the corresponding horizontal projection integral value as a set of coordinate points, and connect the coordinate points corresponding to all row coordinates in ascending order of row coordinates to form the horizontal projection curve of the T-line.

[0040] On the effective area image, determine the preset vertical start row coordinates and preset vertical end row coordinates of line C. From the preset vertical start row coordinates to the preset vertical end row coordinates, extract the gray values ​​of all pixels in each row within the effective area and sum them to obtain the horizontal projection integral value of each row. Then, take the row coordinates of each row and the corresponding horizontal projection integral value as a set of coordinate points, and connect the coordinate points corresponding to all row coordinates in ascending order of row coordinates to form the horizontal projection curve of line C.

[0041] Specifically, the specific steps of S4 include:

[0042] Calculate the mean gray value and standard deviation of all pixels in the effective area of ​​the preprocessed colloidal gold card test strip image, and set the difference between the mean gray value and the standard deviation of gray value as the initial gray value discrimination threshold.

[0043] Calculate the gradient magnitude of each pixel in the effective region of the global gradient gray field, select pixels with gradient magnitudes lower than the preset first quantile to form a base pixel set, calculate the variance of gray values ​​of all pixels in the base pixel set, take the square root of the variance to obtain the standard deviation of gray noise of the blank base of the test strip, and then multiply the standard deviation of gray noise of the blank base of the test strip by a preset multiple to obtain the initial stain bubble abnormal threshold.

[0044] Using the initial grayscale discrimination threshold and the initial stain bubble abnormality threshold as parameters for binarization segmentation, the preprocessed colloidal gold card test strip image is binarized to extract the binarized image of the candidate region of the marking.

[0045] Edge pixels are obtained by performing edge extraction on the binarized image of the candidate region of the marking. The ratio of the mean gray-level gradient magnitude of the edge pixels to the standard deviation of the gray-level noise of the blank substrate of the test paper is calculated to obtain the signal-to-noise ratio of the marking edge.

[0046] Specifically, the steps of S4 further include:

[0047] Determine the absolute value of the difference between the signal-to-noise ratio of the mark edge and the value 1. Determine whether the absolute value of the difference is less than a preset convergence threshold. If the absolute value of the difference is greater than or equal to the preset convergence threshold, increase the current grayscale discrimination threshold by one step. At the same time, increase the current stain bubble abnormality threshold in accordance with the increase ratio of the grayscale discrimination threshold. Re-binarize and recalculate the mark edge signal-to-noise ratio with the increased grayscale discrimination threshold and the increased stain bubble abnormality threshold until the absolute value of the difference is less than the convergence threshold.

[0048] The grayscale discrimination threshold and the stain bubble abnormality threshold at the end of the iteration are solidified into a set of thresholds, which are then output as the solidified grayscale discrimination threshold set.

[0049] Specifically, the specific steps of S5 include:

[0050] Extract the grayscale discrimination threshold from the solidified grayscale discrimination threshold group as the target grayscale value, use the target grayscale value as the expected value for automatic exposure control of the CMOS image sensor, dynamically adjust the integration time and analog gain of the CMOS image sensor, and trigger the acquisition of a real-time colloidal gold card grayscale image after each adjustment.

[0051] Extract the effective area segmentation mask of the card surface from the imaging correction parameter set, and perform a pixel-by-pixel AND operation between each frame of real-time colloidal gold card grayscale image and the effective area segmentation mask of the card surface to lock all effective pixels in the effective area.

[0052] For each frame of real-time colloidal gold card grayscale image, the grayscale value of each effective pixel in the effective area is extracted according to the pixel row priority order. The effective pixel grayscale value sequence of the corresponding frame image is associated with the timestamp and frame number of the corresponding frame image to form the pixel-level grayscale distribution data of the corresponding frame.

[0053] Based on the pixel coordinate range of the T-line feature area, the gray values ​​of all pixels within the T-line feature area are extracted from the pixel-level gray-level distribution data of the current frame, and the average gray value is calculated as the average gray value of the T-line region. Based on the pixel coordinate range of the C-line feature area, the gray values ​​of all pixels within the C-line feature area are extracted from the pixel-level gray-level distribution data of the current frame, and the average gray value is calculated as the average gray value of the C-line region. The ratio of the average gray value of the T-line region to the average gray value of the C-line region is calculated as the T / C line gray-level ratio of the current frame.

[0054] Specifically, the steps of S6 include:

[0055] Obtain the T / C line grayscale ratio values ​​corresponding to each of the continuously acquired real-time colloidal gold card grayscale images, and calculate the median and dispersion values ​​of all T / C line grayscale ratio values;

[0056] If the median value is less than or equal to the preset positive threshold, it is interpreted as a positive result; if the median value is greater than or equal to the preset negative threshold, it is interpreted as a negative result; if the median value is between the preset negative threshold and the preset positive threshold, it is interpreted as a critical result, and the final qualitative interpretation result is output.

[0057] For samples that are interpreted as positive, the median value is matched with a pre-established concentration mapping table; the concentration mapping table contains the range of T / C line grayscale ratio values ​​corresponding to multiple concentration intervals.

[0058] Determine the target grayscale ratio range into which the median value falls, use the concentration range corresponding to the target grayscale ratio range as the quantitative interpretation result, and associate the qualitative interpretation result and the quantitative interpretation result with the sample number of the current colloidal gold card and output them;

[0059] The pixel-level grayscale distribution data, T / C line grayscale ratio, CMOS imaging parameters, and LED light source operating parameters corresponding to each frame of real-time colloidal gold card grayscale image are associated according to the acquisition timestamp to form a new data record. The new data record is appended to the end of the original imaging dataset to update the original imaging dataset.

[0060] Compared with the prior art, the beneficial effects of the present invention are:

[0061] 1. This invention proposes a CMOS imaging detection method for colloidal gold test strips based on global gradient grayscale field reconstruction. It constructs a global gradient grayscale field by fusing multi-level exposure images and forms a complete imaging correction system, effectively solving the pain points of uneven illumination and weak signal loss in traditional detection methods. A pixel-by-pixel gain matrix is ​​obtained through second-order polynomial fitting to complete LED spot homogenization correction, eliminating grayscale deviations caused by differences in light source illuminance. A weak signal enhancement curve is constructed based on the cumulative grayscale distribution to amplify the weak T-line signal of low-concentration samples. Effective region masks are generated by combining region growing and morphological operations to eliminate invalid background interference outside the test strip. Simultaneously, the dual thresholds for grayscale discrimination and stain / bubble anomalies are iteratively optimized based on the substrate noise to distinguish between true markings and impurity artifacts, reducing misjudgments caused by stains and bubbles. This improves the image signal-to-noise ratio from the imaging source and ensures the accuracy of T and C-line grayscale extraction.

[0062] 2. This invention proposes a CMOS imaging detection method for colloidal gold test strips based on global gradient grayscale field reconstruction, achieving adaptive adjustment of imaging parameters and integrated qualitative and quantitative interpretation, significantly improving detection stability and practicality. During the detection phase, CMOS exposure and gain are dynamically adjusted based on a fixed grayscale threshold as the desired value. Combined with masking to lock effective pixels, grayscale data is extracted frame by frame, stably outputting the T / C line grayscale ratio. The median value of the multi-frame ratio is used to determine the result, reducing errors caused by single-frame imaging fluctuations. Three categories of qualitative results are classified: negative, positive, and critical. Accurate quantitative analysis is completed using a preset concentration mapping table. Furthermore, the detection process synchronously updates the original imaging dataset with newly added imaging data in real time, continuously improving the calibration model to adapt to various test strip samples. No manual intervention is required, resulting in a high degree of automation. The entire process of imaging calibration, threshold optimization, and interpretation is closed-loop, offering superior detection repeatability and quantitative accuracy compared to traditional fixed-parameter detection schemes, making it suitable for large-scale rapid screening of agricultural products on-site. Attached Figure Description

[0063] Figure 1 This is a schematic diagram of the CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction according to the present invention;

[0064] Figure 2 This is a flowchart illustrating the principle of the colloidal gold test paper CMOS imaging detection method based on global gradient grayscale field reconstruction of the present invention. Detailed Implementation

[0065] Example 1:

[0066] Please see Figure 1 and Figure 2 The present invention provides an embodiment of a CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction, comprising the following steps:

[0067] S1: Simultaneously acquire the raw imaging dataset of the colloidal gold card;

[0068] S2: Reconstruct the global gradient grayscale field of the colloidal gold card using the original imaging dataset. Based on the global gradient grayscale field, construct the LED spot homogenization correction model and the weak signal enhancement curve respectively. At the same time, generate the effective area segmentation mask of the card surface and integrate them to form an imaging correction parameter set.

[0069] S3: Call the imaging correction parameter set, apply the LED spot homogenization correction model and weak signal enhancement curve to preprocess the colloidal gold card test paper image, and combine the effective area segmentation mask of the card surface to locate the T-line feature area and C-line feature area;

[0070] S4: Based on the preprocessed colloidal gold card test strip image and the global gradient gray field, set the gray level discrimination threshold, extract the gray level noise standard deviation of the blank substrate of the test strip and set the stain bubble abnormality threshold, iteratively optimize the gray level discrimination threshold and the stain bubble abnormality threshold until the absolute value of the difference between the extracted mark edge signal-to-noise ratio and 1 is less than the preset convergence threshold, and output the solidified gray level discrimination threshold group.

[0071] S5: Collect real-time colloidal gold card images based on the solidified grayscale discrimination threshold group, lock effective pixels by relying on the effective area segmentation mask of the card surface, extract pixel-level grayscale distribution data frame by frame and calculate the grayscale ratio of T / C line;

[0072] S6: Based on the grayscale ratio of the T / C line in each frame, complete the qualitative and quantitative interpretation of colloidal gold samples of agricultural products, simultaneously archive pixel-level grayscale distribution data and update the original imaging dataset.

[0073] In summary, this application utilizes a CMOS image sensor for graded exposure imaging and a controllable LED light source to acquire multi-dimensional imaging data of the test strip. A global gradient grayscale field is constructed through multi-exposure image fusion as a unified correction benchmark. A complete set of image correction models is established from three dimensions: uneven illumination, weak signal attenuation, and impurity interference. The segmentation threshold is then iteratively optimized in conjunction with the test strip's substrate noise to accurately separate effective detection lines from background stains. During detection, imaging parameters are dynamically adjusted using the optimal threshold to extract the T / C line grayscale ratio. Qualitative and quantitative interpretation of the immunochromatographic test strip is completed based on multi-frame data statistics. The entire correction and recognition system is continuously optimized through iterative dataset optimization. By combining optical imaging, grayscale field correction, adaptive threshold segmentation, and immunochromatographic ratio quantification, detection errors caused by the imaging system and the test strip itself are eliminated, achieving high-precision automated detection of colloidal gold test strips for agricultural products.

[0074] Example 2:

[0075] The specific steps of S1 in this embodiment include:

[0076] S1.1: The CMOS image sensor is controlled by a timestamp synchronous triggering method to sequentially acquire images of colloidal gold cards under LED light source illumination according to the preset first exposure time, second exposure time and third exposure time, generating a graded exposure image sequence composed of the first exposure image, the second exposure image and the third exposure image, wherein the first exposure time is less than the second exposure time and the second exposure time is less than the third exposure time.

[0077] This embodiment uses an 8-megapixel global shutter CMOS image sensor as the core imaging hardware, and is equipped with four sets of 450nm parallel cool white LED ring light sources as the illumination device for the colloidal gold card stage. The entire imaging device integrates a closed, light-shielding detection chamber to isolate environmental stray light interference. A standardized detection card slot is placed inside the chamber to hold uniformly sized clenbuterol hydrochloride detection cards. These clenbuterol hydrochloride detection cards are colloidal gold immunochromatographic detection cards used to detect clenbuterol hydrochloride residues in pork tissue. A pre-reserved planar positioning reference is provided at the bottom of the card slot to ensure that the placement and tilt angle of each colloidal gold card are completely consistent, eliminating imaging errors caused by placement misalignment. The device has a built-in embedded main control chip, which is equipped with a high-precision hardware timing unit. The hardware timing unit outputs a microsecond-level unified synchronous trigger signal, thereby achieving complete timing synchronization between the CMOS image sensor and the LED light source driving circuit.

[0078] In this embodiment, the operator places the clenbuterol hydrochloride test card, after sample addition and 10-minute reaction, flat into the standard slot inside the cavity, closes the light-proof cavity door, and after the main control chip receives the device start detection command, it first sends a constant duty cycle output command to the LED driver circuit to allow the ring LED light source to stably output a fixed illuminance. It waits for the light source to remain lit for 200 milliseconds to complete the brightness stabilization, avoiding the problem of uneven image brightness caused by brightness fluctuations when the LED is first started. After the stabilization phase, the main control chip generates a synchronous trigger pulse with a unique microsecond-level timestamp through the hardware timing unit. The pulse signal is simultaneously sent to the CMOS image sensor register and the LED driver sampling acquisition module.

[0079] Furthermore, the three-level exposure time parameters are pre-configured within the main control program. Considering the characteristics of the clenbuterol hydrochloride detection card—a light background, weak T-line color signal, and deep C-line color—three-level gradient exposure times are set: the first exposure time is 0.3 milliseconds, the second is 3 milliseconds, and the third is 15 milliseconds. The three exposure times strictly follow a progressively increasing rule. The first exposure image, i.e., the short exposure image, is used to capture details in the high-brightness saturation area of ​​the C-line; the second exposure image, i.e., the medium exposure image, balances the base grayscale and the transition area of ​​the marker lines; and the third exposure image, i.e., the long exposure image, is specifically designed to amplify the weak color signal of the T-line, thus solving the imaging defect that a single exposure level cannot simultaneously capture both strong and weak color marker lines.

[0080] Furthermore, after the synchronous trigger pulse is issued, the CMOS image sensor prioritizes the first-level 0.3-millisecond short exposure acquisition process to fully acquire a first exposure image frame. After acquisition, the sensor immediately sends an acquisition completion feedback signal back to the main control chip. The main control chip issues a second-level 3-millisecond exposure trigger command at 500 microsecond intervals without delay to acquire the second exposure image. Then, at another 500 microsecond interval, it issues a third-level 15-millisecond long exposure trigger command to acquire the third exposure image. Throughout the three-level image acquisition process, the LED light source remains constantly lit without brightness switching, ensuring that the lighting environment of the three images is completely uniform. After the three images are acquired, the three image storage files are automatically integrated to form a complete hierarchical exposure image sequence. Each image file has a reserved storage area at the beginning for writing the globally unified timestamp marker corresponding to the current frame acquisition.

[0081] S1.2: At each frame image acquisition time, the integration time and analog gain corresponding to that frame image are obtained by reading the status register inside the CMOS image sensor as CMOS imaging parameters; the LED light source driving current value at the time of image acquisition is obtained by monitoring the sampling resistor voltage of the LED light source driving circuit, and the current duty cycle value of the pulse width modulation controller is read as LED light source operating condition parameters.

[0082] In this embodiment, the CMOS image sensor hardware is internally divided into multiple sets of independent read-only status registers. During each exposure acquisition process, the sensor latches the integration time value and front-end analog amplification gain value used in this acquisition to the corresponding register address in real time. The value latching operation is completed synchronously with the photoelectric conversion of image pixels, and there is no timing delay. After each single frame image acquisition is completed, the main control chip immediately reads the contents of all status registers of the sensor through the serial communication bus, extracts the two core values ​​of integration time and analog gain corresponding to the current frame, and encapsulates them into a dedicated CMOS imaging parameter data packet for the current frame. The data packet synchronously records the microsecond-level timestamp corresponding to the current frame image, realizing one-to-one binding of imaging parameters with image frames.

[0083] Furthermore, the LED ring light source is equipped with a dedicated constant current drive circuit board. The output circuit of the circuit board is connected in series with a high-precision milliohm sampling resistor, and a high-precision voltage acquisition chip is connected in parallel across the sampling resistor. The voltage acquisition chip continuously and in real time acquires the real-time voltage value across the resistor. The voltage acquisition chip communicates with the main control chip in real time, transmitting voltage sampling data without interruption. Based on Ohm's law conversion logic, the sampled voltage value can be converted into the actual driving current of the LED light source in real time, completely recording the real-time current of the light source corresponding to the moment of each frame image acquisition. The brightness adjustment of the light source is achieved by the built-in 8-bit pulse width modulation controller. The controller refreshes the output duty cycle value every millisecond. At the same microsecond moment when the exposure of each frame image is triggered, the main control chip synchronously reads the currently effective duty cycle parameter of the controller, merges the real-time driving current and the current duty cycle data into an LED light source operating condition parameter data packet, and also binds it to the acquisition timestamp corresponding to the current frame image.

[0084] S1.3: Associate each frame of graded exposure image with its corresponding CMOS imaging parameters and LED light source operating parameters according to the acquisition timestamp to form multiple image-parameter association units, and summarize and store all image-parameter association units as the original imaging dataset.

[0085] Furthermore, the main control chip has a built-in local high-speed storage cache partition. After each frame of image acquisition and synchronous reading of the corresponding CMOS imaging parameters and LED light source operating parameters, it uses the microsecond-level timestamp of the current frame image as the unique association key to bind and package the current frame image file, CMOS imaging parameter data package, and LED light source operating parameter data package into an independent and indivisible image-parameter association unit. Each image-parameter association unit has three layers of independent storage partitions: the first layer stores the original image pixel file, the second layer stores the structured CMOS imaging parameter text, and the third layer stores the structured LED light source operating parameter text. The header of the image-parameter association unit is uniformly marked with a globally unique timestamp. To ensure rapid matching and retrieval via timestamps, in this embodiment, after all three levels of exposure images are acquired, the device automatically generates three independent image-parameter association units: the first unit corresponds to short exposure frames, the second unit to medium exposure frames, and the third unit to long exposure frames. After all image-parameter association units are generated, the main control program automatically traverses all image-parameter association units, sorts them uniformly according to the order of acquisition time, and integrates and packages them into a standardized raw imaging dataset file package. The dataset file package contains a unified index table, which records the timestamp, exposure level, storage path, file size, and hardware parameter summary information of each image-parameter association unit.

[0086] The specific steps of S2 include:

[0087] S2.1: Extract the first exposure image, the second exposure image, and the third exposure image from the original imaging dataset, and use a weighted fusion-based exposure fusion algorithm to synthesize the first exposure image, the second exposure image, and the third exposure image into a single global grayscale image;

[0088] Furthermore, the built-in index table of the original imaging dataset is read. Based on the exposure level markings in the index table, the three sets of original exposure images stored within the image-parameter association units are accurately located and completely read. After reading, color space conversion processing is performed on the read first, second, and third exposure images. All three images are RGB three-channel color images, uniformly converted to single-channel grayscale images. The color conversion is calculated using fixed weight parameters: the red channel weight is set to 0.299, the green channel weight to 0.587, and the blue channel weight to 0.114. Weighted calculation of the three channel weights eliminates the interference of color channel differences on grayscale calculation. After conversion, three independent grayscale images are obtained, corresponding to the short-exposure grayscale image generated from the first exposure image, the medium-exposure grayscale image generated from the second exposure image, and the long-exposure grayscale image generated from the third exposure image, respectively. The resolution of the three grayscale images remains unchanged at 2592×1944 pixels. The fusion weight of the short exposure grayscale image is set to 0.2, the fusion weight of the medium exposure grayscale image is set to 0.5, and the fusion weight of the long exposure grayscale image is set to 0.3. The three grayscale images are traversed pixel by pixel to complete the basic weighted fusion operation. The traversal order follows the row priority order of the images. The row coordinate value ranges from 0 to 1943, and the column coordinate value ranges from 0 to 2591. During the traversal, the grayscale values ​​at the same row coordinate and column coordinate position of the three grayscale images are read simultaneously. The three grayscale values ​​are multiplied by their respective fusion weight values ​​to complete the basic weighted summation operation. The point-by-point weighted fusion operation is completed for all pixels. The traversal range covers all pixel coordinates from row coordinate 0 to 1943 and column coordinate 0 to 2591. After the operation is completed, a global grayscale image is generated. The resolution of the global grayscale image is consistent with the resolution of the original image acquired by CMOS, with a resolution value of 2592×1944 pixels.

[0089] S2.2: Taking each pixel in the global grayscale image as the center, extract the grayscale difference between adjacent pixels in the horizontal and vertical directions, combine the grayscale differences in the horizontal and vertical directions into the gradient vector of the pixel, and the gradient vectors of all pixels constitute the global gradient grayscale field.

[0090] Furthermore, the entire grayscale image is traversed pixel by pixel in row-major order. For the target pixel currently traversed, its horizontal and vertical coordinates are first locked. The grayscale values ​​of its horizontally adjacent pixels and vertically adjacent pixels are then extracted. Specifically, in the horizontal direction, the left and right adjacent pixels of the target pixel are selected, and the grayscale differences between the left and right pixels and the target pixel are calculated. The average of these two differences is taken as the horizontal grayscale difference of the pixel. In the vertical direction, the upper and lower adjacent pixels of the target pixel are selected, and the grayscale differences between the upper and lower pixels and the target pixel are calculated. The average of these two differences is taken as the horizontal grayscale difference of the pixel. The vertical grayscale difference is calculated; the calculated horizontal and vertical grayscale differences are bound and paired to form a two-dimensional gradient vector for the current pixel. The two-dimensional gradient vector completely records the horizontal and vertical grayscale change range of the pixel, which can intuitively distinguish four different image regions: the smooth blank base of the card surface, the edge of the T / C mark, the edge of the stain bubble, and the light and dark transition area of ​​the LED spot. After traversing all pixels of the global grayscale image, each image coordinate position corresponds to a set of independent gradient vectors. All pixel gradient vectors are completely integrated according to the original image pixel coordinate arrangement order to form a matrix structure global gradient grayscale field. The global gradient grayscale field corresponds one-to-one with the pixel coordinates of the global grayscale image.

[0091] S2.3: Using the gray value and coordinate position of each pixel in the global gradient gray field as input data, a second-order polynomial surface fitting algorithm is used to fit the illuminance distribution fitting surface of the LED light source on the card surface. The illuminance distribution fitting surface is compared pixel by pixel with the standard uniform illuminance plane to generate a pixel-by-pixel gain coefficient matrix composed of illuminance compensation coefficients at each pixel position, which serves as the LED spot homogenization correction model.

[0092] The specific steps of S2.3 include:

[0093] S2.3.1: Using the horizontal and vertical coordinates of each pixel in the full-domain grayscale image as independent variable data and the grayscale value of the pixel as dependent variable data, construct a second-order polynomial fitting equation.

[0094] Furthermore, based on the global gradient grayscale field, a basic pixel set without large-area stains or bubble obstruction is initially screened within the image. All pixels in this basic pixel set are located in the blank substrate area of ​​the colloidal gold card, unaffected by the T-line and C-line color pigments. The grayscale variation of the substrate is only caused by the difference in illuminance of the light spot with the center bright and the surrounding dark areas of the LED ring light source, which can truly reflect the illuminance distribution law of the light source. The horizontal and vertical coordinate values ​​of each pixel in the basic pixel set are extracted as two sets of independent variables, and the grayscale value of the global grayscale image corresponding to the same pixel is extracted as the dependent variable. All independent and dependent variable data are organized into a structured dataset, imported into a second-order polynomial, and a second-order polynomial fitting equation adapted to the colloidal gold card planar imaging scene is automatically generated. The second-order polynomial fitting equation completely associates the pixel coordinates with the corresponding illuminance grayscale, and is used to restore the uneven light spot distribution law of the center bright and the surrounding attenuation produced by the LED light source shining on the card surface. The second-order polynomial fitting equation is the prior art in this field and is not an inventive solution of this application, so it will not be described in detail here.

[0095] S2.3.2: Solve the coefficient matrix of the second-order polynomial fitting equation using the least squares method, and substitute the obtained coefficient matrix into the second-order polynomial fitting equation to obtain the illuminance distribution fitting surface.

[0096] Furthermore, the least squares method is used to automatically iteratively solve all the coefficient values ​​inside the second-order polynomial equation. The iterative process continuously reduces the overall error between the fitted gray value and the actual pixel gray value until the overall error converges to a preset small error threshold of 0.001. The iteration stops and the final stable coefficient matrix is ​​locked. The solved coefficient matrix is ​​completely substituted into the second-order polynomial fitting equation. By inputting the horizontal and vertical coordinates of any pixel in the image, the standard fitted gray value that should appear at that coordinate position under ideal LED illumination can be directly calculated. The fitted gray values ​​corresponding to all coordinates are integrated to form a continuous and smooth illuminance distribution fitting surface. The illuminance distribution fitting surface completely replicates the gradient spot effect formed when the colloidal gold card is illuminated by a ring LED light source, with high center illuminance and gradually decreasing edge illuminance. The least squares method is prior art in this field and is not an inventive solution of this application, so it will not be described in detail here.

[0097] S2.3.3: Compare the fitted gray value of each pixel position on the illuminance distribution fitting surface with the actual gray value of the corresponding pixel position in the global grayscale image pixel by pixel, and calculate the ratio of the fitted gray value to the actual gray value as the illuminance compensation coefficient for that pixel position.

[0098] In this embodiment, the entire global grayscale image is traversed point by point according to pixel coordinates. For each set of the same horizontal and vertical coordinates, the standard fitted grayscale value output by the illuminance distribution fitting surface and the original actual grayscale value stored in the global grayscale image are retrieved simultaneously. The ratio of the standard fitted grayscale value to the original actual grayscale value is calculated, and the resulting ratio is the illuminance compensation coefficient specific to the current coordinate pixel. For the central area of ​​the LED spot, the actual illuminance of the light source is too high, and the actual grayscale value is greater than the standard fitted grayscale value. The illuminance compensation coefficient is less than 1. During image correction, the pixel grayscale of this area is reduced to eliminate the problem of excessive brightness in the center. For the edge areas of the card surface around the image, the illuminance of the light source is significantly reduced, and the actual grayscale value is lower than the standard fitted grayscale value. The illuminance compensation coefficient is greater than 1. During correction, the edge pixel grayscale is increased to compensate for the dark image defect caused by insufficient illumination. The pixel illuminance compensation coefficient of the completely uniformly illuminated area approaches 1 infinitely, and there is no significant change in grayscale after correction.

[0099] S2.3.4: Traverse all pixel positions and arrange the illumination compensation coefficients of all pixel positions according to the pixel coordinates to form a pixel-wise gain coefficient matrix with the same resolution as the original image.

[0100] Furthermore, after traversing all pixel coordinates of the image, the illuminance compensation coefficient calculated for each coordinate is completely filled into the two-dimensional matrix according to the pixel row and column arrangement order of the original image. The number of rows and columns of the matrix perfectly matches the number of rows and columns of pixels in the original CMOS image. Each matrix unit inside the matrix corresponds to the gain compensation coefficient of the same coordinate pixel in the image, i.e., the illuminance compensation coefficient. There are no pixel missing or row and column misalignment issues. This complete two-dimensional gain coefficient matrix is ​​directly encapsulated as an LED spot uniformity correction model, recording the grayscale compensation ratio required for each pixel on the entire card surface. In the subsequent image preprocessing, the two-dimensional gain coefficient matrix is ​​directly called to complete the pixel-by-pixel spot brightness and darkness correction, eliminating the uneven imaging defect of the ring LED light source with a bright center and dark edges.

[0101] S2.4: Statistically calculate the cumulative grayscale distribution of all pixels in the global gradient grayscale field, determine the lower stretching reference point and the upper stretching reference point based on the cumulative grayscale distribution at the first percentile and the second percentile, and perform grayscale stretching using a logarithmic mapping curve in the grayscale interval between the lower stretching reference point and the upper stretching reference point to form a grayscale remapping curve as a weak signal enhancement curve, wherein the first percentile is less than the second percentile.

[0102] Furthermore, the grayscale values ​​of all pixels in the global grayscale image associated with the global gradient grayscale field are extracted, and all grayscale values ​​are sorted in ascending order. The number of pixels corresponding to different grayscale values ​​is counted to generate a cumulative grayscale distribution statistical sequence. The cumulative grayscale distribution statistical sequence records the percentage of pixels corresponding to each grayscale range from the lowest to the highest grayscale. In this embodiment, for the weak T-line color development signal of the colloidal gold card, the first percentile is set at 2% of the total number of pixels, and the second percentile is set at 98% of the total number of pixels. Extremely dark noise pixels and extremely bright saturated pixels with a very low percentage in the image are excluded to avoid extreme pixels interfering with the determination of the grayscale stretching range.

[0103] Furthermore, the grayscale value corresponding to the 2% percentile in the grayscale cumulative distribution sequence is located and set as the lower limit benchmark for grayscale stretching; the grayscale value corresponding to the 98% percentile is located and set as the upper limit benchmark for grayscale stretching. The grayscale range between the two benchmarks includes the grayscale information of most effective pixels in the blank base of the card, the weakly colored T-line, the moderately colored transition area, and the strongly colored C-line. A logarithmic mapping curve is constructed within the grayscale range defined by the upper and lower limit benchmarks. The characteristics of the logarithmic mapping curve are that the grayscale value is amplified more in the low grayscale range and the grayscale value is compressed less in the high grayscale range, perfectly adapting to the colloid. The requirement for weak signal enhancement in the T-line of the gold card: The weak color pixels of the T-line, which originally had very small grayscale differences and were difficult for the human eye and devices to distinguish, have their grayscale differences widened after logarithmic mapping transformation, resulting in a significant improvement in signal recognition. The grayscale of the high grayscale saturation area of ​​the C-line is moderately compressed, so that there will be no problem of pixel overexposure and loss of edge details. The generated logarithmic grayscale remapping curve completely records the one-to-one conversion relationship between the original grayscale values ​​and the target grayscale values ​​after enhancement. All corresponding value points of the entire mapping curve are completely stored and encapsulated as the weak signal enhancement curve. The logarithmic mapping is the prior art in this field and is not an inventive solution of this application, so it will not be described in detail here.

[0104] S2.5: Based on the global gradient gray field, select pixels with gray values ​​greater than the global gray average as seed points, grow regions from the seed points to neighboring pixels, and then perform morphological closing operations on the region growth results to close the edges, generating a binary mask image of the effective reaction area of ​​the card surface as the effective area segmentation mask of the card surface.

[0105] Furthermore, the arithmetic mean of the gray levels of all pixels in the global grayscale image is first calculated to obtain the global grayscale mean of the entire card surface. Simultaneously, the global gradient grayscale field is used to filter out all pixels with grayscale values ​​higher than the global grayscale mean. These pixels are concentrated in the white reaction substrate area of ​​the colloidal gold card. The grayscale values ​​of the dark sample pad, absorbent pad, and card edge are generally lower than the global mean and can be directly excluded. All the selected high grayscale pixels are marked as regional growth seed points. The seed points are distributed throughout the reaction area of ​​the entire test strip, and there is no problem of missing local seed points. Starting from each seed point, the process is traversed sequentially. The four adjacent pixels above, below, left, and right of the seed point are used to retrieve the calculated standard deviation of grayscale noise on the blank substrate of the test paper. Three times the standard deviation of grayscale noise on the blank substrate of the test paper is used as the grayscale difference judgment threshold. If the grayscale difference between the neighboring pixels and the seed point is less than or equal to the grayscale difference judgment threshold, they are judged to belong to the same effective reaction substrate pixels and included in the growth area. The growth continues to expand outward iteratively until the grayscale difference between adjacent pixels exceeds the threshold and the growth stops. Finally, the large area of ​​continuously connected pixels is the core effective reaction area of ​​the colloidal gold card, and a preliminary grayscale map of the area is generated.

[0106] Furthermore, the edges of the effective reaction area within the preliminary grayscale image contain minute holes and small gaps. Therefore, morphological closing operations need to be performed on the preliminary grayscale image. A standard operation window adapted to the size of the test strip area is selected. First, an expansion operation is performed to fill the small gaps and holes at the edges. Then, an erosion operation of the same size is performed to restore the original outline size of the effective area. After the operation is completed, a reaction area image with continuous edges, no holes, and no breaks is obtained. The morphological closing operation is prior art in this field and is not an inventive solution of this application. Therefore, it will not be described in detail here.

[0107] Furthermore, the reaction area image is converted into a binary mask image. Pixels belonging to the effective reaction area of ​​the colloidal gold card in the binary mask image are uniformly marked with a value of 255 (white), while the card case, sample pad, absorbent pad, and external blank background are all marked with a value of 0 (black). The resolution of the binary mask image is completely consistent with the original imaging image, and the coordinates correspond one-to-one. This binary mask image is the effective area segmentation mask of the card surface.

[0108] S2.6: Package the LED spot homogenization correction model, weak signal enhancement curve, and card surface effective region segmentation mask into an imaging correction parameter set.

[0109] The specific steps of S3 include:

[0110] S3.1: Extract the pixel-wise gain coefficient matrix from the LED spot homogenization correction model and the gray-level remapping curve from the weak signal enhancement curve from the imaging correction parameter set;

[0111] S3.2: Multiply the gray value of each pixel in the acquired original colloidal gold card test strip image by the illuminance compensation coefficient of the corresponding pixel position in the pixel-by-pixel gain coefficient matrix to obtain the homogenized and corrected image;

[0112] Furthermore, the original colloidal gold card test paper image to be processed is converted into a single-channel grayscale image. The entire single-channel grayscale image is traversed pixel by pixel in row and column order. For each pixel at a coordinate position, the original grayscale value is read, and the illuminance compensation coefficient corresponding to the same row and column coordinate of the pixel-by-pixel illuminance compensation coefficient matrix is ​​retrieved simultaneously. The original grayscale value and the illuminance compensation coefficient are multiplied, and the result is used as the corrected grayscale value of the current pixel. After all pixels of the entire image have completed the point-by-point grayscale compensation operation, a homogenized and corrected image is generated to eliminate the defects of excessive brightness in the center of the LED light spot and insufficient illumination around the edges. The grayscale of the entire card surface is uniform and consistent, and there is no brightness gradient with bright center and dark edge, which solves the grayscale recognition error of the marking caused by uneven illumination of the ring light source.

[0113] S3.3: Based on the gray value of each pixel in the homogenized and corrected image, perform gray value conversion according to the gray-level remapping curve to obtain the preprocessed colloidal gold card test paper image;

[0114] Furthermore, the grayscale values ​​of the homogenized and corrected image are read pixel by pixel, and the complete grayscale remapping lookup table corresponding to the weak signal enhancement curve is read simultaneously. The complete grayscale remapping lookup table records the logarithmically stretched output grayscale values ​​corresponding to all original grayscale values ​​from 0 to 255. Using the current grayscale value as the search index, the corresponding logarithmically stretched output grayscale value is matched in the grayscale remapping curve lookup table. The enhanced grayscale value obtained by matching is used to replace the original grayscale value of the current pixel. The grayscale of low grayscale weak T-line pixels is significantly improved after mapping, and the grayscale difference between them and the blank substrate is significantly widened. The grayscale of high grayscale C-line pixels is moderately compressed, and there is no loss of edge details due to grayscale saturation. After the grayscale mapping conversion of all pixels is completed, a preprocessed colloidal gold card test paper image is generated, which has completed both spot homogenization and weak signal grayscale enhancement. The image substrate is uniform and the weak color is clear, reducing the recognition difficulty of mark extraction and grayscale threshold segmentation.

[0115] S3.4: Extract the effective area segmentation mask of the card surface from the imaging correction parameter set, perform a pixel-by-pixel AND operation between the preprocessed colloidal gold card test paper image and the effective area segmentation mask of the card surface, and block the pixels outside the effective area to obtain the effective area image;

[0116] Furthermore, the binarized effective region segmentation mask stored in the imaging correction parameter set is read, and the pixel grayscale values ​​and binarized effective region segmentation mask of the preprocessed colloidal gold card test strip image are read pixel by pixel synchronously. The pixel AND operation rules are executed: if the mask pixel is marked as 0, the grayscale value of the pixel at that coordinate is directly assigned to 0 after the operation, completely blocking irrelevant areas such as the card, absorbent pad, sample pad, and external blank background; if the mask pixel is marked as 255, the original grayscale value of the preprocessed image is completely retained after the operation without modification. After the preprocessed colloidal gold card test strip image completes the pixel-by-pixel AND operation, all invalid backgrounds become pure black, and only the pixel grayscale information of the white reaction substrate area of ​​the colloidal gold card is retained, generating an effective region image containing only the reaction area, reducing the amount of invalid pixel operations, and eliminating interference from background stains and card color differences with T / C line recognition.

[0117] S3.5: On the effective area image, based on the preset vertical position intervals of the T-line and C-line on the colloidal gold card, perform horizontal gray-scale projection integration on the pixels within the preset vertical position interval of the T-line to obtain the horizontal projection curve of the T-line, and perform horizontal gray-scale projection integration on the pixels within the preset vertical position interval of the C-line to obtain the horizontal projection curve of the C-line.

[0118] The step of performing horizontal grayscale projection integration on pixels within a preset vertical position range of the T-line to obtain the horizontal projection curve of the T-line, and performing horizontal grayscale projection integration on pixels within a preset vertical position range of the C-line to obtain the horizontal projection curve of the C-line, includes:

[0119] S3.5.1: Determine the preset vertical start row coordinates and preset vertical end row coordinates of the T-line on the effective area image. Extract the gray values ​​of all pixels in the effective area of ​​each row from the preset vertical start row coordinates to the preset vertical end row coordinates and sum them to obtain the horizontal projection integral value of the row. Then, take the row coordinates of each row and the corresponding horizontal projection integral value of the row as a set of coordinate points, and connect the coordinate points corresponding to all row coordinates in ascending order of row coordinates to form the horizontal projection curve of the T-line.

[0120] Furthermore, the clenbuterol hydrochloride test strip is a standardized test strip with a fixed physical longitudinal position of the T-line on the reaction membrane. The device is equipped with a closed standard slot, ensuring that the placement, tilt angle, and imaging magnification of each test strip are completely consistent. This allows for the linear conversion of the printed T-line area on the test strip into pixel row numbers in the effective area image pixel coordinate system. These pixel row numbers represent the longitudinal start and end coordinates of the T-line. By pre-fixing these two sets of pixel row numbers as parameters for the longitudinal distribution range of the T-line, the longitudinal band between the two coordinate lines represents the fixed distribution range of the T-line color band. The slot's positioning eliminates test strip placement offset, preventing the longitudinal deviation of the mark from exceeding the range. This locks the longitudinal... Within the interval, all image rows are processed sequentially from the starting row to the ending row, arranged in ascending order of row number. For each row, all horizontal pixels are traversed, and the valid pixels preserved by the mask within that row are selected. The grayscale value of each valid pixel is extracted, and the grayscale values ​​of all valid pixels in a single row are summed. The total sum is the horizontal projection integral value specific to the current row. The vertical row coordinates of the current row and the horizontal projection integral value of that row are bound to a set of two-dimensional coordinate points to fully record the total accumulated grayscale value of that row. After all rows within the vertical interval have undergone integration, an ordered set of coordinate points is generated. The set is smoothly connected in ascending order of row coordinates from top to bottom to form a continuous and complete T-line horizontal projection curve. The total grayscale value of pixels in the row containing the T-line will show obvious troughs, and the integral value of the blank base row will be higher. The horizontal center position of the T-line can be accurately located by relying on the position of the curve trough.

[0121] S3.5.2: Determine the preset vertical start row coordinates and preset vertical end row coordinates of line C on the effective area image. Extract the gray values ​​of all pixels in the effective area of ​​each row from the preset vertical start row coordinates to the preset vertical end row coordinates and sum them to obtain the horizontal projection integral value of the row. Then, take the row coordinates of each row and the corresponding horizontal projection integral value of the row as a set of coordinate points, and connect the coordinate points corresponding to all row coordinates in ascending order of row coordinates to form the horizontal projection curve of line C.

[0122] Furthermore, the specific steps in S3.5.2 include:

[0123] (1) Retrieve the pre-fixed C-line longitudinal interval parameters within the effective area image. The C-line preset longitudinal start row coordinate is set to 1260, and the C-line preset longitudinal end row coordinate is set to 1420. The two coordinate values ​​constitute the C-line color band longitudinal interval. The T-line preset longitudinal end row coordinate is set to 1180. The C-line preset longitudinal start row coordinate 1260 is greater than the T-line preset longitudinal end row coordinate 1180. The C-line color band longitudinal interval and the T-line color band longitudinal interval are independent of each other and do not overlap.

[0124] (2) Traverse all image rows in the vertical interval of the C-line color band line by line. The starting value of the line traversal is 1260 and the ending value of the line traversal is 1420. The traversal order is advanced in order of the line number from small to large. For the single line image currently read during the traversal, filter the effective pixels in the line that are retained by the effective area segmentation mask of the card surface. The effective area segmentation mask of the card surface is the internal storage file of the imaging correction parameter set. Extract the gray values ​​corresponding to all the effective pixels that have been filtered in the line. Perform a summation operation on all the extracted gray values. The summation operation retains two decimal places. The result of the operation is defined as the exclusive horizontal projection integral value of the current line.

[0125] (3) Bind the row coordinate value of the current traversed row with the horizontal projection integral value calculated for that row to form a set of independent coordinate points. Each time the gray-scale summation operation of a row of images is completed, a set of coordinate points is generated. After traversing all row coordinates from 1260 to 1420, multiple sets of independent coordinate points are generated.

[0126] (4) Connect all coordinate points in ascending order of row coordinate values. After the connection is completed, a C-line horizontal projection curve is generated. The C-line horizontal projection curve stores the correspondence between all row coordinates and the corresponding horizontal projection integral values. The overall gray value of the pixels from the C-line color band is lower, and the lowest point of the integral value inside the curve forms a trough.

[0127] S3.6: Search for the trough positions of the horizontal projection curves of the T-line and the C-line respectively, and determine the horizontal coordinates corresponding to the trough positions as the center column coordinates of the T-line and the center column coordinates of the C-line;

[0128] S3.7: Determine the column coordinate range of the T-line feature area with the T-line center column coordinates as the center and the preset width threshold as the radius, and determine the column coordinate range of the C-line feature area with the C-line center column coordinates as the center and the preset width threshold as the radius. Combine the preset row coordinate range to finally determine the pixel coordinate range of the T-line feature area and the C-line feature area on the image.

[0129] Further, the center column coordinates of line T are retrieved. In this embodiment, the fixed example value of the center column coordinates of line T is 1306. Using this column coordinate value as the midpoint of the interval, a preset width threshold of 28 pixels is extended to the left column coordinate direction and a preset width threshold of 28 pixels is extended to the right column coordinate direction. The minimum column value of the horizontal column coordinate interval of line T is calculated to be 1278 and the maximum column value is 1334. The two sets of values ​​together constitute the complete horizontal column coordinate interval of the feature area of ​​line T. The center column coordinates of line C are retrieved. In this embodiment, the fixed example value of the center column coordinates of line C is 1302. Using this column coordinate value as the midpoint of the interval, a preset width threshold of 28 pixels is extended to the left column coordinate direction and a preset width threshold of 28 pixels is extended to the right column coordinate direction. The minimum column value of the horizontal column coordinate interval of line C is calculated to be 1274 and the maximum column value is 1330. The two sets of values ​​together constitute the complete horizontal column coordinate interval of the feature area of ​​line C.

[0130] Furthermore, the complete horizontal column coordinate range of the T-line feature area is combined with the preset vertical row coordinate range of the T-line fixed in S3.5.1 to form a closed rectangular pixel area, which completely encloses all T-line colored pixels in the image; the complete horizontal column coordinate range of the C-line feature area is combined with the preset vertical row coordinate range of the C-line fixed in S3.5.2 to form another closed rectangular pixel area, which completely encloses all C-line colored pixels in the image; all row and column coordinate boundary values ​​of the rectangular area corresponding to the T-line are packaged and stored together, and marked as the pixel coordinate range of the T-line feature area; all row and column coordinate boundary values ​​of the rectangular area corresponding to the C-line are packaged and stored together, and marked as the pixel coordinate range of the C-line feature area.

[0131] The specific steps of S4 include:

[0132] S4.1: Calculate the mean gray value and standard deviation of all pixels in the effective area of ​​the preprocessed colloidal gold card test paper image, and set the difference between the mean gray value and the standard deviation of gray value as the initial gray value discrimination threshold.

[0133] Furthermore, the effective region image is read, and only the grayscale values ​​of all effective pixels in the masked reaction area are extracted, excluding background masked pixels. The arithmetic mean of all effective pixel grayscale values ​​is calculated to obtain the global grayscale mean of the effective region. Then, the dispersion of all pixel grayscale values ​​is calculated to generate the grayscale standard deviation of the effective region. The grayscale standard deviation is subtracted from the global grayscale mean to obtain the initial grayscale discrimination threshold. This initial grayscale discrimination threshold serves as the starting reference value for binary segmentation of the marking line and the blank substrate. The grayscale of the colloidal gold card marking line is generally lower than that of the blank substrate. Pixels lower than the initial grayscale discrimination threshold are initially identified as candidate pixels for marking lines, while those higher than the initial grayscale discrimination threshold are identified as blank substrate pixels. The initial grayscale discrimination threshold is generated based on the true grayscale distribution of the current sample image, without using a uniform threshold to adapt to all samples, thus improving the adaptability of the initial segmentation.

[0134] S4.2: Calculate the gradient magnitude of each pixel in the effective region of the global gradient gray field, select pixels with gradient magnitudes lower than the preset first quantile to form a base pixel set, calculate the variance of gray values ​​of all pixels in the base pixel set, take the square root of the variance to obtain the standard deviation of gray noise of the blank base of the test paper, and then multiply the standard deviation of gray noise of the blank base of the test paper by a preset multiple to obtain the initial stain bubble abnormal threshold.

[0135] Furthermore, the specific steps in S4.2 include:

[0136] (1) Obtain the global gradient grayscale field, the effective reaction area pixel range, the card surface effective area segmentation mask, and the pre-fixed preset first quantile parameter 0.3 and preset magnification parameter 6;

[0137] (2) Extract the pixel data corresponding to the effective response area in the global gradient gray field, retrieve all pixel storage information of the global gradient gray field, and complete the filtering based on the effective pixel coordinates of the mask markings in the effective area of ​​the card surface. Only retain all pixels with coordinates matching the effective response area, and remove pixels marked as invalid backgrounds by the mask. Read the horizontal gradient difference and vertical gradient difference corresponding to each pixel after filtering, and complete the gradient magnitude integration calculation based on the two sets of differences. The gradient magnitude is used to characterize the degree of gray level change at the current pixel position.

[0138] (3) Sort the gradient magnitudes of all valid pixels in ascending order from smallest to largest, and filter the pixels by combining the pre-fixed first quantile of 0.3. Extract all pixels within the first 30% of the sorted sequence. The horizontal and vertical grayscale changes of these pixels are at a low level, and the pixel area is a uniform blank base. There are no grayscale abrupt changes caused by markings, stains, or bubbles. Collect all the filtered pixels to generate a base pixel set.

[0139] (4) Extract the gray values ​​corresponding to all pixels in the base pixel set, perform discrete variance operation on all gray values, and use the variance value obtained to characterize the fluctuation of the imaging noise of the blank base. Take the square root of the variance as the standard deviation of the gray noise of the blank base of the test paper.

[0140] (5) Retrieve the pre-cured preset magnification parameter 6, multiply the gray noise standard deviation of the blank substrate of the test paper with the magnification 6, and define the obtained value as the initial stain bubble abnormality threshold.

[0141] (6) Traverse all local regions of the image and calculate the local gray-level variance. Regions whose local gray-level variance values ​​exceed the initial dirt bubble abnormality threshold are identified as dirt bubble impurity interference regions. Automatically remove all pixels in the region to avoid impurity gray levels interfering with subsequent line gray-level calculations.

[0142] S4.3: Using the initial grayscale discrimination threshold and the initial stain bubble abnormality threshold as parameters for binarization segmentation, perform binarization segmentation on the preprocessed colloidal gold card test paper image and extract the binarized image of the candidate region of the marking.

[0143] Furthermore, an initial grayscale discrimination threshold and an initial stain / bubble anomaly threshold are simultaneously loaded, and a two-layer screening and segmentation operation is performed on the preprocessed test strip image: The first layer completes basic binary segmentation based on the initial grayscale discrimination threshold. Pixels with grayscale values ​​lower than the initial grayscale discrimination threshold are marked as candidate pixels for the marking line, and pixels with grayscale values ​​higher than the initial grayscale discrimination threshold are marked as base pixels. The second layer synchronously traverses all local regions of the segmented image and calculates the local pixel grayscale variance block by block. If the local variance exceeds the initial stain / bubble anomaly threshold, all candidate pixels in that region are removed and determined to be impurity interference regions, and are not included in the marking line candidate range. After the two-layer screening is completed, only continuous pixel regions with grayscale values ​​that meet the marking line characteristics and are free from stain / bubble interference are retained to generate a binary image of the marking line candidate region. White pixels in the image are potential T / C marking line regions, and black pixels are blank base and impurity regions.

[0144] S4.4: Extract edge pixels from the binarized image of the candidate region of the marking line, calculate the ratio of the mean gray-level gradient magnitude of the edge pixels to the standard deviation of the gray-level noise of the blank substrate of the test paper, and obtain the signal-to-noise ratio of the marking line edge.

[0145] Furthermore, standard edge extraction is performed on the binarized image of the candidate regions of the caliper, and the contour boundaries of all white candidate regions are identified. The pixels of the original preprocessed image corresponding to the contour boundary coordinates are the edge pixels of the caliper. The gradient magnitude of the corresponding edge pixel coordinates in the global gradient gray field is retrieved, and the arithmetic mean of the gradient magnitudes of all edge pixels is calculated to obtain the mean edge gradient. The mean edge gradient is divided by the pre-calculated standard deviation of the gray noise of the blank substrate of the test paper to obtain the dimensionless signal-to-noise ratio of the caliper edge. The higher the signal-to-noise ratio of the caliper edge, the clearer the caliper color signal is compared with the substrate noise, and the better the segmentation threshold adaptability.

[0146] S4.5: Determine the absolute value of the difference between the signal-to-noise ratio of the tread edge and the value 1, and determine whether the absolute value of the difference is less than a preset convergence threshold. If the absolute value of the difference is greater than or equal to the preset convergence threshold, then increase the current grayscale discrimination threshold by one step, and simultaneously increase the current stain bubble abnormality threshold according to the increase ratio of the grayscale discrimination threshold. Re-binarize and recalculate the tread edge signal-to-noise ratio with the increased grayscale discrimination threshold and the increased stain bubble abnormality threshold until the absolute value of the difference is less than the convergence threshold.

[0147] Furthermore, the specific steps of S4.5 include:

[0148] (1) Read the signal-to-noise ratio of the mark edge, the standard deviation of gray noise of the blank substrate of the test paper, the current gray discrimination threshold and the current abnormal threshold of the stain bubble, and set the convergence threshold to 0.02 and the single increment step of the gray discrimination threshold to 0.8.

[0149] (2) Calculate the absolute value of the difference between the signal-to-noise ratio at the edge of the grading line and the constant 1;

[0150] (3) Compare the absolute value of the obtained difference with the pre-fixed preset convergence threshold of 0.02;

[0151] If the absolute value of the difference is greater than or equal to the convergence threshold of 0.02, the threshold synchronization update operation is performed. First, the current grayscale discrimination threshold is superimposed with a fixed increment step of 0.8 to obtain the updated grayscale discrimination threshold. Then, the current grayscale discrimination threshold value is increased by the same increment step. The current stain bubble abnormal threshold is synchronously amplified to obtain the updated stain bubble abnormal threshold. After completing the update of the two sets of threshold parameters, the updated grayscale discrimination threshold and the updated stain bubble abnormal threshold are used as new input parameters. Jump to S4.3 to perform complete binary segmentation. After S4.3 outputs the binary image of the candidate area of ​​the datum line, jump to S4.4 to complete the edge extraction and datum line edge signal-to-noise ratio calculation again. After the calculation is completed, return to (2) repeat the difference operation and comparison judgment.

[0152] If the absolute value of the difference is less than the convergence threshold of 0.02, all threshold iteration loops are terminated directly, and the grayscale discrimination threshold and the stain bubble abnormality threshold used at the time of loop termination are used as the final output parameters.

[0153] S4.6: Solidify the grayscale discrimination threshold and the stain bubble abnormality threshold at the end of the iteration into a set of thresholds, and output the solidified grayscale discrimination threshold set.

[0154] The specific steps of S5 include:

[0155] S5.1: Extract the grayscale discrimination threshold from the solidified grayscale discrimination threshold group as the target grayscale value, use the target grayscale value as the expected value of the automatic exposure control of the CMOS image sensor, dynamically adjust the integration time and analog gain of the CMOS image sensor, and trigger the acquisition of a real-time colloidal gold card grayscale image after each adjustment.

[0156] Furthermore, the specific steps in S5.1 include:

[0157] (1) Obtain the solidified grayscale discrimination threshold group, and simultaneously pre-solidify the automatic exposure single adjustment step parameters, wherein the integral time single adjustment step is set to 0.1 milliseconds and the analog gain single adjustment step is set to 0.3 times;

[0158] (2) Read the optimal grayscale discrimination threshold stored in the solidified grayscale discrimination threshold group, and define the obtained grayscale discrimination threshold value as the target expected grayscale value of the CMOS image sensor automatic exposure control loop;

[0159] (3) Read the effective area image obtained by S3.4 from the current acquired image, calculate the arithmetic mean of the gray values ​​of all effective pixels in the effective area image, and compare the calculated average gray value of the effective area with the obtained target expected gray value.

[0160] If the average gray level of the current effective area of ​​the image is higher than the target expected gray level, the hardware parameter reduction operation is performed, that is, the current integration time of the CMOS image sensor is reduced by a preset integration time adjustment step of 0.1 milliseconds, and the current analog gain of the CMOS image sensor is reduced by a preset analog gain adjustment step of 0.3 times, thus completing the synchronous reduction of integration time and analog gain.

[0161] If the average gray level of the current effective area of ​​the image is lower than the target expected gray level, the hardware parameter adjustment operation is performed, that is, the current integration time of the CMOS image sensor is added to the preset integration time by a single adjustment step of 0.1 milliseconds, and the current analog gain of the CMOS image sensor is added to the preset analog gain by a single adjustment step of 0.3 times, so as to complete the synchronous adjustment of integration time and analog gain.

[0162] (4) After completing one round of integration time and analog gain hardware parameter adjustment, the main control chip outputs hardware synchronization trigger signal. After the synchronization trigger signal is sent to the CMOS image sensor, the CMOS image sensor acquires a frame of real-time colloidal gold card grayscale image. The single round of hardware parameter adjustment operation corresponds to the output of a single frame of real-time colloidal gold card grayscale image.

[0163] (5) Repeat (3)-(4) to complete multiple rounds of dynamic adjustment of hardware parameters and corresponding real-time image acquisition, and generate continuous multi-frame real-time colloidal gold card grayscale images.

[0164] S5.2: Extract the effective area segmentation mask of the card surface from the imaging correction parameter set, and perform a pixel-by-pixel AND operation between each frame of real-time colloidal gold card grayscale image and the effective area segmentation mask of the card surface to lock all effective pixels within the effective area;

[0165] Furthermore, the specific steps in S5.2 include:

[0166] (1) Obtain the real-time colloidal gold card grayscale image, imaging correction parameter set, and card surface effective area segmentation mask. The card surface effective area segmentation mask and the real-time colloidal gold card grayscale image are both uniformly set to 2592×1944 pixel resolution.

[0167] (2) Read the binary card surface effective area segmentation mask stored in the imaging correction parameter set. The effective reaction substrate pixel mark value is uniformly set to 255, and the invalid background pixel mark value is uniformly set to 0. The two types of mark values ​​are global static fixed parameters.

[0168] (3) Sequentially retrieve the grayscale image of the single frame of the colloidal gold card, and synchronously read the grayscale value of a single coordinate position of the single frame of the real-time colloidal gold card grayscale image and the value marked at the same coordinate position of the effective area segmentation mask of the card surface, and perform a pixel-by-pixel AND operation; if the value marked at the coordinate corresponding to the effective area segmentation mask of the card surface is equal to 0, then the grayscale value of the pixel at that coordinate is assigned to 0, and the invalid pixels of the card case, absorbent pad, and background are masked; if the value marked at the coordinate corresponding to the effective area segmentation mask of the card surface is equal to 255, then the original grayscale value of the real-time colloidal gold card grayscale image is retained, and the white reaction substrate pixel of the test paper is retained.

[0169] (4) After completing the pixel-by-pixel AND operation of all coordinates of the single-frame real-time colloidal gold card grayscale image, the corresponding single-frame real-time effective area image is generated. Only the effective pixels corresponding to the mask mark 255 are retained inside the single-frame real-time effective area image. All effective pixels constitute the exclusive effective pixel set of this frame. Each real-time colloidal gold card grayscale image independently performs complete mask masking processing and generates an independent single-frame real-time effective area image.

[0170] S5.3: For each frame of real-time colloidal gold card grayscale image, extract the grayscale value of each effective pixel in the effective area according to the pixel row priority order, and associate the effective pixel grayscale value sequence of the frame image with the timestamp and frame number of the frame image to form the pixel-level grayscale distribution data of the frame.

[0171] Furthermore, for the real-time effective area image after single-frame masking, the grayscale value of each effective pixel is read sequentially according to the row-first traversal order from top to bottom and from left to right for each row. All grayscale values ​​are arranged in the traversal order to generate an ordered one-dimensional grayscale value sequence, which completely records the grayscale distribution details of all pixels in the image reaction area of ​​this frame. The microsecond-level global timestamp and the continuous acquisition frame number corresponding to the current frame acquisition are extracted. The grayscale value sequence, timestamp, and frame number are bound and encapsulated to generate independent pixel-level grayscale distribution data for the current frame. Each real-time image generates a set of exclusive pixel-level grayscale distribution data, completely preserving the original grayscale information of all pixels in the frame.

[0172] S5.4: Based on the pixel coordinate range of the T-line feature area, extract the gray values ​​of all pixels within the T-line feature area from the pixel-level gray-level distribution data of the current frame and calculate the average gray value as the average gray value of the T-line region; based on the pixel coordinate range of the C-line feature area, extract the gray values ​​of all pixels within the C-line feature area from the pixel-level gray-level distribution data of the current frame and calculate the average gray value as the average gray value of the C-line region; calculate the ratio of the average gray value of the T-line region to the average gray value of the C-line region as the T / C line gray-level ratio of the current frame.

[0173] Furthermore, the pre-locked rectangular pixel coordinate ranges of the T-line and C-line feature areas are retrieved. Combined with the pixel-level grayscale distribution data of the current frame, all pixel grayscale values ​​falling within the T-line rectangular range are precisely selected. The sum of all T-line pixel grayscale values ​​is divided by the total number of pixels to obtain the average grayscale value of the T-line region. Similarly, all pixel grayscale values ​​within the C-line feature area rectangular range are selected, and the arithmetic mean is calculated to obtain the average grayscale value of the C-line region. The average grayscale value of the T-line region is divided by the average grayscale value of the C-line region to obtain the T / C line grayscale ratio of the current frame in the range of 0 to 1. The higher the concentration of the analyte in the colloidal gold card sample, the deeper the T-line color and the lower the average grayscale value, and the smaller the T / C line grayscale ratio. The qualitative and quantitative judgment of the sample is achieved by relying on the size of the ratio. A set of exclusive T / C line grayscale ratios is independently calculated for each real-time image frame. The ratios of multiple frames are used together for the final sample interpretation to avoid misjudgment caused by single-frame imaging fluctuations.

[0174] The specific steps of S6 include:

[0175] S6.1: Obtain the T / C line grayscale ratio values ​​corresponding to each of the continuously acquired real-time colloidal gold card grayscale images, and calculate the median and dispersion values ​​of all T / C line grayscale ratio values;

[0176] Furthermore, after the device completes continuous acquisition of multiple frames of real-time images, it summarizes the T / C line grayscale ratios calculated independently for all frames, sorts all ratio values ​​from smallest to largest to obtain a sorted sequence, and extracts the value at the middle position of the sorted sequence as the median value of all frame ratios. The median can avoid extreme value interference caused by individual abnormal fluctuations in frame ratios and is more stable than the average value. At the same time, it calculates the dispersion between the ratios of multiple frames to generate a dispersion value. The dispersion is used to judge the stability of multi-frame imaging. If the dispersion value is too high, it means that there are obvious fluctuations in brightness and darkness in the real-time image, and the device will automatically prompt to re-acquire sample images.

[0177] S6.2: If the median value is less than or equal to the preset positive threshold, it is interpreted as a positive result; if the median value is greater than or equal to the preset negative threshold, it is interpreted as a negative result; if the median value is between the preset negative threshold and the preset positive threshold, it is interpreted as a critical result. Finally, a qualitative interpretation result is output. In this embodiment, the negative threshold is set to 0.62 and the positive threshold is set to 0.38.

[0178] S6.3: For samples that are interpreted as positive, the median value is matched with a pre-established concentration mapping table; the concentration mapping table contains the range of T / C line grayscale ratio values ​​corresponding to multiple concentration intervals.

[0179] Furthermore, the device locally stores a standardized concentration mapping table, which is generated through repeated imaging and calibration of clenbuterol samples at different gradient standard concentrations. The concentration mapping table is divided into multiple continuous concentration intervals, each of which corresponds to a fixed range of T / C line grayscale ratio values. The ratio has a stable negative correlation with the concentration of the analyte. After a sample is qualitatively determined to be positive, the complete concentration mapping table is directly retrieved. Using the median of the ratios across multiple frames as the search keyword, all ratio ranges within the concentration mapping table are traversed to match the ratio interval in which the median value falls.

[0180] S6.4: Determine the target gray ratio range into which the median value falls, take the concentration range corresponding to the target gray ratio range as the quantitative interpretation result, and associate the qualitative interpretation result and the quantitative interpretation result with the sample number of the current colloidal gold card and output them;

[0181] Furthermore, after completing the mapping table interval matching, the concentration range of the analyte bound to the target ratio interval is extracted as the quantitative detection result of the current sample, and the approximate concentration range of clenbuterol residue in the sample is fully recorded. Before the test, the operator pre-enters the unique sample number of the current sample to be tested, and binds the three sets of information, namely the sample number, qualitative judgment result, and quantitative concentration range, to generate a standardized test report. The standardized test report is displayed intuitively on the device screen at the same time, and the complete test record is stored locally, realizing the integrated output of qualitative and quantitative analysis of a single sample.

[0182] S6.5: Associate the pixel-level grayscale distribution data, T / C line grayscale ratio, CMOS imaging parameters and LED light source operating parameters corresponding to each frame of real-time colloidal gold card grayscale image according to the acquisition timestamp to form a new data record. Append the new data record to the end of the original imaging dataset to update the original imaging dataset.

[0183] Furthermore, all real-time image frames acquired during this detection are traversed. For each real-time image frame, the complete pixel-level grayscale distribution data, the grayscale ratio of the T / C line in this frame, the corresponding CMOS integration time and analog gain during dynamic adjustment, and the LED drive current and duty cycle parameters at the moment of real-time acquisition are extracted. Using the microsecond-level acquisition timestamp of this frame as the unified association key, all data are packaged to generate independent new data records, with one independent new data record corresponding to each image frame. After all new data records are generated, they are arranged in chronological order of acquisition time and appended to the end of the original imaging dataset file package generated in the initial detection. The built-in index table of the dataset is updated synchronously, and the storage path, timestamp, sample number, and detection result summary information of each record are added. The original imaging dataset completes the real-time sample data expansion and update, and the dataset continuously accumulates original data of colloidal gold card imaging with different concentrations and different color development states.

[0184] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments under the guidance of the present invention without departing from the spirit and scope of the present invention. All of these variations are within the protection scope of the present invention.

Claims

1. A CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction, characterized in that, include: S1: Simultaneously acquire the raw imaging dataset of the colloidal gold card; S2: Reconstruct the global gradient grayscale field of the colloidal gold card using the original imaging dataset. Based on the global gradient grayscale field, construct the LED spot homogenization correction model and the weak signal enhancement curve respectively. At the same time, generate the effective area segmentation mask of the card surface and integrate them to form an imaging correction parameter set. S3: Call the imaging correction parameter set, apply the LED spot homogenization correction model and weak signal enhancement curve to preprocess the colloidal gold card test paper image, and combine the effective area segmentation mask of the card surface to locate the T-line feature area and C-line feature area; S4: Based on the preprocessed colloidal gold card test strip image and the global gradient gray field, set the gray level discrimination threshold, extract the gray level noise standard deviation of the blank substrate of the test strip and set the stain bubble abnormality threshold, iteratively optimize the gray level discrimination threshold and the stain bubble abnormality threshold until the absolute value of the difference between the extracted mark edge signal-to-noise ratio and 1 is less than the preset convergence threshold, and output the solidified gray level discrimination threshold group. S5: Collect real-time colloidal gold card images based on the solidified grayscale discrimination threshold group, lock effective pixels by relying on the effective area segmentation mask of the card surface, extract pixel-level grayscale distribution data frame by frame and calculate the grayscale ratio of T / C line; S6: Based on the grayscale ratio of the T / C line in each frame, complete the qualitative and quantitative interpretation of colloidal gold samples of agricultural products, and simultaneously archive pixel-level grayscale distribution data and update the original imaging dataset.

2. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 1, characterized in that, The specific steps of S1 include: The CMOS image sensor is controlled by a timestamp synchronous triggering method to sequentially acquire images of colloidal gold cards under LED light source according to the preset first exposure time, second exposure time and third exposure time, generating a graded exposure image sequence composed of the first exposure image, the second exposure image and the third exposure image, wherein the first exposure time is shorter than the second exposure time, and the second exposure time is shorter than the third exposure time. At each frame of image acquisition time, the integration time and analog gain corresponding to each frame of image are obtained by reading the status register inside the CMOS image sensor as CMOS imaging parameters; the LED light source driving current value at each frame of image acquisition time is obtained by monitoring the sampling resistor voltage of the LED light source driving circuit, and the current duty cycle value of the pulse width modulation controller is read as LED light source operating condition parameters. Each frame of graded exposure image is associated with its corresponding CMOS imaging parameters and LED light source operating parameters according to the acquisition timestamp, forming multiple image-parameter association units. All image-parameter association units are then aggregated and stored as the original imaging dataset.

3. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 2, characterized in that, The specific steps of S2 include: A weighted fusion-based exposure fusion algorithm is used to synthesize the first exposure image, the second exposure image, and the third exposure image into a single global grayscale image. Taking each pixel in the global grayscale image as the center, extract the grayscale difference between adjacent pixels in the horizontal and vertical directions for each pixel, combine the grayscale differences in the horizontal and vertical directions to form the gradient vector of the corresponding pixel, and the gradient vectors of all pixels constitute the global gradient grayscale field. Using the grayscale value and coordinate position of each pixel in the global gradient grayscale field as input data, a second-order polynomial surface fitting algorithm is used to fit the illuminance distribution fitting surface of the LED light source on the card surface. The illuminance distribution fitting surface is compared pixel by pixel with the standard uniform illuminance plane to generate a pixel-by-pixel gain coefficient matrix composed of illuminance compensation coefficients at each pixel position, which serves as the LED spot homogenization correction model.

4. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 3, characterized in that, The specific steps of S2 also include: The cumulative grayscale distribution of all pixels in the global gradient grayscale field is statistically analyzed. Based on the cumulative grayscale distribution, the lower stretching reference point and the upper stretching reference point are determined at the first percentile and the second percentile. In the grayscale interval between the lower stretching reference point and the upper stretching reference point, a logarithmic mapping curve is used to stretch the grayscale to form a grayscale remapping curve as a weak signal enhancement curve, wherein the first percentile is smaller than the second percentile. Based on the global gradient gray field, pixels with gray values ​​greater than the global gray average are selected as seed points. Region growth is performed from the seed points to the neighboring pixels. Then, morphological closing operations are performed on the region growth results to close the edges, generating a binary mask image of the effective reaction area of ​​the card surface as the effective area segmentation mask of the card surface. The LED spot homogenization correction model, weak signal enhancement curve, and card surface effective region segmentation mask are packaged into an imaging correction parameter set.

5. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 4, characterized in that, The method of fitting the illuminance distribution of the LED light source on the card surface using a second-order polynomial surface fitting algorithm includes: Using the horizontal and vertical coordinates of each pixel in the full-domain grayscale image as independent variable data and the grayscale value of the corresponding pixel as dependent variable data, a second-order polynomial fitting equation is constructed. The coefficient matrix of the second-order polynomial fitting equation is solved using the least squares method. The obtained coefficient matrix is ​​then substituted into the second-order polynomial fitting equation to obtain the illuminance distribution fitting surface. The fitted gray value at each pixel position on the illuminance distribution fitting surface is compared pixel by pixel with the actual gray value at the corresponding pixel position in the global grayscale image, and the ratio of the fitted gray value to the actual gray value is calculated as the illuminance compensation coefficient for the corresponding pixel position. Traverse all pixel positions and arrange the illumination compensation coefficients of all pixel positions according to pixel coordinates to form a pixel-wise gain coefficient matrix with the same resolution as the original image.

6. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 5, characterized in that, The specific steps of S3 include: Extract the pixel-wise gain coefficient matrix from the LED spot homogenization correction model and the gray-level remapping curve from the weak signal enhancement curve from the imaging correction parameter set; The gray value of each pixel in the acquired original colloidal gold card test strip image is multiplied by the illuminance compensation coefficient of the corresponding pixel position in the pixel-by-pixel gain coefficient matrix to obtain the homogenized corrected image. Based on the gray value of each pixel in the homogenized image, gray value conversion is performed according to the gray-level remapping curve to obtain the preprocessed colloidal gold card test paper image. Extract the effective area segmentation mask from the imaging correction parameter set, perform a pixel-by-pixel AND operation between the preprocessed colloidal gold test paper image and the effective area segmentation mask, and mask out pixels outside the effective area to obtain the effective area image.

7. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 6, characterized in that, The specific steps of S3 also include: On the effective area image, based on the preset vertical position intervals of the T-line and C-line on the colloidal gold card, the horizontal gray-scale projection integration is performed on the pixels within the preset vertical position interval of the T-line to obtain the horizontal projection curve of the T-line, and the horizontal gray-scale projection integration is performed on the pixels within the preset vertical position interval of the C-line to obtain the horizontal projection curve of the C-line. Search for the trough positions of the horizontal projection curves of the T-line and the C-line respectively, and determine the horizontal coordinates corresponding to the trough positions as the center column coordinates of the T-line and the center column coordinates of the C-line; The column coordinate range of the T-line feature area is determined by taking the center column coordinates of the T-line as the center and the preset width threshold as the radius. The column coordinate range of the C-line feature area is determined by taking the center column coordinates of the C-line as the center and the preset width threshold as the radius. The pixel coordinate range of the T-line feature area and the C-line feature area on the image is finally determined by combining the preset row coordinate range.

8. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 7, characterized in that, The step of performing horizontal grayscale projection integration on pixels within a preset vertical position range of the T-line to obtain the horizontal projection curve of the T-line, and performing horizontal grayscale projection integration on pixels within a preset vertical position range of the C-line to obtain the horizontal projection curve of the C-line, includes: On the effective area image, determine the preset vertical start row coordinates and preset vertical end row coordinates of the T-line. From the preset vertical start row coordinates to the preset vertical end row coordinates, extract the gray values ​​of all pixels in each row within the effective area and sum them to obtain the horizontal projection integral value of each row. Then, take the row coordinates of each row and the corresponding horizontal projection integral value as a set of coordinate points, and connect the coordinate points corresponding to all row coordinates in ascending order of row coordinates to form the horizontal projection curve of the T-line. On the effective area image, determine the preset vertical start row coordinates and preset vertical end row coordinates of line C. From the preset vertical start row coordinates to the preset vertical end row coordinates, extract the gray values ​​of all pixels in each row within the effective area and sum them to obtain the horizontal projection integral value of each row. Then, take the row coordinates of each row and the corresponding horizontal projection integral value as a set of coordinate points, and connect the coordinate points corresponding to all row coordinates in ascending order of row coordinates to form the horizontal projection curve of line C.

9. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 8, characterized in that, The specific steps of S4 include: Calculate the mean gray value and standard deviation of all pixels in the effective area of ​​the preprocessed colloidal gold card test strip image, and set the difference between the mean gray value and the standard deviation of gray value as the initial gray value discrimination threshold. Calculate the gradient magnitude of each pixel in the effective region of the global gradient gray field, select pixels with gradient magnitudes lower than the preset first quantile to form a base pixel set, calculate the variance of gray values ​​of all pixels in the base pixel set, take the square root of the variance to obtain the standard deviation of gray noise of the blank base of the test strip, and then multiply the standard deviation of gray noise of the blank base of the test strip by a preset multiple to obtain the initial stain bubble abnormal threshold. Using the initial grayscale discrimination threshold and the initial stain bubble abnormality threshold as parameters for binarization segmentation, the preprocessed colloidal gold card test strip image is binarized to extract the binarized image of the candidate region of the marking. Edge pixels are obtained by performing edge extraction on the binarized image of the candidate region of the marking. The ratio of the mean gray-level gradient magnitude of the edge pixels to the standard deviation of the gray-level noise of the blank substrate of the test paper is calculated to obtain the signal-to-noise ratio of the marking edge.

10. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 9, characterized in that, The specific steps of S4 also include: Determine the absolute value of the difference between the signal-to-noise ratio of the mark edge and the value 1. Determine whether the absolute value of the difference is less than a preset convergence threshold. If the absolute value of the difference is greater than or equal to the preset convergence threshold, increase the current grayscale discrimination threshold by one step. At the same time, increase the current stain bubble abnormality threshold in accordance with the increase ratio of the grayscale discrimination threshold. Re-binarize and recalculate the mark edge signal-to-noise ratio with the increased grayscale discrimination threshold and the increased stain bubble abnormality threshold until the absolute value of the difference is less than the convergence threshold. The grayscale discrimination threshold and the stain bubble abnormality threshold at the end of the iteration are solidified into a set of thresholds, which are then output as the solidified grayscale discrimination threshold set.

11. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 10, characterized in that, The specific steps of S5 include: Extract the grayscale discrimination threshold from the solidified grayscale discrimination threshold group as the target grayscale value, use the target grayscale value as the expected value for automatic exposure control of the CMOS image sensor, dynamically adjust the integration time and analog gain of the CMOS image sensor, and trigger the acquisition of a real-time colloidal gold card grayscale image after each adjustment. Extract the effective area segmentation mask of the card surface from the imaging correction parameter set, and perform a pixel-by-pixel AND operation between each frame of real-time colloidal gold card grayscale image and the effective area segmentation mask of the card surface to lock all effective pixels in the effective area. For each frame of real-time colloidal gold card grayscale image, the grayscale value of each effective pixel in the effective area is extracted according to the pixel row priority order. The effective pixel grayscale value sequence of the corresponding frame image is associated with the timestamp and frame number of the corresponding frame image to form the pixel-level grayscale distribution data of the corresponding frame. Based on the pixel coordinate range of the T-line feature area, the gray values ​​of all pixels within the T-line feature area are extracted from the pixel-level gray-level distribution data of the current frame, and the average gray value is calculated as the average gray value of the T-line region. Based on the pixel coordinate range of the C-line feature area, the gray values ​​of all pixels within the C-line feature area are extracted from the pixel-level gray-level distribution data of the current frame, and the average gray value is calculated as the average gray value of the C-line region. The ratio of the average gray value of the T-line region to the average gray value of the C-line region is calculated as the T / C line gray-level ratio of the current frame.

12. The CMOS imaging detection method for colloidal gold test paper based on global gradient grayscale field reconstruction as described in claim 11, characterized in that, The specific steps of S6 include: Obtain the T / C line grayscale ratio values ​​corresponding to each of the continuously acquired real-time colloidal gold card grayscale images, and calculate the median and dispersion values ​​of all T / C line grayscale ratio values; If the median value is less than or equal to the preset positive threshold, it is interpreted as a positive result; if the median value is greater than or equal to the preset negative threshold, it is interpreted as a negative result; if the median value is between the preset negative threshold and the preset positive threshold, it is interpreted as a critical result, and the final qualitative interpretation result is output. For samples that are interpreted as positive, the median value is matched with a pre-established concentration mapping table; the concentration mapping table contains the range of T / C line grayscale ratio values ​​corresponding to multiple concentration intervals. Determine the target gray-scale ratio range into which the median value falls, take the concentration range corresponding to the target gray-scale ratio range as the quantitative interpretation result, and associate the qualitative interpretation result and the quantitative interpretation result with the sample number of the current colloidal gold card and output them; The pixel-level grayscale distribution data, T / C line grayscale ratio, CMOS imaging parameters, and LED light source operating parameters corresponding to each frame of real-time colloidal gold card grayscale image are associated according to the acquisition timestamp to form a new data record. The new data record is appended to the end of the original imaging dataset to update the original imaging dataset.