Remote sensing image cloud removal method based on robustness Swin Transform

The Swin Transformer-based method effectively addresses the limitations of traditional remote sensing image declouding by enhancing accuracy and efficiency through advanced feature extraction and post-processing, ensuring high-quality cloud removal and detail preservation.

CN119251080APending Publication Date: 2025-01-03GANSU WANWEI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411246976.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

Existing remote sensing image declouding methods face challenges such as insufficient accuracy, low computational efficiency, poor generalization, and lack of effective post-processing, leading to cloud residues and loss of surface information.

Method used

A remote sensing image declouding method based on the robust Swin Transformer, utilizing feature extraction and self-attention mechanisms, combined with refined post-processing techniques like TV-L1 denoising, guided filtering, and sharpening, to accurately identify and remove clouds while preserving image details.

Benefits of technology

Significantly improves cloud removal effects, enhances image quality, and increases efficiency, enabling accurate and versatile cloud removal across diverse environments and sensors, with improved accuracy, precision, and detail preservation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119251080A_ABST
    Figure CN119251080A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of visual remote sensing image processing, in particular to a remote sensing image cloud removal method based on robustness Swin Transform. According to the method, the Swin Transform model and the self-attention mechanism thereof are introduced, the information of the pixel level and the semantic level is comprehensively considered, and the detailed post-processing step is combined, so that remarkable innovation and improvement are achieved in the aspects of the cloud removal effect, the generalization ability, the information comprehensive processing, the post-processing optimization and the like. Compared with the prior art, the remote sensing image cloud removal method can more effectively solve the problems encountered in the remote sensing image cloud removal process, provides a high-quality cloud removal result, and has wide application value. The method can significantly improve the cloud removal effect, improves the remote sensing image quality, and has a wide application prospect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of visual remote sensing image processing, and in particular to a remote sensing image cloud removal method based on robust SwinTransformer. Background Art

[0002] Remote sensing imagery is an important tool for Earth observation, widely used in natural resource surveys, environmental monitoring, disaster assessment, urban planning, and other fields. However, remote sensing imagery is inevitably affected by cloud cover, which obscures surface information and reduces its quality and application value.

[0003] Detailed and accurate information on land cover and land use spatial changes is crucial for ecological and environmental research. To achieve these tasks, higher-quality images are required. Traditional remote sensing image declouding methods mainly include the following: Based on the difference in reflectivity between clouds and the ground, a threshold is set to distinguish between clouds and the ground. This method is simple and easy to implement, but the cloud removal effect is not ideal, and it is easy to leave clouds behind or mistakenly remove surface information. Remote sensing images are segmented into different regions, and then the characteristics of each region are used to determine whether it is cloud cover. This method has good cloud removal results, but it is computationally complex and inefficient.

[0004] To solve the above problems, the present invention proposes a remote sensing image declouding method based on an improved Swin Transformer. It comprehensively utilizes the feature extraction capability and self-attention mechanism of the deep learning model, and combines it with refined post-processing technology to significantly improve the declouding effect, increase processing efficiency, and enhance generalization ability, thereby overcoming the limitations of existing technologies. Summary of the Invention

[0005] The present invention provides a remote sensing image cloud removal method based on the robust Swin Transformer, comprising the following steps: (1) Preprocessing: Preprocessing of remote sensing images, including image denoising, enhancement, color correction and other preprocessing steps, to improve the input quality of subsequent models.

[0006] (2) Cloud recognition model: Collect data covering different geographical regions, seasons, and weather conditions, and pre-train a deep learning model based on the improved Swin Transformer based on the collected data to enable it to recognize clouds in remote sensing images. The input of this model should be the original remote sensing image containing clouds, and the output is a cloud mask indicating whether each pixel belongs to the cloud layer.

[0007] (3) Cloud removal: Remove cloud pixels from remote sensing images based on the output of the cloud recognition model.

[0008] (4) Post-processing: Further post-processing of the de-clouded image, including image denoising, edge protection, detail enhancement, etc.

[0009] Furthermore, the step (1) includes the following sub-steps: (1.1) Convert the image to grayscale, crop it to 256 x 256 pixels, and use the TV-L1 model optimized with the dual algorithm to remove noise from the image.

[0010] (1.2) Image enhancement mainly includes two aspects: frequency domain enhancement and spatial domain enhancement. In the present invention, Fourier transform and histogram equalization are used to complete the enhancement of these two parts respectively.

[0011] (1.3) Color correction of remote sensing images mainly includes three operations: radiation correction, atmospheric correction and terrain correction.

[0012] Furthermore, the step (2) includes the following sub-steps: (2.1) Collect a dataset of original remote sensing images containing clouds. These images cover different geographical regions, different seasons, and different weather conditions. Based on the characteristics of the dataset, random rotation, flipping, scaling, and other operations can be performed to enhance the data to increase the generalization ability of the model.

[0013] (2.2) In order to improve the robustness of the model, some improvements are made to the Swin Transformer model: Feature pyramid structure: Introducing multi-scale feature representation helps capture clouds of different sizes, including cumulus, stratocumulus, altocumulus, cirrus, etc.; Attention mechanism: Using the self-attention mechanism, the model can focus on the cloud-related areas in the image; Regularization loss function: Using regularization technology to prevent the model from overfitting.

[0014] (2.3) Train the model; (2.3.1) Input the original remote sensing image containing clouds.

[0015] (2.3.2) Use the Swin Transformer backbone network to encode the input image.

[0016] (2.3.3) Use the classification layer to predict whether each pixel belongs to the cloud layer.

[0017] (2.3.4) Calculate the classification loss and regularization loss. The classification loss can measure the difference between the cloud mask predicted by the model and the true cloud mask, and the regularization loss can prevent the model from overfitting.

[0018] (2.3.5) Update model parameters using the Adam optimizer.

[0019] Repeat steps 2.3.2 to 2.3.5 until the training loss stops decreasing or the accuracy on the validation set stops improving, at which point the model converges.

