A pixel extraction reconstruction method for large-size SAR image simulation of unmanned aerial vehicles

By combining image size alignment and automatic edge patching mechanisms with array slicing and CycleGAN models, the computational complexity and memory consumption issues in large-size image processing of UAV-borne SAR systems are solved, achieving efficient and accurate image reconstruction and stitching, which is suitable for high-resolution remote sensing applications.

CN120892586BActive Publication Date: 2026-06-02NANJING INST OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING INST OF TECH
Filing Date
2025-10-09
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

When processing large-size images, UAV-borne SAR systems suffer from problems such as high computational complexity, excessive memory consumption, inaccurate image reconstruction, and edge misalignment, which affect the efficiency and accuracy of disaster monitoring.

Method used

It employs image size alignment strategies, automatic edge-padding mechanisms, and block numbering logic, and uses array slicing to replace multiple loops for image segmentation and stitching. It also combines deep learning models such as CycleGAN for large-size image processing.

Benefits of technology

It significantly improves image processing efficiency, reduces memory usage, minimizes boundary line issues, ensures spatial consistency and visual quality of image reconstruction, adapts to various image types and sub-block sizes, and expands the application scope of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120892586B_ABST
    Figure CN120892586B_ABST
Patent Text Reader

Abstract

This invention discloses a pixel extraction and reconstruction method for simulating large-size SAR images from unmanned aerial vehicles (UAVs), comprising: acquiring the path and image type of the image to be processed, and creating a storage directory; reading the original width and height of the image to be processed; calculating the width and height of the image after filling according to a preset sub-block size; adjusting the image to be processed to the filled width and height, and storing the filled image in the storage directory; segmenting the filled image into multiple sub-block images using an array slicing method; creating an empty array with the same size as the filled image as a reconstruction canvas; sequentially reading each sub-block image according to the number of rows and columns of the sub-block, and writing the sub-block image into the corresponding position on the reconstruction canvas using an array slicing method; converting the reconstruction canvas into an image, adjusting it to the width and height of the original image, obtaining the reconstructed image and storing it; and deleting the storage directory of the sub-block images. This invention improves segmentation and reconstruction efficiency, ensures reconstruction accuracy, and enhances robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of remote sensing image processing and computer vision interdisciplinary technology, and in particular relates to a pixel extraction and reconstruction method for simulating large-size SAR images from unmanned aerial vehicles. Background Technology

[0002] Unmanned aerial vehicle (UAV) SAR systems, with their mobility, flexibility, lack of weather and lighting limitations, and ability to perform all-weather, day-and-night imaging, have become an important means of acquiring high-resolution surface observation data. Compared with traditional satellite SAR, UAV SAR gets closer to the observation target and can acquire image data with centimeter-level to meter-level resolution. However, a single flight can generate large-size images ranging from tens to hundreds of gigabytes, such as scene images with a swath width of several kilometers and a resolution of 0.5 meters. Moreover, these images exhibit significant speckle noise, geometric distortion, and radiometric inhomogeneity.

[0003] When processing such images, due to their large data volume and high resolution, direct processing often faces problems such as excessive memory consumption and low computational efficiency. Current technologies typically employ a method of segmenting the large image into multiple sub-blocks for step-by-step processing, and then reconstructing the complete image from the processed sub-blocks. However, traditional segmentation methods often use multiple loops for pixel-level processing, resulting in high computational complexity and slow processing speed. Furthermore, during the reconstruction process, inaccurate sub-block stitching can easily lead to edge misalignment and image distortion, affecting the quality of the reconstructed image.

[0004] With the development of generative adversarial networks (GANs), unsupervised image translation models such as CycleGAN have been widely applied in fields such as style transfer, pseudo-color conversion of remote sensing images, and SAR image reconstruction. CycleGAN, by introducing cycle consistency constraints, can achieve high-quality mapping between different image domains without requiring paired samples, exhibiting good cross-domain generalization ability. However, image generation networks like CycleGAN have certain limitations when processing large images, such as 2048×2048 or 4096×4096. Inputting large images into deep neural networks leads to a surge in GPU memory consumption, and training is prone to interruption due to memory overflow. Therefore, they are typically limited to processing smaller images of 256×256 or 512×512. Large images often have dimensions that are not divisible by an integer, resulting in inconsistent image patch sizes in the last row or column, affecting the accuracy of model training and subsequent image stitching. Cropping or padding may lead to loss of original image information or distorted reconstruction. In practical applications, to accommodate network input, large images are often divided into several fixed-size blocks for separate processing. However, because the slicing operation cannot fully preserve contextual information, CycleGAN is prone to generating regions with inconsistent styles or obvious dividing lines at the boundaries of each image block, resulting in grid-like or splicing marks in the reconstructed image.

