Pesticide residue detection method and system based on artificial intelligence

By normalizing the difference of image area blocks and labeling the trend of multi-directional gradient changes, a multi-dimensional feature system is constructed, which solves the shortcomings of existing pesticide residue detection methods in analyzing weak signals in local areas and identifying them in complex scenes, and realizes high-precision and classification-guided pesticide residue detection.

CN120672700AInactive Publication Date: 2025-09-19CANGZHOU YIBAN BIOTECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510768834.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-19
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing pesticide residue detection methods lack the ability to specifically analyze weak signal performance in local areas within the image, making it difficult to effectively capture traces of pollution caused by nonlinear diffusion in the image. In addition, the output lacks hierarchy and directionality in complex scenarios, resulting in insufficient stability in the detection results.

Method used

The local brightness contrast is enhanced by normalizing the difference of image area blocks, and regional attributes are labeled based on the multi-directional gradient change trend. A multidimensional feature system is constructed, and a label dependency sequence is constructed based on color difference path sorting to improve the ability to recognize subtle differences. Primary and secondary screening output is performed based on the relationship between pesticide residue intensity and threshold.

Benefits of technology

It improves the screening accuracy of pesticide residue detection and the classification guidance of identification results, effectively distinguishes residues of highly similar categories, and enhances the adaptive supervision capabilities for complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120672700A_ABST
    Figure CN120672700A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of pesticide detection, in particular to a pesticide residue detection method and system based on artificial intelligence, and the method comprises the following steps: obtaining an image and normalizing brightness difference, constructing a gradient trend labeling region, extracting features to generate a label weight sequence, matching categories to calculate residue intensity, and outputting an identification result. According to the method, local brightness comparison is enhanced through difference value normalization of image region blocks, region attributes are labeled in combination with a multi-direction gradient change trend, the dynamic perception capability of deposition features is improved, a multi-dimensional feature system is constructed by fusing brightness, edge and density indexes, the screening precision of pesticide residue salient regions is enhanced, and the screening precision of the pesticide residue salient regions is improved. A label dependency sequence is constructed based on color difference path sorting, structural optimization of category judgment is achieved, the micro-difference recognition capacity is improved through texture and gray matrix double alignment, primary and secondary screening output is conducted according to the relation between pesticide residue intensity and a threshold value, the classification guidance and risk screening functions are achieved, and the capacity of adapting to supervision requirements is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of pesticide detection, and in particular to a pesticide residue detection method and system based on artificial intelligence. Background Art

[0002] The field of pesticide detection technology encompasses the analysis, identification, and quantitative detection of pesticide residues in crops, soil, water, and agricultural products. Core areas include the extraction, separation, identification, and quantitative analysis of pesticide residues, encompassing a wide range of methods, including spectral detection, chromatography, and immunoassay. Pesticide residue monitoring and assessment are achieved through a variety of testing equipment and standardized procedures, with a focus on controlling pesticide residues during production and distribution. This approach aims to safeguard food safety and environmental health, integrating multiple technologies, including chemical analysis, biological testing, and data processing.

[0003] Among them, artificial intelligence-based pesticide residue detection methods use artificial neural network models to extract features, perform data training, and perform discriminant analysis on pesticide residue information in agricultural product images or spectral signals. This method primarily relies on convolutional neural networks to automatically identify suspicious residue features in crop surface images and classify samples using deep learning models that combine spectral reflectance data. This method primarily constructs a training set containing characteristic pesticide residue samples and employs a multi-layer neural network for data fitting and error correction to automatically identify pesticide residues in unknown samples. The analysis process relies on image acquisition devices or spectral acquisition devices to acquire raw data, which is then input into a model for classification output after numerical normalization and feature encoding.

[0004] Existing agricultural pesticide detection processes often rely on learning residue features at the overall image level, lacking targeted analysis of weak signal signatures in localized regions within the image, resulting in deposition traces being obscured by high-contrast backgrounds. Regional classification often uses static classification criteria for rough demarcation, ignoring the dynamic nature of gradient trends between regions and making it difficult to effectively capture nonlinear diffusion of contamination within the image. Feature combination relies on a single dimensional structure and fails to organically integrate multivariate statistical features, limiting extraction capabilities in scenarios with complex residue patterns. Classification mechanisms lack modeling of intrinsic connections between labels and rely solely on single-point comparisons, making it prone to misclassification of similar pesticides or similar patterns. Output representation typically only provides probability values ​​or classification labels, failing to integrate residue intensity with standard thresholds to establish hierarchical screening models, making it difficult to effectively support subsequent classification, disposal, or regulatory actions. Existing methods exhibit insufficient stability in complex scenarios with overlapping regions or uneven illumination, and their output lacks hierarchy and directionality, reducing the guiding value of pesticide detection results in practical applications. Summary of the Invention

[0005] The purpose of the present invention is to solve the shortcomings of the existing technology and propose a pesticide residue detection method based on artificial intelligence.

[0006] In order to achieve the above objectives, the present invention adopts the following technical solution: a method for detecting pesticide residues based on artificial intelligence, comprising the following steps:

[0007] S1: Obtain the surface image of agricultural products, divide it into equal blocks, extract the Y channel pixels of each block, perform normalization processing on the maximum and minimum pixel value differences, and generate regional standard brightness difference data;

[0008] S2: Based on the regional standard brightness difference data, construct four-neighborhood gradient vectors for each regional block, sort the difference vector set, analyze the trend and mark the deposition area, transition area and background area, and generate an image deposition trend distribution record;

[0009] S3: Read the image deposition trend distribution record, extract the V channel mean, edge frequency, and pixel density of the deposition and transition areas, select the corresponding category label template, calculate the color difference distance between the templates, establish a sorting path, and generate a pesticide label feature weight sequence;

[0010] S4: extracting LBP texture features and gray-level co-occurrence matrix features from each sedimentary area block according to the pesticide label feature weight sequence, performing cosine similarity matching with the label template, and generating a category path priority matching result;

[0011] S5: Based on the category path priority matching results, the residue ratio intensity of each category in the overall image is calculated, and the categories with residue limits higher than the threshold are selected as the main recognition results to generate pesticide residue classification recognition records.

[0012] As a further solution of the present invention, the regional standard brightness difference data includes brightness range distribution, standard interval mapping value, and image local contrast index; the image deposition trend distribution record includes deposition area position index, transition area adjacency relationship, and brightness gradient sorting sequence; the pesticide label feature weight sequence includes color difference distance matrix, label dependency path, and structural feature template mapping relationship; the category path priority matching result includes texture similarity score, grayscale matrix correlation score, and feature vector matching sequence; the pesticide residue classification identification record includes the main identification category, secondary reference item, and residue proportion intensity analysis result.