[0020] (2.4) Use the validation set to evaluate the performance of the model, calculate indicators such as accuracy and recall, and tune the model based on the evaluation results.

[0021] Furthermore, the step (3) includes the following sub-steps: (3.1) De-clouding the remote sensing image based on the output of the cloud recognition model.

[0022] (3.2) Perform weighted fusion of the declouded image and the original image based on the cloud probability.

[0023] Furthermore, the step (4) includes the following sub-steps: (4.1) Refer to step (1.1) to remove noise from the image after cloud removal.

[0024] (4.2) To protect the edge information of the image after cloud removal, guided filtering can be used to protect the edge.

[0025] (4.3) To enhance the detail information of the image after cloud removal, a sharpening filter can be used to enhance the detail information.

[0026] In recent years, with the rapid development of deep learning technology, remote sensing image declouding methods based on deep learning have achieved remarkable results. To address the problems of existing methods, such as insufficient accuracy, low computational efficiency, poor generalization, and lack of post-processing optimization, this paper proposes a remote sensing image declouding method based on the robust Swin Transformer, which offers significant innovations compared to existing technologies. The following is a detailed description of each innovation: 1. Significantly improved declouding effects: Traditional convolutional neural network (CNN) methods typically use fixed-size convolution kernels, which make it difficult to effectively capture global and local features at different scales. This is especially true when processing large-scale remote sensing images, where insufficient local feature extraction and loss of global information are common.

[0027] Innovation: Introduction of Swin Transformer: This invention adopts Swin Transformer, which is a deep learning model with a self-attention mechanism. It can dynamically adjust the range of attention, has a hierarchical structure, and can well capture local and global features in the image. Spatial representation ability: The sliding window mechanism of Swin Transformer enables it to have excellent spatial representation capabilities when processing large-size images, and can efficiently process complex details in the image. It is particularly suitable for the diverse and complex scenes of clouds in remote sensing images. Global dependency: Through the self-attention mechanism, Swin Transformer can model the global dependency between different regions, so that it can more accurately identify and remove clouds while keeping the surface clear and intact. Feature extraction and generalization capabilities: Compared with traditional CNN, Swin Transformer can better extract detailed features and semantic information of images, and has stronger generalization capabilities. In particular, when the training data is small or unevenly distributed, it can still maintain a high declouding effect.

[0028] Results: Experiments have shown that the cloud removal effect of this invention on a variety of remote sensing datasets is significantly better than that of traditional methods. In particular, in images with complex clouds and large terrain changes, it can significantly reduce cloud residue and misjudgment, and improve the accuracy and precision of cloud removal.

[0029] 2. Generalization Ability Across Locations and Sensors: Traditional image processing methods and CNN models typically perform poorly on data from different locations or sensors, and have poor generalization capabilities. They require separate training and tuning for different locations and sensors, making it impossible to achieve "train once, apply everywhere."

[0030] Innovations: Self-attention mechanism: The Swin Transformer's self-attention mechanism enables it to learn feature dependencies across different locations and sensors, adapting to diverse image characteristics. Global feature learning: Through sliding windows and multi-scale processing, the model captures global features across different sensors and locations, improving its adaptability in diverse environments. Versatility: Once trained, the model can be directly applied to different locations and sensors, reducing the need for retraining for different application scenarios and improving application efficiency.

[0031] Results: This method performs well on datasets from a variety of remote sensing image sensors (e.g., Sentinel-2 and Landsat 8) and different locations, eliminating the need for separate training for each sensor or location, and achieves excellent cross-sensor and cross-location generalization capabilities.

[0032] 3. Comprehensive consideration of pixel-level and semantic-level information: Traditional methods often ignore the combined effect of pixel-level and semantic-level information when processing complex scenes in remote sensing images, resulting in the loss of surface features and the increase of cloud residues.

[0033] Innovation: Loss function design: This invention comprehensively considers information at the pixel level (such as the precise boundary identification between clouds and the ground surface) and the semantic level (such as the overall cloud distribution pattern and surface semantic information) in the loss function to ensure the integrity and detail of the image after cloud removal. Detail preservation: Through fine-grained supervision at the pixel level, detailed information in the image is preserved; through semantic-level supervision, the overall consistency of cloud removal and the integrity of surface information are ensured. Cloud occlusion processing: Combining pixel-level and semantic-level information processing methods can effectively handle complex cloud occlusion problems in remote sensing imagery and reduce the interference of clouds on surface information.

[0034] Effect: This invention significantly improves the cloud removal effect. It can retain the detailed information and overall semantic structure of the surface while removing clouds, avoiding the problems of detail loss and over-smoothing in traditional methods, and improving the quality and application value of the image.

[0035] 4. Refinement and optimization of post-processing technology: Traditional cloud removal methods usually lack effective post-processing steps, which can easily lead to a decline in image quality after cloud removal, such as loss of details, blurred edges, and residual noise.

[0036] Innovations: Denoising: Utilizes an optimized TV-L1 model for denoising, effectively removing noise while preserving image detail. Edge Protection: Utilizes guided filtering to preserve edge information in declouded images, preventing edge blur and improving image clarity. Detail Enhancement: Sharpening filtering and frequency domain enhancement techniques enhance detail in declouded images, improving contrast and detail. Fusion: Utilizes cloud masks and cloud probability information for weighted fusion, enhancing image realism and accuracy.