[0005] In UAV-borne SAR disaster monitoring, after an earthquake or flood, it is necessary to quickly segment and process the acquired large-scale SAR images of the disaster area to identify areas of damaged buildings, and then reconstruct a complete disaster map from the local results. If traditional methods are used, not only is segmentation too time-consuming, affecting rescue decisions, but the reconstructed image may also misjudge road connectivity due to inter-block misalignment, causing serious consequences.

[0006] Therefore, given the characteristics of UAV-borne SAR (Synthetic Aperture Radar) images, such as large size, strong noise, and the need for high-precision reconstruction, there is an urgent need for a technical solution that can efficiently segment, consume little memory, accurately reconstruct, and adapt to deep learning models, in order to promote the application of UAV-borne SAR in high-precision remote sensing applications. Summary of the Invention

[0007] This invention addresses the shortcomings of existing technologies by providing a method for large-size image segmentation and reconstruction based on extracted pixels. By introducing image size alignment strategies, automatic edge-padding mechanisms, block numbering logic, and lossless stitching methods during reconstruction, the method achieves information preservation and edge continuity during image segmentation, improves the spatial consistency and visual quality of the final image translation results, and is applicable to high-resolution image processing scenarios such as SAR images.

[0008] To achieve the above objectives, the present invention adopts the following technical solution:

[0009] A pixel extraction and reconstruction method for simulating large-size SAR images from UAVs includes the following steps:

[0010] S1. Obtain the path and image type of the image to be processed, and create a storage directory;

[0011] S2. Read the image to be processed and obtain its original width and original height;

[0012] S3. Calculate the width and height of the image to be processed after filling according to the preset sub-block size. The width and height after filling are both integer multiples of the sub-block size.

[0013] S4. Adjust the image to be processed to the width and height after filling, obtain the filled image, and save the filled image in the storage directory;

[0014] S5. Determine the number of rows and columns of the segmented sub-blocks based on the size of the filled image and the size of the sub-blocks;

[0015] S6. Based on the number of rows and columns of the sub-blocks, the filled image is divided into multiple sub-block images using array slicing. Each sub-block image is stored in the storage directory and its storage path is recorded.

[0016] S7. Obtain the storage directory of the sub-block image, the width and height of the padded image, and the width and height of the original image;

[0017] S8. Create an empty array with the same size as the filled image as the reconstruction canvas;

[0018] S9. Based on the number of rows and columns of the sub-block, read the image of each sub-block in sequence, and write the sub-block image to the corresponding position on the reconstruction canvas using array slicing;

[0019] S10. Convert the reconstructed canvas into an image, adjust its width and height to match the original image, obtain the reconstructed image, and save it;

[0020] S11. Delete the storage directory of the sub-block image.

[0021] To optimize the above technical solution, the specific measures also include:

[0022] Furthermore, in S1, the path of the image to be processed is a local storage path or a network path, and the image type includes jpg format and png format;

[0023] The creation of the storage directory is specifically done recursively to ensure that parent directories at all levels are automatically created when the parent directory does not exist, and that the output directory is not created again when it already exists. The naming rule for the storage directory is set to "original image name + _split + _timestamp".

[0024] Furthermore, S2 specifically refers to:

[0025] Open image files using functions from a library that supports multiple image formats;

[0026] The original width and original height can be obtained through the size property of the image object. The first element of the tuple returned by the size property is the width, and the second element is the height.

[0027] If an error occurs during the reading process, the error message will be logged, and empty image data and zero-value size information will be returned.

[0028] Furthermore, S3 specifically refers to:

[0029] The preset sub-block size is used to calculate the width and height of the image after filling, based on the preset sub-block size. The calculation method is as follows:

[0030] The formula for calculating the width after padding is: padded_width = max (split_width, math.ceil(original_width / split_width) * split_width), where padded_width is the width of the image to be processed after padding, split_width is the width of the sub-block, and original_width is the original width of the image to be processed;

[0031] The formula for calculating the height after filling is: padded_height = max (split_height, math.ceil(original_height / split_height) * split_height), where padded_height is the height of the image to be processed after filling, split_height is the height of the sub-block, and original_height is the original height of the image to be processed;

[0032] The `math.ceil` function is used to round up; the `max` function is used to find the maximum value.

[0033] Furthermore, S4 specifically refers to:

[0034] An image scaling algorithm is used to adjust the width and height of the image to be processed to the padded width and height. The storage path of the padded image is set to "padded_image + image type" in the output directory, and the original color mode of the image to be processed is preserved when storing.

[0035] Furthermore, S5 specifically refers to:

[0036] The formula for calculating the number of sub-block rows is: blocks_row_num = padded_height / split_height, where blocks_row_num represents the number of sub-block rows, padded_height represents the height of the image to be processed after filling, and split_height represents the height of the sub-block;

[0037] The formula for calculating the number of sub-block columns is: blocks_col_num = padded_width / split_width, where blocks_col_num is the number of sub-block columns, padded_width is the width of the image to be processed after filling, and split_width is the width of the sub-block.

[0038] Furthermore, S6 specifically refers to:

[0039] The padded image is converted into a NumPy array with dimensions padded_height * padded_width * channels. Here, padded_height represents the height of the padded image, padded_width represents the width of the padded image, and channels represents the number of channels in the image. Images in RGB mode have 3 channels, images in RGBA mode have 4 channels, and images in grayscale mode have 1 channel.

[0040] For the sub-block in row 'row' and column 'col':

[0041] The starting row coordinates are start_row = row * split_height; where start_row is the starting row coordinates and split_height represents the height of the sub-block.

[0042] The coordinates of the end row are given by end_row = start_row + split_height; where end_row is the coordinates of the end row, start_row is the coordinates of the start row, and split_height represents the height of the sub-block.

[0043] The starting column coordinates are start_col = col * split_width; where start_col is the starting column coordinates and split_width is the width of the sub-block.

[0044] The coordinates of the end column are given by end_col = start_col + split_width; where end_col is the coordinate of the end column.

[0045] Extract the array data corresponding to the sub-block using the array slice `img_array [start_row:end_row, start_col:end_col]`; where `img_array` is a NumPy array.

[0046] The extracted sub-block array data is converted into image objects using the Image.fromarray function and stored according to the naming rule of "padded_image + row index + column index + image type";

[0047] The storage paths of the sub-block images are all recorded in a list, which corresponds one-to-one with the row and column indices of the sub-blocks.

[0048] Furthermore, S7 specifically refers to:

[0049] The process involves traversing the storage directory to obtain all sub-block images, the width of the image to be processed after filling, the height of the image to be processed after filling, the original width of the image to be processed, and the original height of the image to be processed. If any abnormalities are found in the obtained size information, the reconstruction process is terminated and an error message is returned.

[0050] S8 specifically refers to:

[0051] The dimensions of the empty array are set to padded_height*padded_width*channels, where padded_height represents the height of the image to be processed after being padded, padded_width is the width of the image to be processed after being padded, and channels is the number of channels of the image, which is consistent with the number of channels of the image before segmentation;

[0052] An empty array has its data type set to an 8-bit unsigned integer, and its initial value is set to 0.

[0053] Furthermore, S9 specifically refers to:

[0054] For the sub-block in row 'row' and column 'col':

[0055] The filename of the sub-padded image is "padded_image + row + col + image type", and the corresponding sub-padded image file can be found in the storage directory accordingly;

[0056] If the sub-block image file does not exist, record a warning message and skip the sub-block, then continue processing other sub-blocks;

[0057] Read the sub-block image and convert it to a NumPy array;

[0058] The position of this sub-block image in the reconstruction canvas is determined by the following formula:

[0059] The starting row coordinates are start_row = row * split_height; where start_row is the starting row coordinates and split_height represents the height of the sub-block.