[0013] As a further solution of the present invention, the step of obtaining the regional standard brightness difference data is specifically as follows:

[0014] S111: Based on the surface image of the agricultural product captured by the camera, the image is divided into preset rows and columns, the image data corresponding to each area block is obtained, each area image is converted to YUV color space, the Y channel brightness pixel value set in each area block is extracted, and a brightness pixel set matrix is ​​established;

[0015] S112: Calculate the maximum pixel value and the minimum pixel value in the Y channel of each area according to the brightness pixel set matrix, obtain the brightness difference of the pixels in the area, and perform a normalization operation on each pixel value based on the difference, mapping all pixel values ​​to a standard interval to generate a brightness normalization value matrix;

[0016] S113: According to the brightness normalization value matrix, traverse each area block, perform difference calculation on the normalized brightness values ​​of all pixels in the area, count the degree of difference in the brightness values ​​of each block of pixels, obtain the brightness difference distribution of each area in the standard range, and obtain regional standard brightness difference data.

[0017] As a further solution of the present invention, the steps of obtaining the image deposition trend distribution record are specifically as follows:

[0018] S211: Based on the regional standard brightness difference data, taking the central pixel in each regional block as the starting point, collecting the brightness values ​​of pixels equidistant from the center point in the four directions of up, down, left, and right, calculating the brightness differences relative to the center point in the four groups of directions, establishing a four-dimensional vector with the center point as the origin, and generating a four-neighborhood gradient vector matrix;

[0019] S212: Based on the four-neighborhood gradient vector matrix, perform modulus calculation on the four-dimensional gradient vector in each region block, perform L2 norm sorting on the vector modulus results of all regions, construct a continuous difference sequence according to the sequence number difference after sorting, calculate the gradient change trend index of each region, and determine the trend change of the gradient difference in the region sequence to generate a gradient change trend index sequence;

[0020] S213: According to the gradient change trend indicator sequence, determine the change in the ranking position of the gradient difference of each area, mark the deposition area, transition area and background area, and after completing the marking of all areas, summarize them into a two-dimensional image space to establish an image deposition trend distribution record.

[0021] As a further solution of the present invention, the step of obtaining the pesticide label feature weight sequence is specifically as follows:

[0022] S311: Read all regional block image segments marked as deposition areas and transition areas in the image deposition trend distribution record, obtain the image pixel set of each area, convert it to the HSV color space, extract the V channel brightness value and calculate the mean, record the number of valid edge pixels as edge frequency statistics, and simultaneously count the pixel density values ​​within the regional range to generate a regional basic image feature group;

[0023] S312: Based on the regional basic image feature group, a label data set with the same image category as the pesticide residue image library is selected, a label template is extracted, and the image feature difference between the proposed region and the label template is compared and calculated. The image features are sorted in ascending order of the difference value to generate an image feature distance sorting result;

[0024] S313: Based on the image feature distance sorting results, mapping paths between the pesticide labels are established in sequence according to the sorting order, the difference values ​​between adjacent label pairs in the sorting are accumulated and summed, and normalized and converted based on the frequency statistics of the corresponding areas in the label classification samples. The difference values ​​are combined with the classification dependency weights to establish a pesticide label feature weight sequence.

[0025] As a further solution of the present invention, the steps for obtaining the category path priority matching result are specifically as follows:

[0026] S411: Read the image content of each image block in the deposition area one by one according to the sorting order of the paths in the pesticide label feature weight sequence, and calculate the local binary pattern (LBP) texture features corresponding to the image blocks using the grayscale image as input, simultaneously construct a grayscale co-occurrence matrix, and extract the three feature parameters of energy value, contrast value, and entropy value in the matrix, combine them to form a texture feature set, and obtain a regional image texture feature vector group;

[0027] S412: Based on the regional image texture feature vector group, feature matching processing is performed on the texture feature vector of each region with the label template in the pesticide label feature weight sequence, the corresponding ratio and difference between the regional vector and the label template in each dimension are calculated, and the three label templates that best match each region are extracted as preferred identification objects for the corresponding region, and a regional label cosine similarity matching sequence is generated;

[0028] S413: According to the cosine similarity matching sequence of the regional labels, the label with the highest similarity is selected from the three candidate labels of each deposition area as the regional preferred category, and the suboptimal label is used as its alternative path node. The identification sequence corresponding to each deposition area is established in turn, and all regional identification results are merged. A two-dimensional mapping matrix is ​​constructed in the order of regional indexes to establish the category path priority matching result.

[0029] As a further embodiment of the present invention, the steps for obtaining the pesticide residue classification and identification record are specifically as follows:

[0030] S511: Based on the category path priority matching result, read the image pixel information to calculate the area of ​​the image area block corresponding to each category, read the pixel area covered by each type of pesticide residue area marked in the image, calculate the proportion intensity of each category of residue in the image, and generate category residue proportion intensity data;

[0031] S512: Based on the residue intensity data of the categories and the maximum pesticide residue limit threshold, determine whether the residue intensity of each category exceeds the threshold, mark the main identification result candidate, mark the remaining categories that do not exceed the standard threshold as reference items, and perform a Boolean judgment operation to obtain a list of category identifiers exceeding the standard;

[0032] S513: Based on the list of category identifiers exceeding the standard, the corresponding category names, proportion intensity values, and determination label information are collected, and record items in a standardized output format are jointly generated to obtain pesticide residue classification identification records.

[0033] An artificial intelligence-based pesticide residue detection system, comprising:

[0034] The image brightness division module extracts the pixel value of the Y channel of the agricultural product image, calculates the difference between the maximum and minimum values ​​of each regional block, and normalizes it to generate regional standard brightness difference data;

[0035] The sedimentation trend analysis module constructs a vector based on the standard brightness difference data of the region by using the brightness difference of the central pixel and the four neighboring pixels, determines the decreasing trend, and generates an image sedimentation trend distribution record;

[0036] The regional structure quantity extraction module extracts the V channel mean, edge frequency, and pixel density of the deposition and transition areas based on the image deposition trend distribution record, calculates the color difference with the pesticide image library template, establishes the category path, and generates the pesticide label feature weight sequence;

[0037] The feature vector matching module extracts the LBP value and gray-level co-occurrence matrix of the regional block according to the pesticide label feature weight sequence, calculates the cosine value with the label template, selects the path matching item, and generates the category path priority matching result;

[0038] The residue classification identification module prioritizes the matching results of the category paths, summarizes the area ratio of the matching areas, compares and screens them with the residue limit threshold, and generates a pesticide residue classification identification record.

