Crop recognition method and system based on segmentation mask adaptive median filtering denoising

CN122990219APending Publication Date: 2026-10-27XIAN CENT OF GEOLOGICAL SURVEY CGS
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

然而,上述两种降噪方法都存在以下问题:均值滤波虽然能抑制噪声,但会破坏农作物区域的边缘细节,导致后续模型对边界识别不准;复杂降噪网络虽然能保留细节,却需要额外的标注数据与训练成本,无法零成本迁移应用

Benefits of technology

本发明获取的多时相遥感影像样本及对应的分割掩码数据,为后续的农作物识别提供了数据基础,确保农作物识别模型能够捕获到农作物完整生长周期的光谱规律变化;其次,对分割掩码数据进行自适应中值滤波处理,在有效滤除孤立噪声点的同时保留了农作物地块的边缘细节,提升了分割掩码数据的标注质量;将降噪后的分割掩码数据作为监督信号训练Transformer模型,避免了因孤立噪声点被误判为农作物而引入的虚假特征,提升了对农作物识别的准确性,并对输出的二值分类掩码进行地理坐标配准,得到农作物识别结果,实现了从输入到输出的完整流程。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122990219A_ABST
    Figure CN122990219A_ABST
Patent Text Reader

Abstract

The present application relates to the field of remote sensing images, in particular to a crop recognition method and system based on segmentation mask adaptive median filtering denoising, the present application first acquires multi-temporal remote sensing image samples and corresponding segmentation mask data; the density of isolated noise points in the segmentation mask data is counted, and a median filtering window is adaptively selected for median filtering processing to obtain denoised segmentation mask data; the multi-temporal remote sensing image samples and the denoised segmentation mask data are input into a Transformer model for training to obtain a crop recognition model; finally, the multi-temporal remote sensing image samples to be recognized are input into the crop recognition model, and the crop recognition result is output; the present application effectively filters out isolated noise points while retaining crop edge details, without additional training cost, significantly improving the accuracy and spatial positioning accuracy of crop recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of remote sensing imagery, specifically to a method and system for crop identification using segmentation mask adaptive median filtering for noise reduction. Background Technology

[0002] In the field of agricultural remote sensing monitoring, multi-temporal remote sensing images have become an important data source for deep learning crop identification because they can capture spectral changes during the crop growth cycle. Among them, segmentation mask data serves as key supervisory information for model training, and its quality directly determines the classification accuracy. However, the current process of acquiring segmentation mask data is susceptible to noise from atmospheric scattering, sensor interference, and other sources, resulting in defects such as isolated noise points and blurred edges, which seriously impair data quality.

[0003] Currently, existing technologies mainly employ two types of denoising methods: one is mean filtering, which smooths noise by averaging neighboring pixels; this method is computationally simple and requires no training. The other is complex denoising networks, which learn the difference between noise and signal through deep convolutional structures, achieving denoising while preserving edge details and possessing a certain degree of adaptability. However, both of these denoising methods suffer from the following problems: while mean filtering can suppress noise, it destroys the edge details of crop areas, leading to inaccurate boundary recognition in subsequent models; and while complex denoising networks can preserve details, they require additional labeled data and training costs, making them unsuitable for zero-cost transfer applications.

[0004] Furthermore, none of the above methods are adapted for multi-temporal remote sensing images with 3 phases and 6 channels. Moreover, the existing deep learning training process lacks a preprocessing step for segmentation mask data. Using segmentation mask data without noise reduction directly for training will cause the model to learn to misidentify isolated noise points as false features of crops, ultimately resulting in low crop identification accuracy and large spatial positioning deviation. Summary of the Invention

[0005] To address the problems mentioned in the prior art, this invention proposes a crop identification method and system based on adaptive median filtering denoising using segmentation masks. By statistically analyzing the density of isolated noise points in the segmentation mask data and adaptively selecting a median filtering window for denoising, noise is filtered out without destroying edge details. The denoised segmentation mask data is then used to supervise the training of a Transformer model, thereby solving the problems mentioned in the background art.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: This invention proposes a crop identification method based on segmentation mask adaptive median filtering noise reduction, comprising the following steps: S1. Obtain multi-temporal remote sensing image samples of the crop identification area and segmentation mask data corresponding to the multi-temporal remote sensing image samples; the multi-temporal remote sensing image samples include multiple continuous growth phases, and each phase includes image data of multiple spectral channels; S2. Perform median filtering on the segmentation mask data, including obtaining the density of isolated noise points in the segmentation mask data, selecting a corresponding median filtering window based on the density of isolated noise points, taking the pixel values ​​of all pixels within the corresponding median filtering window for each target pixel in the segmentation mask data, using the median value of all pixel values ​​sorted as the new value of the target pixel, and replacing the pixel value of the target pixel with the new value; after traversing all target pixels, obtain the noise-reduced segmentation mask data; S3. Input the multi-temporal remote sensing image samples and the denoised segmentation mask data into the pre-built Transformer model for training to obtain the crop recognition model. S4. Input the multi-temporal remote sensing image samples to be identified into the crop identification model, output the prediction mask, and output the crop identification result according to the prediction mask.

