Intelligent agricultural product pesticide residue detection method and system based on spectrum technology

By acquiring hyperspectral reflectance data and illumination confidence factors, combined with black-and-white board correction and illumination confidence assessment, the background signal is adaptively subtracted, pesticide characteristic signals are enhanced, and a pesticide residue distribution heatmap is generated. This solves the problem of insufficient accuracy in pesticide residue detection for agricultural products with complex curved surfaces and achieves highly robust detection results.

CN121661003APending Publication Date: 2026-03-13东营市华科农业科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-02
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing technologies lack effective correction for uneven light distribution and adaptive suppression of strong biological matrix background when detecting agricultural products with complex curved surfaces, resulting in insufficient detection accuracy.

Method used

By acquiring hyperspectral reflectance data, illumination confidence factor, and net residual spectrum, and combining black-and-white board correction and illumination confidence assessment, the background signal is adaptively subtracted, pesticide characteristic signals are enhanced, and noise is suppressed to generate a heat map of pesticide residue distribution and perform segmentation judgment.

Benefits of technology

It enables precise detection of pesticide residues in agricultural products with complex curved surfaces, improves the robustness and accuracy of detection, and effectively solves the detection challenges under uneven illumination and strong background interference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121661003A_ABST
    Figure CN121661003A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of image processing, and particularly relates to an intelligent agricultural product pesticide residue detection method and system based on a spectrum technology, and the method comprises the steps: obtaining the hyperspectral reflectivity according to the original hyperspectrum, dark current and whiteboard image data; calculating an illumination confidence factor by using the average spectral intensity; performing linear scaling on the obtained standard biological matrix background spectrum according to the illumination confidence factor to obtain a local background estimated value and obtain a net residual spectrum; generating a pesticide residue distribution thermodynamic diagram by combining the cosine similarity of the net residual spectrum and the target pesticide standard fingerprint spectrum and the noise suppression weight based on the illumination confidence factor; and pesticide residue detection is carried out according to the statistical characteristics of the connected region of the suspected defect mask. Through adaptive background deduction and noise suppression, the problems of uneven curved surface illumination and strong background interference are solved, and the detection accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology. More specifically, this invention relates to a smart agriculture pesticide residue detection method and system based on spectral technology. Background Technology

[0002] Agricultural product safety testing plays a crucial role in modern agricultural production and food supply chain management. During the growth and storage of agricultural products, pesticides are widely used to control pests and diseases; however, pesticide residues directly impact consumer health and food safety. Traditional pesticide residue detection methods, such as gas chromatography and liquid chromatography, while highly accurate, are complex, time-consuming, and destructive, making them unsuitable for the rapid, non-destructive testing of large quantities of agricultural products. Therefore, developing a rapid, non-destructive, and accurate pesticide residue detection method is essential for ensuring the quality and safety of agricultural products.

[0003] In related technologies, for example, Chinese patent document CN104931470B discloses a pesticide residue detection device and method based on fluorescence hyperspectral technology. This method constructs a database containing characteristic models of different vegetables, pesticides, and their concentrations. It uses an tunable wavelength excitation light source to irradiate the leaves under test, acquires fluorescence hyperspectral images, and calculates the pesticide type and concentration by extracting spectral characteristic wavelengths and matching them with models in the database. This approach combines fluorescence spectroscopy and image technology, achieving rapid and non-destructive detection of pesticide residues to a certain extent.

[0004] However, the relevant technologies still have certain limitations when processing spectral data of agricultural products with complex shapes. First, the method mainly relies on the matching of fluorescence characteristics with a pre-set database. However, in actual detection, the surface of agricultural products is usually an irregular convex surface, resulting in extremely uneven surface illumination distribution. The difference in reflection intensity between the central bright area and the edge shadow area is huge. This light attenuation caused by geometric shape will seriously affect the signal-to-noise ratio of spectral data, and the existing technology lacks an effective quantification and correction mechanism for this spatial illumination difference. Second, the surface of agricultural products is rich in water, pigments and other biological matrices, and the background signal intensity generated is much higher than that of trace pesticides. Moreover, the background signal fluctuates with the illumination conditions of the curved surface. The relevant technologies do not involve adaptive background subtraction strategies for illumination distribution, which makes it easy for weak pesticide characteristics to be masked by strong biological matrix background or uneven illumination, thus affecting the sensitivity and accuracy of detection. Summary of the Invention