[0039] Compared with the prior art, the advantages and positive effects of the present invention are:

[0040] In the present invention, local brightness contrast is enhanced by normalizing the difference of image area blocks, regional attributes are labeled in combination with multi-directional gradient change trends, the dynamic perception ability of sedimentation features is improved, and a multidimensional feature system is constructed by integrating brightness, edge and density indicators. The screening accuracy of areas with significant pesticide residues is enhanced, and a label dependency sequence is constructed based on color difference path sorting to achieve structural optimization of category judgment. The ability to recognize micro-differences is improved through dual alignment of texture and grayscale matrices, and residues of highly similar categories are effectively distinguished. Primary and secondary screening outputs are performed based on the relationship between pesticide residue intensity and threshold, so that the recognition results have classification guidance and risk screening functions, thereby improving the ability to adapt to regulatory needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a flow chart of the main steps of the present invention;

[0042] Figure 2 This is a flow chart for obtaining regional standard brightness difference data of the present invention;

[0043] Figure 3 A flow chart for obtaining image deposition trend distribution records of the present invention;

[0044] Figure 4 The flowchart for obtaining the pesticide label feature weight sequence of the present invention;

[0045] Figure 5 A flowchart for obtaining the category path priority matching results of the present invention;

[0046] Figure 6 The present invention is a flow chart for obtaining pesticide residue classification and identification records. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0048] In the description of the present invention, it should be understood that the terms "length," "width," "up," "down," "front," "back," "left," "right," "vertical," "horizontal," "top," "bottom," "inside," "outside," and the like, indicating positions or relationships, are based on the positions or relationships shown in the accompanying drawings and are intended only to facilitate the description of the present invention and simplify the description. They do not indicate or imply that the devices or elements referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limiting the present invention. Furthermore, in the description of the present invention, "plurality" means two or more, unless otherwise expressly and specifically defined.

[0049] See also Figure 1, a pesticide residue detection method based on artificial intelligence, comprising the following steps:

[0050] S1: Use a camera to capture the surface image of agricultural products, divide the image into equal blocks according to preset rows and columns, extract the Y channel (the standard channel for representing brightness in digital image processing) pixels of each block in the YUV color space, obtain the maximum pixel value and the minimum pixel value, perform difference normalization, and classify the pixels in each block into the standard interval of [0, 255] to generate regional standard brightness difference data;

[0051] S2: Based on the regional standard brightness difference data, for each regional block, with the center pixel as the reference, the brightness of the four equally spaced pixels in the upper, lower, left, and right directions is collected to construct a four-neighborhood gradient vector (gradient calculation based on the four-directional neighborhood of the center pixel in image processing). The difference vector sets of all regional blocks are sorted by L2 norm (Euclidean distance standard for vector amplitude calculation), and the difference trend of the sorted position is analyzed. If three consecutive groups of differences are decreasing in the negative direction, the corresponding regional block is marked as a sedimentation area. If two groups of differences are decreasing, they are marked as transition areas. The rest are marked as background areas, and the image sedimentation trend distribution record is generated;

[0052] S3: Read the area blocks marked as deposition and transition areas in the image deposition trend distribution record, extract the corresponding HSV color space V channel (the color space dimension representing brightness) mean, Canny edge detection (standard edge detection) frequency, and pixel density statistics, select the structural feature templates corresponding to the category label in the pesticide residue image library, calculate the color difference distance between the templates, establish a sorting path for the dependency structure between the labels, and generate a pesticide label feature weight sequence;

[0053] S4: Based on the sequential dependency structure of each path in the pesticide label feature weight sequence, LBP texture features and gray-level co-occurrence matrix features are extracted for each sedimentary area block, and cosine similarity matching is performed with the label template to generate category path priority matching results;

[0054] S5: Based on the category path priority matching results, calculate the residue ratio intensity of each category in the overall image, and screen categories with a ratio intensity higher than the GB2763-2021 residue limit threshold (the maximum residue limit of pesticides in the food safety standard) as the main identification results. The remaining categories are marked as secondary reference items to generate pesticide residue classification identification records.

[0055] Regional standard brightness difference data include brightness range distribution, standard interval mapping value, and image local contrast index. Image deposition trend distribution records include deposition area position index, transition area adjacency relationship, and brightness gradient sorting sequence. Pesticide label feature weight sequence includes color difference distance matrix, label dependency path, and structural feature template mapping relationship. Category path priority matching results include texture similarity score, grayscale matrix correlation score, and feature vector matching sequence. Pesticide residue classification and identification records include main identification category, secondary reference item, and residue ratio intensity analysis results.

[0056] See also Figure 2 , S1 step is:

[0057] S111: Based on the surface image of the agricultural product captured by the camera, the image is divided into preset rows and columns, the image data corresponding to each area block is obtained, each area image is converted to YUV color space, the Y channel brightness pixel value set in each area block is extracted, and a brightness pixel set matrix is ​​established;

[0058] Based on the surface image of agricultural products captured by the camera, the image is divided into preset rows and columns. During the execution process, the pixel resolution and region segmentation parameters of each image need to be clarified. For example, if the image resolution is 1920×1080 pixels, it can be divided into 6 rows and 8 columns to obtain 48 region blocks, each of which is approximately 240×180 pixels. After the division is performed, the coordinate index of each block in the image matrix needs to be recorded for region tracking and data attribution in subsequent image processing. After obtaining the image data of each area, the YUV color space conversion is performed on the RGB image in each area. This conversion requires calling all images in the area. The RGB values ​​of the pixels are converted to the Y values ​​of the brightness channel using the standard BT.601 format conversion formula Y = 0.299R + 0.587G + 0.114B. All RGB values ​​are then converted to Y values ​​of the brightness channel. The pixel values ​​of all Y channels within each block are recorded on a per-region basis. Taking a 1080p image as an example, if each block is 240 × 180 pixels, each block contains 43,200 pixels, and the total brightness matrix of the region needs to be a dataset of 48 × 43,200 dimensions. This matrix will be used as input data for the next step. To facilitate the description of the basic brightness parameters of each region, some basic regional data is organized as follows:

[0059] Table 1 Basic parameters of regional brightness

[0060]

[0061]

[0062] As shown in Table 1, the maximum and minimum brightness values ​​of each region are significantly different, which provides a parameter basis for the subsequent difference normalization processing and ultimately establishes the brightness pixel set matrix.

[0063] S112: Calculate the maximum and minimum pixel values ​​in the Y channel of each area based on the brightness pixel set matrix, obtain the brightness difference of the pixels in the area, and perform a normalization operation on each pixel value based on the difference, mapping all pixel values ​​to a standard interval to generate a brightness normalization value matrix;