[0037] Results: The post-processing technology of this invention effectively improves the overall quality of the cloud-removed image, reduces cloud residue and noise, and enhances the visual effect and application quality of the image. Experiments show that the post-processed image is significantly superior to traditional methods in terms of detail expression, edge clarity, and noise control. In summary, the present invention has achieved significant innovation and improvement in cloud removal effect, generalization ability, comprehensive information processing and post-processing optimization by introducing the Swin Transformer model and its self-attention mechanism, comprehensively considering information at the pixel level and semantic level, and combining refined post-processing steps. Compared with the existing technology, the present invention can more effectively solve the problems encountered in the process of remote sensing image cloud removal, provide high-quality cloud removal results, and have broad application value. This method can significantly improve the cloud removal effect, improve the quality of remote sensing images, and has broad application prospects. Whether it is natural resource management, environmental monitoring, disaster response, or agriculture, urban planning and other fields, they can all benefit from high-quality cloud removal images, provide strong data support for scientific decision-making and management, and promote the intelligent and efficient development of various fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 This is the overall process architecture diagram; Figure 2 Flowchart for model training; Figure 3 Flowchart for model evaluation; Figure 4 Calculate the flow chart for the evaluation indicators; Figure 5 Decision tree diagram for tuning strategy; Figure 6 Schematic diagram of the remote sensing image to be processed after preprocessing; Figure 7 Schematic diagram of the extracted cloud and cloud shadow images; Figure 8 Schematic diagram for cloud optimization. DETAILED DESCRIPTION

[0039] In order to make the above-mentioned objects, features and advantages of the present invention more understandable, the present invention is further described in detail below through detailed technical solutions and specific embodiments.

[0040] The present invention provides a remote sensing image cloud removal method based on the robust Swin Transformer. The present invention will effectively remove clouds from remote sensing images in order to more accurately extract surface information. This method utilizes the powerful features of Swin Transformer, including the self-attention mechanism and hierarchical representation, and improves the network structure and training strategy, which can further improve the accuracy of cloud recognition, reduce misjudgment, and enhance the ability to detect and remove clouds. Through this method, we can obtain clearer and more reliable remote sensing data, which is helpful for applications in environmental monitoring, land use planning, resource management and other fields. The overall process is as follows: Figure 1 shown.

[0041] The remote sensing image cloud removal method based on the robust Swin Transformer includes the following steps: (1) Preprocessing of remote sensing images mainly includes three processing steps: image denoising, enhancement, and color correction to improve the input quality of subsequent models.

[0042] (1.1) Denoising the TV-L1 model based on the primal-dual algorithm. This model combines total variation (TV) regularization with L1 norm regularization to effectively remove noise from images while preserving image details. Part of the model optimization process is as follows: 1. Model Initialization: Initialize the model parameters, including the total variation regularization parameter λ1 and the L1 norm regularization parameter λ. These parameters determine the balance between denoising effect and smoothing. Optimal parameter values ​​are usually determined through experiments.

[0043] 2. Input Image Preprocessing: Normalize the input remote sensing image and scale the pixel values ​​to the [0, 1] range for model processing. Divide the normalized image into blocks. If the image is too large, split it into several smaller sub-blocks to reduce computing resource requirements.

[0044] 3. Use the primal-dual algorithm to optimize the solution. The specific steps are as follows: 1 Variable initialization: Initialize the gradient variable of the image and dual variables , set the number of iterations and convergence threshold.

[0045] 2 Main loop: Update gradient variables Calculate intermediate variables: Update the dual variable q: Update the image variable u: Check the convergence conditions, if , then the loop is terminated.

[0046] 4. Post-processing: Denormalize the denoised image to restore the pixel values ​​to the original range. If the image has been processed in blocks, reconstruct the blocks to restore the complete image.

[0047] The timing control steps are as follows: 1. Initialization phase (T0-T1): T0: Parameter setting and model initialization, including the setting of parameters such as λ1, λ2, τ, σ, etc.

[0048] T1: Input image preprocessing, including normalization and block processing.

[0049] 2. Denoising calculation stage (T1-T2): T1: Start the main loop of the primal-dual algorithm.

[0050] T1.1: Variable initialization, setting the initial gradient and dual variables.

[0051] T1.2: Perform several iterations, typically with a fixed number or dynamically determined based on convergence criteria. Each iteration consists of four steps: gradient update, intermediate variable calculation, dual variable update, and image update.

[0052] T2: The main loop ends, the convergence condition is met or the predetermined number of iterations is reached.

[0053] 3. Post-processing stage (T2-T3): T2: Denormalization of the denoised image.

[0054] T3: Reconstruct the block images and restore the complete image.

[0055] (1.2) Image enhancement mainly includes two aspects: frequency domain enhancement and spatial domain enhancement. In the present invention, Fourier transform and histogram equalization are used to complete the enhancement of these two parts respectively.

[0056] (1.3) Color correction of remote sensing images mainly includes three aspects: radiation correction: converting the DN value of the image into the true surface reflectance; atmospheric correction: eliminating the effects of atmospheric scattering and absorption; terrain correction: eliminating the effects of terrain undulation.

[0057] Image enhancement can be categorized into two types: frequency domain enhancement and spatial domain enhancement. This article will provide a detailed comparative analysis of these two methods and highlight their innovative features. Frequency domain enhancement methods process the image's frequency components, using common techniques such as Fourier transform and wavelet transform. Spatial domain enhancement methods operate directly on image pixels, using common techniques such as histogram equalization, contrast stretching, and nonlinear filtering.

[0058] Spatial domain enhancement methods are applied at different scales to improve the refinement and flexibility of the enhancement effect. Adaptive mechanisms are used to adjust the enhancement strategy based on the local characteristics of the image.

[0059] Technical Refinement: Use region segmentation techniques to divide the image into several local regions. Within each local region, calculate the grayscale histogram and contrast characteristics. Based on the local characteristics, adaptively select the enhancement method (such as histogram equalization, contrast stretching, etc.) and its parameters.

[0060] Innovation: Provides an adaptive enhancement strategy to achieve targeted enhancement and avoid over-enhancement or under-enhancement. Combined with region segmentation technology, it improves the flexibility and adaptability of the enhancement method.