[0005] To address the technical problems of insufficient detection accuracy caused by the lack of effective correction for uneven light distribution and the lack of adaptive suppression of strong biological matrix background interference in the detection of agricultural products with complex curved surfaces, the present invention provides solutions in the following aspects.

[0006] In a first aspect, the present invention provides a smart agricultural pesticide residue detection method based on spectral technology, comprising: acquiring original hyperspectral image data, dark current image data, and whiteboard image data of the agricultural product to be detected; acquiring hyperspectral reflectance data based on the difference between the original hyperspectral image data and the dark current image data, and the difference between the whiteboard image data and the dark current image data; acquiring the average spectral intensity based on the arithmetic mean of the pixels in the hyperspectral reflectance data across all bands; acquiring the illumination confidence factor based on the ratio of the average spectral intensity of the pixels to the maximum average spectral intensity in the entire image; acquiring the background spectrum of a standard biological matrix, and based on... The illumination confidence factor linearly scales the background spectrum of the standard biological matrix to obtain a local background estimate that matches the illumination intensity of the pixel. The net residual spectrum is obtained based on the difference between the hyperspectral reflectance data and the local background estimate. The standard fingerprint spectral vector of the target pesticide is obtained. The pesticide residue spectral fingerprint enhancement index is obtained based on the cosine similarity between the net residual spectrum and the standard fingerprint spectral vector, and the noise suppression weights constructed based on the illumination confidence factor, and a pesticide residue distribution heatmap is generated. The pesticide residue distribution heatmap is segmented to obtain a suspected defect mask. Based on the statistical characteristics of the connected regions in the suspected defect mask, pesticide residue detection is performed on agricultural products.

[0007] This invention achieves accurate detection of pesticide residues in agricultural products by combining hyperspectral imaging technology with black-and-white plate calibration and illumination confidence assessment. By acquiring raw spectral data and performing black-and-white plate calibration, the systemic errors of sensor dark current noise and uneven illumination are eliminated, obtaining reflectance data that truly reflects the physicochemical properties of agricultural products. By constructing an illumination confidence factor, the distribution of light intensity caused by the curved surface geometry is evaluated, providing a basis for subsequent data reliability weighting. By acquiring the background spectrum of a standard biological matrix and performing linear scaling based on light intensity, adaptive subtraction of background signals in different illumination areas is achieved, effectively removing weak pesticide signals from strong backgrounds. Through standard fingerprint spectral matching and illumination confidence weighting, pesticide characteristic signals are enhanced and random noise in low-light areas is suppressed, generating an intuitive heatmap of pesticide residue distribution. Finally, through adaptive threshold segmentation and regional statistics, the analysis is moved from pixel-level to region-level judgment, improving the robustness and accuracy of the detection results and effectively solving the problem of pesticide residue detection in complex curved agricultural products under uneven illumination and strong background interference.

[0008] Preferably, obtaining hyperspectral reflectance data based on the difference between the original hyperspectral image data and the dark current image data, and the difference between the whiteboard image data and the dark current image data, includes: obtaining spectral reflectance based on the difference between the original hyperspectral image data and the dark current image data, and the difference between the whiteboard image data and the dark current image data, and reconstructing and mapping the spectral reflectance according to its original spatial coordinates and wavelength order to form three-dimensional hyperspectral reflectance data.