[0060] The coordinates of the end row are given by end_row = start_row + split_height; where end_row is the coordinates of the end row, start_row is the coordinates of the start row, and split_height represents the height of the sub-block.

[0061] The starting column coordinates are start_col = col * split_width; where start_col is the starting column coordinates and split_width is the width of the sub-block.

[0062] The coordinates of the end column are given by end_col = start_col + split_width; where end_col is the coordinate of the end column.

[0063] The sub-block data is written to the reconstructed canvas array `rebuilt_array` by slicing the array `rebuilt_array [start_row:end_row, start_col:end_col] = block_array`, where `block_array` represents the NumPy array of the sub-block image.

[0064] Furthermore, S10 specifically refers to:

[0065] Convert the reconstructed canvas array into an image object;

[0066] A scaling algorithm is used to adjust the image object to its original width and height;

[0067] The naming convention for reconstructed images is set to "merge_ + original image name + image type";

[0068] The storage path for the reconstructed image is set to the parent directory of the sub-block storage directory.

[0069] The beneficial effects of this invention are:

[0070] Replacing traditional multiple loops with array slicing for image segmentation and stitching reduces the time complexity of image segmentation and reconstruction from O(n^2) to O(n^2). 2 m 2 The processing efficiency is reduced to O(nm) (where n and m are the number of pixels in the height and width directions of the image, respectively), which significantly improves processing efficiency.

[0071] By segmenting large images into sub-blocks for processing, memory consumption is significantly reduced, resolving the issue of program crashes or slow performance caused by insufficient memory when CycleGAN directly processes large images. This makes style transfer and other processing of large images possible. It can adapt to the step-by-step processing requirements of models like CycleGAN for large images, shortening the overall processing time.

[0072] This invention can significantly reduce boundary line problems caused by image stitching. Traditional methods often encounter problems such as color abruptness and edge misalignment when restoring image blocks, resulting in obvious grid-like boundary lines or discontinuous areas in the generated image. This invention adopts a unified edge patching, non-overlapping block cutting, and in-situ alignment restoration mechanism to ensure seamless stitching of image blocks during reconstruction, minimizing boundary errors in image reconstruction.

[0073] It is highly adaptable and suitable for various types of images and different sub-block size settings. It has good versatility and flexibility, especially in the field of large-size image processing such as SAR images. It can also be seamlessly integrated with deep learning models such as CycleGAN, expanding the application scope of the model. Attached Figure Description

[0074] Figure 1 This is an overall flowchart of the method of the present invention;

[0075] Figure 2 Here is the flowchart for the image segmentation module;

[0076] Figure 3 A schematic diagram illustrating pixel extraction and segmentation into sub-image blocks for a large image;

[0077] Figure 4 Here is a flowchart of the image reconstruction module;

[0078] Figure 5 This is a flowchart illustrating the combination of this invention with CycleGAN for large-scale image block processing. Detailed Implementation

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

[0080] Example 1

[0081] This invention proposes a pixel extraction and reconstruction method for simulating large-size SAR images from unmanned aerial vehicles (UAVs). The overall process of this method is as follows: Figure 1 As shown, it includes two parts: image segmentation and image reconstruction. Image segmentation is as follows: Figure 2 As shown, image reconstruction is as follows Figure 4 As shown, the overall method includes the following steps:

[0082] S1. Obtain the path and image type of the image to be processed, and create a storage directory; the path of the image to be processed is a local storage path or a network path, and the image type includes jpg and png formats; the creation of the storage directory is specifically done recursively to ensure that parent directories at all levels are automatically created when the parent directory does not exist, and that the output directory is not created repeatedly when it already exists, thus avoiding redundant operations; the naming rule of the storage directory is set to "original image name + _split + _timestamp" to ensure the uniqueness of the directory and prevent the segmented sub-blocks of different images from being confused with each other.

[0083] S2. Read the image to be processed and obtain its original width and original height; specifically:

[0084] Use functions from image reading libraries that support multiple image formats to open image files; such as the Image.open function in the PIL library, to ensure that images of different formats can be read effectively.