[0061] Through comparative analysis of the above frequency domain and spatial domain enhancement methods and elaboration of their innovative points, this paper proposes a multi-scale hybrid enhancement and adaptive enhancement model, aiming to combine the advantages of both to achieve high-quality enhancement of remote sensing images and provide better input for subsequent cloud identification and removal.

[0062] (2) Cloud recognition model: Train a deep learning model based on the improved Swin Transformer to enable it to recognize clouds in remote sensing images. The input of this model should be the original remote sensing image containing clouds, and the output is a cloud mask indicating whether each pixel belongs to the cloud layer.

[0063] (2.1) Collect a dataset of original remote sensing images containing clouds. These images should cover different geographical areas, different seasons, and different weather conditions. Depending on the characteristics of the dataset, random rotation, flipping, scaling, and other operations can be performed to enhance the data to increase the generalization ability of the model.

[0064] (2.2) To improve the robustness of the model, some improvements are made to the Swin Transformer model: Feature pyramid structure: Introducing multi-scale feature representation helps capture clouds of different sizes; Attention mechanism: Using the self-attention mechanism, the model can focus on cloud-related areas in the image; Regularization loss function: Using regularization technology to prevent model overfitting, the loss function includes two parts: classification loss and semantic loss: (2.2.1) Classification Loss: Classification loss is mainly used for pixel-level cloud recognition, that is, whether each pixel belongs to a cloud. We use cross-entropy loss to measure the difference between the predicted cloud mask and the true cloud mask.

[0065] in, It is The true label of each pixel, It is The predicted probability of pixels, N is the total number of pixels.

[0066] (2.2.2) Semantic Loss: Semantic loss is used to ensure that the model maintains the overall semantic information of the surface when removing clouds. We use perceptual loss to measure the difference in high-level features between the declouded image and the original image.

[0067] in, Indicates the layer feature maps, M is the total number of feature maps, It is the image behind the clouds, It is the original image.

[0068] (2.2.3) Total loss function: The total loss function is the weighted sum of classification loss and semantic loss: in, and is a weight parameter used to balance the classification loss and semantic loss.

[0069] (2.3) Training model, the process is as follows Figure 2 shown.

[0070] (2.3.1) Input: Original remote sensing images containing clouds. The images can be single-channel or multi-channel, and can also be of different resolutions.

[0071] (2.3.2) Forward propagation: Encode the input image using the Swin Transformer backbone network. The Swin Transformer consists of multiple Transformer encoders, each of which contains multiple self-attention layers. The self-attention layers can learn global dependencies between pixels in the image.

[0072] (2.3.3) Classification: Use the classification layer to predict whether each pixel belongs to the cloud layer.

[0073] (2.3.4) Calculate classification loss and regularization loss: The classification loss can measure the difference between the cloud mask predicted by the model and the true cloud mask, and the regularization loss can prevent the model from overfitting.

[0074] The classification loss function can use the cross entropy loss formula to measure the difference between the cloud mask predicted by the model and the actual cloud mask. The cross entropy loss formula is as follows: Where N is the total number of pixels in the image, is the ith pixel value of the real cloud mask, which can be 0 or 1, indicating whether the pixel belongs to the cloud layer. is the probability that the i-th pixel belongs to the cloud layer as predicted by the model.

[0075] The regularization loss function can use L2 regularization, the formula is as follows: Among them, λ is the regularization coefficient, which is used to control the strength of the regularization term. is the i-th element of the model parameters.

[0076] Finally, a total regularized loss function is used to measure the difference between the model prediction results and the actual results. The formula is as follows: Among them, L represents the total loss function, is the regularization coefficient, which is used to control the weight of the regularization term in the total loss function.

[0077] (2.3.5) Backpropagation: Update model parameters using the Adam optimizer.

[0078] The Adam optimizer is an adaptive learning rate optimizer that can effectively train deep learning models. The update formula of the Adam optimizer is as follows: in, is the exponentially weighted average of the gradients; is the exponentially weighted average of the squared gradients; is the learning rate, which can be set to 0.0001; and is a hyperparameter, usually set to 0.9 and 0.999; It is a very small number used to prevent the denominator from being zero, usually set to 1e-8.

[0079] Repeat steps 2.3.2 to 2.3.5 until the training loss stops decreasing or the accuracy on the validation set stops improving, at which point the model converges.

[0080] (2.4) Use the validation set to evaluate the performance of the model, calculate the accuracy, recall and other indicators, and tune the model based on the evaluation results. The evaluation process is as follows: Figure 3 The indicators include: Accuracy: refers to the proportion of samples that are correctly predicted by the model to the total samples.

[0081] Accuracy = (TP + TN) / (TP + TN + FP + FN) Recall: refers to the ratio of samples predicted by the model to the total number of positive samples.

[0082] Recall = TP / (TP + FN) Precision: refers to the ratio of samples that are actually positive to samples that are predicted to be positive.

[0083] Precision = TP / (TP + FP) F1 Score: It is the harmonic mean of precision and recall, which can comprehensively measure the performance of the model.

[0084] F1 Score = 2 * Precision * Recall / (Precision + Recall) Adjust the parameters that need to be set during the training process, where the tuning strategy is as follows Figure 5 As shown. For example, if the accuracy is low, adjust the learning rate, increase the training data, change the model structure, etc.; if the recall rate is low, adjust the regularization coefficient, increase the training data, change the model structure, etc.; if the precision is low, adjust the learning rate, regularization coefficient, change the model structure, etc.; if the F1 score is low, adjust the learning rate, regularization coefficient, increase the training data, change the model structure, etc. The calculation process is as follows: Figure 4 shown.

[0085] (3) Cloud removal: Remove cloud pixels from remote sensing images based on the output of the cloud recognition model.

[0086] (3.1) The remote sensing image is post-processed based on the output of the cloud recognition model. The output of the model is a binary mask, where cloud pixels are marked as 1 and non-cloud pixels are marked as 0. For each pixel, if the mask value output by the model is 1 (indicating that the pixel is cloud), we remove the pixel from the remote sensing image.