[0009] Preferably, the spectral reflectance satisfies the following relationship: In the formula, The coordinates in the hyperspectral reflectance data are The pixels at wavelength Spectral reflectance at that location The coordinates in the original hyperspectral image data are The pixels at wavelength The original light intensity value at that location, The coordinates in the dark current image data are The pixels at wavelength The dark current intensity value at that location. The coordinates in the whiteboard image data are The pixels at wavelength The light intensity value of the whiteboard at that location. For standard whiteboards at wavelength The standard reflectance factor at that location.

[0010] This invention eliminates the inherent thermal noise of the sensor and the interference caused by the uneven spatial distribution of the light source by using black and white plate differential and ratio calculations. It achieves normalization processing of the original light intensity data, so that the obtained spectral reflectance is only related to the material properties of the agricultural product surface and is independent of the absolute magnitude of the external light intensity, thus ensuring the stability of subsequent processing under different lighting environments.

[0011] Preferably, the illumination confidence factor satisfies the following relationship: In the formula, The coordinates in the image are The illumination confidence factor of the pixel. The coordinates in the image are The average spectral intensity of the pixels, It is the set of coordinates of all pixels in the image. For set The coordinates of any pixel in the image. It is a function for maximizing the value.

[0012] This invention constructs an illumination confidence factor by using the ratio of average spectral intensity to global maximum value, mapping the influence of complex three-dimensional geometric curvature on illumination into a two-dimensional dimensionless value. This intuitively characterizes the ability of each pixel to receive illumination, providing a key physical basis for subsequent adaptive background subtraction and noise weighting, and solving the problem of difficult edge detection of curved objects.

[0013] Preferably, the average spectral intensity satisfies the following relationship: In the formula, The coordinates in the image are The average spectral intensity of the pixels, This represents the total number of bands in the spectral reflectance data. For the first Wavelength of each band The coordinates in the hyperspectral reflectance data are The pixels at wavelength Spectral reflectance at that location.

[0014] Preferably, obtaining the net residual spectrum based on the difference between the hyperspectral reflectance data and the local background estimate includes: using the difference between the hyperspectral reflectance data and the local background estimate as the net residual spectral reflectance, and combining the net residual spectral reflectance of each pixel to form the net residual spectrum.

[0015] Preferably, the net residual spectral reflectance satisfies the following relationship: In the formula, The coordinates in the image are The pixels at wavelength Net residual spectral reflectance at the location, The coordinates in the image are The pixels at wavelength Spectral reflectance at that location Standard biological matrix background at wavelength The reflectivity value at that location, The coordinates in the image are The illumination confidence factor of the pixel. This is the preset background adjustment coefficient.

[0016] This invention obtains the net residual spectral reflectance by using spectral reflectance and illumination confidence factor, thereby achieving adaptive dynamic adjustment of background subtraction intensity. This prevents over-subtraction or negative value anomalies caused by weak signals, and improves the algorithm's adaptability to agricultural products with different shapes and curvatures.

[0017] Preferably, the step of detecting pesticide residues in agricultural products based on the statistical characteristics of connected regions in the suspected defect mask includes: calculating the total area of ​​the defect connected regions in the suspected defect mask image; if the proportion of the total area of ​​the defect connected regions to the pesticide residue distribution heatmap is greater than a preset proportion threshold, it is determined that the agricultural product contains pesticide residues.

[0018] Preferably, the step of detecting pesticide residues in agricultural products based on the statistical characteristics of connected regions in the suspected defect mask includes: counting the number of pixels in all connected regions of the suspected defect mask image; if the number of pixels in the largest defective connected region exceeds a preset threshold, it is determined that the agricultural product contains pesticide residues.

[0019] This invention uses the number of pixels in the largest defective connected region for discrimination, which enables the keen detection of local high concentrations of pesticide residues, ensures the strictness of detection standards, prevents the problem of missed detection of severe local contamination caused by averaging, and further protects the food safety of consumers.

[0020] Secondly, the present invention provides a smart agricultural product pesticide residue detection system based on spectral technology, including a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned smart agricultural product pesticide residue detection method based on spectral technology is implemented.