[0064] According to the brightness pixel set matrix, the maximum and minimum brightness values ​​of the pixels in each area are counted respectively to clarify the brightness distribution boundary, and the normalization conversion operation is performed on all pixels in the area based on the difference. The original pixel brightness value is normalized to the standard interval [0, 255] in a linear mapping manner. The regional difference is used as the denominator for normalization. For example, the maximum brightness value of area 1 is 240 and the minimum value is 100, then the brightness difference is 140. If the original brightness of a pixel is 170, the normalized brightness value is (170-100) / 140×255≈127.5. During the execution process, if the brightness difference of a certain area is found to be less than 10, the area is normalized. Domain normalization introduces noise, so the minimum brightness difference threshold is set to 10 to determine whether the current difference meets the normalization execution conditions. For example, if the brightness difference of region 2 is 120, normalization can be performed normally. However, if the difference between the maximum and minimum values ​​in region x is only 6, normalization is skipped or fixed to a constant value. Statistics are then taken based on the absolute value of the difference between the average brightness value of each pixel in each region and the brightness of each point, further recording the degree of brightness dispersion within the region. Taking region 3 as an example, its average brightness is 180 and the absolute sum of deviations is 3000, indicating that the brightness value is relatively outliers. This indicator will be used for subsequent quantitative evaluation of the difference distribution of each region, and ultimately obtain the brightness normalization value matrix.

[0065] S113: traversing each area block according to the brightness normalization value matrix, performing difference calculation on the normalized brightness values ​​of all pixels in the area, counting the degree of difference in the brightness values ​​of each block of pixels, obtaining the brightness difference distribution of each area within the standard range, and obtaining regional standard brightness difference data;

[0066] Based on the brightness normalization matrix, the normalized pixel data within each region is processed. Specifically, the normalized brightness values ​​of all pixels in each region are traversed sequentially, and the variance method is used to measure the degree of brightness fluctuation within the region. For example, the variance of the normalized pixel set in region 1 is 1250, indicating that the brightness variation within this region is relatively wide, while the variance value of region 4 is 250, indicating that the pixel brightness is relatively concentrated. After performing the same difference calculation for all regions, a variance reference interval is set as the criterion for dividing the intensity of brightness difference. Referring to actual image experiments, if the brightness variance of a region exceeds 1000, it is defined as a high brightness difference region; otherwise, it is defined as a low brightness difference region. This standard is formed by summarizing the measured results of multiple image samples and combining image edge position information to further determine whether the region is adjacent to a strong light interference boundary. For example, the leftmost and rightmost regions of the image have drastic brightness changes in multiple acquisitions and need to be marked as areas of concern based on this information. Finally, the difference value data obtained after normalization for all region blocks is output to establish regional standard brightness difference data.

[0067] See also Figure 3 , step S2 is:

[0068] S211: Based on the regional standard brightness difference data, starting from the center pixel in each regional block, collect the brightness values ​​of pixels equidistant from the center point in the four directions of up, down, left, and right, calculate the brightness differences relative to the center point in the four directions, establish a four-dimensional vector with the center point as the origin, and generate a four-neighborhood gradient vector matrix;

[0069] Based on the regional standard brightness difference data, the coordinates of the central pixel in each regional block need to be located and the pixel brightness values ​​in the four directions of up, down, left and right need to be collected with reference to it. Assuming the regional block is 40×40 pixels, the center point is the pixel in the 20th row and 20th column, and the sampling distance is set to 5 pixels, then the sampled pixels are the pixels with ±5 in the upper and lower rows and ±5 in the left and right columns, that is, the four pixels in the 15th row and 20th column, the 25th row and 20th column, the 20th row and 15th column, and the 20th row and 25th column. The brightness values ​​(Y channel) of these five pixels are collected. For example, the brightness of the central pixel in region 1 is 160, and the brightness of the four neighboring points are 165, 158, 159, and 161 respectively. The brightness differences in the four directions are +5, -2, -1, and +1. The four differences are combined into a four-dimensional vector [5, -2, -1, 1] to represent the spatial directionality of the regional brightness change. All regions are processed accordingly to construct the regional vector data structure. The sampling results of some regions are shown in the following table:

[0070] Table 2 Four neighborhood sampling brightness table

[0071] Area Number Center pixel brightness Upper neighbor pixel brightness Lower neighbor pixel brightness Brightness of the left neighboring pixel Brightness of the right neighboring pixel Area 1 160 165 158 159 161 Area 2 155 159 152 153 156 Area 3 162 168 160 161 163 Area 4 158 161 157 156 159

[0072] As shown in Table 2, each region constructs four neighborhood vectors through the difference between the brightness of the center point and the brightness of the surrounding pixels. The vector of region 1 is [5, -2, -1, 1], region 2 is [4, -3, -2, 1], region 3 is [6, -2, -1, 1], and region 4 is [3, -1, -2, 1]. Finally, the four-neighborhood gradient vector matrix is ​​generated.

[0073] S212: Based on the four-neighborhood gradient vector matrix, perform modulus calculation on the four-dimensional gradient vector in each area block, sort the vector modulus results of all areas by L2 norm, and construct a continuous difference sequence according to the sequence difference after sorting, using the formula:

[0074]

[0075] Calculate the gradient change trend index Δ* of each region, and judge the trend change of the gradient difference within the regional sequence to generate a gradient change trend index sequence, where g r,i is the brightness difference of the neighborhood of region r in the i-th direction, is the mean of the four-directional gradients in region r, It is the evaluation value of the continuous decreasing amplitude of the gradient difference;

[0076] Based on the four-neighborhood gradient vector matrix, the modulus of each region vector is calculated to represent the comprehensive amplitude of the brightness change in the region. Taking region 1 as an example, the vector is [5, -2, -1, 1], and the Euclidean modulus calculation is performed:

[0077]

[0078] Then perform the sorting and set the region modulus value to be: region 1 is 5.57, region 2 is Area 3 is Area 4 is According to the L2 norm, the order from large to small is: region 3, region 1, region 2, and region 4. The continuous module length difference is constructed for the sorted sequence. The difference between region 3 and region 1 is 6.48-5.57=0.91, the difference between region 1 and region 2 is 5.57-5.48=0.09, and the difference between region 2 and region 4 is 5.48-3.87=1.61. The constructed difference sequence is [0.91, 0.09, 1.61], and the difference difference analysis is performed in the difference sequence.