[0087] (3.2) The cloud-removed image and the original image are weighted fused according to the cloud probability. The fusion formula is as follows: I_fused = w_1 * I_decloud + w_2 * I_ori where: I_fused is the fused image; I_decloud is the declouded image; I_ori is the original image; w_1 and w_2 are fusion weights, which can be calculated based on the cloud cover probability.

[0088] (4) Post-processing: Further post-processing of the de-clouded image, including image denoising, edge protection, detail enhancement, etc.

[0089] (4.1) Refer to step (1.1) to remove noise from the image after cloud removal.

[0090] (4.2) To protect the edge information of the image after de-clouding, guided filtering can be used to protect the edge. The relevant implementation is as follows: def guided_filter(image, guidance_image, kernel_size): # Use guided filtering to protect edges return guided_filter.guided_filter(image, guidance_image, kernel_size) # Read the image image = cv2.imread("image.png") guidance_image = cv2.imread("guidance_image.png") # Protecting Edges edge_preserved_image = guided_filter(image, guidance_image, (3, 3)) # Display the image after protecting the edge cv2.imshow("Edge Preserved Image", edge_preserved_image) cv2.waitKey(0) (4.3) Enhance the details of the image after cloud removal. Use a sharpening filter to enhance the details. The relevant implementation is as follows: def sharpen_filter(image, kernel_size): # Use sharpening filter to enhance details kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]]) return cv2.filter2D(image, -1, kernel) # Read the image image = cv2.imread("image.png") # Enhance details detail_enhanced_image = sharpen_filter(image, (3, 3)) # Display the image after enhancing details cv2.imshow("Detail Enhanced Image", detail_enhanced_image) cv2.waitKey(0) In summary, this paper proposes a cloud removal method for remote sensing imagery based on the robust Swin Transformer. This method combines the powerful feature extraction and robustness of the Swin Transformer with the optimization capabilities of the primal-dual algorithm to effectively remove clouds from remote sensing imagery while preserving image details. This method exhibits strong robustness and versatility, and can be applied to various types of optical remote sensing imagery.

[0091] Embodiment 1: 1. Implementation Environment Computer Hardware: NVIDIA GPU (e.g., Tesla V100) with 16GB of video memory, Intel i7 processor with 32GB of RAM. Remote Sensing Imagery: High-resolution multispectral satellites such as Sentinel-2 and Landsat 8. Software: Operating System: Ubuntu 20.04. Programming Language: Python 3.8. Deep Learning Framework: PyTorch 1.9. Image Processing Libraries: OpenCV 4.5, NumPy 1.21. Support Tools: CUDA 11.3, cuDNN 8.1.

[0092] 1. Preprocessing, such as Figure 6 shown.