[0007] As a further improvement to the present invention, The size of the multi-temporal remote sensing image sample is 224 pixels × 224 pixels; The multiple consecutive growth phases refer to three consecutive growth phases; The image data of the multiple spectral channels are blue band, green band, red band, near-infrared band, short-wave infrared 1 band, and short-wave infrared 2 band; The multi-temporal remote sensing image samples and segmentation mask data use the same geographic coordinate system to ensure a one-to-one correspondence in spatial location.

[0008] As a further improvement of the present invention, before performing S2, the following is also included: The segmentation mask data is converted into a single-channel grayscale image with pixel values ​​ranging from 0 to 1, where pixel value 0 represents non-crop areas and pixel value 1 represents crop areas. In the single-channel grayscale image, pixels with a pixel value of 1 and whose pixel values ​​of all adjacent pixels in the 8-neighborhood are 0 are identified as isolated noise points.

[0009] As a further improvement of the present invention, in step S2, a median filtering window is selected according to the density of the isolated noise points. For each target pixel in the segmentation mask data, the pixel values ​​of all pixels within the corresponding median filtering window are taken, and the median value after sorting all pixel values ​​is used as the new value of the target pixel, including: When the density of isolated noise points in the single-channel grayscale image is greater than 10%, a median filter window of size 5×5 is selected. When the density of isolated noise points in the single-channel grayscale image is no greater than 10%, a median filter window of size 3×3 is selected; The median value of all sorted pixel values ​​is used as the new value of the target pixel, calculated using the following formula:

[0010] In the formula: For target element The new value; The pixel values ​​within the median filter window; median{ } is the median function; This is the horizontal offset relative to the target element within the median filter window; This represents the vertical offset relative to the target element within the median filter window. This is half the width of the median filter window; This is the size of the median filter window, which can be 3 or 5. This is the floor function.

[0011] As a further improvement of the present invention, step S3 inputs multi-temporal remote sensing image samples and denoised segmentation mask data into a pre-constructed Transformer model for training to obtain a crop recognition model, including: All image data in the multi-temporal remote sensing image sample are stitched together according to the channel dimension to obtain a multi-channel feature matrix. The pixel values ​​in the multi-channel feature matrix are normalized to obtain a normalized multi-channel feature matrix. The Transformer model includes an input layer, an encoder, and a decoder; The input layer receives the normalized multi-channel feature matrix and performs convolution processing on the multi-channel feature matrix to obtain a feature map. The encoder encodes the feature map layer by layer and outputs the encoded feature map; the encoder includes 6 layers of multi-head attention modules, each layer of multi-head attention modules has 8 attention heads, and the hidden layer dimension is 512; The multi-head attention module includes a LayerNorm layer and a feedforward network, wherein the feedforward network includes a fully connected layer and a ReLU activation function; The decoder performs convolution processing on the encoded feature map and outputs a prediction mask; the decoder includes two transposed convolution layers, each with a kernel size of 2×2 and a stride of 2.

[0012] As a further improvement of the present invention, the training parameters of the Transformer model in S3 include: The Adam optimizer was trained using the cross-entropy loss function and the Adam optimizer. The initial learning rate of the Adam optimizer was 0.001, and the batch size was set to 32. The number of training iterations was 100 rounds. The convergence threshold was that the value of the cross-entropy loss function was no greater than 0.005.

[0013] As a further improvement of the present invention, in step S4, the multi-temporal remote sensing image samples to be identified are input into the crop identification model, and the crop identification results are output, including: The predicted mask output by the crop recognition model is classified. Pixels with a value of not less than 0.5 are assigned a value of 1 and marked as crop areas, while pixels with a value less than 0.5 are assigned a value of 0 and marked as non-crop areas, thus obtaining a binary classification mask. The binary classification mask and the multi-temporal remote sensing image sample to be identified are subjected to geographic coordinate registration processing. Using the pixel row and column number as the association index, the binary classification mask and the multi-temporal remote sensing image sample to be identified are spatially bound pixel by pixel, so that each pixel matches the actual latitude and longitude coordinates, and the bound geographic coordinate information is obtained. The crop identification and segmentation results are generated based on the bound geographic coordinate information.