[0079] Taking area 1 as an example, g r,i =[5, -2, -1, 1], modulus length part: Absolute sum of differences: |-2-5|+|-1-(-2)|+|1-(-1)|=7+1+2=10, mean Sum of squared deviations: (5-0.75) 2 +(-2-0.75) 2+(-1-0.75) 2 +(1-0.75) 2 =18.06+7.56+3.06+0.06=28.74, the normalized denominator is Finally, we get:

[0080]

[0081] All regions are processed in this way to obtain trend indicators for each region and establish a gradient change trend indicator sequence.

[0082] The gradient change trend index is a numerical quantitative result used to measure the brightness gradient change characteristics within each area block in the image. Its core significance lies in comprehensively reflecting whether there is a continuous and stable brightness decreasing trend in the area by analyzing the brightness difference amplitude in the four directions of the area center point and the changing law between adjacent gradients, thereby assisting in judging the structural properties of the area in the overall image, such as whether it belongs to the sedimentation, transition or background area. The smaller the index, the larger the regional gradient change amplitude and the uneven distribution, tending to form a regional state with a single and decreasing gradient direction. Conversely, if the value is too large, it means that the gradient change in the area is relatively uniform or there is no continuous decreasing trend. Therefore, this index plays a key role in image structure recognition and area classification, and is directly used to support subsequent area annotation and image trend distribution structure construction.

[0083] The operational logic of the formula is to measure the degree of gradient vector change trend in each region. The numerator of the formula takes the square root of the sum of the squares of the gradient values ​​in the four directions to calculate the overall brightness change amplitude modulus of the region, reflecting the comprehensive brightness mutation intensity of the region in the four spatial directions. The larger the value, the more significant the gradient response within the region. At the same time, the sum of the absolute values ​​of the gradient differences between the three adjacent directions is subtracted from the modulus to reflect whether the gradient within the region is evenly distributed. If the adjacent gradient changes are large, the difference term is large, and the modulus minus the difference tends to decrease, indicating that the change within the region is unstable. The denominator first sums the squares of the differences between all gradients and their average value to represent the degree of discreteness of the gradient in the four directions in the region. 1 is added and the square root is taken to prevent the denominator from being zero and improve scale balance. At the same time, the more discrete the gradient, the larger the denominator, and the smaller the overall result value, further weakening the impact of unstable regions on the trend score. Finally, the overall expression forms a unified trend measurement value by comparing the modulus and difference fluctuations and controlling the scale through standard deviation normalization. In this structure, the sum of squares emphasizes the intensity of change, the difference reflects the fluctuation trend, and the standard deviation adjusts the comparison scale. The combination of the three constitutes a complete gradient trend evaluation logic.

[0084] S213: Based on the gradient change trend indicator sequence, determine the ranking position change of the gradient difference of each region, mark the deposition area, transition area and background area, and after completing the marking of all areas, summarize them into a two-dimensional image space to establish an image deposition trend distribution record;

[0085] Based on the gradient change trend indicator sequence, trend judgment is performed on each group of regions. The corresponding indicators after region sorting are: region 3 is 0.510, region 1 is 0.687, region 2 is 0.820, and region 4 is 1.320. The increasing or decreasing direction is determined. If three consecutive groups of indicators show a gradually decreasing trend, it is judged as a sedimentary area. For example, if region A is 0.950, B is 0.720, and C is 0.580, the difference is -0.23 and -0.14, and the two groups are negative, which is still less than three groups. The sedimentary condition is not met, but the transition judgment rule is met. If the three groups are -0.23, -0.30, and -0.45, showing a negative increase, that is, a continuous decrease in the negative direction, the area is marked as a sedimentary area. Finally, all the region labels are projected into a two-dimensional map according to their matrix coordinates in the image. The labeling result matrix is ​​established and assigned: sedimentary area is 1, transition area is 2, and background is 0. After projection into the image space, a pixel-level classification layer is formed to generate the image sedimentation trend distribution record.

[0086] See also Figure 4 , S3 steps are:

[0087] S311: Read all regional block image segments marked as deposition areas and transition areas in the image deposition trend distribution record, obtain the image pixel set of each area, convert it to the HSV color space, extract the V channel brightness value and calculate the mean, record the number of valid edge pixels as edge frequency statistics, and simultaneously calculate the pixel density value within the regional range to generate a regional basic image feature group;

[0088] After reading the image segments of the regional blocks marked as deposition and transition in the image deposition trend distribution record, an image feature extraction operation is performed on each region. Specifically, the regional pixel block is used as the input object, the RGB image is converted to the HSV color space, and the V channel data is extracted. The V channel values ​​of all pixels are summed and then divided by the number of regional pixels to obtain the mean. For example, the sum of the V values ​​in region A is 1620000 and the total number of pixels is 10000, so the V channel mean is 162. Then, the Canny edge detection operation is called based on the grayscale image channel to count the total number of edge pixels detected. In region A, this value is 340 pixels. Then, the ratio between the number of non-background pixels and the total number of pixels in the region is counted, and the pixel density is 7200 / 10000 = 0.72. The same extraction process is completed in regions B and C, and the basic image feature combination of each region is constructed, as shown in Table 3.

[0089] Table 3 Comparison of image features and label templates

[0090]

[0091] As shown in Table 3, there are numerical differences in the brightness, edge complexity, and density structure of different regions. Region C has high brightness, high edge frequency, and the density is close to the maximum. The overall feature value of region B is closest to label 2. Finally, the regional basic image feature group value is obtained.

[0092] S312: Based on the regional basic image feature group, select a label data set with the same image category in the pesticide residue image library, extract the label template, compare and calculate the image feature difference between the proposed region and the label template, and sort them in ascending order of the difference value to generate an image feature distance sorting result;

[0093] Based on the regional basic image feature group values, the template feature values ​​of each category in the label library are matched region by region. By calculating the difference between the V channel mean, edge frequency and pixel density in the regional features and each label respectively, a three-dimensional difference index set is constructed, and the distance between the labels is evaluated based on each set of indicators. For example, the difference between the V channel mean of region B and label 2 is 1, the edge frequency difference is 5, and the pixel density difference is 0.03. Under this dimension, it is judged as the preferred label for the current region. Each label is compared in turn, and the degree of proximity between the regional features and the template is sorted. The matching relationship between each region and each label is sorted and numbered from small to large according to the feature distance, and a one-dimensional sorting vector result is constructed. This sorting is used to establish a relative dependency structure, and finally the image feature distance sorting result is obtained.

[0094] S313: Based on the image feature distance sorting results, mapping paths between the pesticide labels are established in the sorted order. The difference values ​​between adjacent label pairs in the sorting are accumulated and summed, and normalized based on the frequency statistics of the corresponding regions in the label classification samples. The difference values ​​are combined with the classification dependency weights to establish a pesticide label feature weight sequence.