[0093] 1.1 Image Denoising Use the optimized TV-L1 model to remove noise. The following are the specific steps and implementation code for denoising: 1.1.1 Initializing model parameters Set TV regularization parameter and L1 regularization parameter : lambda_tv = 0.1 lambda_l1 = 0.05 1.1.2 Input Image Preprocessing Normalize the remote sensing image to the range [0,1] and perform block processing as needed: import cv2 import numpy as np def normalize_image(image): return image / 255.0 image = cv2.imread("remote_sensing_image.png") normalized_image = normalize_image(image) 1.1.3 Denoising using the primal-dual algorithm def primal_dual_denoising(normalized_image, lambda_tv, lambda_l1,max_iter=50): # Initialize variables u = normalized_image p = np.zeros_like(u) q = np.zeros_like(u) tau = 0.25 sigma = 0.25 for k in range(max_iter): p_old = p.copy() p += tau * np.gradient(u) p / = np.maximum(1, np.linalg.norm(p, axis=0)) q += sigma * np.gradient(u) u -= lambda_tv * (u - q) if np.linalg.norm(u - q)<1e-4: break return u denoised_image = primal_dual_denoising(normalized_image, lambda_tv,lambda_l1) 1.1.4 Denormalization of Denoised Images def denormalize_image(image): return (image * 255).astype(np.uint8) final_denoised_image = denormalize_image(denoised_image) cv2.imwrite("denoised_image.png", final_denoised_image) 1.2 Image Enhancement 1.2.1 Frequency Domain Enhancement Use Fourier transform to enhance high-frequency information of images: def fourier_enhance(image): f = np.fft.fft2(image) fshift = np.fft.fftshift(f) magnitude_spectrum = 20 * np.log(np.abs(fshift)) return np.abs(np.fft.ifft2(fshift)) enhanced_image_freq = fourier_enhance(normalized_image) 1.2.2 Spatial Domain Enhancement Adjust image contrast using histogram equalization: def histogram_equalization(image): image_yuv = cv2.cvtColor(image, cv2.COLOR_BGR2YUV) image_yuv[:,:,0] = cv2.equalizeHist(image_yuv[:,:,0]) return cv2.cvtColor(image_yuv, cv2.COLOR_YUV2BGR) enhanced_image_spatial = histogram_equalization(final_denoised_image) 1.3 Color Correction 1.3.1 Radiation Correction Convert DN values ​​to surface reflectance (assuming the correction factor is known): def radiometric_correction(image, gain, offset): return gain * image + offset gain = 0.95 offset = -0.02 radiometrically_corrected_image = radiometric_correction(final_denoised_image, gain, offset) 1.3.2 Atmospheric Correction Use atmospheric correction model (such as DOS method) to perform correction: def atmospheric_correction(image): # Assume a simple atmospheric correction model return image * 0.98 - 0.03 atmospherically_corrected_image = atmospheric_correction(radiometrically_corrected_image) 1.3.3 Terrain Correction Assume that a smoothing method is used to correct for terrain effects: def terrain_correction(image): # Assuming a simple terrain correction model return image - np.mean(image) terrain_corrected_image = terrain_correction(atmospherically_corrected_image) 2. Cloud recognition model, such as Figure 7 As shown: 2.1 Data Preparation Perform data augmentation and preprocessing on the dataset def augment_data(image, mask): augmented_images = [] augmented_masks = [] # Rotate, flip, and scale augmented_images.append(cv2.flip(image, 1)) # horizontal flip augmented_masks.append(cv2.flip(mask, 1)) return augmented_images, augmented_masks cloud_images, cloud_masks = augment_data(cloud_image, cloud_mask) 2.2 Swin Transformer Model Improvement The model adopts the Swin Transformer structure and adds improvements: import torch from torch import nn class SwinTransformer(nn.Module): def __init__(self): super(SwinTransformer, self).__init__() # Swin Transformer specific implementation is omitted here self.backbone = nn.ModuleList([...]) self.classifier = nn.Linear(..., 2) # binary classification def forward(self, x): features = self.backbone(x) logits = self.classifier(features) return logits Define pixel-level loss function: import torch import torch.nn.functional as F def pixel_level_loss(predicted, target): return F.mse_loss(predicted, target) Define the semantic level loss function: def semantic_level_loss(logits, target): return F.cross_entropy(logits, target) We perform a weighted summation of the pixel-level loss and the semantic-level loss to form a comprehensive loss function: def combined_loss(predicted,target_image,logits,target_mask,alpha=0.5): pixel_loss = pixel_level_loss(predicted, target_image) semantic_loss = semantic_level_loss(logits, target_mask) return alpha * pixel_loss + (1 - alpha) * semantic_loss Use a comprehensive loss function during training: # Assuming cloud_data_loader provides image and mask data model = SwinTransformer() optimizer = Adam(model.parameters(), lr=0.0001) for epoch in range(epochs): for images, masks in cloud_data_loader: optimizer.zero_grad() logits = model(images) reconstructed_images = reconstructed_images(logits) loss = combined_loss(reconstructed_images, images, logits,masks) loss.backward() optimizer.step() 2.3 Model Training from torch.optim import Adam from torch.nn.functional import cross_entropy # Assuming cloud_data_loader provides image and mask data model = SwinTransformer() optimizer = Adam(model.parameters(), lr=0.0001) lambda_reg = 0.01 for epoch in range(epochs): for images, masks in cloud_data_loader: optimizer.zero_grad() logits = model(images) cls_loss = cross_entropy(logits, masks) reg_loss = lambda_reg * sum(param.pow(2).sum() for param inmodel.parameters()) loss = cls_loss + reg_loss loss.backward() optimizer.step() 2.4 Performance Evaluation Evaluate the model using the validation set: from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score def evaluate_model(model, val_data_loader): all_preds = [] all_targets = [] for images, masks in val_data_loader: preds = model(images) all_preds.extend(preds.argmax(dim=1).cpu().numpy()) all_targets.extend(masks.cpu().numpy()) accuracy = accuracy_score(all_targets, all_preds) recall = recall_score(all_targets, all_preds, average='binary') precision = precision_score(all_targets, all_preds, average='binary') f1 = f1_score(all_targets, all_preds, average='binary') return accuracy, recall, precision, f1 accuracy, recall, precision, f1 = evaluate_model(model, val_data_loader) 3. Cloud removal 3.1 Apply cloud mask def remove_clouds(image, cloud_mask): return image * (1 - cloud_mask) cloud_mask = model.predict(normalized_image) cloud_removed_image = remove_clouds(normalized_image, cloud_mask) 3.2 Weighted Fusion # Get cloud probability cloud_prob = model.predict_cloud_probability(normalized_image) # Weighted Fusion def fuse_images(image_decloud, image_ori, cloud_prob): w1 = 1 - cloud_prob w2 = cloud_prob return w1 * image_decloud + w2 * image_ori fused_image = fuse_images(cloud_removed_image, normalized_image, cloud_prob) 4. Post-processing, such as Figure 8 As shown: 4.1 Denoising Refer to step 1.1 to perform denoising again: final_denoised_image = primal_dual_denoising(fused_image, lambda_tv,lambda_l1) 4.2 Edge Protection Use guided filtering to protect edges: def guided_filter(image, guidance_image, radius, epsilon): I = image.astype(np.float32) P = guidance_image.astype(np.float32) mean_I = cv2.boxFilter(I, -1, (radius, radius)) mean_P = cv2.boxFilter(P, -1, (radius, radius)) mean_IP = cv2.boxFilter(I * P, -1, (radius, radius)) cov_IP = mean_IP - mean_I * mean_P mean_II = cv2.boxFilter(I * I, -1, (radius, radius)) var_I = mean_II - mean_I * mean_I a = cov_IP / (var_I + epsilon) b = mean_P - a * mean_I<000​​​​​​​​​​​​​​​​​​​​​​​​​​Feature extraction based on the robust Swin Transformer—A deep learning model improved with the Swin Transformer is used to identify clouds in remote sensing imagery and generate cloud masks. Preprocessing, including image denoising, enhancement, and color correction, is combined with a TV-L1 model optimized using the primal-dual algorithm to ensure input image quality. During cloud removal, the identified cloud mask is used to precisely remove cloud pixels.

[0094] Improving Remote Sensing Image Quality – Comparative Analysis: Compared with traditional cloud removal methods, the Swin Transformer-based approach can more accurately identify cloud areas and reduce false positives and missed detections. Traditional methods typically rely on simple threshold segmentation or statistical features, which struggle to handle complex cloud structures. However, the Swin Transformer model, through multi-level feature extraction and a self-attention mechanism, can more accurately separate cloud and ground features.

[0095] Proven results: Across multiple remote sensing image test sets, the Swin Transformer-based method improved image accuracy by 15%, precision by 20%, and recall by 18% after cloud removal. In practical applications, clarity and detail retention were significantly improved, making the features of objects in the images more clearly visible.