[0014] This invention proposes a crop identification system with segmentation mask adaptive median filtering noise reduction, comprising: The acquisition module is used to acquire multi-temporal remote sensing image samples of the crop identification area and segmentation mask data corresponding to the multi-temporal remote sensing image samples; the multi-temporal remote sensing image samples include multiple continuous growth phases, and each phase includes image data of multiple spectral channels; The filtering module is used to perform median filtering on the segmentation mask data. This includes obtaining the density of isolated noise points in the segmentation mask data; selecting a corresponding median filtering window based on the density of the isolated noise points; for each target pixel in the segmentation mask data, taking the pixel values ​​of all pixels within the corresponding median filtering window; using the median of all pixel values ​​after sorting as the new value of the target pixel; and replacing the pixel value of the target pixel with the new value. After traversing all target pixels, the denoised segmentation mask data is obtained. The training module is used to input multi-temporal remote sensing image samples and denoised segmentation mask data into a pre-built Transformer model for training, so as to obtain a crop recognition model. The identification module is used to input multi-temporal remote sensing image samples to be identified into the crop identification model, output a prediction mask, and output the crop identification result based on the prediction mask.

[0015] This invention proposes a crop identification device with segmentation mask adaptive median filtering noise reduction, comprising a processor and a memory, wherein the processor executes a computer program stored in the memory to implement the crop identification method with segmentation mask adaptive median filtering noise reduction as described above.

[0016] This invention proposes a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the crop identification method with adaptive median filtering and noise reduction using segmentation mask as described above.

[0017] Compared with the prior art, the present invention achieves the following technical effects: The multi-temporal remote sensing image samples and corresponding segmentation mask data acquired in this invention provide a data foundation for subsequent crop identification, ensuring that the crop identification model can capture the spectral regularity changes throughout the entire growth cycle of crops. Secondly, adaptive median filtering is applied to the segmentation mask data, effectively filtering out isolated noise points while preserving the edge details of crop plots, thus improving the annotation quality of the segmentation mask data. The denoised segmentation mask data is used as a supervisory signal to train the Transformer model, avoiding false features introduced by isolated noise points being misclassified as crops, improving the accuracy of crop identification. Finally, geographic coordinate registration is performed on the output binary classification mask to obtain the crop identification result, realizing a complete process from input to output.

[0018] This invention statistically analyzes the density of isolated noise points in segmented mask data and adaptively selects a median filter window based on this density. When the density of isolated noise points is high, a 5×5 median filter window is used to filter out noise; when the density is low, a 3×3 median filter window is used to preserve edge details. This effectively filters out isolated noise points while preserving the edge information of crop plots to the greatest extent, avoiding the drawback of traditional mean filtering which destroys boundaries when smoothing noise. It also eliminates the need for additional labeled data and training costs required by complex denoising networks. Furthermore, this invention uses the denoised segmented mask data as supervisory labels to train the Transformer model, enabling the Transformer model to focus on the actual spectral variation patterns of crops. This avoids misclassifying isolated noise points as false features of crops during learning, significantly improving the accuracy of crop identification and spatial positioning precision. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the overall process of the present invention; Figure 2 This is a schematic diagram of multi-temporal remote sensing image samples of the present invention; Figure 3 This is a schematic diagram of the segmentation mask data of the present invention; Figure 4 This is a schematic diagram comparing the segmentation mask data and the noise-reduced segmentation mask data of the present invention; Figure 5 This is another comparative diagram of the segmentation mask data and the noise-reduced segmentation mask data of the present invention; Figure 6 The ROC (Receiver Operating Characteristic) of this invention is the subject's working... Schematic diagram of characteristic curve; Figure 7 This is a schematic diagram of the classification results of the present invention. Detailed Implementation

[0020] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0021] like Figure 1 As shown, this embodiment provides a crop identification method using segmentation mask adaptive median filtering for noise reduction, including the following steps: S1. Obtain multi-temporal remote sensing image samples of the crop identification area and segmentation mask data corresponding to the multi-temporal remote sensing image samples; the multi-temporal remote sensing image samples include multiple continuous growth phases, and each phase includes image data of multiple spectral channels; S2. Perform median filtering on the segmentation mask data, including obtaining the density of isolated noise points in the segmentation mask data, selecting a corresponding median filtering window based on the density of isolated noise points, taking the pixel values ​​of all pixels within the corresponding median filtering window for each target pixel in the segmentation mask data, using the median value of all pixel values ​​sorted as the new value of the target pixel, and replacing the pixel value of the target pixel with the new value; after traversing all target pixels, obtain the noise-reduced segmentation mask data; S3. Input the multi-temporal remote sensing image samples and the denoised segmentation mask data into the pre-built Transformer model for training to obtain the crop recognition model. S4. Input the multi-temporal remote sensing image samples to be identified into the crop identification model, output the prediction mask, and output the crop identification result according to the prediction mask.