[0095] According to the image feature distance sorting results, the order of labels in the sorting vector is called, and the differences between each adjacent label pair in the three dimensions of V channel, edge frequency, and pixel density are accumulated. Then, combined with the sample occurrence frequency of the corresponding label in the image library, such as label 1 has an occurrence frequency of 40, label 2 is 60, and label 3 is 30, the weighted distance value in the sorting path is calculated, and the reciprocal of the cumulative difference of each label in the path is used as the sorting factor of the label in the overall sequence. For example, label 2 has the smallest cumulative difference and the largest sorting factor, so it is positioned at the front in the label sequence. It is arranged from large to small according to the sorting factor to establish a label list for subsequent identification weight allocation, and finally a pesticide label feature weight sequence is obtained.

[0096] See also Figure 5 , step S4 is:

[0097] S411: Read the image content of each image block in the deposition area one by one according to the sorting order of the paths in the pesticide label feature weight sequence, and use the grayscale image as input to calculate the local binary pattern (LBP) texture features corresponding to the image blocks. Simultaneously construct a grayscale co-occurrence matrix, and extract the three feature parameters of energy value, contrast value, and entropy value from the matrix. Combine them to form a texture feature set, and obtain a regional image texture feature vector group;

[0098] According to the path sequence structure marked by the pesticide label feature weight sequence, the image blocks judged as deposition areas in the image deposition trend distribution record are extracted, and the texture feature extraction operation is performed one by one. First, each area block is converted into a grayscale image, and then the local binary pattern LBP encoding is performed in units of 3×3 windows. The grayscale size relationship between the central pixel and its surrounding 8 pixels is compared to construct a binary code. After completing the LBP traversal of the entire area image, the code value histogram is statistically analyzed and then normalized to obtain the LBP energy index of the area. For example, area 1 is statistically analyzed. After calculation, the main frequency LBP value is concentrated on the code "00101111". After normalization, the energy value is 0.082. Then, the grayscale co-occurrence matrix is ​​generated based on the same grayscale image. The grayscale level is set to 8 and the offset is 1 pixel in the horizontal direction. The three indicators of contrast, entropy and energy value in the co-occurrence matrix are extracted. For example, the co-occurrence matrix of area 1 has a grayscale contrast index of 1.55 and an entropy value of 2.15. It is sorted together with other areas. The texture indicators of the three types of regional samples and their preliminary matching label template comparison values ​​are listed below.

[0099] Table 4 Comparison of regional texture features and label templates

[0100]

[0101] As shown in Table 4, the three-dimensional index differences between region 2 and label B are 0.003, 0.05, and 0.05, respectively. The differences are the smallest and the directions are consistent. Region 1 and label A also show a highly close feature alignment state. Based on the above value combination, the regional image texture feature vector group is obtained.

[0102] S412: Based on the regional image texture feature vector group, feature matching is performed on the texture feature vector of each region with the label templates in the pesticide label feature weight sequence. The corresponding ratios and differences between the regional vector and the label template in each dimension are calculated. The three label templates that best match each region are extracted as the preferred identification objects for the corresponding region, and a regional label cosine similarity matching sequence is generated.

[0103] Based on the regional image texture feature vector group, a feature matching evaluation is performed between each region and the label template. During matching, the difference between the corresponding values ​​of the region and the label is statistically calculated according to the three indicators listed in the table. For example, the LBP energy value of region 3 is 0.077, which is 0.002 lower than that of label C at 0.079. The co-occurrence matrix contrast is 1.62, and that of label C is 1.60, with a difference of 0.02. The entropy values ​​are 2.10 and 2.08, respectively, with a difference of 0.02. The total difference in this region is 0.042, which is the smallest among all label templates. Therefore, label C is ranked as the preferred matching label for region 3. Through this operation, the top three labels with the smallest similarity difference are extracted for each regional sample and a ranking structure is established. The preferred label for region 1 is A, the preferred label for region 2 is B, and the preferred label for region 3 is C. A multi-region parallel ranking table is constructed, and finally the regional label cosine similarity matching sequence is output.

[0104] S413: Based on the cosine similarity matching sequence of regional labels, the label with the highest similarity among the three candidate labels of each deposition area is selected as the preferred category of the region, and the suboptimal label is used as its alternative path node. The recognition sequence corresponding to each deposition area is established in sequence, and all regional recognition results are merged to construct a two-dimensional mapping matrix in the order of regional indexes to establish the category path priority matching result;

[0105] According to the cosine similarity matching sequence of regional labels, the top label in each region's ranking is extracted as the main path matching label, and the two suboptimal labels are used as secondary path candidates. For example, if the matching ranking of region 2 is label B, label A, and label C, then the preferred label for this region is B, and the alternative paths are A and C. After performing this operation on all deposition regions, the region numbers and their path labels are combined to establish a mapping table. Then, the two-dimensional structure matrix is ​​output according to the order of the original block numbers of the image, such as region 1 → label A, region 2 → label B, and region 3 → label C. The main label is filled in the main channel of the matrix, and the secondary label combination is stored in the additional path layer structure. A path table with candidate node expansion capability is constructed, and finally the category path priority matching result is integrated and established.

[0106] See also Figure 6 , step S5 is:

[0107] S511: Based on the category path priority matching result, read the image pixel information and calculate the area of ​​the image area block corresponding to each category. Read the pixel area covered by each type of pesticide residue area marked in the image using the formula:

[0108]

[0109] Calculate the ratio intensity R of each category residue in the image and generate category residue ratio intensity data, where S irepresents the total number of pixels covered in the image area corresponding to the i-th category, S total Represents the total pixel value of the entire image. This value is obtained by multiplying the image width and height. All parameters are collected based on actual image data and obtained through real-time statistics.

[0110] Based on the category path priority matching results, the image pixel information is called to calculate the area of ​​the image area block corresponding to each category. First, the pixel distribution information of each category of pesticide residues in the image is read. The total image size is 4000 pixels × 3000 pixels, and the total pixel area of ​​the image is 12,000,000 pixels. On this basis, the pixel value occupied by each category area is extracted. For example, the coverage area of ​​category A is 360,000 pixels, category B is 900,000 pixels, and category C is 300,000 pixels. The total pixel value S of the image is called total The pixel value S corresponding to each category area i , use the formula to calculate the proportion, and calculate the proportion intensity R of each category remaining in the image i , that is, the coverage percentage of each category in the entire image, where the calculation process of category A is: Category B is Category C is To ensure data reproducibility, real image data is used to manually mark the corresponding areas, and image processing tools are used to verify the closure and connectivity of the boundaries of various areas to prevent area calculation deviations. After area extraction, the pixels at the edge of the image need to be denoised to remove misjudged pixels in incomplete areas. For example, discrete spots with less than 50 pixels are removed to avoid affecting the category area ratio. Finally, the category residual ratio intensity data is generated from the coverage ratio results calculated for multiple categories.

