Cotton field weed grading recognition and variable spraying method based on feature weight enhancement
By employing dynamic feature weighting and multimodal fusion, the accuracy and adaptability issues of cotton field weed identification in complex environments were addressed, enabling precise variable spraying decisions and improving identification accuracy and control effectiveness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU UNIV
- Filing Date
- 2026-03-25
- Publication Date
- 2026-07-07
AI Technical Summary
Traditional methods for identifying weeds in cotton fields suffer from unstable accuracy in complex environments, insufficient feature differentiation capabilities, weak adaptability, and severe background noise interference, making it difficult to achieve precise control.
By using dynamic feature weighting and multimodal fusion, images are acquired using an aerial vision sensor for agricultural applications. High-frequency edge features and color channel features are extracted. By combining feature saliency evaluation and spatial-spectral attention mechanisms, background noise is suppressed, enabling cross-modal feature fusion and adaptive recognition.
It significantly improves the accuracy and adaptability of weed identification in complex environments, enables precise variable spraying decisions, reduces pesticide overuse, and protects the agricultural ecological environment.
Smart Images

Figure CN122347736A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart agriculture, specifically to a method for graded identification and variable spraying of weeds in cotton fields based on feature weight enhancement. Background Technology
[0002] Precise weed control in cotton fields is crucial for ensuring cotton yield and quality, reducing pesticide overuse, and protecting the agricultural ecological environment. Traditional weed identification and spraying methods mainly rely on standardized threshold segmentation or basic machine learning models, but these methods face significant challenges in complex field scenarios.
[0003] Currently, existing technical solutions have the following limitations: First, insufficient feature discrimination ability. In the seedling stage, cotton and some noxious weeds are highly similar in visual features such as color and texture. Relying solely on RGB color space or simple vegetation indices is insufficient for effective differentiation. Furthermore, conventional image processing methods are extremely sensitive to changes in lighting, shadow occlusion, and background interference such as soil and mulch, leading to unstable recognition accuracy. Second, rigid feature utilization and weak adaptability. Although most deep learning-based methods can automatically extract features, they typically perform simple splicing or linear fusion of the extracted features, lacking a dynamic enhancement mechanism for key discriminative features. Especially in areas where weed and crop morphological features overlap, the model cannot adaptively adjust the dependence on different feature channels according to the local context, thus limiting its recognition accuracy in complex scenes. Third, severe background noise interference. Cotton field environments are complex, often containing reflective mulch, exposed sand, crop residues, etc. Traditional attention mechanisms or segmentation models are easily affected by these noisy areas, making it difficult to focus computational resources on the true vegetation targets, leading to false positives and false negatives.
[0004] Therefore, there is an urgent need in this field for a technical solution that can overcome the above-mentioned shortcomings. It needs to have strong feature discrimination and enhancement capabilities, effectively suppress interference from complex backgrounds, and seamlessly integrate accurate identification results with intelligent spraying decisions, ultimately achieving graded, precise, and adaptive variable control of weeds in cotton fields. Summary of the Invention
[0005] To ensure cotton yield and quality, reduce pesticide overuse, and protect the agricultural ecological environment during plant protection, this invention presents a method for weed classification and variable spraying in cotton fields based on enhanced feature weights. Through dynamic feature weighting and multimodal fusion, the method significantly improves the accuracy of identifying similar weeds in complex field environments and enhances the system's adaptability.
[0006] The cotton field weed classification and identification and variable spraying method based on feature weight enhancement of the present invention includes the following steps:
[0007] Step 1: Decoupling and preprocessing of multi-channel data. Real-time images of cotton fields are acquired using the onboard visual sensor of the plant protection aircraft. High-frequency edge features in the images are extracted through Laplacian transform to construct texture channels. At the same time, RGB components are extracted to construct color channels that reflect chlorophyll distribution.
[0008] Step 2, heterogeneous feature embedding and dynamic weighting: the texture channel feature matrix and the color channel feature matrix are mapped to a high-dimensional embedding space respectively. A feature saliency evaluation function is introduced. Based on the difference in edge curvature between cotton seedlings and specific noxious weeds, the weight bias of the texture features is calculated, and the texture feature matrix is nonlinearly weighted to enhance it.
[0009] Step 3: Cross-modal feature fusion and correlation modeling. The enhanced texture features and color features are concatenated and then input into the improved Transformer encoder. The encoder integrates a spatial-spectral attention mechanism, which uses the semantic distribution of color channels as a mask constraint to guide the self-attention mechanism to focus on the vegetation area and suppress background noise from mulch and sand.
[0010] Step 4: Target classification and disaster level assessment. The decoder outputs the category and coordinate mask of the target to be identified, and calculates the pixel ratio of weeds per unit area as a growth density indicator.
[0011] Step 5, graded decision-making and prescription map generation: The identified weed species, coverage area and growth density are input into the fuzzy decision model. The disaster level is automatically determined according to the preset threshold, and the corresponding pesticide spraying dosage is matched to generate a variable spraying prescription map in real time.
[0012] Furthermore, the specific process of step one is as follows:
[0013] Real-time images of cotton fields were acquired using an aerial vision sensor for agricultural protection. Multi-channel data decoupling and preprocessing were performed, and high-frequency edge features were extracted from the images using Laplacian transform to construct texture channels. Simultaneously, RGB components were extracted to construct color channels reflecting chlorophyll distribution. The specific steps included:
[0014] I. System Input and Preprocessing
[0015] A cotton field weed classification and variable spraying method based on feature weight enhancement begins by acquiring a sequence of raw digital images of the cotton field from a multispectral or RGB imaging sensor mounted on a spraying machine; let a single frame input image be:
[0016]
[0017] In the formula, For the original image, For the set of real numbers, The height of the image. The width of the image. For an RGB image, the number of channels is... For multispectral images, For the number of bands; first, for Standardized preprocessing is performed, including illumination white balance correction and sensor noise filtering, to output a standardized image. ;
[0018] II. Intelligent Construction of Texture Feature Channels
[0019] The construction of texture channels aims to extract and enhance the differences in morphology, edges, and microstructure between crops and weeds. This method is achieved through a cascaded intelligent module.
[0020] Learnable multi-scale texture primitive extraction module
[0021] This module is implemented using a lightweight deep convolutional neural network, denoted as . It receives preprocessed images. By stacking depth-separating convolutional layers, batch normalization layers, and non-linear activation function layers, multi-level feature abstraction is achieved; this process is described as follows:
[0022]
[0023] In the formula, The baseline texture features extracted by the convolutional network. Representing the One convolutional block, This represents the total number of floors. It is a learnable multi-scale texture feature extraction convolutional neural network, employing a shallow-to-medium layer structure similar to MobileNetV3 to achieve a balance between computational efficiency and feature richness; the total number of layers is [missing information]. It contains primitive features at multiple scales, ranging from low-level edges to mid-level texture patterns; among them, , It refers to the height and width of the unified feature map space. This represents the number of texture feature channels;
[0024] Differentiable spatial frequency enhancement module
[0025] To explicitly enhance the ability to detect fine weed textures and resist light disturbance, in Based on the output features, a differentiable wavelet transform layer is introduced. This layer is for Each feature channel is independently subjected to a two-dimensional discrete wavelet transform to decompose high-frequency detail components;
[0026] Specifically, for the feature map of the 1st... One channel ,have:
[0027]
[0028] In the formula, Two-dimensional discrete wavelet transform operation, This is a low-frequency approximation component. For high-frequency detail components in the horizontal direction, These are the high-frequency detail components in the vertical direction. These are the high-frequency detail components in the diagonal direction;
[0029] To enhance texture, three high-frequency components were extracted. They are then concatenated along the channel dimension to form a multi-directional high-frequency feature tensor. ,in For multi-directional high-frequency feature tensors
[0030] Next, through a Convolutional layer right Channel fusion and dimensionality reduction are performed to learn effective combinations of high-frequency information.
[0031]
[0032] In the formula, It is a high-frequency enhancement feature. for Convolutional layers;
[0033] Finally, bilinear interpolation is used to... Upsampling to Same space size and with By summing the residuals, we obtain the enhanced texture feature map. :
[0034]
[0035] In the formula, Enhanced texture feature map, Used for upsampling operations;
[0036] III. Intelligent Construction of Color Feature Channels
[0037] The construction of color channels aims to learn the differences in pigment composition and spectral reflectance characteristics between vegetation, especially cotton seedlings and different weed species; this method is implemented through an adaptive color decoupling network.
[0038] Multi-color space fusion and mapping
[0039] First, standardize the RGB image Parallel conversion to HSV and CIELAB color spaces yields... and , For images converted to the HSV color space, The image is converted to the Lab color space. These three color spaces represent different color attributes: RGB corresponds to the sensor's original response, HSV corresponds to hue, saturation, and lightness, and Lab is more in line with human eye perception and separates brightness from color.
[0040] Subsequently, the images from these three spaces are stitched together along the channel dimension to form a richly colored representation:
[0041]
[0042] In the formula, To fuse images across multiple color spaces, For splicing operations;
[0043] Adaptive Spectral Feature Learning Network
[0044] Will Input a lightweight convolutional network The network consists of several convolutional layers, and its core function is to learn an optimal linear or nonlinear transformation to maximize the response to sensitive spectral features such as chlorophyll content and water content, and to suppress the effects of light changes and shadows.
[0045]
[0046] In the formula, For the final color semantic features, Learn a convolutional neural network for adaptive color features;
[0047] Preferably, the last layer of the network uses the Sigmoid or Tanh activation function to constrain the feature values within a certain range to enhance its stability; the network is trained end-to-end and can automatically learn color features similar to the normalized vegetation index and the overgreen index, but which are more discriminative for cotton field weeds.
[0048] IV. Feature Map Alignment and Output
[0049] To ensure the effectiveness of subsequent fusion steps, spatial interpolation is used to transform the texture feature map. and color feature map Adjust to a uniform feature map size ,in , The number of texture feature channels, The number of color feature channels; finally, output a set of dual-channel feature maps. This serves as the input for subsequent heterogeneous feature embedding and dynamic weighting modules.
[0050] Furthermore, the specific process of step two is as follows:
[0051] By employing heterogeneous feature embedding and dynamic weighting, the texture channel feature matrix and color channel feature matrix are mapped to a high-dimensional embedding space, respectively. A feature saliency evaluation function is introduced, and the weight bias of the texture features is calculated based on the difference in edge curvature between cotton seedlings and specific noxious weeds. The texture feature matrix is then nonlinearly weighted and enhanced, specifically including the following sub-steps:
[0052] I. Heterogeneous Feature High-Dimensional Embedding Module
[0053] This module receives the dual-channel feature map set output from the preprocessing stage. ,in , Its function is to map two heterogeneous features to a common, higher-dimensional feature space through nonlinear transformation, so as to facilitate subsequent interaction and fusion.
[0054] Texture feature embedding
[0055] Through a Convolutional layer This convolutional layer increases the channel dimension of texture features and introduces non-linearity without changing the spatial dimensions.
[0056]
[0057] In the formula, To embed texture features into a higher-dimensional space, For use in feature embedding Convolution kernel parameters, To modify the activation function of the linear unit, For batch normalization operations, For convolution operations, The dimension of a public high-dimensional space;
[0058] Color feature embedding
[0059] Through an independent Convolutional layer The implementation and processing are symmetrical with the texture features;
[0060]
[0061] In the formula, This involves embedding color features into a high-dimensional space; at this point, texture and color features are mapped to the same channel dimension. This facilitates subsequent attention calculations and feature interactions;
[0062] II. Curvature-Aware Spatial Attention Generation Module
[0063] This module quantifies and utilizes the systematic differences in local geometry, i.e., curvature, between cotton seedling leaves and common weeds; this module uses embedded texture features As input, output a spatial weight map;
[0064] Local curvature feature extraction
[0065] First, edge- and curvature-sensitive representations are recovered from high-dimensional texture features; specifically, from... A subset of feature channels representing the main edge responses is extracted, and each spatial location is approximated by gradient calculation operations such as the Sobel operator. gradient magnitude The direction is determined to estimate its approximate mean curvature. ;
[0066] Design a lightweight curvature estimation subnetwork It consists of several convolutional layers, directly from... Regress a single-channel curvature response plot :
[0067]
[0068] In the formula, For curvature feature extraction subnetwork, This is a curvature response diagram; where The value of each element is positively correlated with the edge curvature at that location; higher values indicate higher curvature. Values typically correspond to the slender, highly curved leaf margins or stems of weeds, while lower values... The value corresponds to the relatively rounded and gently sloping leaf edges of cotton seedlings;
[0069] Prior-guided attention map generation
[0070] curvature response diagram Compare this to a learnable cotton seedling curve prior distribution; this prior can be represented as an adjustable threshold function or a Gaussian kernel function; through a miniature network containing a Sigmoid activation function. Generate spatial attention weight map :
[0071]
[0072] In the formula, Generate subnetworks for spatial attention. This is a spatial attention weight map. The Sigmoid function maps values to... interval; Through learning, high curvature regions are assigned weights to weeds. Pushing to 1 pushes the weight of low curvature regions for cotton seedlings to 0; this process is trainable, allowing the system to learn the optimal curvature discrimination threshold from the data.
[0073] III. Channel Attention Generation Module
[0074] This module runs in parallel with spatial attention and aims to evaluate the global importance of each channel of texture features. Its structure borrows from the idea of squeeze-excitation networks, but operates on the embedded texture features. ;
[0075] Global information compression
[0076] right Global average pooling is performed on each channel to compress spatial information into a channel descriptor vector. :
[0077]
[0078] In the formula, For channel index, For the first Global descriptors for each channel, For the first Feature maps of each channel;
[0079] Incentives and Weight Generation
[0080] Through a gating mechanism, consisting of two fully connected layers, the non-linear dependencies between channels are learned, and the weights of each channel are output.
[0081]
[0082] In the formula, The weight matrix is a learnable matrix. For the reduction ratio, It is the ReLU activation function. For the Sigmoid function; output This is the channel attention weight vector, where each element... For the first Global significance of each channel;
[0083] IV. Dynamic Weighting and Feature Fusion Module
[0084] This module integrates spatial and channel attention to refine texture features and initially fuse them with color features;
[0085] Dynamic weighting of features
[0086] Spatial attention map With channel attention vector Combined with embedded texture features Perform element-wise weighted summation:
[0087]
[0088] In the formula, This represents element-wise multiplication, with respect to channel weights. It will extend to spatial dimensions through a broadcasting mechanism; The texture features are enhanced by both spatial and channel attention. Spatially, this operation strengthens the feature response of high-curvature weed areas; and channelally, it enhances the feature channels that contribute significantly to classification and identification.
[0089] Heterogeneous feature splicing
[0090] The enhanced texture features and the embedded color features are concatenated along the channel dimension to form a dynamically weighted fused feature. ;
[0091]
[0092] In the formula, The final output is a dynamically weighted fusion feature that includes both texture information enhanced by morphological priors and the original spectral color information, providing a robust and discriminative input for subsequent accurate recognition.
[0093] Furthermore, the specific process of step three is as follows:
[0094] Cross-modal feature fusion and correlation modeling involves concatenating enhanced texture and color features and inputting them into an improved Transformer encoder. The encoder integrates a spatial-spectral attention mechanism, utilizing the semantic distribution of color channels as a mask constraint to guide the self-attention mechanism to focus on vegetated areas and suppress background noise from mulch film and sand. Specifically, this includes the following sub-steps:
[0095] I. Color Semantic Mask Generation Subnetwork
[0096] This sub-network, as a lightweight preprocessing module, aims to quickly and initially segment the vegetation foreground, including cotton seedlings and weeds, from color features, and generate a binary mask to suppress interference from complex backgrounds such as soil and residual film in subsequent global attention calculations.
[0097] Input and Encoding
[0098] Color features output by the dynamic weighting module As input, this feature is passed through an encoder consisting of several convolutional and pooling layers. Feature compression and abstraction are performed:
[0099]
[0100] In the formula, The encoder for the mask generation subnetwork, These are the high-level semantic features after encoding;
[0101] Decoding and Mask Prediction
[0102] Encoded features are processed by a symmetric decoder. Upsampling is performed to gradually restore spatial resolution; the decoder is typically composed of transposed convolutional layers or a combination of upsampling layers and convolutional layers; finally, through a... The convolutional layer is followed by a sigmoid activation function, outputting a single-channel probability map with the same resolution as the input. :
[0103]
[0104] In the formula, The decoder for the mask generation subnetwork, This is a probability map of vegetation areas, where each pixel value represents the probability that the location belongs to a vegetation area; a threshold is set... A value of 0.5 is used to obtain a hard binary mask. :
[0105]
[0106] in, The vegetation area will have access to subsequent attention calculations; This represents the background area, and its influence will be greatly suppressed.
[0107] II. Spectral-Spatial Hybrid Attention Transformer Encoder
[0108] This module is the core of feature fusion, receiving dynamically weighted fused features. and mask By introducing an attention mechanism that decouples spectral and spatial information, precise cross-modal information interaction can be achieved.
[0109] Tokenization and Location Encoding
[0110] feature map Remodeled into a series of tokens ,in The total number of spatial locations; to preserve location information, learnable location codes are added. :
[0111]
[0112] In the formula, This is the input to layer 0 of the encoder. For flattening operation;
[0113] Mask-guided spectral-spatial hybrid attention layer
[0114] The encoder is made by It is made up of identical layers stacked together, each layer The core is a mask-guided spectral-spatial hybrid attention mechanism;
[0115] Query, key-value generation: For input sequences The query, key, and value vectors required for the spectral attention head and spatial attention head are generated respectively through linear projection:
[0116]
[0117] In the formula, For query, As key, For value, For spectral channel attention heads, For spatial position attention; The projected weight matrix is a learnable matrix. For projection dimensions;
[0118] Mask bias matrix construction: constructing a binary mask Flatten into vectors Construct a mask bias matrix :
[0119]
[0120] In the formula, For mask-guided attention bias matrix, The mask value; this matrix ensures that the value is only valid if the query position is specified. and bond position Attention weights are only allowed to be calculated when the mask value is 1, and all are located in vegetation areas; otherwise, the weights are forced to 0.
[0121] Hybrid attention calculation: The logarithms (its) of spectral attention and spatial attention are added together, and a mask bias is also included. The hybrid attention weights are calculated using Softmax:
[0122]
[0123] In the formula, The scaling factor for the spectral attention head. The scaling factor for the spatial attention head; For mask-guided spectral-spatial hybrid attention mechanisms, It is a normalized exponential function; this design allows the model to simultaneously focus on the similarity of spectral features between different locations, i.e., spectral attention, and the contextual relationship of spatial location, i.e., spatial attention, and the calculation is strictly limited to the vegetation area.
[0124] Feedforward networks and layer stacking
[0125] Each attention sublayer is followed by a feedforward network, typically consisting of two linear transformations and a non-linear activation function; residual connections and layer normalization are added to ensure training stability.
[0126]
[0127]
[0128] In the formula, For the first The output features of the layer For the first Intermediate features of the layer For the first The final output features of the layer For layer normalization operation, This is a feedforward neural network function;
[0129] go through After layer stacking, a deep fused feature sequence is obtained. ;
[0130] III. Parallel Decoding and Recognition Head
[0131] This module is responsible for analyzing fusion features. The final recognition result is decoded, including pixel-level segmentation and image-level classification;
[0132] Feature map reshaping
[0133] Serialized features Reconstructing back to a two-dimensional spatial format ' ;
[0134] Segmentation head
[0135] Employ a lightweight decoder It typically consists of several upsampling layers and convolutional layers, Upsampled to original image size It outputs the category probability distribution for each pixel;
[0136]
[0137] In the formula, It is a lightweight segmentation decoder. For pixel-level segmentation mask prediction, The number of weed categories to be identified. Represents the background class;
[0138] Classification Head
[0139] Features in the spatial dimension Perform global average pooling to obtain a global feature vector, and then use a multilayer perceptron to predict the weed category in the image;
[0140]
[0141] In the formula, Each element represents the probability that the corresponding category of weeds exists in the image. For activation function, Multilayer perceptron for classification This is a global average pooling operation;
[0142] IV. Multi-task joint training strategy
[0143] To optimize the entire recognition network, a multi-task loss function combining segmentation loss, classification loss, and boundary loss is used for end-to-end training:
[0144]
[0145] In the formula, For the total loss, To divide the loss, For classifying losses, For boundary consistency loss, These are the weighting coefficients for the segmentation loss. These are the weighting coefficients for the classification loss. These are the weighting coefficients for the boundary consistency loss;
[0146] Segmentation loss
[0147] A combination of cross-entropy loss and Dice loss is used to address the class imbalance between foreground and background and to optimize the overlapping region;
[0148]
[0149] In the formula, For the actual segmentation mask, For the predicted segmentation mask, For smoothing terms;
[0150] Classification loss
[0151] The binary cross-entropy loss is used to calculate the error of image-level multi-label classification;
[0152]
[0153] In the formula, Let be the true class label vector of the image. It is the prediction probability vector The One element;
[0154] Boundary consistency loss
[0155] Encourage clear and accurate predicted weed boundaries by calculating the gradient domain between the true and predicted boundaries. Distance implementation;
[0156]
[0157] In the formula, For the operation of extracting boundaries, This is the gradient operator.
[0158] Furthermore, the specific process of step four is as follows:
[0159] Target classification and disaster level assessment: The decoder outputs the category and coordinate mask of the target to be identified, and calculates the pixel ratio of weeds per unit area as a growth density indicator. This process includes the following sub-steps:
[0160] I. Input and Data Preparation
[0161] The input to this module comes directly from the two outputs of the "Cross-modal Feature Fusion and Accurate Recognition" module:
[0162] Pixel-level semantic segmentation mask ,in The last channel represents the total number of weed categories that the model can identify, and the last channel represents the background. The hard-assigned segmentation result can be obtained by taking the maximum index of the channel dimension at each pixel location. ,in Representative position Identified as the first Weeds and ;
[0163] Image-level multi-label category probability vector This indicates the confidence level that various types of weeds exist in the entire image;
[0164] Based on the segmentation result image It can be used for every type of weed. Generate a binary mask :
[0165]
[0166] in, ;all The set consists of binary masks for each weed category. ;
[0167] II. Density-Sensitive Growth Parameter Calculation Module
[0168] This module aims to calculate three core growth parameters: pixel coverage, distribution uniformity index, and species coexistence index. Among them, the calculation of the distribution uniformity index introduces a learning-based density estimation network to more accurately reflect the spatial aggregation characteristics of weed communities.
[0169] Pixel coverage This parameter measures the macroscopic proportion of weed populations within the entire region of interest; it is a basic density indicator.
[0170]
[0171] The numerator is the total number of pixels for all weed categories, and the denominator is the total number of pixels in the image, representing the unit area. A higher value indicates a higher spatial coverage rate of weeds.
[0172] Distribution evenness index This parameter quantifies the uniformity or aggregation of weed populations in spatial distribution; traditional statistical methods are sensitive to noise; this invention introduces a lightweight fully convolutional density estimation network. Its structure is based on a simplified VGG feature extractor, removing fully connected layers to preserve spatial dimensions;
[0173] Network forward propagation: merging weed masks That is, the logical OR of all weed categories, input to the density estimation network. ;
[0174]
[0175] In the formula, A binary mask merging all weed categories. For lightweight density estimation fully convolutional networks, The density map predicted by the network; This indicates the network's prediction of the location. Normalized weed density or count contribution value at the location; the network is trained through supervised learning, and its true label... The weed center points, which are manually labeled, are generated by diffusion using a Gaussian kernel function, thereby learning the mapping from binary shape to continuous density distribution;
[0176] Uniformity calculation based on information entropy: predicting the density map Normalized to a discrete probability distribution ;
[0177]
[0178] In the formula, The probability distribution obtained by normalization, A very small positive number is used for numerical stability; then, the information entropy of the distribution is calculated. As a uniformity index The basis:
[0179]
[0180] In the formula, Entropy is the information entropy function used to calculate the uniformity or diversity of a distribution; entropy value. The larger the value, the higher the density distribution. The more uniform, close to a uniform distribution, the smaller the entropy value, indicating a more clustered distribution, concentrated in a few regions; therefore... It directly and robustly reflects the spatial distribution pattern of weeds;
[0181] Multi-weed symbiosis index This parameter quantifies the complexity of multiple weeds coexisting in a field; first, it calculates the relative area percentage of each type of weed. :
[0182]
[0183] In the formula, For the first The pixel area of the target object, occupying all of the image. The proportion of the total pixel area of the target object. for Binarization segmentation mask for the first type of target. Circular index for categories; all The area proportion of each category constitutes a probability distribution vector. ,satisfy Then, the information entropy of this distribution is calculated as the co-occurrence index:
[0184]
[0185] In the formula, It is the numerical stability constant. The entropy value is a multi-weed species symbiosis index based on the entropy of species area ratio. The larger the entropy value, the more diverse the weed species and the more balanced their area distribution, indicating a more complex community structure. The smaller the value, the more limited the variety of weeds or the more dominant a single species is.
[0186] III. Parameter Encapsulation and Output
[0187] The growth parameters calculated above are encapsulated with the image-level category confidence to form a feature vector that comprehensively describes the weed growth status of the current image region. :
[0188]
[0189] In the formula, This encapsulates the state feature vectors for all evaluation parameters.
[0190] Furthermore, the specific process of step five is as follows:
[0191] The hierarchical decision-making and prescription map generation process involves inputting the identified weed species, coverage area, and growth density into a fuzzy decision model. Based on preset thresholds, the model automatically determines the severity of the infestation and matches the corresponding pesticide application dosage, generating a variable application prescription map in real time. This process includes the following sub-steps:
[0192] I. Definition of State Space, Action Space, and Reward Function
[0193] This module provides a formal framework for defining the interactive environment of reinforcement learning agents.
[0194] state space The agent at any moment Observed environmental conditions The output vector is directly derived from the growth parameter extraction and grade evaluation module. The extension;
[0195]
[0196] In the formula, For a moment The environmental conditions, Let represent the probability of the presence of various types of weeds in the image. For grass pixel coverage, It is an entropy-based distribution uniformity index. This is an entropy-based weed species symbiosis index. Optional environmental context vector, containing real-time collected information on crop canopy height, soil moisture, or daily light intensity;
[0197] Action space Discrete spraying actions that an agent can execute; defined as... Dosage levels:
[0198]
[0199] In the formula, For a moment Environmental actions, Number of actions; per level Mapped to a baseline spray flow rate The unit is milliliters per minute; the design of the action space is matched with the discrete control levels of the actual spray valve;
[0200] reward function This function is crucial for guiding the agent to learn and optimize strategies, and it requires comprehensive consideration of three dimensions: effectiveness, economy, and ecology; rewards are given in the action. After execution The results were obtained through image review and assessment.
[0201]
[0202] In the formula, For a moment Environmental rewards; In order to prevent and reward, As an economic reward, As an ecological reward, The weighting coefficient for the effectiveness reward, This is the weighting coefficient for economic rewards. This refers to the weighting coefficient for ecological rewards;
[0203] Prevention effect bonus Effective weed control is encouraged, and the calculation is the reduction rate of weed biomass and cover after treatment.
[0204]
[0205] In the formula, The weed cover before treatment. To process The weed cover of the Queen;
[0206] Economic rewards Encouraging cost savings in pesticides is negatively correlated with the dosage applied.
[0207]
[0208] In the formula, For action The corresponding dosage Let [the value] be the cost coefficient;
[0209] Ecological rewards Encourage reduction of environmental impact, correlated with predicted exposure doses in non-target areas or changes in biodiversity indices in work areas, estimated through a simplified environmental model;
[0210]
[0211] In the formula, For environmental modeling;
[0212] II. Deep Q-Network Decision Model and Offline Training
[0213] This module uses a deep Q-network to approximate the optimal action-value function. This function represents the state. Next action And then follow the expected cumulative discount reward that can be obtained by following the optimal strategy;
[0214] Network Architecture: Building a Deep Neural Network The parameters are ;
[0215] Input layer: Receives the state vector ;
[0216] Hidden layers: consist of several fully connected layers, with ReLU activation function used in between;
[0217] Output layer: a layer with A fully connected layer of 100 neurons, where each neuron corresponds to an action. Q-value estimation ;
[0218] Offline training: utilizing historical job datasets DQN is pre-trained; empirical replay and target network techniques are used to stabilize the training.
[0219] Target network: Maintain a network with the same structure but different parameters Slower updated target network ;
[0220] Loss function: Updates online network parameters by minimizing temporal difference error. ;
[0221] III. Real-time prescription chart generation and instruction issuance
[0222] Decision-making: Regarding the real-time perceived state intelligent agents through - Greedy strategy for selecting actions:
[0223]
[0224] When doing online assignments, It is usually set to a small value, typically 0.05, to favor the use of learned strategies while retaining a certain degree of exploratory nature;
[0225] Spatial prescription map Generation: Spraying equipment is typically equipped with a GNSS / RTK positioning system; for the geographical area corresponding to the current image acquisition time, the determined dose level will be determined. Assign the center coordinates of this area As the equipment moves forward, a two-dimensional dose level matrix is generated. Each grid cell corresponds to a small area of a field;
[0226] Control command sequence conversion: combined with the dynamic parameters of the spraying equipment: travel speed Spray width Spatial prescription map The control commands are converted into a time sequence and sent to each independent spray valve controller.
[0227] Traffic settings:
[0228] Nozzle switch: For nozzles located in non-weed areas, the instruction can be set to off even at this dosage level, enabling precise target aiming;
[0229] IV. Online Adaptive and Incremental Learning Module
[0230] To enable the system to adapt to specific field conditions, climate conditions, and dynamic changes in weed populations over the long term, an online learning closed loop is deployed.
[0231] Data collection: After each spraying operation, the system automatically records the quaternion. ,in and From The results of the automatic review of the images by the Queen; this new data is stored in a recurring experience pool. ;
[0232] Incremental learning: Periodically start a background learning thread, from... Mid-sample small batches of data, using the same loss function as offline training, for the online DQN network parameters. Perform several gradient descent updates.
[0233] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0234] Compared with existing technologies, this invention effectively overcomes the limitations of traditional methods through a series of innovative designs, achieving significant improvements in the accuracy, robustness, and intelligence of cotton field weed identification and control. Specific beneficial effects are as follows:
[0235] 1. Significantly improves the recognition accuracy of similar weeds in the seedling stage. In response to the problem that cotton seedlings and noxious weeds have highly similar visual features and are difficult to distinguish in the seedling stage, this invention innovatively introduces a curvature perception spatial attention mechanism through the "heterogeneous feature embedding and dynamic weighting" module.
[0236] 2. It achieves strong robustness against complex field background noise. To solve the problem of interference from complex backgrounds such as reflective plastic film and sand, this invention designs a mask-guided spectral-spatial hybrid attention Transformer encoder in the "cross-modal feature fusion and correlation modeling" step.
[0237] 3. It breaks through the bottleneck of rigid feature fusion and enhances the model's adaptability. Unlike the traditional simple splicing or linear fusion feature utilization method, this invention constructs a dynamic and hierarchical feature enhancement and fusion path. Attached Figure Description
[0238] Figure 1. Overall flowchart of the cotton field weed classification and identification and variable spraying method based on feature weight enhancement.
[0239] Figure 2. Feature Dynamic Weighting Enhancement Sub-Flowchart
[0240] Figure 3. Flowchart of Mask-Guided Transformer Recognition Sub-Flowchart
[0241] Figure 4. Overall structure diagram of the cotton field weed classification and identification and variable spraying system based on feature weight enhancement. Detailed Implementation
[0242] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on these embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.
[0243] In this case, as Figure 1 :
[0244] This invention discloses a method for graded identification and variable spraying of weeds in cotton fields based on feature weight enhancement, the specific implementation of which is described below. This implementation combines intelligent algorithms (such as deep learning, attention mechanisms, reinforcement learning, etc.) to achieve full automation of the process from image acquisition to variable spraying through modular steps. The implementation process is described with executable formulas, parameter descriptions, and case examples to ensure reproducibility. The implementation environment is a cotton field plant protection machine equipped with a multispectral camera, an RTK-GNSS positioning system, and a spraying controller.
[0245] 1. Multi-channel data decoupling and preprocessing
[0246] Data acquisition and hardware configuration:
[0247] The image was captured using a Cumarket UHD 285 multispectral camera (1000×1000 pixels resolution, 8 bands: 450nm, 500nm, 550nm, 600nm, 650nm, 700nm, 750nm, 800nm) at a frame rate of 10FPS. The original image is... .
[0248] Radiometric correction and geometric registration are performed on the image. The radiometric correction formula is:
[0249]
[0250] Texture feature channel construction:
[0251] Multi-scale texture extraction, using shallow modules of MobileNetV3 as feature extractors. .enter The output feature map size is This is 4 times the downsampling rate.
[0252]
[0253] High frequency enhancement, for High-frequency components are extracted using Haar wavelet transform. Convolutional fusion:
[0254]
[0255] After upsampling to 250×250, the residuals are summed. .
[0256] Color feature channel construction:
[0257] Multi-color space fusion converts RGB images (bands 650nm, 550nm, 450nm) to HSV and Lab colors, and then stitches them together. , It consists of 8 bands + 3 HSV + 3 Lab.
[0258] Adaptive learning, through lightweight CNNs (3 convolutional layers, 64 output channels) Extract color features:
[0259]
[0260] Output:
[0261] Dual-channel feature alignment to Output .
[0262] In the input image, the RGB mean values for the cotton seedling area are (120, 180, 100), and for the weed area are (110, 170, 90). The texture features show significant differences in response at the 750nm band, with the cotton seedling edge curvature being approximately 0.05 and the weed (barnyard grass) curvature being approximately 0.15.
[0263] 2. Heterogeneous Feature Embedding and Dynamic Weighting
[0264] In practice, the curvature was first set based on the range of cotton seedling leaf curvature [0.02, 0.08].
[0265] Feature embedding:
[0266] use Convolution maps texture and color features to a 128-dimensional space:
[0267]
[0268] Curvature perception attention:
[0269] Curvature calculation, from Gradient extraction and curvature approximation plot calculated using the Sobel operator. The first a priori hypothesis of cotton seedling curvature is a Gaussian distribution. .
[0270] Attention generation, micronetworks (2 convolutional layers, outputting a sigmoid function) Generate weights:
[0271]
[0272] Regions with curvature > 0.1 have a weight close to 1 (weeds), while regions with curvature < 0.03 have a weight close to 0 (cotton seedlings).
[0273] Channel attention:
[0274] Compression-incentive mechanism, reduction ratio :
[0275]
[0276] Dynamic weighting:
[0277] Feature enhancement,
[0278] A certain weed pixel has a curvature of 0.12 and a weight. The cotton seedling pixel curvature is 0.04, with a weight of 0.1. Channel attention enhancement is applied to the 750nm band response, with a weight of 0.95.
[0279] 3. Cross-modal feature fusion and accurate recognition
[0280] Transformer encoder layers , 8 heads.
[0281] Color semantic mask:
[0282] U-Net generates a vegetation mask M, and the threshold is set. The training loss weight for Dice is 0.7.
[0283] Transformer encoder:
[0284] Tokenization will Serialized into 62,500 tokens (250×250), dimension 256.
[0285] Mask bias matrix Non-vegetated areas are designated Attention calculation:
[0286]
[0287] in, .
[0288] Parallel decoding:
[0289] Segmentation head, output mask .
[0290] The classification head, with its sigmoid output, shows the class probabilities. .
[0291] Identification results: Cotton seedlings account for 60% of the area, weed A coverage is 15%, and weed B coverage is 10%. Classification confidence level is 0.98.
[0292] 4. Growth parameter extraction and grade evaluation
[0293] enter:
[0294] Segmentation mask Number of categories .
[0295] Parameter calculation:
[0296] Pixel coverage for That is, 25% coverage.
[0297] Distribution uniformity index, density network Output density map The entropy is calculated as follows:
[0298]
[0299]
[0300] This instance is a medium cluster.
[0301] Species symbiosis index, area ratio entropy ,in Calculated .
[0302] Output:
[0303] State vector .
[0304] 5. Hierarchical decision-making and prescription map generation
[0305] Reward Weight .
[0306] Reinforcement learning framework:
[0307] state , environment vector Including wind speed of 2m / s and humidity of 40%.
[0308] Action space, 5 dose levels Corresponding traffic .
[0309] Reward function: Among them, the cost coefficient , environment function Estimate soil exposure dose.
[0310] DQN training:
[0311] The network structure has a 128-dimensional input layer, hidden layers [64, 32], and a learning rate of 0.001.
[0312] Experience replay, buffer size 10000, batch size 32.
[0313] Prescription image generation:
[0314] Decision as state Down, Greedy strategy for selecting actions .
[0315] The command was issued, based on the machine speed of 1.2 m / s, the spray width of 4 m, and the flow rate. .
[0316] Seven days after treatment, weed coverage decreased to 5%, and a reward was given. The system incrementally updates the DQN parameters.
[0317] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0318] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0319] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0320] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for weed classification and variable spraying in cotton fields based on feature weight enhancement, characterized in that, Includes the following steps: Step 1: Decoupling and preprocessing of multi-channel data. Real-time images of cotton fields are acquired using the onboard visual sensor of the plant protection aircraft. High-frequency edge features in the images are extracted through Laplacian transform to construct texture channels. At the same time, RGB components are extracted to construct color channels that reflect chlorophyll distribution. Step 2, heterogeneous feature embedding and dynamic weighting: the texture channel feature matrix and the color channel feature matrix are mapped to a high-dimensional embedding space respectively. A feature saliency evaluation function is introduced. Based on the difference in edge curvature between cotton seedlings and specific noxious weeds, the weight bias of the texture features is calculated, and the texture feature matrix is nonlinearly weighted to enhance it. Step 3: Cross-modal feature fusion and correlation modeling. The enhanced texture features and color features are concatenated and then input into the improved Transformer encoder. The encoder integrates a spatial-spectral attention mechanism, which uses the semantic distribution of color channels as a mask constraint to guide the self-attention mechanism to focus on the vegetation area and suppress background noise from mulch and sand. Step 4: Target classification and disaster level assessment. The decoder outputs the category and coordinate mask of the target to be identified, and calculates the pixel ratio of weeds per unit area as a growth density indicator. Step 5, graded decision-making and prescription map generation: The identified weed species, coverage area and growth density are input into the fuzzy decision model. The disaster level is automatically determined according to the preset threshold, and the corresponding pesticide spraying dosage is matched to generate a variable spraying prescription map in real time.
2. The method for graded identification and variable spraying of cotton field weeds based on feature weight enhancement according to claim 1, characterized in that, Step 1 is as follows: Real-time images of cotton fields were acquired using an aerial vision sensor for agricultural protection. Multi-channel data decoupling and preprocessing were performed, and high-frequency edge features were extracted from the images using Laplacian transform to construct texture channels. Simultaneously, RGB components were extracted to construct color channels reflecting chlorophyll distribution. The specific steps included: I. System Input and Preprocessing A cotton field weed classification and variable spraying method based on feature weight enhancement begins by acquiring a sequence of raw digital images of the cotton field from a multispectral or RGB imaging sensor mounted on a spraying machine; let a single frame input image be: In the formula, For the original image, For the set of real numbers, The height of the image. The width of the image. For an RGB image, the number of channels is... For multispectral images, For the number of bands; first, for Standardized preprocessing is performed, including illumination white balance correction and sensor noise filtering, to output a standardized image. ; II. Intelligent Construction of Texture Feature Channels The construction of texture channels aims to extract and enhance the differences in morphology, edges, and microstructure between crops and weeds. This method is achieved through a cascaded intelligent module. Learnable multi-scale texture primitive extraction module This module is implemented using a lightweight deep convolutional neural network, denoted as . ; It receives preprocessed images By stacking depth-separating convolutional layers, batch normalization layers, and non-linear activation function layers, multi-level feature abstraction is achieved; this process is described as follows: In the formula, The baseline texture features extracted by the convolutional network, Representing the One convolutional block, Total number of floors; It is a learnable multi-scale texture feature extraction convolutional neural network, employing a shallow-to-medium layer structure similar to MobileNetV3 to achieve a balance between computational efficiency and feature richness; the total number of layers is [missing information]. It contains primitive features at multiple scales, ranging from low-level edges to mid-level texture patterns; among them, , It refers to the height and width of the unified feature map space. This represents the number of texture feature channels; Differentiable spatial frequency enhancement module To explicitly enhance the ability to detect fine weed textures and resist light disturbance, in Based on the output features, a differentiable wavelet transform layer is introduced. This layer is for Each feature channel is independently subjected to a two-dimensional discrete wavelet transform to decompose high-frequency detail components; Specifically, for the feature map of the 1st... One channel ,have: In the formula, Two-dimensional discrete wavelet transform operation, This is a low-frequency approximation component. For high-frequency detail components in the horizontal direction, These are the high-frequency detail components in the vertical direction. These are the high-frequency detail components in the diagonal direction; To enhance texture, three high-frequency components were extracted. They are then concatenated along the channel dimension to form a multi-directional high-frequency feature tensor. ,in For multi-directional high-frequency feature tensors Next, through a Convolutional layer right Channel fusion and dimensionality reduction are performed to learn effective combinations of high-frequency information. In the formula, It is a high-frequency enhancement feature. for Convolutional layers; Finally, bilinear interpolation is used to... Upsampling to Same space size and with By summing the residuals, we obtain the enhanced texture feature map. : In the formula, Enhanced texture feature map, Used for upsampling operations; III. Intelligent Construction of Color Feature Channels The construction of color channels aims to learn the differences in pigment composition and spectral reflectance characteristics between vegetation, especially cotton seedlings and different weed species; this method is implemented through an adaptive color decoupling network. Multi-color space fusion and mapping First, standardize the RGB image Parallel conversion to HSV and CIELAB color spaces yields... and , For images converted to the HSV color space, The image is converted to the Lab color space. These three color spaces represent different color attributes: RGB corresponds to the sensor's original response, HSV corresponds to hue, saturation, and lightness, and Lab is more in line with human eye perception and separates brightness from color. Subsequently, the images from these three spaces are stitched together along the channel dimension to form a richly colored representation: In the formula, To fuse images across multiple color spaces, For splicing operations; Adaptive Spectral Feature Learning Network Will Input a lightweight convolutional network The network consists of several convolutional layers, and its core function is to learn an optimal linear or nonlinear transformation to maximize the response to sensitive spectral features such as chlorophyll content and water content, and to suppress the effects of light changes and shadows. In the formula, For the final color semantic features, Learn a convolutional neural network for adaptive color features; Preferably, the last layer of the network uses the Sigmoid or Tanh activation function to constrain the feature values within a certain range to enhance its stability; the network is trained end-to-end and can automatically learn color features similar to the normalized vegetation index and the overgreen index, but which are more discriminative for cotton field weeds. IV. Feature Map Alignment and Output To ensure the effectiveness of subsequent fusion steps, spatial interpolation is used to transform the texture feature map. and color feature map Adjust to a uniform feature map size ,in , The number of texture feature channels, The number of color feature channels; finally, output a set of dual-channel feature maps. This serves as the input for subsequent heterogeneous feature embedding and dynamic weighting modules.
3. The method for graded identification and variable spraying of cotton field weeds based on feature weight enhancement according to claim 1, characterized in that, Step 2 is as follows: By employing heterogeneous feature embedding and dynamic weighting, the texture channel feature matrix and color channel feature matrix are mapped to a high-dimensional embedding space, respectively. A feature saliency evaluation function is introduced, and the weight bias of the texture features is calculated based on the difference in edge curvature between cotton seedlings and specific noxious weeds. The texture feature matrix is then nonlinearly weighted and enhanced, specifically including the following sub-steps: I. Heterogeneous Feature High-Dimensional Embedding Module This module receives the dual-channel feature map set output from the preprocessing stage. ,in , ; Its function is to map two heterogeneous features to a common, higher-dimensional feature space through nonlinear transformation, so as to facilitate subsequent interaction and fusion. Texture feature embedding Through a Convolutional layer This convolutional layer increases the channel dimension of texture features and introduces non-linearity without changing the spatial dimensions. In the formula, To embed texture features into a higher-dimensional space, For use in feature embedding Convolution kernel parameters, To modify the activation function of the linear unit, For batch normalization operations, For convolution operations, The dimension of a public high-dimensional space; Color feature embedding Through an independent Convolutional layer The implementation and processing are symmetrical with the texture features; In the formula, For color features embedded into a higher-dimensional space; At this point, texture and color features are mapped to the same channel dimension. This facilitates subsequent attention calculations and feature interactions; II. Curvature-Aware Spatial Attention Generation Module This module quantifies and utilizes the systematic differences in local geometry, i.e., curvature, between cotton seedling leaves and common weeds; this module uses embedded texture features As input, output a spatial weight map; Local curvature feature extraction First, edge- and curvature-sensitive representations are recovered from high-dimensional texture features; specifically, from... A subset of feature channels representing the main edge responses is extracted, and each spatial location is approximated by gradient calculation operations such as the Sobel operator. gradient magnitude The direction is determined to estimate its approximate mean curvature. ; Design a lightweight curvature estimation subnetwork It consists of several convolutional layers, directly from... Regress a single-channel curvature response plot : In the formula, For curvature feature extraction subnetwork, This is a curvature response diagram; where The value of each element is positively correlated with the edge curvature at that location; higher values indicate a higher value. Values typically correspond to the slender, highly curved leaf margins or stems of weeds, while lower values... The value corresponds to the relatively rounded and gently sloping leaf edges of cotton seedlings; Prior-guided attention map generation curvature response diagram Compare this to a learnable cotton seedling curve prior distribution; this prior can be represented as an adjustable threshold function or a Gaussian kernel function; through a miniature network containing a Sigmoid activation function. Generate spatial attention weight map : In the formula, Generate subnetworks for spatial attention. This is a spatial attention weight map. The Sigmoid function maps values to... interval; Through learning, high curvature regions are assigned weights to weeds. Pushing to 1 pushes the weight of low curvature regions for cotton seedlings to 0; this process is trainable, allowing the system to learn the optimal curvature discrimination threshold from the data. III. Channel Attention Generation Module This module runs in parallel with spatial attention and aims to evaluate the global importance of each channel of texture features. Its structure borrows from the idea of squeeze-excitation networks, but operates on the embedded texture features. ; Global information compression right Global average pooling is performed on each channel to compress spatial information into a channel descriptor vector. : In the formula, For channel indexing, For the first Global descriptors for each channel, For the first Feature maps of each channel; Incentives and Weight Generation Through a gating mechanism consisting of two fully connected layers, the non-linear dependencies between channels are learned, and the weights of each channel are output. In the formula, The weight matrix is a learnable matrix. For the reduction ratio, It is the ReLU activation function. For the Sigmoid function; output This is the channel attention weight vector, where each element... For the first Global significance of each channel; IV. Dynamic Weighting and Feature Fusion Module This module integrates spatial and channel attention to refine texture features and initially fuse them with color features; Feature dynamic weighting Spatial attention map With channel attention vector Combined with embedded texture features Perform element-wise weighted summation: In the formula, This represents element-wise multiplication, with respect to channel weights. It will extend to spatial dimensions through a broadcasting mechanism; The texture features are enhanced by both spatial and channel attention. Spatially, this operation strengthens the feature response of high-curvature weed areas; and channelally, it enhances the feature channels that contribute significantly to classification and identification. Heterogeneous feature splicing The enhanced texture features and the embedded color features are concatenated along the channel dimension to form a dynamically weighted fused feature. ; In the formula, The final output is a dynamically weighted fusion feature that includes both texture information enhanced by morphological priors and the original spectral color information, providing a robust and discriminative input for subsequent accurate recognition.
4. The method for graded identification and variable spraying of cotton field weeds based on feature weight enhancement according to claim 1, characterized in that, Step 3 is as follows: Cross-modal feature fusion and correlation modeling involves concatenating enhanced texture and color features and inputting them into an improved Transformer encoder. The encoder integrates a spatial-spectral attention mechanism, utilizing the semantic distribution of color channels as a mask constraint to guide the self-attention mechanism to focus on vegetated areas and suppress background noise from mulch film and sand. Specifically, this includes the following sub-steps: I. Color Semantic Mask Generation Subnetwork This sub-network, as a lightweight preprocessing module, aims to quickly and initially segment the vegetation foreground, including cotton seedlings and weeds, from color features, and generate a binary mask to suppress interference from complex backgrounds such as soil and residual film in subsequent global attention calculations. Input and Encoding Color features output by the dynamic weighting module As input, this feature is passed through an encoder consisting of several convolutional and pooling layers. Feature compression and abstraction are performed: In the formula, The encoder for the mask generation subnetwork, These are the high-level semantic features after encoding; Decoding and Mask Prediction Encoded features are processed by a symmetric decoder. Upsampling is performed to gradually restore spatial resolution; Decoders typically consist of transposed convolutional or upsampling layers combined with convolutional layers; ultimately, they are processed through a... The convolutional layer is followed by a sigmoid activation function, outputting a single-channel probability map with the same resolution as the input. : In the formula, The decoder for the mask generation subnetwork, This is a probability map of vegetation areas, where each pixel value represents the probability that the location belongs to a vegetation area; a threshold is set... A value of 0.5 is used to obtain a hard binary mask. : in, The vegetation area will have access to subsequent attention calculations; This represents the background area, and its influence will be greatly suppressed. II. Spectral-Spatial Hybrid Attention Transformer Encoder This module is the core of feature fusion, receiving dynamically weighted fused features. and mask By introducing an attention mechanism that decouples spectral and spatial information, precise cross-modal information interaction can be achieved. Tokenization and Location Encoding feature map Remodeled into a series of tokens ,in The total number of spatial locations; to preserve location information, learnable location codes are added. : In the formula, This is the input to layer 0 of the encoder. For flattening operation; Mask-guided spectral-spatial hybrid attention layer The encoder is made by It is made up of identical layers stacked together, each layer The core is a mask-guided spectral-spatial hybrid attention mechanism; Query, key, and value generation: For input sequences The query, key, and value vectors required for the spectral attention head and spatial attention head are generated respectively through linear projection: In the formula, For query, As key, For value, For spectral channel attention heads, For spatial position attention; The projected weight matrix is a learnable matrix. For projection dimensions; Mask bias matrix construction: constructing a binary mask Flatten into vectors Construct a mask bias matrix : In the formula, For mask-guided attention bias matrix, The mask value; this matrix ensures that the value is only valid if the query position is specified. and bond position Attention weights are only allowed to be calculated when the mask value is 1, and all are located in vegetation areas; otherwise, the weights are forced to 0. Hybrid attention calculation: The logarithms (its) of spectral attention and spatial attention are added together, and a mask bias is also included. The hybrid attention weights are calculated using Softmax: In the formula, The scaling factor for the spectral attention head. The scaling factor for the spatial attention head; For mask-guided spectral-spatial hybrid attention mechanisms, It is a normalized exponential function; this design allows the model to simultaneously focus on the similarity of spectral features between different locations, i.e., spectral attention, and the contextual relationship of spatial location, i.e., spatial attention, and the calculation is strictly limited to the vegetation area. Feedforward networks and layer stacking Each attention sublayer is followed by a feedforward network, typically consisting of two linear transformations and a non-linear activation function; residual connections and layer normalization are added to ensure training stability. In the formula, For the first The output features of the layer For the first Intermediate features of the layer For the first The final output features of the layer For layer normalization operation, This is a feedforward neural network function; go through After layer stacking, a deep fused feature sequence is obtained. ; III. Parallel Decoding and Recognition Head This module is responsible for analyzing fusion features. The final recognition result is decoded, including pixel-level segmentation and image-level classification; Feature map reshaping Serialized features Reconstructing back to a two-dimensional spatial format ' ; Segmentation head Employ a lightweight decoder It typically consists of several upsampling layers and convolutional layers, which... Upsampled to original image size It outputs the category probability distribution for each pixel; In the formula, It is a lightweight segmentation decoder. For pixel-level segmentation mask prediction, The number of weed categories to be identified. Represents the background class; Classification Head Features in the spatial dimension Perform global average pooling to obtain a global feature vector, and then use a multilayer perceptron to predict the weed category in the image; In the formula, Each element represents the probability that the corresponding category of weeds exists in the image. For activation function, Multilayer perceptron for classification This is a global average pooling operation; IV. Multi-task joint training strategy To optimize the entire recognition network, a multi-task loss function combining segmentation loss, classification loss, and boundary loss is used for end-to-end training: In the formula, For the total loss, To divide the loss, For classifying losses, For boundary consistency loss, These are the weighting coefficients for the segmentation loss. These are the weighting coefficients for the classification loss. These are the weighting coefficients for the boundary consistency loss; Segmentation loss A combination of cross-entropy loss and Dice loss is used to address the class imbalance between foreground and background and to optimize the overlapping region; In the formula, For the actual segmentation mask, For the predicted segmentation mask, For smoothing terms; Classification loss The binary cross-entropy loss is used to calculate the error of image-level multi-label classification; In the formula, Let be the true class label vector of the image. It is the prediction probability vector The One element; Boundary consistency loss Encourage clear and accurate predicted weed boundaries by calculating the gradient domain between the true and predicted boundaries. Distance implementation; In the formula, For the operation of extracting boundaries, This is the gradient operator.
5. The method for graded identification and variable spraying of cotton field weeds based on feature weight enhancement according to claim 1, characterized in that, Step 4 is as follows: Target classification and disaster level assessment: The decoder outputs the category and coordinate mask of the target to be identified, and calculates the pixel ratio of weeds per unit area as a growth density indicator. This process includes the following sub-steps: I. Input and Data Preparation The input to this module comes directly from the two outputs of the "Cross-modal Feature Fusion and Accurate Recognition" module: Pixel-level semantic segmentation mask ,in The last channel represents the total number of weed categories that the model can identify, and the last channel represents the background. The hard-assigned segmentation result can be obtained by taking the maximum index of the channel dimension at each pixel location. ,in Representative position Identified as the first Weeds and ; Image-level multi-label category probability vector This indicates the confidence level that various types of weeds exist in the entire image; Based on the segmentation result image It can be used for every type of weed. Generate a binary mask : in, ;all The set consists of binary masks for each weed category. ; II. Density-Sensitive Growth Parameter Calculation Module This module aims to calculate three core growth parameters: pixel coverage, distribution uniformity index, and species coexistence index. Among them, the calculation of the distribution uniformity index introduces a learning-based density estimation network to more accurately reflect the spatial aggregation characteristics of weed communities. Pixel coverage This parameter measures the macroscopic proportion of weed populations within the entire region of interest; it is a basic density indicator. The numerator is the total number of pixels for all weed categories, and the denominator is the total number of pixels in the image, representing the unit area. A higher value indicates a higher spatial coverage rate of weeds. Distribution evenness index This parameter quantifies the uniformity or aggregation of weed populations in spatial distribution; traditional statistical methods are sensitive to noise; this invention introduces a lightweight fully convolutional density estimation network. Its structure is based on a simplified VGG feature extractor, removing fully connected layers to preserve spatial dimensions; Network forward propagation: merging weed masks That is, the logical OR of all weed categories, input to the density estimation network. ; In the formula, A binary mask merging all weed categories. For lightweight density estimation fully convolutional networks, This is the density map predicted by the network. This indicates the network's prediction of the location. Normalized weed density or count contribution value at the location; the network is trained through supervised learning, and its true label... The weed center points, which are manually labeled, are generated by diffusion using a Gaussian kernel function, thereby learning the mapping from binary shape to continuous density distribution; Uniformity calculation based on information entropy: predicting the density map Normalized to a discrete probability distribution ; In the formula, The probability distribution obtained by normalization, A very small positive number is used for numerical stability; then, the information entropy of the distribution is calculated. As a uniformity index The basis: In the formula, Entropy is the information entropy function used to calculate the uniformity or diversity of a distribution; entropy value. The larger the value, the higher the density distribution. The more uniform, close to a uniform distribution, the smaller the entropy value, indicating a more clustered distribution, concentrated in a few regions; therefore... It directly and robustly reflects the spatial distribution pattern of weeds; Multi-weed symbiosis index This parameter quantifies the complexity of multiple weeds coexisting in a field; first, it calculates the relative area percentage of each type of weed. : In the formula, For the first The pixel area of the target object, occupying all of the image. The proportion of the total pixel area of the target object. for Binarization segmentation mask for the first type of target. Circular index for categories; all The area proportion of each category constitutes a probability distribution vector. ,satisfy Then, the information entropy of this distribution is calculated as the co-occurrence index: In the formula, It is the numerical stability constant. The entropy value is a multi-weed species symbiosis index based on the entropy of species area ratio. The larger the entropy value, the more diverse the weed species and the more balanced their area distribution, indicating a more complex community structure. The smaller the value, the more limited the variety of weeds or the more dominant a single species is. III. Parameter Encapsulation and Output The growth parameters calculated above are encapsulated with the image-level category confidence to form a feature vector that comprehensively describes the weed growth status of the current image region. : In the formula, This encapsulates the state feature vectors for all evaluation parameters.
6. The method for graded identification and variable spraying of cotton field weeds based on feature weight enhancement according to claim 1, characterized in that, Step 5 is as follows: The hierarchical decision-making and prescription map generation process involves inputting the identified weed species, coverage area, and growth density into a fuzzy decision model. Based on preset thresholds, the model automatically determines the severity of the infestation and matches the corresponding pesticide application dosage, generating a variable application prescription map in real time. This process includes the following sub-steps: I. Definition of State Space, Action Space, and Reward Function This module provides a formal framework for defining the interactive environment of reinforcement learning agents. state space The agent at any moment Observed environmental conditions The output vector is directly derived from the growth parameter extraction and grade evaluation module. The extension; In the formula, For a moment The environmental conditions, Let represent the probability of the presence of various types of weeds in the image. For grass pixel coverage, It is an entropy-based distribution uniformity index. This is an entropy-based weed species symbiosis index. Optional environmental context vector, containing real-time collected information on crop canopy height, soil moisture, or daily light intensity; Action space Discrete spraying actions that an agent can execute; defined as... Dosage levels: In the formula, For a moment Environmental actions, Number of actions; per level Mapped to a baseline spray flow rate The unit is milliliters per minute; the design of the action space is matched with the discrete control levels of the actual spray valve; reward function This function is crucial for guiding the agent to learn and optimize strategies, and it requires comprehensive consideration of three dimensions: effectiveness, economy, and ecology; rewards are given in the action. After execution The results were obtained through image review and assessment. In the formula, For a moment Environmental rewards; In order to prevent and reward, As an economic reward, As an ecological reward, The weighting coefficient for the effectiveness reward, This is the weighting coefficient for economic rewards. This refers to the weighting coefficient for ecological rewards; Prevention effect bonus Effective weed control is encouraged, and the calculation is the reduction rate of weed biomass and cover after treatment. In the formula, The weed cover before treatment. To process The weed cover of the Queen; Economic rewards Encouraging cost savings in pesticides is negatively correlated with the dosage applied. In the formula, For action The corresponding dosage Let [the value] be the cost coefficient; Ecological rewards Encourage reduction of environmental impact, correlated with predicted exposure doses in non-target areas or changes in biodiversity indices in work areas, estimated through a simplified environmental model; In the formula, For environmental modeling; II. Deep Q-Network Decision Model and Offline Training This module uses a deep Q-network to approximate the optimal action-value function. This function represents the state. Next action And then follow the expected cumulative discount reward that can be obtained by following the optimal strategy; Network Architecture: Building a Deep Neural Network The parameters are ; Input layer: Receives the state vector ; Hidden layers: consist of several fully connected layers, with ReLU activation function used in between; Output layer: a layer with A fully connected layer of 100 neurons, where each neuron corresponds to an action. Q-value estimation ; Offline training: Utilizing historical job datasets DQN is pre-trained; empirical replay and target network techniques are used to stabilize the training. Target network: Maintain a network with the same structure but different parameters Slower updated target network ; Loss function: Updates online network parameters by minimizing temporal difference error. ; III. Real-time prescription chart generation and instruction issuance Decision-making: Regarding the real-time perceived state intelligent agents through - Greedy strategy for selecting actions: When doing online assignments, It is usually set to a small value, typically 0.05, to favor the use of learned strategies while retaining a certain degree of exploratory nature; Spatial prescription map Generation: Spraying equipment is typically equipped with a GNSS / RTK positioning system; for the geographical area corresponding to the current image acquisition time, the determined dose level will be determined. Assign the center coordinates of this area ; As the equipment moves forward, a two-dimensional dose level matrix is generated. Each grid cell corresponds to a small area of a field; Control command sequence conversion: combined with the dynamic parameters of the spraying equipment: travel speed Spray width Spatial prescription map The control commands are converted into a time sequence and sent to each independent spray valve controller. Traffic settings: Nozzle switch: For nozzles located in non-weed areas, the instruction can be set to off even at this dosage level, enabling precise target aiming; IV. Online Adaptive and Incremental Learning Module To enable the system to adapt to specific field conditions, climate conditions, and dynamic changes in weed populations over the long term, an online learning closed loop is deployed. Data collection: After each spraying operation, the system automatically records the quaternion. ,in and From The results of the automatic review of the images by the Queen; this new data is stored in a recurring experience pool. ; Incremental learning: Periodically start a background learning thread, from... Mid-sample small batches of data, using the same loss function as offline training, for the online DQN network parameters. Perform several gradient descent updates.