[0022] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments: Step 1: In this embodiment, multi-temporal remote sensing image samples and corresponding segmentation mask data are acquired. Specifically, the multi-temporal remote sensing image samples are satellite or UAV remote sensing images containing multiple consecutively growing temporal phases. Each temporal phase contains image data from multiple spectral channels.

[0023] like Figure 2 As shown in the embodiment, each multi-temporal remote sensing image sample is 224 pixels × 224 pixels in size. This size not only preserves sufficient spatial structure information of ground features but also avoids placing a computational burden on the subsequent Transformer model. Each multi-temporal remote sensing image sample contains three consecutive growth phases, such as the sowing period, jointing period, and harvest period of crops. Each phase corresponds to six spectral channels, specifically the blue band (B2), green band (B3), red band (B4), near-infrared band (B8), shortwave infrared 1 band (B11), and shortwave infrared 2 band (B12). Among them, the blue, green, and red bands are visible light bands, which can reflect chlorophyll content and canopy color changes. The near-infrared band can sense vegetation biomass, while the shortwave infrared 1 and shortwave infrared 2 bands can distinguish vegetation moisture content and soil background. By using these six bands in combination, the growth status of crops can be comprehensively captured.

[0024] like Figure 3 As shown, the segmentation mask data in this embodiment contains a large number of isolated bright yellow noise points. To ensure the accuracy of subsequent steps, this embodiment requires that the multi-temporal remote sensing image samples and the segmentation mask data use the same geographic coordinate system, preferably the WGS (World Geodetic System) 84 coordinate system, and the data format is uniformly GeoTIFF (Geographic Tagged Image File Format), so that the spatial position of each pixel corresponds one-to-one between the multi-temporal remote sensing image samples and the segmentation mask data, avoiding misalignment.

[0025] Step 2: Before performing median filtering in this embodiment, the segmentation mask data needs to be converted into a single-channel grayscale image with pixel values ​​ranging from 0 to 1. Pixel value 0 represents non-crop areas, and pixel value 1 represents crop areas. Using binarization can clearly distinguish between the target and the background.

[0026] In this embodiment, isolated noise points are defined as pixels in a single-channel grayscale image with a pixel value of 1, and whose pixel values ​​are all 0 in all eight neighboring pixels (i.e., up, down, left, right, upper left, upper right, lower left, and lower right). Isolated noise points are usually caused by random noise or labeling errors in remote sensing images and do not represent the actual distribution of crops.

[0027] The density of isolated noise points in a single-channel grayscale image is calculated as the percentage of isolated noise points to the total number of pixels. When the density of isolated noise points is greater than 10%, it indicates severe noise pollution, requiring a larger 5×5 median filter window to achieve stronger noise reduction. When the density of isolated noise points is less than or equal to 10%, it indicates low noise, and a 3×3 median filter window is sufficient to remove noise while better preserving edge details.

[0028] After determining the median filtering window size, median filtering is performed on each target pixel in the single-channel grayscale image. For example, for a target pixel with coordinates (x, y), the pixel values ​​of all pixels within the median filtering window centered on that pixel are extracted. These pixel values ​​are then arranged in ascending order, and the value at the middle position is taken as the new value of the target pixel. This new value replaces the original pixel value. The result is calculated using the following formula:

[0029] In the formula: For target element The new value; The pixel values ​​within the median filter window; median{ } is the median function; This is the horizontal offset relative to the target element within the median filter window; This represents the vertical offset relative to the target element within the median filter window. This is half the width of the median filter window; This is the size of the median filter window, which can be 3 or 5. This is the floor function.

[0030] After traversing all target pixels to complete the median filtering calculation, the denoised segmentation mask data is obtained. In order to ensure that the denoising effect meets the requirements of subsequent training, this embodiment also includes a verification process for the denoised segmentation mask data. Specifically, the entire denoised segmentation mask data is traversed again to ensure that there are no isolated noise points remaining. At the same time, the rate of change of edge pixel values ​​is calculated to ensure that the rate of change of edge pixel values ​​does not exceed 5%. The verification process can effectively avoid the problem of excessive edge smoothing caused by an excessively large median filtering window, and ensure that the boundary information of the crop plots is completely preserved.

[0031] In this embodiment, the calculation of the edge pixel value change rate is as follows: For the segmentation mask data before median filtering, all pixels are traversed; for a pixel with a pixel value of 1 (representing a crop area), if there is at least one pixel with a value of 0 (non-crop area) in the 8-neighborhood of the pixel, the pixel is determined to be an edge pixel, and the total number of edge pixels is counted.

[0032] The number of edge pixels that changed before and after median filtering was counted and calculated using the following formula:

[0033] In the formula: The rate of change of edge pixel values; This represents the number of edge pixels that change before and after median filtering. This represents the total number of edge pixels.