[0021] By adopting the above technical solution, the above-mentioned smart agriculture pesticide residue detection method based on spectral technology is generated into a computer program and stored in a memory so that it can be loaded and executed by a processor. In this way, a terminal device can be made based on the memory and processor for convenient use.

[0022] The beneficial effects of this invention are as follows: This invention utilizes an illumination confidence factor to adaptively linearly scale the background spectrum of a standard biological matrix, constructing a dynamic local background estimate. This accurately removes strong background signals generated by the fruit peel matrix from the original spectrum, highlighting previously masked trace pesticide signals and avoiding signal distortion caused by fixed background subtraction, significantly improving the ability to capture weak pesticide residues. This invention also utilizes an illumination confidence factor to construct noise suppression weights, automatically suppressing random noise responses in low signal-to-noise ratio regions such as edges and shadows. This effectively distinguishes between real pesticide residues and edge noise caused by geometric shapes, solving the problem of misjudgment caused by illumination attenuation at the edges of curved agricultural products. Furthermore, this invention achieves highly specific identification based on material fingerprints by calculating the cosine similarity between the net residual spectrum and the standard fingerprint spectrum of the target pesticide. This accurately locks the characteristic absorption peaks of the target pesticide in complex mixed spectral environments, effectively resisting interference from non-target substances such as dust and mechanical scratches. Finally, this invention generates a pesticide residue distribution heatmap and extracts suspected defect masks, using statistical features such as the area or number of pixels of connected regions for final discrimination, effectively filtering isolated noise points and ensuring the reliability of automated detection results. Attached Figure Description

[0023] Figure 1 This is a flowchart illustrating the smart agriculture pesticide residue detection method for agricultural products based on spectral technology in this invention; Figure 2 This is a schematic diagram illustrating the distribution of the illumination confidence factor in this invention; Figure 3 This is a schematic illustration of the net residual spectrum in this invention; Figure 4 This is a schematic diagram illustrating the distribution of the pesticide residue spectral fingerprint enhancement index in this invention. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0025] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0026] This invention discloses a smart agriculture pesticide residue detection method for agricultural products based on spectral technology, referring to... Figure 1 This includes steps S1-S5: S1. Calculate spectral reflectance based on the original hyperspectral image data, dark current image data, and whiteboard image data.

[0027] It should be noted that, due to the physical characteristics of dark current noise and uneven light source distribution during the acquisition process, the raw light intensity signal acquired by the hyperspectral camera contains systematic errors not inherent to the sample itself, resulting in a reduced signal-to-noise ratio of the spectral data. To obtain spectral reflectance data that accurately reflects the surface physicochemical properties of agricultural products, interference from sensor dark current and uneven illumination must be eliminated. Therefore, this invention uses a black-and-white plate correction method to process the raw light intensity image to obtain the spectral reflectance.

[0028] Specifically, a hyperspectral camera is used to scan the agricultural product to be tested, acquiring original hyperspectral image data containing spatial and spectral dimensions, dark current image data under complete darkness, and white board image data under the same illumination conditions. Based on the original hyperspectral image data, dark current image data, and white board image data, difference and ratio calculations are performed to obtain the spectral reflectance of the target. All calculated spectral reflectances are then reconstructed and mapped according to their original spatial coordinates and wavelength order to construct three-dimensional hyperspectral reflectance data.

[0029] Specifically, spectral reflectance satisfies the following relationship: ; In the formula, The coordinates in the hyperspectral reflectance data are The pixels at wavelength Spectral reflectance at that location The coordinates in the original hyperspectral image data are The pixels at wavelength The original light intensity value at that location, The coordinates in the dark current image data are The pixels at wavelength The dark current intensity value at that location. The coordinates in the whiteboard image data are The pixels at wavelength The light intensity value of the whiteboard at that location. For standard whiteboards at wavelength The standard reflectance factor at that location.