[0111] Proportion intensity refers to the ratio between the pixel area occupied by a specific pesticide type in the entire image and the total pixel area of ​​the image. It is expressed as a percentage and is used to quantify the spatial coverage of the pesticide type in the image. This indicator reflects the relative distribution scale of the pesticide residues of this type in the target area. The larger the value, the wider the distribution range of the type in the image. It serves as a judgment basis in the subsequent residue risk assessment and comparison with the standard limit. The proportion intensity can be obtained by calculating the pixels in the image area and is objective and measurable.

[0112] S512: Based on the category residue intensity data and the maximum pesticide residue limit threshold, determine whether the residue intensity of each category exceeds the threshold, mark the main identification result candidate, and mark the remaining categories that do not exceed the standard threshold as reference items. Then perform a Boolean judgment operation to obtain a list of categories that exceed the standard;

[0113] Based on the category residue intensity data and the pesticide residue limit requirements in GB2763-2021, a numerical judgment operation is performed on the percentage of each category. First, the pesticide residue limit threshold is set at 35.0%. This threshold is used as the screening benchmark, and a binary comparison operation is performed on the percentage of each category with the threshold. If the residue intensity of a category is higher than the standard value, its Boolean judgment result is set to 1, indicating that it is included in the main identification object. Otherwise, the Boolean value is set to 0, indicating that it is only used as a reference item. For example, if the residue intensity of category B is 42%, it is greater than the threshold, and the Boolean judgment result is 1. The proportion of category A is 3%, which is less than the threshold, and the Boolean judgment result is 0. The judgment result is used to record the primary and secondary status of the corresponding label and generate a tag field for the identification type output field. The threshold of 35.0% is set according to food safety standards. The specific value comes from experimental statistics on the average residue levels of conventional pesticides in different parts of vegetables, fruits and other categories. This ensures that the screening operation has a unified reference benchmark and obtains a list of categories that exceed the standard.

[0114] S513: Based on the list of exceeded category identifiers, the corresponding category names, percentage intensity values, and judgment label information are collected and jointly generated into a record item in a standardized output format. The record content includes the category name, residue percentage intensity, standard threshold, and judgment label value, thereby obtaining a pesticide residue classification identification record;

[0115] For the list of categories that exceed the standard, the corresponding field data of each category is called to build a structured record set. The extracted fields include the category name field, the actual proportion intensity field, the national limit threshold field and the Boolean judgment field. The field values ​​are combined to form a unified output record content. The record format is unified as {category name, proportion value, limit threshold, judgment value}. For example, the data of category B is {category B, 42.0%, 35.0%, 1}, and the data of category A is {category A, 3.0%, 35.0%, 0}. The field format supports subsequent unified table processing and text export operations to ensure that each type of identification result has readability and data traceability. After the record is output, it is bound to the standard timestamp and image number to form an identification data serial number, realizing unified coding and management of the complete data structure, and finally generating a pesticide residue classification identification record.

[0116] An artificial intelligence-based pesticide residue detection system, comprising:

[0117] The image brightness division module extracts the pixel value of the Y channel of the agricultural product image, calculates the difference between the maximum and minimum values ​​of each regional block, and normalizes it to generate regional standard brightness difference data;

[0118] The sedimentation trend analysis module constructs a vector based on the regional standard brightness difference data, using the difference between the central pixel brightness and the four neighboring pixels, determines the decreasing trend, and generates an image sedimentation trend distribution record;

[0119] The regional structure extraction module extracts the V channel mean, edge frequency, and pixel density of the deposition and transition areas based on the image deposition trend distribution records. It calculates the color difference with the pesticide image library template, establishes the category path, and generates the pesticide label feature weight sequence.

[0120] The feature vector matching module extracts the LBP value and gray-level co-occurrence matrix of the regional block based on the pesticide label feature weight sequence, calculates the cosine value with the label template, selects the path matching item, and generates the category path priority matching result;

[0121] The residue classification and identification module prioritizes the matching results based on the category path, summarizes the area ratio of the matching area, compares and screens it with the residue limit threshold, and generates a pesticide residue classification and identification record.

[0122] The above are merely preferred embodiments of the present invention and do not limit the present invention in any other form. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall still fall within the scope of protection of the technical solution of the present invention.

Claims

1. A pesticide residue detection method based on artificial intelligence, characterized in that: The following steps are involved: S1: Obtain the surface image of agricultural products, divide it into equal blocks, extract the Y channel pixels of each block, perform normalization processing on the maximum and minimum pixel value differences, and generate regional standard brightness difference data; S2: Based on the regional standard brightness difference data, construct four-neighborhood gradient vectors for each regional block, sort the difference vector set, analyze the trend and mark the deposition area, transition area and background area, and generate an image deposition trend distribution record; S3: Read the image deposition trend distribution record, extract the V channel mean, edge frequency, and pixel density of the deposition and transition areas, select the corresponding category label template, calculate the color difference distance between the templates, establish a sorting path, and generate a pesticide label feature weight sequence; S4: extracting LBP texture features and gray-level co-occurrence matrix features from each sedimentary area block according to the pesticide label feature weight sequence, performing cosine similarity matching with the label template, and generating a category path priority matching result; S5: Based on the category path priority matching results, the residue ratio intensity of each category in the overall image is calculated, and the categories with residue limits higher than the threshold are selected as the main recognition results to generate pesticide residue classification recognition records.

2. The method for detecting pesticide residues based on artificial intelligence according to claim 1, characterized in that: The regional standard brightness difference data includes brightness range distribution, standard interval mapping value, and image local contrast index; the image deposition trend distribution record includes deposition area position index, transition area adjacency relationship, and brightness gradient sorting sequence; the pesticide label feature weight sequence includes color difference distance matrix, label dependency path, and structural feature template mapping relationship; the category path priority matching result includes texture similarity score, grayscale matrix correlation score, and feature vector matching sequence; the pesticide residue classification and identification record includes the main identification category, secondary reference item, and residue proportion intensity analysis result.