[0034] If the rate of change of edge pixel values ​​is no greater than 5%, the segmentation mask data after noise reduction is qualified, and the subsequent steps continue; if the rate of change of edge pixel values ​​is greater than 5%, a smaller median filtering window is selected to re-execute the median filtering process, and the verification process is performed again.

[0035] like Figure 4 and Figure 5 As shown, the comparison between the segmented mask data and the denoised segmented mask data is presented. Figure 4 Image a shows the denoised segmentation mask data, and image b shows the segmentation mask data. Figure 5 Image a shows the effect of the segmented mask data after noise reduction, and image b shows the effect of the segmented mask data. As can be seen from the images... Figure 4 b and Figure 5 In image b, numerous isolated bright yellow noise points are scattered throughout, exhibiting a discrete distribution. Simultaneously, noticeable jagged, blurred edges are present at the edges of the crop plots, resulting in unclear plot boundaries. Figure 4 a and Figure 5 In image a, bright yellow noise was filtered out, and the edges of the crop plots became smooth and sharp, with the edge contours well preserved.

[0036] Step 3: Input the multi-temporal remote sensing image samples and the denoised segmentation mask data into the pre-built Transformer model for training to obtain the crop recognition model. First, the multi-temporal remote sensing image samples need to be preprocessed. The image data from the three temporal phases in the multi-temporal remote sensing image samples are stitched together according to the channel dimension to form a multi-channel feature matrix of size 224×224×18. This integrates the spectral channel information from different temporal phases, providing complete input for the subsequent Transformer model.

[0037] The pixel values ​​in the multi-channel feature matrix are subjected to maximum-minimum normalization, mapping the pixel values ​​of each spectral channel in the multi-channel feature matrix to the interval [0,1], resulting in a normalized multi-channel feature matrix. In this embodiment, channel-by-channel normalization is used. For the c-th spectral channel in the multi-channel feature matrix, the minimum and maximum values ​​of all pixels in that spectral channel are calculated, and normalization is performed channel by channel. The calculation formula is as follows:

[0038] In the formula: c is the spectral channel number; This represents the original pixel value to be normalized in the c-th spectral channel of the multi-channel feature matrix. and These are the minimum and maximum pixel values ​​of all pixels in the c-th spectral channel of the multi-channel feature matrix, respectively. Let be the pixel value corresponding to the c-th spectral channel in the normalized multi-channel feature matrix. Through the above normalization process, all pixel values ​​are mapped to the interval [0,1], thus obtaining the normalized multi-channel feature matrix.

[0039] The Transformer model in this embodiment adopts an encoder-decoder structure, mainly composed of an input layer, an encoder, and a decoder. Specifically, the input layer receives the normalized multi-channel feature matrix, and performs convolution processing on the normalized multi-channel feature matrix through a convolutional layer with a kernel size of 3×3 and a stride of 1, which can compress the number of channels of the normalized multi-channel feature matrix to 512, resulting in a feature map with a size of 224×224×512.

[0040] In this embodiment, the feature map is segmented into patches: using a non-overlapping patch size of 16×16, the 224×224×512 feature map is divided into 14×14 patch blocks in spatial dimension, and the features within each patch block are flattened into a one-dimensional vector.

[0041] A one-dimensional vector is mapped to a 512-dimensional sequence consistent with the hidden layer dimension of the encoder by linear projection, resulting in a patch token sequence with a length of 196. A learnable positional encoding is added to the patch token sequence, and the learnable positional encoding is added to the patch token sequence element by element to obtain a token sequence carrying spatial positional information. The token sequence is then input into the encoder.

[0042] The encoder consists of six stacked multi-head attention modules, each with eight attention heads and a hidden layer dimension of 512. Each multi-head attention module first performs normalization through a LayerNorm layer, using the multi-head attention mechanism to capture long-range spatial dependencies between different sequence elements in the token sequence. Then, a feedforward network is used to enhance the non-linear expressive power of the features. In this embodiment, the feedforward network includes a fully connected layer and a ReLU (Rectified Linear Unit) activation function. After the encoder completes the encoding process, it outputs the encoded token sequence, which is then reshaped into a 14×14×512 two-dimensional spatial feature map to obtain the encoded feature map, which is then fed into the decoder.

[0043] The decoder consists of two transposed convolutional layers. Each transposed convolutional layer has a kernel size of 2×2 and a stride of 2. The transposed convolutional layers gradually restore the encoded feature map to 224×224 pixels through upsampling operations, and finally output a prediction mask. Each pixel value in the prediction mask represents the probability that the position belongs to the crop category.