[0085] The original width and original height can be obtained through the size property of the image object. The first element of the tuple returned by the size property is the width, and the second element is the height.

[0086] If an error occurs during the reading process, such as the file not existing or the format not being supported, the error message will be logged and empty image data and zero-value size information will be returned.

[0087] S3. Based on the preset sub-block size, calculate the width and height of the image to be processed after filling, where the width and height after filling are both integer multiples of the sub-block size; specifically:

[0088] The preset sub-block size can be adjusted according to the actual application scenario. Typical values ​​are 128×128, 256×256, 512×512, etc., and the width and height of the sub-blocks can be set to the same or different values. Same values ​​result in square sub-blocks, while different values ​​result in rectangular sub-blocks. Based on the preset sub-block size, the width and height of the image to be processed after filling are calculated. When the original width is less than the sub-block width, the filled width is the sub-block width; when the original width is an integer multiple of the sub-block width, the filled width is equal to the original width; otherwise, the filled width is the minimum value that is greater than the original width and an integer multiple of the sub-block width. The same applies to the height. The calculation method is expressed by the following formula:

[0089] The formula for calculating the padded width is: padded_width = max (split_width, math.ceil(original_width / split_width) * split_width), where padded_width is the padded width of the image to be processed, split_width is the width of the sub-block, original_width is the original width of the image to be processed, the math.ceil function is used to round up, and the max function is used to get the maximum value.

[0090] The formula for calculating the height after filling is: padded_height = max (split_height, math.ceil(original_height / split_height) * split_height), where padded_height is the height of the image to be processed after filling, split_height is the height of the sub-block, and original_height is the original height of the image to be processed.

[0091] S4. Adjust the image to be processed to the width and height after padding, obtain the padded image, and save the padded image in the storage directory; specifically:

[0092] An image scaling algorithm is used to adjust the image to the width and height after padding, ensuring the clarity and detail retention of the padded image. The storage path for the padded image is set to "padded_image + image type" in the output directory. For example, if the output directory is "test_split_202310011200" and the image type is ".png", then the storage path is "test_split_202310011200 / padded_image.png". The original color mode of the image is preserved during storage, such as RGB, RGBA, and grayscale, ensuring complete preservation of image information.

[0093] S5. Based on the dimensions of the filled image and the sub-block dimensions, determine the number of rows and columns of the segmented sub-blocks; S5 specifically involves:

[0094] The formula for calculating the number of sub-block rows is: blocks_row_num = padded_height / split_height, where blocks_row_num represents the number of sub-block rows, padded_height represents the height of the image to be processed after filling, and split_height represents the height of the sub-block; that is, the height after filling is divided by the height of the sub-block, and the quotient obtained by integer division is the number of sub-block rows.

[0095] The formula for calculating the number of sub-block columns is: blocks_col_num = padded_width / split_width, where blocks_col_num is the number of sub-block columns, padded_width is the width of the image after filling, and split_width is the width of the sub-block. That is, the padded width is divided by the sub-block width using integer division, and the quotient is the number of sub-block columns.

[0096] For example, if the height after filling is 1024 and the height of the child block is 256, then the number of rows in the child block is 1024 / 256=4; if the width after filling is 768 and the width of the child block is 256, then the number of columns in the child block is 768 / 256=3.

[0097] S6. Based on the number of rows and columns of each sub-block, divide the filled image into multiple sub-block images using array slicing. Store each sub-block image in a storage directory and record its storage path; for example... Figure 3 As shown, S6 specifically refers to:

[0098] The padded image is converted into a NumPy array (img_array) with dimensions padded_height * padded_width * channels. Here, padded_height represents the height of the padded image, padded_width represents the width of the padded image, and channels represents the number of channels in the image. Images in RGB mode have 3 channels, images in RGBA mode have 4 channels, and images in grayscale mode have 1 channel.

[0099] For the sub-block in row 'row' (where row ranges from 0 to blocks_row_num - 1) and column 'col' (where col ranges from 0 to blocks_col_num - 1):

[0100] The starting row coordinates are start_row = row * split_height; where start_row is the starting row coordinates and split_height represents the height of the sub-block.

[0101] The coordinates of the end row are given by end_row = start_row + split_height; where end_row is the coordinates of the end row, start_row is the coordinates of the start row, and split_height represents the height of the sub-block.