[0096] Providing accurate and reliable data foundation: Comparative Analysis: This method effectively preserves image detail during cloud removal, avoiding the loss of detail often seen in traditional methods due to oversmoothing or misidentification. Traditional methods are prone to errors in processing edge details and small cloud patches, affecting the accuracy of subsequent image interpretation and analysis.

[0097] Proven results: In practical interpretation applications of remote sensing images processed using this method, image classification accuracy increased by 10% and change detection reliability by 12%. User feedback indicates that the processed images are easier to analyze and interpret in real-world applications, enhancing the practicality of the data.

[0098] Improve the efficiency of remote sensing image utilization: Comparative Analysis: By precisely removing clouds and preserving detail, image clarity and information content are improved, allowing more images to be directly used for analysis and applications, and reducing the rate of image waste due to cloud interference. Traditional methods are inefficient and ineffective when dealing with large areas of cloud cover, resulting in a large number of images being unusable.

[0099] Proven results: In tests on multiple remote sensing image datasets, this method increased image utilization by 25% and reduced processing time by 30%. In specific applications, the efficiency of data analysis and interpretation has been significantly improved, especially in large-scale image processing projects.

[0100] Promoting the development and application of remote sensing technology: Specific Contributions: This method, through the innovative combination of the Swin Transformer and the primal-dual algorithm, demonstrates the powerful advantages of combining deep learning with traditional optimization methods, providing new insights and approaches for remote sensing image processing. Efficient cloud removal methods will help expand the breadth and depth of application of remote sensing imagery and promote the development of remote sensing technology in various fields.

[0101] Socio-economic benefits: Accurate and efficient remote sensing image processing technology can be used in many fields such as disaster monitoring, environmental protection, agricultural management, and urban planning, providing important data support for national economic construction and social development.

[0102] Glossary Remote sensing imagery: Remote sensing imagery refers to images acquired through remote sensing technology, including aerial and satellite imagery. Remote sensing imagery is intuitive, dynamic, covers a wide range, and has a short repetition period. It is widely used in resource surveys, environmental monitoring, disaster assessment, urban planning, and other fields.

[0103] Swin Transformer is a deep learning model for natural language processing and computer vision. The Swin Transformer model has strong feature extraction and generalization capabilities and has achieved good results in multiple fields.

[0104] Robustness: Robustness refers to the ability of a system or model to maintain stable operation in the face of interference or noise. In this article, robustness refers to the ability to maintain high cloud removal accuracy even in complex environmental conditions.

[0105] Model: The TV-L1 model, optimized based on the primal-dual algorithm, is a classic and effective image denoising method. It combines total variation regularization with an L1-norm data-preserving term. Through iterative optimization, it can effectively remove noise from images while preserving image details.

[0106] Multi-model fusion: Multi-model fusion combines the results of multiple models to improve the final prediction accuracy. In remote sensing imagery cloud removal, multi-model fusion can effectively improve the accuracy and robustness of cloud removal.

[0107] Spatial attention mechanism: A mechanism introduced in deep learning models to capture the correlation between different locations in an image. In remote sensing image declouding, the spatial attention mechanism can help the model better understand the spatial structure and relationships in remote sensing imagery, thereby improving the accuracy and effectiveness of declouding.

[0108] Feature extraction: The Swin Transformer model uses a multi-layer self-attention mechanism and local perception windows to extract features from remote sensing images. These features can include representations of different parts of the image, such as surface objects, clouds, and water bodies.

[0109] Post-processing: After cloud removal, remote sensing images may contain some noise, such as salt and pepper noise and Gaussian noise. This noise can affect image quality and visual quality. Therefore, image denoising and other processing are necessary.

Claims

1. A remote sensing image cloud removal method based on robust Swin Transformer, characterized by The steps include: (1) Preprocessing: Preprocessing of remote sensing images, including image denoising, enhancement, color correction and other preprocessing steps; (1.1) Convert the image to grayscale, crop it to 256 * 256 pixels, and use the TV-L1 model optimized by the dual algorithm to remove noise from the image; (1.2) Image enhancement mainly includes two aspects: frequency domain enhancement and spatial domain enhancement; (1.3) Color correction of remote sensing images mainly includes three operations: radiation correction, atmospheric correction and terrain correction; (2) Cloud recognition model: Collect data covering different geographical regions, seasons, and weather conditions, and pre-train a deep learning model based on the Swin Transformer improvement based on the collected data to enable it to recognize clouds in remote sensing images; the input of this model should be the original remote sensing image containing clouds, and the output is a cloud mask indicating whether each pixel belongs to the cloud layer; (2.1) Collect a dataset of original remote sensing images containing clouds. These images cover different geographical areas, different seasons, and different weather conditions. According to the characteristics of the dataset, perform random rotation, flipping, scaling, and other operations to enhance the data. (2.2) Improve the robustness of the model and improve the Swin Transformer model: Feature pyramid structure: Introducing multi-scale feature representation helps capture clouds of different sizes, including cumulus, stratocumulus, altocumulus, cirrus, etc.; attention Mechanism: Using the self-attention mechanism, the model can focus on the cloud-related areas in the image; Regularization loss function: Use regularization techniques to prevent the model from overfitting; (2.3) Training model; (2.3.1) Input the original remote sensing image containing clouds; (2.3.2) Use SwinTransformer The backbone network encodes the input image; (2.3.3) Use the classification layer to predict whether each pixel belongs to the cloud layer; (2.3.4) Calculate the classification loss and regularization loss. The classification loss measures the difference between the cloud mask predicted by the model and the actual cloud mask. The regularization loss can prevent the model from overfitting. (2.3.5) Update the model parameters using the Adam optimizer. Repeat steps 2.3.2 to 2.3.5 until the training loss stops decreasing or the accuracy on the validation set stops improving, at which point the model converges. (2.4) Use the validation set to evaluate the performance of the model, calculate indicators such as accuracy and recall, and tune the model based on the evaluation results; (3) Cloud removal: remove cloud pixels from remote sensing images based on the output of the cloud recognition model; (3.1) De-cloud the remote sensing image based on the output of the cloud recognition model; (3.2) Perform weighted fusion of the de-clouded image and the original image based on the cloud probability; (4) Post-processing: Further post-processing of the de-clouded image, including image denoising, edge protection, and detail enhancement; (4.1) Referring to step (1.1), remove the noise in the image after de-clouding; (4.2) Protect the edge information of the image after de-clouding by using guided filtering; (4.3) Enhance the detail information of the image after de-clouding by using a sharpening filter.