[0044] In this embodiment, the cross-entropy loss function is used to calculate the error between the predicted mask and the denoised segmented mask data during Transformer model training. The optimizer is Adam, the initial learning rate is set to 0.001, the batch size is set to 32, and a total of 100 training epochs are performed. Training is complete when the value of the cross-entropy loss function decreases below 0.005, resulting in the crop recognition model. Figure 6 As shown, Figure 6 The ROC curve in the figure has the false positive rate (FPR) on the horizontal axis and the true positive rate (TPR) on the vertical axis. As can be seen from the figure, the area under the curve (AUC) of the method in this embodiment is 0.85, which shows that the crop identification model of the present invention has a strong identification ability.

[0045] Step 4: Input the multi-temporal remote sensing image samples to be identified into the crop identification model, output the prediction mask, and output the crop identification result based on the prediction mask. The specific process is as follows: First, the multi-temporal remote sensing image samples to be identified are input into the crop identification model. The crop identification model finally outputs a prediction mask with a size of 224×224 pixels. The value of each pixel in the prediction mask is between 0 and 1, representing the predicted probability that the pixel location belongs to a crop plot. The closer the probability value is to 1, the higher the confidence that the location belongs to a crop; the closer the probability value is to 0, the higher the confidence that the location belongs to a non-crop area.

[0046] The predicted mask is classified in this embodiment using a fixed threshold classification method, with a preferred threshold of 0.5. Specifically, all pixels of the predicted mask are iterated over. For any pixel, if its predicted probability is greater than or equal to 0.5, the pixel is classified as a valid crop area and its pixel value is set to 1; if its predicted probability is less than 0.5, the pixel is classified as a non-crop area and its pixel value is set to 0. This process effectively eliminates transitional pixels with ambiguous probabilities, clearly defining the boundary between crops and background features.

[0047] Following this, geographic coordinate registration is performed. The binary classification mask itself only contains pixel-level classification information and does not possess actual geospatial meaning. Therefore, the geographic coordinate information attached to the multi-temporal remote sensing image samples to be identified is required. Specifically, the geographic coordinate system of the remote sensing image to be identified is read (in this embodiment, the WGS84 coordinate system is used), and the spatial projection parameters in the GeoTIFF format file are also read. Using the row and column numbers of the pixels as association indices, each pixel in the binary classification mask is bound one by one to the corresponding pixel in the multi-temporal remote sensing image samples to be identified. This ensures that each crop pixel in the binary classification mask is matched to its actual latitude and longitude coordinates, achieving precise alignment between the classification result and the geospatial location.

[0048] This embodiment proposes a specific application of the crop identification method based on segmentation mask adaptive median filtering noise reduction, including the following steps: Step 1: Acquire Sentinel-2 satellite images of a certain region in April, June, and September 2024. Each time phase contains 6 spectral channels (B2 / B3 / B4 / B8 / B11 / B12), with a spatial resolution of 10m. The satellite images are cropped to obtain 10,000 multi-temporal remote sensing image samples with a size of 224 pixels × 224 pixels. All multi-temporal remote sensing image samples are stored in GeoTIFF format and use the WGS84 coordinate system. The corresponding segmentation mask data also uses GeoTIFF format and the WGS84 coordinate system. According to statistics, the density of isolated noise points in the segmentation mask data is about 12%.

[0049] Step 2: Since the density of isolated noise points in the segmentation mask data is about 12%, a 5×5 median filter window is selected to perform median filtering on the segmentation mask data to obtain the noise-reduced segmentation mask data.

[0050] Step 3: Concatenate the image data from the three time phases into a 224×224×18 multi-channel feature matrix and normalize it. Input the normalized multi-channel feature matrix into the Transformer model for training. The training set consists of 8000 samples, the validation set consists of 2000 samples, the batch size is 32, and the iteration is 100 rounds. Cross-entropy loss and Adam optimizer are used (initial learning rate 0.001). After 65 rounds of training, the loss converges to 0.004 (≤0.005), resulting in the crop recognition model.

[0051] Step 4: Select Sentinel-2 satellite images of the same region from April, June, and September 2024, input them into the crop identification model, and output the crop identification result image, such as... Figure 7 As shown, Figure 7 Three consecutive Sentinel-2 satellite images of a specific region taken in April, June, and September visually illustrate the spectral changes of crops from sowing, jointing, to maturity. Furthermore... Figure 7 The ground truth mask is a manually labeled label of the actual distribution of crops in a certain area, where the bright yellow area represents the crop area and the dark red background represents the non-crop area. The prediction mask is the classification result output by the crop recognition model of this invention. Comparing the prediction mask and the ground truth mask, it can be seen that the spatial distribution of crops in the two are highly consistent. The location, shape and area of ​​the main crop plots are highly consistent with the ground truth. The plot edges in the prediction mask are continuous and smooth, without obvious isolated noise points or scattered misclassifications. The output result is clean and the overall recognition accuracy is excellent, which verifies the effectiveness and reliability of the method of this invention.