[0102] The starting column coordinates are start_col = col * split_width; where start_col is the starting column coordinates and split_width is the width of the sub-block.

[0103] The coordinates of the end column are given by end_col = start_col + split_width; where end_col is the coordinate of the end column.

[0104] Extract the array data corresponding to the sub-block using the array slice `img_array [start_row:end_row, start_col:end_col]`; where `img_array` is a NumPy array.

[0105] The extracted sub-block array data is converted into image objects using the Image.fromarray function and stored according to the naming rule of "padded_image + row index + column index + image type"; for example, the sub-block in row 0 and column 1 is stored as "padded_image_0_1.png".

[0106] The storage paths of the sub-block images are all recorded in a list, which corresponds one-to-one with the row and column indices of the sub-blocks.

[0107] S7. Obtain the storage directory of the sub-block image, the width and height of the padded image, and the width and height of the original image; S7 specifically includes:

[0108] The process involves traversing the storage directory to obtain all sub-block images, the width of the image to be processed after filling, the height of the image to be processed after filling, the original width of the image to be processed, and the original height of the image to be processed. If the obtained size information is abnormal, such as being negative or zero, the reconstruction process is terminated and an error message is returned.

[0109] S8. Create an empty array with the same dimensions as the filled image as the reconstruction canvas; specifically:

[0110] The dimensions of the empty array are set to padded_height*padded_width*channels, where padded_height represents the height of the image to be processed after being padded, padded_width is the width of the image to be processed after being padded, and channels is the number of channels of the image, which is consistent with the number of channels of the image before segmentation;

[0111] The data type of the empty array is set to an 8-bit unsigned integer (np.uint8) to match the range of image pixel values ​​from 0 to 255; the initial value of the array is set to 0 to ensure that the uncovered areas do not affect the quality of the reconstructed image.

[0112] S9. Based on the number of rows and columns of each sub-block, read the image of each sub-block sequentially, and write the sub-block image to the corresponding position on the reconstructed canvas using an array slicing method; specifically:

[0113] For the sub-block in row 'row' and column 'col':

[0114] The filename of the sub-padded image is "padded_image + row + col + image type", and the corresponding sub-padded image file can be found in the storage directory accordingly;

[0115] If the sub-block image file does not exist, record a warning message and skip the sub-block, then continue processing other sub-blocks;

[0116] Read the sub-block image and convert it to a NumPy array;

[0117] The position of this sub-block image in the reconstruction canvas is determined by the following formula:

[0118] The starting row coordinates are start_row = row * split_height; where start_row is the starting row coordinates and split_height represents the height of the sub-block.

[0119] The coordinates of the end row are given by end_row = start_row + split_height; where end_row is the coordinates of the end row, start_row is the coordinates of the start row, and split_height represents the height of the sub-block.

[0120] The starting column coordinates are start_col = col * split_width; where start_col is the starting column coordinates and split_width is the width of the sub-block.

[0121] The coordinates of the end column are given by end_col = start_col + split_width; where end_col is the coordinate of the end column.

[0122] The sub-block data is written to the reconstructed canvas array `rebuilt_array` by slicing the array `rebuilt_array [start_row:end_row, start_col:end_col] = block_array`, where `block_array` represents the NumPy array of the sub-block image.

[0123] S10. Convert the reconstructed canvas into an image, adjust its width and height to match the original image, obtain the reconstructed image, and save it; specifically:

[0124] Convert the reconstructed canvas array into an image object;

[0125] Scaling algorithms, such as bicubic interpolation, are used to adjust the image objects to their original width and height, ensuring that the image size is consistent with the original image before segmentation.

[0126] The naming convention for reconstructed images is set to "merge_ + original image name + image type"; for example, if the original image is "SARMap.jpg", then the reconstructed image is stored as "merge_SARMap.jpg".

[0127] The storage path for the reconstructed image is set to the parent directory of the sub-block storage directory to distinguish it from the original image and the segmentation directory.

[0128] S11. Delete the storage directory of sub-block images. After the reconstructed image is successfully stored, the sub-block storage directory and all sub-block image files contained therein are removed using a recursive deletion method. If errors such as insufficient permissions occur during the deletion process, the error information is logged, but this does not affect the availability of the reconstructed image.