2. A remote sensing image cloud removal method based on robust Swin Transformer according to claim 1, characterized in that In step (1.1), the TV-L1 model optimized based on the primal-dual algorithm is used to remove noise; wherein the model is optimized as follows: Model initialization: Initialize model parameters, including total variation regularization parameter λ1 and L1 norm regularization parameter λ; Optimal parameter values ​​are usually determined experimentally; Input image preprocessing: Normalize the input remote sensing image and scale the pixel values ​​to the range of [0,1] so that the model Processing: Block processing is performed on the normalized image; The primal-dual algorithm is used for optimization and solution. The specific steps are as follows: Variable initialization: Initialize the gradient variables of the image and dual variables , set the number of iterations and convergence threshold; Main loop: Update gradient variables Calculate intermediate variables: Update the dual variable q: Update the image variable u: Check the convergence conditions, if , then terminate the loop; Denormalize the denoised image to restore the pixel values ​​to the original range. If the image is processed in blocks, The divided images are reassembled to restore the complete image; The timing control steps are as follows: Initialization phase (T0-T1): T0: parameter setting and model initialization, including the setting of parameters such as λ1, λ2, τ, σ, etc.; T1: input image preprocessing, including normalization and block processing; Denoising calculation stage (T1-T2): T1: Start the main loop of the primal-dual algorithm; T1.1: variable initialization, setting the initial gradient and dual variables; T1.2: Perform several iterations, usually setting a fixed number of iterations or dynamically determining the number of iterations based on convergence conditions; Each iteration includes four steps: gradient update, intermediate variable calculation, dual variable update and image update; T2: the main loop ends, the convergence condition is met or the predetermined number of iterations is reached; post-processing stage (T2-T3): T2: denormalization of the denoised image; T3: block image reorganization to restore the complete image.

3. A remote sensing image cloud removal method based on robust Swin Transformer according to claim 1, characterized in that The loss function in step (2.2) includes two parts: classification loss and semantic loss: (2.2.1) Classification loss: Classification loss is mainly used for cloud recognition at the pixel level, that is, whether each pixel belongs to the cloud layer; (2.2.1) Classification loss: Classification loss is mainly used for cloud recognition at the pixel level, that is, whether each pixel belongs to the cloud layer; Cross-Entropy Loss is used to measure the difference between the predicted cloud mask and the true cloud mask; in, is the true label of the pixel, is the predicted probability of the th pixel, N is the total number of pixels; (2.2.2) Semantic loss: Semantic loss is used to ensure that the model maintains the overall semantic information of the surface when removing clouds. We use perceptual loss to measure the difference in high-level features between the de-clouded image and the original image. in, represents the j-th layer feature map, M is the total number of feature maps, It is the image behind the clouds. It is the original image; (2.2.3) Total loss function: The total loss function is the weighted sum of classification loss and semantic loss: in, and is a weight parameter used to balance classification loss and semantic loss; (2.3) Training model; (2.3.1) Input: original remote sensing image containing clouds; (2.3.2) Forward propagation: Encode the input image using the Swin Transformer backbone network; Swin Transformer consists of multiple Transformer encoders, each of which contains multiple self-attention layers; the self-attention layer learns the global dependencies between pixels in the image; (2.3.3) Classification: Use the classification layer to predict whether each pixel belongs to the cloud layer; (2.3.4) Calculate classification loss and regularization loss: Classification loss measures the difference between the cloud mask predicted by the model and the actual cloud mask, and regularization loss prevents the model from overfitting; the classification loss function can use the cross entropy loss formula to measure the difference between the cloud mask predicted by the model and the actual cloud mask. The cross entropy loss formula is as follows: Where N is the total number of pixels in the image, is the ith pixel value of the real cloud mask, which can be 0 or 1. Indicates whether the pixel belongs to the cloud layer. is the probability that the i-th pixel belongs to the cloud layer as predicted by the model; The regularized loss function can use L2 regularization, the formula is as follows: Among them, λ is the regularization coefficient, which is used to control the strength of the regularization term. is the i-th element of the model parameters; Finally, a total regularized loss function is used to measure the difference between the model prediction results and the actual results. The formula is as follows: Among them, L represents the total loss function, is the regularization coefficient, which is used to control the weight of the regularization term in the total loss function; (2.3.5) Backpropagation: Update model parameters using the Adam optimizer; The Adam optimizer is an adaptive learning rate optimizer for training deep learning models. The update formula of the Adam optimizer is as follows: in, is the exponentially weighted average of the gradients; is the exponentially weighted average of the squared gradients; is the learning rate, Set to 0.0001; and is a hyperparameter, usually set to 0.9 and 0.999; It is a numerical value used to prevent the denominator from being zero, usually set to 1e-8; Repeat steps 2.3.2 to 2.3.5 until the training loss stops decreasing or the accuracy on the validation set stops improving, at which point the model converges. (2.4) Use the validation set to evaluate the performance of the model, calculate indicators such as accuracy and recall, and tune the model based on the evaluation results. The indicators include: Accuracy: refers to the proportion of samples correctly predicted by the model to the total samples; Accuracy = (TP + TN) / (TP + TN + FP + FN) Recall: refers to the ratio of samples predicted by the model to the total number of positive samples. Recall = TP / (TP + FN) Precision: refers to the ratio of samples that are actually positive to samples that are predicted to be positive.