[0052] Based on the same inventive concept, this invention also provides a crop identification system with segmentation mask adaptive median filtering noise reduction. Since the principle of solving the problem in this crop identification system with segmentation mask adaptive median filtering noise reduction is similar to the aforementioned crop identification method with segmentation mask adaptive median filtering noise reduction, the implementation of this crop identification system with segmentation mask adaptive median filtering noise reduction can refer to the implementation of the crop identification method with segmentation mask adaptive median filtering noise reduction, and the repeated parts will not be described again.

[0053] In specific implementation, the crop identification system with segmentation mask adaptive median filtering and noise reduction provided in this embodiment of the invention specifically includes: The acquisition module is used to acquire multi-temporal remote sensing image samples and segmentation mask data corresponding to the multi-temporal remote sensing image samples; the multi-temporal remote sensing image samples include multiple consecutive growth phases, and each phase includes image data of multiple spectral channels; The filtering module is used to perform median filtering on the segmentation mask data. This includes obtaining the density of isolated noise points in the segmentation mask data; selecting a corresponding median filtering window based on the density of the isolated noise points; for each target pixel in the segmentation mask data, taking the pixel values ​​of all pixels within the corresponding median filtering window; using the median of all pixel values ​​after sorting as the new value of the target pixel; and replacing the pixel value of the target pixel with the new value. After traversing all target pixels, the denoised segmentation mask data is obtained. The training module is used to input multi-temporal remote sensing image samples and denoised segmentation mask data into a pre-built Transformer model for training, so as to obtain a crop recognition model. The identification module is used to input multi-temporal remote sensing image samples to be identified into the crop identification model and output the crop identification results.

[0054] Accordingly, this embodiment of the invention also provides a crop identification device with segmentation mask adaptive median filtering noise reduction, including a processor and a memory, wherein the processor executes a computer program stored in the memory to implement the crop identification method with segmentation mask adaptive median filtering noise reduction as provided in this embodiment of the invention.

[0055] For a more detailed explanation of the above method, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.

[0056] Accordingly, embodiments of the present invention also provide a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the crop identification method with adaptive median filtering and noise reduction using segmentation mask as described above in embodiments of the present invention.

[0057] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems, devices, and storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0058] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0059] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0060] Finally, 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.

[0061] The above provides a detailed description of the crop identification method, system, device, and storage medium for segmentation mask adaptive median filtering noise reduction provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A crop identification method using segmentation mask adaptive median filtering for noise reduction, characterized in that, Includes the following steps: S1. Obtain multi-temporal remote sensing image samples of the crop identification area and segmentation mask data corresponding to the multi-temporal remote sensing image samples; the multi-temporal remote sensing image samples include multiple continuous growth phases, and each phase includes image data of multiple spectral channels; S2. Perform median filtering on the segmentation mask data, including: obtaining the density of isolated noise points in the segmentation mask data; selecting a corresponding median filtering window based on the density of the isolated noise points; for each target pixel in the segmentation mask data, taking the pixel values ​​of all pixels within the corresponding median filtering window; using the median value of all pixel values ​​after sorting as the new value of the target pixel; and replacing the pixel value of the target pixel with the new value; after traversing all target pixels, obtain the denoised segmentation mask data. S3. Input the multi-temporal remote sensing image samples and the denoised segmentation mask data into the pre-built Transformer model for training to obtain the crop recognition model. S4. Input the multi-temporal remote sensing image samples to be identified into the crop identification model, output the prediction mask, and output the crop identification result according to the prediction mask.

2. The crop identification method using segmentation mask adaptive median filtering for noise reduction according to claim 1, characterized in that, The size of the multi-temporal remote sensing image sample is 224 pixels × 224 pixels; The multiple consecutive growth phases refer to three consecutive growth phases; The image data of the multiple spectral channels are blue band, green band, red band, near-infrared band, short-wave infrared 1 band, and short-wave infrared 2 band; The multi-temporal remote sensing image samples and segmentation mask data use the same geographic coordinate system to ensure a one-to-one correspondence in spatial location.

3. The crop identification method using segmentation mask adaptive median filtering for noise reduction according to claim 1, characterized in that, Before proceeding to S2, the following is also included: The segmentation mask data is converted into a single-channel grayscale image with pixel values ​​ranging from 0 to 1, where pixel value 0 represents non-crop areas and pixel value 1 represents crop areas. In the single-channel grayscale image, pixels with a pixel value of 1 and whose pixel values ​​of all adjacent pixels in the 8-neighborhood are 0 are identified as isolated noise points.