[0129] This invention is highly adaptable and can accommodate the step-by-step processing requirements of models such as CycleGAN for large images. For example, if style transfer of a large image is required using CycleGAN, only the style transfer of the sub-block images obtained in step S6 needs to be performed on each sub-block image to obtain style-transferred sub-block images; then, by performing steps S7-S11 on these style-transferred sub-block images, the style-transferred large image can be reconstructed. Figure 5 As shown, this solves the problem of program crashes or slow operation caused by insufficient memory when CycleGAN directly processes large images.

[0130] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware or a combination of computer software and electronic hardware. 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.

[0131] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should be considered within the scope of protection of the present invention.

Claims

1. A pixel extraction and reconstruction method for simulating large-size SAR images from unmanned aerial vehicles, characterized in that, Includes the following steps: S1. Obtain the path and image type of the image to be processed, and create a storage directory; S2. Read the image to be processed and obtain its original width and original height; S3. Calculate the width and height of the image to be processed after filling according to the preset sub-block size. The width and height after filling are both integer multiples of the sub-block size. S4. Adjust the image to be processed to the width and height after filling, obtain the filled image, and save the filled image in the storage directory; S5. Determine the number of rows and columns of the segmented sub-blocks based on the size of the filled image and the size of the sub-blocks; S6. Based on the number of rows and columns of the sub-blocks, divide the filled image into multiple sub-block images using array slicing, store each sub-block image in a storage directory, and record its storage path; S6 specifically involves: Convert the padded image to a NumPy array with dimension padded_height. padded_width channels, where padded_height represents the height of the image after filling, padded_width represents the width of the image after filling, and channels represents the number of channels of the image. An image with RGB color mode has 3 channels, an image with RGBA color mode has 4 channels, and an image with grayscale color mode has 1 channel. For the sub-block in row 'row' and column 'col': The starting row coordinate is start_row = row split_height; where start_row is the starting row coordinate and split_height represents the height of the sub-block; The coordinates of the end row are given by end_row = start_row + split_height; where end_row is the coordinates of the end row, start_row is the coordinates of the start row, and split_height represents the height of the sub-block. The starting column coordinates are start_col = col split_width; where start_col is the starting column coordinate and split_width is the width of the sub-block; The coordinates of the end column are given by end_col = start_col + split_width; where end_col is the coordinate of the end column. Extract the array data corresponding to the sub-block using the array slice `img_array [start_row:end_row, start_col:end_col]`; where `img_array` is a NumPy array. The extracted sub-block array data is converted into image objects using the Image.fromarray function and stored according to the naming rule of "padded_image + row index + column index + image type"; The storage paths of the sub-block images are all recorded in a list, which corresponds one-to-one with the row and column indices of the sub-blocks; S7. Use CycleGAN to perform style transfer on the sub-block images obtained in S6 to obtain style-transferred sub-block images; S8. Obtain the storage directory of the style-transferred sub-block image, the width and height of the padded image, and the width and height of the original image; S9. Create an empty array with the same dimensions as the filled image as the reconstruction canvas; S10. Based on the number of rows and columns of each sub-block, read the style-transferred sub-block images sequentially, and write the sub-block images to the corresponding positions on the reconstructed canvas using array slicing; S10 specifically involves: For the sub-block in row 'row' and column 'col': The filename of the sub-padded image is "padded_image + row + col + image type", which is used to locate the corresponding sub-padded image file in the storage directory; If the sub-block image file does not exist, record a warning message and skip the sub-block, then continue processing other sub-blocks; Read the sub-block image and convert it to a NumPy array; The position of this sub-block image in the reconstruction canvas is determined by the following formula: The starting row coordinate is start_row = row split_height; where start_row is the starting row coordinate and split_height represents the height of the sub-block; The coordinates of the end row are given by end_row = start_row + split_height; where end_row is the coordinates of the end row, start_row is the coordinates of the start row, and split_height represents the height of the sub-block. The starting column coordinates are start_col = col split_width; where start_col is the starting column coordinate and split_width is the width of the sub-block; The coordinates of the end column are given by end_col = start_col + split_width; where end_col is the coordinate of the end column. The sub-block data is written to the reconstructed canvas array `rebuilt_array` by slicing the array `rebuilt_array [start_row:end_row, start_col:end_col] = block_array`, where `block_array` represents the NumPy array of the sub-block image. S11. Convert the reconstructed canvas into an image, adjust its width and height to match the original image, obtain the reconstructed image, and save it.