[0030] in, This represents the target signal after deducting the inherent thermal noise of the sensor. The larger the value, the stronger the intensity of the reflected light from the target. This represents the maximum dynamic range response of the detector under the current illumination conditions. By dividing the net target signal by the maximum dynamic range response, the spectral data is normalized, so that the final spectral reflectance is only related to the material properties of the agricultural product surface and is independent of the absolute magnitude of the external light intensity, thus ensuring the stability of subsequent processing under different illumination environments.

[0031] It should be added that when the dark current light intensity value is equal to the white board light intensity value, the spectral reflectance is set to 0 to avoid the calculation error of zero denominator.

[0032] S2. Calculate the average spectral intensity based on the spectral reflectance and then calculate the illumination confidence factor.

[0033] It should be noted that agricultural products typically have irregular convex surfaces, resulting in perpendicular light incidence and high reflection intensity in the central area, while the incident angle increases at the edges, leading to a sharp decrease in diffuse reflection intensity. This difference in brightness caused by geometric shape directly reflects the signal-to-noise ratio (SNR) of the data: a high SNR in the central area indicates reliable data, while a low SNR in the darker edge areas indicates significant noise interference. To quantify this difference in data reliability caused by geometric curvature, an index characterizing the distribution of light intensity needs to be constructed. Therefore, this invention constructs an illumination confidence factor by statistically analyzing the average intensity of pixels.

[0034] Specifically, each pixel in the hyperspectral reflectance data is traversed, and the spectral reflectance of the pixel under all wavelengths is arithmetically averaged to obtain the average spectral intensity. The maximum value of the average spectral intensity of all pixels in the entire image is counted, and the normalization process is performed based on the ratio of the average spectral intensity of the pixel to the maximum value to obtain the illumination confidence factor.

[0035] Specifically, the illumination confidence factor satisfies the following relationship: ; ; In the formula, The coordinates in the image are The average spectral intensity of the pixels, This represents the total number of bands in the spectral reflectance data. For the first Wavelength of each band The coordinates in the image are The illumination confidence factor of the pixel. The coordinates in the hyperspectral reflectance data are The pixels at wavelength Spectral reflectance at that location It is the set of coordinates of all pixels in the image. For set The coordinates of any pixel in the image. It is a function for maximizing the value.

[0036] in, The overall reflection energy of pixels across all wavelengths was statistically analyzed. This value is directly affected by the angle between the surface normal vector and the incident light, and can truly reflect the ability of curved surface geometry to receive light. Map brightness to arrive The dimensionless values ​​between, when the value is close to When the value is close to a certain value, it indicates that the point is located in a flat, highly lit area, with a high signal-to-noise ratio and high confidence level. If the answer is no, it indicates that the point is located in an edge or shaded area, is greatly affected by noise, and has a low confidence level.

[0037] For example, Figure 2 This image presents the distribution of illumination confidence factors, visually reflecting the impact of the 3D geometric surface characteristics of the agricultural product (apple) on the imaging illumination intensity. The central region is bright, while the edge regions are dark. This provides basic brightness information for subsequent adaptive background subtraction and noise suppression weights, thereby enabling differentiated processing of different regions.

[0038] S3. Adaptive background subtraction of spectral reflectance based on illumination confidence factor to obtain net residual spectrum.

[0039] It should be noted that the surface of agricultural products contains a large amount of water, pigments, and other biological matrices. The spectral signal intensity of these matrices is much higher than that of trace pesticides, constituting strong background interference. Furthermore, due to the surface effect, the background signal intensity at different locations fluctuates with changes in the illumination confidence factor. Directly subtracting a fixed background spectrum can result in negative values ​​at the edges or incomplete removal at the center. To accurately extract potential anomalous signals from a strong background, the background subtraction intensity needs to be dynamically adjusted according to illumination conditions. Therefore, this invention adaptively scales the background spectrum and performs differential calculations to obtain the net residual spectrum.

[0040] Specifically, the background spectral vector of the standard biological matrix without pesticide residues is obtained. The background spectral vector of the standard biological matrix is ​​linearly scaled based on the illumination confidence factor to generate a local background estimate that matches the illumination intensity of the current pixel. The net residual spectral reflectance is obtained by vector subtraction between the spectral reflectance and the local background estimate. The net residual spectral reflectance of each pixel is combined into a net residual spectrum.