3. The method for detecting pesticide residues based on artificial intelligence according to claim 1, wherein The steps for obtaining the regional standard brightness difference data are specifically as follows: S111: Based on the surface image of the agricultural product captured by the camera, the image is divided into preset rows and columns, the image data corresponding to each area block is obtained, each area image is converted to YUV color space, the Y channel brightness pixel value set in each area block is extracted, and a brightness pixel set matrix is ​​established; S112: Calculate the maximum pixel value and the minimum pixel value in the Y channel of each area according to the brightness pixel set matrix, obtain the brightness difference of the pixels in the area, and perform a normalization operation on each pixel value based on the difference, mapping all pixel values ​​to a standard interval to generate a brightness normalization value matrix; S113: According to the brightness normalization value matrix, traverse each area block, perform difference calculation on the normalized brightness values ​​of all pixels in the area, count the degree of difference in the brightness values ​​of each block of pixels, obtain the brightness difference distribution of each area in the standard range, and obtain regional standard brightness difference data.

4. The method for detecting pesticide residues based on artificial intelligence according to claim 1, wherein The steps for obtaining the image deposition trend distribution record are specifically as follows: S211: Based on the regional standard brightness difference data, taking the central pixel in each regional block as the starting point, collecting the brightness values ​​of pixels equidistant from the center point in the four directions of up, down, left, and right, calculating the brightness differences relative to the center point in the four groups of directions, establishing a four-dimensional vector with the center point as the origin, and generating a four-neighborhood gradient vector matrix; S212: Based on the four-neighborhood gradient vector matrix, perform modulus calculation on the four-dimensional gradient vector in each region block, perform L2 norm sorting on the vector modulus results of all regions, construct a continuous difference sequence according to the sequence number difference after sorting, calculate the gradient change trend index of each region, and determine the trend change of the gradient difference in the region sequence to generate a gradient change trend index sequence; S213: According to the gradient change trend indicator sequence, determine the change in the ranking position of the gradient difference of each area, mark the deposition area, transition area and background area, and after completing the marking of all areas, summarize them into a two-dimensional image space to establish an image deposition trend distribution record.

5. The method for detecting pesticide residues based on artificial intelligence according to claim 1, wherein The steps for obtaining the pesticide label feature weight sequence are specifically as follows: S311: Read all regional block image segments marked as deposition areas and transition areas in the image deposition trend distribution record, obtain the image pixel set of each area, convert it to the HSV color space, extract the V channel brightness value and calculate the mean, record the number of valid edge pixels as edge frequency statistics, and simultaneously count the pixel density values ​​within the regional range to generate a regional basic image feature group; S312: Based on the regional basic image feature group, a label data set with the same image category as the pesticide residue image library is selected, a label template is extracted, and the image feature difference between the proposed region and the label template is compared and calculated. The image features are sorted in ascending order of the difference value to generate an image feature distance sorting result; S313: Based on the image feature distance sorting results, mapping paths between the pesticide labels are established in sequence according to the sorting order, the difference values ​​between adjacent label pairs in the sorting are accumulated and summed, and normalized and converted based on the frequency statistics of the corresponding areas in the label classification samples. The difference values ​​are combined with the classification dependency weights to establish a pesticide label feature weight sequence.

6. The method for detecting pesticide residues based on artificial intelligence according to claim 1, characterized in that: The steps for obtaining the category path priority matching results are as follows: S411: Read the image content of each image block in the deposition area one by one according to the sorting order of the paths in the pesticide label feature weight sequence, and calculate the local binary pattern (LBP) texture features corresponding to the image blocks using the grayscale image as input, simultaneously construct a grayscale co-occurrence matrix, and extract the three feature parameters of energy value, contrast value, and entropy value in the matrix, combine them to form a texture feature set, and obtain a regional image texture feature vector group; S412: Based on the regional image texture feature vector group, feature matching processing is performed on the texture feature vector of each region with the label template in the pesticide label feature weight sequence, the corresponding ratio and difference between the regional vector and the label template in each dimension are calculated, and the three label templates that best match each region are extracted as preferred identification objects for the corresponding region, and a regional label cosine similarity matching sequence is generated; S413: According to the cosine similarity matching sequence of the regional labels, the label with the highest similarity is selected from the three candidate labels of each deposition area as the regional preferred category, and the suboptimal label is used as its alternative path node. The identification sequence corresponding to each deposition area is established in turn, and all regional identification results are merged. A two-dimensional mapping matrix is ​​constructed in the order of regional indexes to establish the category path priority matching result.

7. The method for detecting pesticide residues based on artificial intelligence according to claim 1, wherein: The steps for obtaining the pesticide residue classification and identification record are as follows: S511: Based on the category path priority matching result, read the image pixel information to calculate the area of ​​the image area block corresponding to each category, read the pixel area covered by each type of pesticide residue area marked in the image, calculate the proportion intensity of each category of residue in the image, and generate category residue proportion intensity data; S512: Based on the residue intensity data of the categories and the maximum pesticide residue limit threshold, determine whether the residue intensity of each category exceeds the threshold, mark the main identification result candidate, mark the remaining categories that do not exceed the standard threshold as reference items, and perform a Boolean judgment operation to obtain a list of category identifiers exceeding the standard; S513: Based on the list of category identifiers exceeding the standard, the corresponding category names, proportion intensity values, and determination label information are collected, and record items in a standardized output format are jointly generated to obtain pesticide residue classification identification records.

8. A pesticide residue detection system based on artificial intelligence, characterized in that: The system is used to implement the artificial intelligence-based pesticide residue detection method according to any one of claims 1 to 7, comprising: The image brightness division module extracts the pixel value of the Y channel of the agricultural product image, calculates the difference between the maximum and minimum values ​​of each regional block, and normalizes it to generate regional standard brightness difference data; The sedimentation trend analysis module constructs a vector based on the standard brightness difference data of the region by using the brightness difference of the central pixel and the four neighboring pixels, determines the decreasing trend, and generates an image sedimentation trend distribution record; The regional structure quantity extraction module extracts the V channel mean, edge frequency, and pixel density of the deposition and transition areas based on the image deposition trend distribution record, calculates the color difference with the pesticide image library template, establishes the category path, and generates the pesticide label feature weight sequence; The feature vector matching module extracts the LBP value and gray-level co-occurrence matrix of the regional block according to the pesticide label feature weight sequence, calculates the cosine value with the label template, selects the path matching item, and generates the category path priority matching result; The residue classification identification module prioritizes the matching results of the category paths, summarizes the area ratio of the matching areas, compares and screens them with the residue limit threshold, and generates a pesticide residue classification identification record.

Citation Information

Cited By

  • Method, system and equipment for testing brightness uniformity of liquid crystal screen and medium

    CN121499015A