4. The crop identification method using segmentation mask adaptive median filtering for noise reduction according to claim 3, characterized in that, In step S2, a median filtering window is selected based on the density of the isolated noise points. For each target pixel in the segmentation mask data, the pixel values ​​of all pixels within the corresponding median filtering window are taken, and the median value after sorting all pixel values ​​is used as the new value of the target pixel, including: When the density of isolated noise points in the single-channel grayscale image is greater than 10%, a median filter window of size 5×5 is selected; When the density of isolated noise points in the single-channel grayscale image is no greater than 10%, a median filter window of size 3×3 is selected; The median value of all sorted pixel values ​​is used as the new value of the target pixel, calculated using the following formula: In the formula: For target element The new value; The pixel values ​​within the median filter window; median{ } is the median function; This is the horizontal offset relative to the target element within the median filter window; This represents the vertical offset relative to the target element within the median filter window. This is half the width of the median filter window; This is the size of the median filter window, which can be 3 or 5. This is the floor function.

5. The crop identification method using segmentation mask adaptive median filtering for noise reduction according to claim 1, characterized in that, S3 inputs multi-temporal remote sensing image samples and denoised segmentation mask data into a pre-built Transformer model for training, resulting in a crop recognition model, including: All image data in the multi-temporal remote sensing image sample are stitched together according to the channel dimension to obtain a multi-channel feature matrix. The pixel values ​​in the multi-channel feature matrix are normalized to obtain a normalized multi-channel feature matrix. The Transformer model includes an input layer, an encoder, and a decoder; The input layer receives the normalized multi-channel feature matrix and performs convolution processing on the multi-channel feature matrix to obtain a feature map. The encoder encodes the feature map layer by layer and outputs the encoded feature map; the encoder includes 6 layers of multi-head attention modules, each layer of multi-head attention modules has 8 attention heads, and the hidden layer dimension is 512; The multi-head attention module includes a LayerNorm layer and a feedforward network, wherein the feedforward network includes a fully connected layer and a ReLU activation function; The decoder performs convolution processing on the encoded feature map and outputs a prediction mask; the decoder includes two transposed convolution layers, each with a kernel size of 2×2 and a stride of 2.

6. The crop identification method using segmentation mask adaptive median filtering for noise reduction according to claim 5, characterized in that, The training parameters of the Transformer model in S3 include: The Adam optimizer was trained using the cross-entropy loss function and the Adam optimizer. The initial learning rate of the Adam optimizer was 0.001, and the batch size was set to 32. The number of training iterations was 100 rounds. The convergence threshold was that the value of the cross-entropy loss function was no greater than 0.

005.

7. The crop identification method using segmentation mask adaptive median filtering for noise reduction according to claim 1, characterized in that, In step S4, the multi-temporal remote sensing image samples to be identified are input into the crop identification model, and the crop identification results are output, including: The predicted mask output by the crop recognition model is classified. Pixels with a value of not less than 0.5 are assigned a value of 1 and marked as crop areas, while pixels with a value of less than 0.5 are assigned a value of 0 and marked as non-crop areas, thus obtaining a binary classification mask. The binary classification mask and the multi-temporal remote sensing image sample to be identified are subjected to geographic coordinate registration processing. Using the pixel row and column number as the association index, the binary classification mask and the multi-temporal remote sensing image sample to be identified are spatially bound pixel by pixel, so that each pixel matches the actual latitude and longitude coordinates, and the bound geographic coordinate information is obtained. The crop identification and segmentation results are generated based on the bound geographic coordinate information.

8. A crop identification system with segmentation mask adaptive median filtering noise reduction, characterized in that, include: The acquisition module is used to acquire multi-temporal remote sensing image samples of the crop identification area and the segmentation mask data corresponding to the multi-temporal remote sensing image samples; The multi-temporal remote sensing image sample includes multiple consecutive growth phases, and each phase includes image data from multiple spectral channels; A filtering module is used to perform median filtering on the segmentation mask data, including: obtaining the density of isolated noise points in the segmentation mask data; selecting a corresponding median filtering window according to the density of isolated noise points; for each target pixel in the segmentation mask data, taking the pixel values ​​of all pixels in the corresponding median filtering window; using the median value of all pixel values ​​sorted as the new value of the target pixel; and replacing the pixel value of the target pixel with the new value; after traversing all target pixels, the denoised segmentation mask data is obtained. The training module is used to input multi-temporal remote sensing image samples and denoised segmentation mask data into a pre-built Transformer model for training, so as to obtain a crop recognition model. The identification module is used to input multi-temporal remote sensing image samples to be identified into the crop identification model, output a prediction mask, and output the crop identification result based on the prediction mask.

9. A crop identification device with segmentation mask adaptive median filtering noise reduction, characterized in that, The system includes a processor and a memory, wherein the processor executes a computer program stored in the memory to implement the crop identification method with segmentation mask adaptive median filtering noise reduction as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the crop identification method with segmentation mask adaptive median filtering noise reduction as described in any one of claims 1 to 7.