[0041] Specifically, the net residual spectral reflectance satisfies the following relationship: ; In the formula, The coordinates in the image are The pixels at wavelength Net residual spectral reflectance at the location, The coordinates in the image are The pixels at wavelength Spectral reflectance at that location Standard biological matrix background at wavelength The reflectivity value at that location, The coordinates in the image are The illumination confidence factor of the pixel. The preset background adjustment coefficient is 0.95 in this embodiment.

[0042] Among them, the product term A background model was constructed that dynamically changes with geometric curvature. When a pixel is located in the central highlight area, the background component subtracted is large; when a pixel is located in the edge dark area, the background component subtracted automatically decreases, thus avoiding over-subtraction due to illumination attenuation. minus The function is to remove the spectral response mainly generated by the fruit peel matrix from the total signal, so that the remaining net residual spectrum can better highlight the characteristics of weak chemical components (such as pesticides) that are different from the matrix. This solves the problem of strong background masking weak signals. Moreover, this linear difference process does not involve nonlinear distortion of the spectral shape and preserves the fingerprint characteristics of pesticides.

[0043] For example, Figure 3 The image shows the net residual spectrum in this invention. As can be seen from the image, most of the background signal has been removed. The faintly visible spot area in the image is the potential pesticide residue signal retained after background removal.

[0044] S4. Calculate the pesticide residue spectral fingerprint enhancement index by combining the net residual spectrum and the illumination confidence factor, and generate a pesticide residue distribution heatmap.

[0045] It should be noted that after background subtraction, the net residual spectrum contains pesticide signals and random noise. In low-light edge regions, although the background has been adaptively subtracted, the relative proportion of random noise remains high, easily leading to misjudgment. To effectively suppress edge noise while identifying pesticide fingerprints, it is necessary to combine spectral similarity and data reliability weights. Therefore, this invention combines the net residual spectrum and the illumination confidence factor to calculate the pesticide residue spectral fingerprint enhancement index and generate a pesticide residue distribution heatmap.

[0046] Specifically, the standard fingerprint spectral vector of the pesticide to be tested is obtained, and the effective analytical band range covering the main characteristic absorption peaks of the pesticide to be tested is determined. Based on the net residual spectral reflectance, the spectral vector of each pixel within the effective analytical band range is extracted, and the dot product and modulus operation are performed on the spectral vector and the standard fingerprint spectral vector to obtain the cosine similarity. At the same time, a noise suppression weight function is constructed based on the illumination confidence factor, and the cosine similarity and the noise suppression weight are multiplied and fused to obtain the pesticide residue spectral fingerprint enhancement index. The pesticide residue distribution heatmap is generated by traversing all pixels.

[0047] In one embodiment, determining the effective analytical band range covering the main characteristic absorption peaks of the pesticide to be tested includes: pre-acquiring the full-band spectral reflectance curve of the pure pesticide to be tested, identifying characteristic absorption peaks in the curve with reflectance significantly lower than the baseline; simultaneously acquiring the background spectral curve of the clean agricultural product surface, eliminating peaks that overlap with the strong absorption bands of moisture and pigments in the background spectrum; selecting the peak with the highest signal-to-background ratio among the remaining characteristic absorption peaks as the center wavelength, and using this center wavelength as a reference, extending a preset half-wavelength to both sides to define the effective analytical band range, for example, a half-wavelength of ±10 nm.

[0048] Specifically, the enhancement index of pesticide residue spectral fingerprints satisfies the following relationship: ; In the formula, The coordinates in the image are The spectral fingerprint enhancement index of pesticide residues at each pixel. The coordinates in the image are The net residual spectral vector of the pixels within the effective analysis band range. This refers to the standard fingerprint spectral vector of the target pesticide within the effective analytical wavelength range. The coordinates in the image are The illumination confidence factor of the pixel. The preset noise floor threshold parameter is set to 0.1 in this embodiment. Represents the magnitude of the vector. It is an exponential function with the natural constant as the base.