2. The pixel extraction and reconstruction method for simulating large-size SAR images of UAVs as described in claim 1, characterized in that, In S1, the path of the image to be processed is a local storage path or a network path, and the image type includes jpg format and png format; The creation of the storage directory is specifically done recursively to ensure that parent directories at all levels are automatically created when the parent directory does not exist, and that the output directory is not created again when it already exists. The naming rule for the storage directory is set to "original image name + _split + _timestamp".

3. The pixel extraction and reconstruction method for simulating large-size SAR images of UAVs as described in claim 1, characterized in that, S2 specifically refers to: Open image files using functions from a library that supports multiple image formats; The original width and original height can be obtained through the size property of the image object. The tuple returned by the size property contains two elements, one for the width and the other for the height. If an error occurs during the reading process, the error message will be logged, and empty image data and zero-value size information will be returned.

4. The pixel extraction and reconstruction method for simulating large-size SAR images of UAVs as described in claim 1, characterized in that, S3 specifically refers to: The preset sub-block size is used to calculate the width and height of the image after filling, based on the preset sub-block size. The calculation method is as follows: The formula for calculating the padded width is: padded_width = max(split_width, math.ceil(original_width / split_width)). split_width), where padded_width is the width of the image to be processed after being padded, split_width is the width of the sub-block, and original_width is the original width of the image to be processed; The formula for calculating the padded height is: padded_height = max(split_height, math.ceil(original_height / split_height)). split_height), where padded_height is the height of the image to be processed after being padded, split_height is the height of the sub-block, and original_height is the original height of the image to be processed; The `math.ceil` function is used to round up; the `max` function is used to find the maximum value.

5. The pixel extraction and reconstruction method for simulating large-size SAR images of UAVs as described in claim 1, characterized in that, S4 specifically refers to: An image scaling algorithm is used to adjust the width and height of the image to be processed to the padded width and height. The storage path of the padded image is set to "padded_image + image type" in the output directory, and the original color mode of the image to be processed is preserved when storing.

6. The pixel extraction and reconstruction method for simulating large-size SAR images of UAVs as described in claim 1, characterized in that, S5 specifically refers to: The formula for calculating the number of sub-block rows is: blocks_row_num = padded_height / split_height, where blocks_row_num represents the number of sub-block rows, padded_height represents the height of the image to be processed after filling, and split_height represents the height of the sub-block; The formula for calculating the number of sub-block columns is: blocks_col_num = padded_width / split_width, where blocks_col_num represents the number of sub-block columns, padded_width represents the width of the image to be processed after filling, and split_width represents the width of the sub-block.

7. The pixel extraction and reconstruction method for simulating large-size SAR images of UAVs as described in claim 1, characterized in that, S8 specifically refers to: The process involves traversing the storage directory to obtain all sub-block images, the width of the image to be processed after filling, the height of the image to be processed after filling, the original width of the image to be processed, and the original height of the image to be processed. If any abnormalities are found in the obtained size information, the reconstruction process is terminated and an error message is returned. S9 specifically refers to: The dimension of an empty array is set to padded_height padded_width channels, where padded_height represents the height of the image to be processed after padded, padded_width represents the width of the image to be processed after padded, and channels represents the number of channels of the image, which is consistent with the number of channels of the image before segmentation; An empty array has its data type set to an 8-bit unsigned integer, and its initial value is set to 0.

8. The pixel extraction and reconstruction method for simulating large-size SAR images of UAVs as described in claim 1, characterized in that, S11 specifically refers to: Convert the reconstructed canvas array into an image object; A scaling algorithm is used to adjust the image object to its original width and height; The naming convention for reconstructed images is set to "merge_ + original image name + image type"; The storage path for the reconstructed image is set to the parent directory of the sub-block storage directory.