[0049] in, It characterizes the similarity in shape between the residual signal after background removal and the standard fingerprint of pesticides. The larger the value, the higher the probability of the presence of pesticide residues. It effectively suppresses low signal-to-noise ratio data when the illumination confidence factor is much smaller than the noise threshold. When the light intensity is low, it indicates that the pixel is in an extremely dark edge or dead zone. This value approaches 0, forcibly lowering the final exponent and thus masking the false high similarity caused by high noise at the edge. When the light is sufficient, this value approaches 1, preserving the true spectral matching result.

[0050] For example, Figure 4 The figure shows the distribution of the enhancement index of the spectral fingerprint of pesticide residues. As can be seen from the figure, the present invention successfully shields the interference of the low signal-to-noise ratio region at the edge, eliminates false positives, and enhances the signal contrast of the real pesticide residue region, thereby enabling accurate identification of weak targets.

[0051] S5. Threshold segmentation is performed on the heat map of pesticide residue distribution to generate a mask for suspected defects and the detection results are determined.

[0052] It should be noted that pesticide residues are often distributed on the surface of agricultural products in the form of spots or patches, and the discrimination of single pixels may be subject to random errors. Therefore, the overall quality of the product cannot be determined solely based on the value of a single point. To improve the robustness of detection, it is necessary to move from pixel-level exponential mapping to region-level feature statistics. Therefore, this invention generates a suspected defect mask and makes a final judgment by combining threshold segmentation and connected component analysis.

[0053] Specifically, a heat map of pesticide residue distribution is obtained, and the heat map is processed using the Otsu's method. An adaptive segmentation threshold is determined, and the heat map is binarized to obtain a mask for suspected defects. Morphological opening operations are performed on the mask image to remove isolated noise points. The total area of ​​the remaining connected regions and the area of ​​the largest connected region are calculated. Based on the statistical results, it is determined whether the current agricultural product has excessive pesticide residues.

[0054] In one embodiment, in response to the fact that the total area of ​​the defective connected regions in the mask image is greater than the area of ​​the pesticide residue distribution heatmap, the agricultural product is determined to have pesticide residues, and a rejection signal is output, for example, the proportion threshold is 0.5%.

[0055] In another embodiment, in response to the number of pixels of the largest defective connected region in the mask image exceeding a preset number threshold, it is determined that the agricultural product has a local high concentration of pesticide residues and a rejection signal is output, for example, the number threshold is 50 pixels.

[0056] This invention also discloses a smart agricultural pesticide residue detection system based on spectral technology, including a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the smart agricultural pesticide residue detection method based on spectral technology according to this invention.

[0057] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.

Claims

1. A smart agriculture pesticide residue detection method for agricultural products based on spectral technology, characterized in that, include: Acquire the raw hyperspectral image data, dark current image data, and whiteboard image data of the agricultural products to be tested; Hyperspectral reflectance data is obtained based on the differences between the original hyperspectral image data and dark current image data, as well as the differences between the whiteboard image data and dark current image data. The average spectral intensity is obtained based on the arithmetic mean of the pixels in the hyperspectral reflectance data across all bands. An illumination confidence factor is obtained based on the ratio of the average spectral intensity of the pixels to the maximum average spectral intensity in the entire image. A standard biological matrix background spectrum is obtained, and this spectrum is linearly scaled according to the illumination confidence factor to obtain a local background estimate matching the illumination intensity of the pixels. The net residual spectrum is obtained based on the difference between the hyperspectral reflectance data and the local background estimate. A standard fingerprint spectral vector for the target pesticide is obtained. The pesticide residue spectral fingerprint enhancement index is obtained based on the cosine similarity between the net residual spectrum and the standard fingerprint spectral vector, and a noise suppression weight constructed based on the illumination confidence factor. A pesticide residue distribution heatmap is then generated. The pesticide residue distribution heatmap is segmented to obtain a suspected defect mask. Based on the statistical characteristics of connected regions in suspected defect masks, pesticide residues in agricultural products are detected.

2. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 1, characterized in that, The step of obtaining hyperspectral reflectance data based on the difference between the original hyperspectral image data and the dark current image data, and the difference between the whiteboard image data and the dark current image data, includes: obtaining spectral reflectance based on the difference between the original hyperspectral image data and the dark current image data, and the difference between the whiteboard image data and the dark current image data, and reconstructing and mapping the spectral reflectance according to its original spatial coordinates and wavelength order to form three-dimensional hyperspectral reflectance data.

3. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 2, characterized in that, The spectral reflectance satisfies the following relationship: ; In the formula, The coordinates in the hyperspectral reflectance data are The pixels at wavelength Spectral reflectance at that location The coordinates in the original hyperspectral image data are The pixels at wavelength The original light intensity value at that location, The coordinates in the dark current image data are The pixels at wavelength The dark current intensity value at that location. The coordinates in the whiteboard image data are The pixels at wavelength The light intensity value of the whiteboard at that location. For standard whiteboards at wavelength The standard reflectance factor at that location.

4. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 1, characterized in that, The illumination confidence factor satisfies the following relationship: ; In the formula, The coordinates in the image are The illumination confidence factor of the pixel. The coordinates in the image are The average spectral intensity of the pixels, It is the set of coordinates of all pixels in the image. For set The coordinates of any pixel in the image. It is a function for maximizing the value.

5. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 4, characterized in that, The average spectral intensity satisfies the following relationship: ; In the formula, The coordinates in the image are The average spectral intensity of the pixels, This represents the total number of bands in the spectral reflectance data. For the first Wavelength of each band The coordinates in the hyperspectral reflectance data are The pixels at wavelength Spectral reflectance at that location.

6. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 1, characterized in that, The step of obtaining the net residual spectrum based on the difference between the hyperspectral reflectance data and the local background estimate includes: using the difference between the hyperspectral reflectance data and the local background estimate as the net residual spectral reflectance, and combining the net residual spectral reflectance of each pixel to form the net residual spectrum.

7. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 6, characterized in that, The net residual spectral reflectance satisfies the following relationship: ; In the formula, The coordinates in the image are The pixels at wavelength Net residual spectral reflectance at the location, The coordinates in the image are The pixels at wavelength Spectral reflectance at that location Standard biological matrix background at wavelength The reflectivity value at that location, The coordinates in the image are The illumination confidence factor of the pixel. This is the preset background adjustment coefficient.

8. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 1, characterized in that, The method of detecting pesticide residues in agricultural products based on the statistical characteristics of connected regions in suspected defect masks includes: calculating the total area of ​​connected regions in suspected defect mask images; if the proportion of the total area of ​​connected regions to the area of ​​the pesticide residue distribution heatmap is greater than a preset proportion threshold, it is determined that the agricultural product contains pesticide residues.

9. The method for detecting pesticide residues in agricultural products in smart agriculture based on spectral technology according to claim 1, characterized in that, The method of detecting pesticide residues in agricultural products based on the statistical characteristics of connected regions in the suspected defect mask includes: counting the number of pixels in all connected regions of the suspected defect mask image; if the number of pixels in the largest defective connected region exceeds a preset threshold, it is determined that the agricultural product contains pesticide residues.

10. A smart agricultural pesticide residue detection system based on spectral technology, characterized in that, include: A processor and a memory, wherein the memory stores computer program instructions that, when executed by the processor, implement the smart agricultural pesticide residue detection method based on spectral technology according to any one of claims 1-9.

Citation Information

Patent Citations

  • A pesticide residue detection device and detection method based on fluorescence hyperspectral technology

    CN104931470B

Cited By

  • Flower moisture determination system and method based on image data

    CN121877772A

  • A system and method for measuring flower moisture based on image data

    CN121877772B