A vector-driven large-scale remote sensing image sample clipping method, system, device and storage medium
Patent Information
- Application Number
- CN202611031495.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-13
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2046-07-13
AI Technical Summary
[0004]由上可知,该类全图遍历裁剪方式会无差别覆盖无目标空白区域,导致有效目标样本占比极低,难以支撑稀疏地物场景的模型训练需求,如何提高全图遍历裁剪时有效目标样本占比以支撑稀疏地物场景的模型训练需求仍有待解决
通过矢量标注直接驱动裁剪窗口生成,摒弃传统全图遍历的无差别裁剪模式,仅围绕已知目标图斑的空间范围生成样本,跳过无目标空白区域,可以大幅减少无效背景样本的产生。相较于传统方法在稀疏地物场景下有效目标样本占比极低的问题,本方案生成的样本均包含完整目标地物,有效样本占比显著提升,能够快速积累足量的正样本数据,解决了稀疏地物场景下有效样本匮乏、难以支撑模型训练的问题。
Smart Images

Figure CN122530238B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of remote sensing image processing, and in particular to a vector-driven method, system, device, and storage medium for large-scale remote sensing image sample cropping. Background Technology
[0002] With the continuous maturation of high-resolution satellite and airborne remote sensing technologies, large-scale remote sensing imagery has become a core data source for intelligent interpretation tasks of land use monitoring, building extraction, and landfill site identification. Deep learning-based automated interpretation models heavily rely on large-scale, high-precision training samples. However, large-scale remote sensing imagery, with its area reaching tens of thousands of pixels, cannot be directly input into the model and must be cropped to generate fixed-size image sample blocks.
[0003] Currently, the industry commonly uses the regular grid sliding window cropping method, which performs indiscriminate traversal cropping of the entire image with a fixed size and fixed step size, and simultaneously performs spatial cropping and rasterization processing on the vector labeled data. This is the mainstream preprocessing method in the current sample construction process.
[0004] As can be seen from the above, this type of full-image traversal cropping method will indiscriminately cover blank areas without targets, resulting in a very low proportion of effective target samples, which is difficult to support the model training requirements of sparse terrain scenes. How to increase the proportion of effective target samples during full-image traversal cropping to support the model training requirements of sparse terrain scenes remains to be solved. Summary of the Invention
[0005] To increase the proportion of effective target samples during full-image traversal cropping to support the model training needs of sparse terrain scenes, this application provides a vector-driven large-scale remote sensing image sample cropping method, system, device, and storage medium.
[0006] Firstly, this application provides a vector-driven method for large-scale remote sensing image sample cropping, employing the following technical solution: A vector-driven method for large-scale remote sensing image sample cropping includes: Read large-scale remote sensing images and corresponding vector annotation files and unify the spatial reference system to align the remote sensing images and vector annotation files in space; Traverse each target patch in the vector annotation file, calculate the minimum bounding rectangle of each target patch, obtain the geographic coordinates of the four boundaries of the minimum bounding rectangle, and convert them into the corresponding pixel coordinates by combining the affine transformation parameters of the remote sensing image. Based on the pixel coordinates of the minimum bounding rectangle of the target patch, the preset clipping window size, and the preset safety buffer size, the effective clipping area is calculated. Any point within the effective clipping area is used as the top left corner to generate a clipping window that can completely contain the target patch, and the distance between the edge of the target patch and the corresponding edge of the clipping window is not less than the safety buffer size. Randomly select a point within the effective cropping area as the coordinates of the top left corner of the cropping window to determine the pixel range of the cropping window; Based on the pixel range of the cropping window, the image data of the corresponding area is read directly from the large-size remote sensing image. If the cropping window exceeds the boundary of the large-size remote sensing image, the excess part is truncated and filled to the preset size. Calculate the corresponding geographic range based on the pixel range of the cropping window, construct a geographic cropping box to spatially crop the original vector annotation file, and obtain a sub-vector file corresponding to the image data; The cropped image data and corresponding sub-vector files are saved according to a unified naming rule to form a one-to-one training sample.
[0007] Optionally, the step of calculating the effective cropping area includes: The left boundary pixel coordinates of the effective cropping area are obtained by subtracting the horizontal size of the cropping window from the right boundary pixel coordinates of the smallest bounding rectangle of the target patch, and then adding the preset horizontal safety buffer size. The upper boundary pixel coordinates of the effective cropping area are obtained by subtracting the vertical dimension of the cropping window from the lower boundary pixel coordinates of the smallest bounding rectangle of the target patch, and then adding the preset vertical safety buffer size. The right boundary pixel coordinates of the effective cropping area are obtained by subtracting the preset horizontal safety buffer size from the left boundary pixel coordinates of the smallest bounding rectangle of the target patch. The lower boundary pixel coordinates of the effective cropping area are obtained by subtracting the preset vertical safety buffer size from the upper boundary pixel coordinates of the smallest bounding rectangle of the target patch. Set the range of values for the horizontal and vertical safety buffer dimensions. The horizontal safety buffer dimension is greater than zero and less than half the difference between the horizontal dimension of the clipping window and the horizontal length of the minimum bounding rectangle of the target patch. The vertical safety buffer dimension is greater than zero and less than half the difference between the vertical dimension of the clipping window and the vertical length of the minimum bounding rectangle of the target patch. The horizontal and vertical safety buffer dimensions are set independently and do not affect each other.
[0008] Optionally, the step of directly reading image data of the corresponding region from a large-size remote sensing image based on the pixel range of the cropping window includes: There is no need to load the entire large-size remote sensing image into memory; local data of the corresponding area can be read directly from the large-size remote sensing image file by pixel coordinate index. Preserve the band count, data type, and geographic transformation parameters of large-size remote sensing images; If the cropping window exceeds the boundary of a large-size remote sensing image, zero-value fill is used to fill the truncated blank area to the preset cropping window size.
[0009] Optionally, the step of constructing a geographic clipping box to spatially clip the original vector annotation file and obtain a sub-vector file corresponding to the image data includes: The pixel range of the cropping window is converted into the corresponding geographic coordinate range through the affine transformation parameters of the remote sensing image, and a rectangular geographic cropping box is constructed. Spatial intersection operation is performed on the original vector annotation file to extract all target patches that fall within the geographic clipping box. For target patches that cross the clipping box boundary, they are cut along the clipping box boundary and the part inside the box is retained. The cropped sub-vector files are processed to standardize field names and inherit the spatial reference system of the original vector annotation files.
[0010] Optionally, after the step of forming one-to-one corresponding training samples, the method further includes: Based on the model training requirements, the sub-vector files are converted into corresponding annotation types, including single-channel grayscale label images required for semantic segmentation and annotation files required for object detection.
[0011] Optionally, the step of traversing each target polygon in the vector annotation file includes: For a single target patch, generate multiple clipping windows at different locations within the effective clipping area; Each cropping window generates a separate set of training samples to enhance the spatial diversity of the training data.
[0012] Optionally, the step of setting the value range of the lateral safety buffer size and the longitudinal safety buffer size includes: The values of the lateral and longitudinal safety buffer dimensions should be determined with reference to the size settings of the corresponding target patch. The horizontal safety buffer size is one-third of the horizontal length of the smallest bounding rectangle of the target patch, and the vertical safety buffer size is one-third of the vertical length of the smallest bounding rectangle of the target patch.
[0013] Secondly, this application provides a vector-driven large-scale remote sensing image sample cropping system, which adopts the following technical solution: A vector-driven large-scale remote sensing image sample cropping system includes: The spatial alignment module reads large-scale remote sensing images and corresponding vector annotation files and unifies the spatial reference system to align the remote sensing images and vector annotation files in space. The coordinate transformation module iterates through each target patch in the vector annotation file, calculates the minimum bounding rectangle of each target patch, obtains the geographic coordinates of the four boundaries of the minimum bounding rectangle, and converts them into the corresponding pixel coordinates by combining the affine transformation parameters of the remote sensing image. The effective area calculation module calculates the effective clipping area based on the pixel coordinates of the minimum bounding rectangle of the target patch, the preset clipping window size, and the preset safety buffer size. Any point within the effective clipping area is used as the upper left corner to generate a clipping window that can completely contain the target patch, and the distance between the edge of the target patch and the corresponding edge of the clipping window is not less than the safety buffer size. The window generation module randomly selects a point within the effective cropping area as the coordinates of the top-left corner of the cropping window to determine the pixel range of the cropping window; The image cropping module reads the corresponding area image data directly from the large-size remote sensing image based on the pixel range of the cropping window. If the cropping window exceeds the boundary of the large-size remote sensing image, the excess part is truncated and filled to the preset size. The vector cropping module calculates the corresponding geographic range based on the pixel range of the cropping window, constructs a geographic cropping box to spatially crop the original vector annotation file, and obtains a sub-vector file corresponding to the image data. The sample output module saves the cropped image data and corresponding sub-vector files according to a unified naming rule, forming a one-to-one corresponding training sample.
[0014] Thirdly, this application provides an electronic device that adopts the following technical solution: An electronic device includes a processor in which a program is running for the vector-driven large-scale remote sensing image sample cropping method described in any one of the preceding claims.
[0015] Fourthly, this application provides a storage medium, which adopts the following technical solution: A storage medium storing a program for the vector-driven large-scale remote sensing image sample cropping method described in any one of the above.
[0016] In summary, this application includes at least one of the following beneficial technical effects: By directly driving the clipping window generation through vector annotation, this approach abandons the traditional indiscriminate clipping mode that involves traversing the entire map. It generates samples only within the spatial range of known target features, skipping blank areas without targets, thus significantly reducing the generation of invalid background samples. Compared to traditional methods that suffer from extremely low effective target sample ratios in sparse terrain scenarios, this method generates samples that all contain complete target features, significantly increasing the effective sample ratio. This allows for the rapid accumulation of sufficient positive sample data, solving the problem of scarce effective samples and difficulty in supporting model training in sparse terrain scenarios.
[0017] Meanwhile, by using a random window mechanism with a safety buffer for effective regions, multiple location samples of the same target are generated while ensuring the target remains intact and uncut, thus enhancing the spatial diversity of the training data. The use of local streaming readout eliminates the need to load the entire large-scale image, reducing hardware resource consumption and improving sample production efficiency. The synchronous cropping and standardization of images and vector annotations ensures strict spatial alignment between samples and annotations, further improving the quality of the training data and providing a high-value, low-redundancy training foundation for the intelligent interpretation model of sparse ground features. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating a vector-driven large-scale remote sensing image sample cropping method according to an exemplary embodiment.
[0019] Figure 2 This is a schematic diagram illustrating the coordinates of geometric targets in a vector-driven large-scale remote sensing image sample cropping method according to an exemplary embodiment.
[0020] Figure 3 This is a schematic diagram illustrating a vector patch-driven random cropping window generation strategy in a vector-driven large-scale remote sensing image sample cropping method according to an exemplary embodiment.
[0021] Figures 4-1 to 4-4 This is a schematic diagram of four extreme cases in a vector-driven large-scale remote sensing image sample cropping method according to an exemplary embodiment.
[0022] Figure 5 This is a schematic diagram illustrating the vector synchronous cropping effect in a vector-driven large-scale remote sensing image sample cropping method according to an exemplary embodiment.
[0023] Figure 6 This is a schematic diagram of a regular grid sliding window cropping method in a vector-driven large-scale remote sensing image sample cropping method according to an exemplary embodiment.
[0024] Figure 7 This is a schematic diagram illustrating the cropping effect of a vector-driven large-scale remote sensing image sample cropping method by introducing an overlapping sliding window, according to an exemplary embodiment.
[0025] Figure 8 This is a schematic diagram illustrating the cropping effect in a vector-driven large-scale remote sensing image sample cropping method according to an exemplary embodiment.
[0026] Figure 9 This is a structural block diagram of a vector-driven large-scale remote sensing image sample cropping system according to an exemplary embodiment. Detailed Implementation
[0027] The embodiments of this application are described in detail below, and examples of the embodiments are shown in the accompanying drawings.
[0028] In the description of this specification, the references to "certain embodiments," "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples" refer to specific features, structures, materials, or characteristics described in connection with the described embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0029] This application discloses a vector-driven method for cropping large-scale remote sensing image samples. With the continuous maturation of high-resolution satellite and airborne remote sensing technologies, large-scale remote sensing imagery has become a core data source for intelligent interpretation tasks such as land use monitoring, building extraction, and landfill site identification. Deep learning-based automated interpretation models heavily rely on large-scale, high-precision training samples. However, large-scale remote sensing images, with their image size reaching tens of thousands of pixels, cannot be directly input into the model and require cropping to generate image sample blocks of fixed sizes.
[0030] Currently, the industry commonly uses a regular grid sliding window cropping method, which performs indiscriminate traversal cropping of the entire image with a fixed size and fixed step size, and simultaneously performs spatial cropping and rasterization processing on the vector labeled data. This is the mainstream preprocessing method in the current sample construction process. This type of full-image traversal cropping method indiscriminately covers blank areas without targets, resulting in a very low proportion of effective target samples, which is difficult to support the model training requirements of sparse terrain scenes.
[0031] This application embodiment directly drives the generation of the clipping window through vector annotation, generating samples only around the spatial range of known target patches, skipping blank areas without targets, significantly reducing the generation of invalid background samples from the source, significantly increasing the proportion of effective samples, and enabling the rapid accumulation of sufficient positive sample data. This can solve the problem of scarce effective samples and difficulty in supporting model training in sparse terrain scenes.
[0032] Reference Figure 1 The vector-driven large-scale remote sensing image sample cropping method of this application includes the following steps: S100 reads large-scale remote sensing images and corresponding vector annotation files and unifies the spatial reference system to align the remote sensing images and vector annotation files in space.
[0033] In this embodiment of the invention, the specific execution process of S100 is as follows: S101, Perform a data reading operation to read the large-scale remote sensing image file to be processed. The large-scale remote sensing image file adopts the GeoTIFF format and contains image data, geographic transformation parameters and spatial reference system information. At the same time, read the corresponding vector annotation file. The vector annotation file adopts the Shapefile format and contains polygon patch data, attribute information and spatial reference system information of all target features.
[0034] S102, Perform a spatial reference system check operation to parse the spatial reference system information of large-scale remote sensing image files and vector annotation files respectively, and obtain the coordinate system parameters of both.
[0035] S103, Perform the spatial reference system operation. If the spatial reference system of the large-scale remote sensing image and the vector annotation file are inconsistent, the vector annotation file will be reprojected onto the spatial reference system of the large-scale remote sensing image to ensure that each pixel on the large-scale remote sensing image and the patch in the vector annotation file correspond strictly in geographical location. This can avoid spatial misalignment between the image and the annotation during the subsequent cropping process.
[0036] S200 iterates through each target patch in the vector annotation file, calculates the minimum bounding rectangle of each target patch, obtains the geographic coordinates of the four boundaries of the minimum bounding rectangle, and converts them into corresponding pixel coordinates by combining the affine transformation parameters of the remote sensing image.
[0037] In this embodiment of the invention, the specific execution process of S200 is as follows: S201 performs a vector patch traversal operation, sequentially reading each target patch in the vector annotation file. Each target patch corresponds to an independent ground feature, such as a building, garbage dump, or road. For a single target patch, multiple clipping windows at different locations can be generated within the subsequent effective clipping area. Each clipping window corresponds to a set of independent training samples, enhancing the spatial diversity of the training data. Traditional regular grid sliding window clipping methods generate samples with fixed positions, resulting in poor spatial diversity and a tendency for model overfitting.
[0038] In this embodiment, for a single target patch, multiple clipping windows at different locations can be generated within the effective clipping area, with each clipping window corresponding to an independent set of training samples. This allows for the generation of multiple different training samples for the same target patch, each with a different position and context, thus enhancing the spatial diversity of the training data and improving the model's generalization ability. The number of generated clipping windows can be set according to actual needs. Generally, a larger number of generated windows results in better spatial diversity of the training data, but the sample creation time will also increase accordingly. In practical applications, the number of clipping windows generated for each target patch can be reasonably set based on the number of target patches and the model training requirements.
[0039] S202, perform the minimum bounding rectangle calculation operation. For each target patch, calculate the minimum rectangle that can completely enclose the patch, i.e., the minimum bounding rectangle. Obtain the geographic coordinates of the four vertices of the minimum bounding rectangle, and then obtain the geographic coordinates of the four boundaries of the minimum bounding rectangle, including the minimum longitude, maximum longitude, minimum latitude, and maximum latitude. (Refer to...) Figure 2 , Figure 2 This is a schematic diagram illustrating the coordinates of a geometric target, where the red pentagram represents the target patch, and the dashed rectangle represents the smallest bounding rectangle of the target patch. , These are the minimum and maximum x-coordinates of the minimum bounding rectangle, respectively. , These are the minimum and maximum ordinates of the smallest bounding rectangle, respectively.
[0040] S203, perform a transformation operation from geographic coordinates to pixel coordinates. Combining the affine transformation parameters of the large-scale remote sensing image, convert the geographic coordinates of the minimum bounding rectangle into the corresponding pixel coordinates, obtaining the pixel coordinates of the minimum bounding rectangle of the target patch, including the leftmost pixel coordinate. Top pixel coordinates Rightmost pixel coordinates and the coordinates of the lowest pixel .
[0041] S300: Calculate the effective cropping region based on the pixel coordinates of the minimum bounding rectangle of the target patch, the preset cropping window size, and the preset safety buffer size. Generate a cropping window that can completely contain the target patch by taking any point within the effective cropping region as the top left corner, and the distance between the edge of the target patch and the corresponding edge of the cropping window is not less than the safety buffer size.
[0042] In this embodiment of the invention, the specific execution process of S300 is as follows: S301, Perform parameter acquisition operation to obtain a preset cropping window size, which is a fixed value and can be set according to the input requirements of the subsequent deep learning model; simultaneously obtain a preset safety buffer size, which includes a horizontal safety buffer size. and longitudinal safety buffer size This is used to reserve a safe distance between the target patch and the edge of the clipping window, preventing information loss caused by the target patch being too close to the edge of the clipping window. Lateral safety buffer size. (i.e., the x-direction safety distance) is used to reserve space inside the pixel boundary in the x-axis direction to prevent the target from being too close to the cropping edge; the vertical safety buffer size The y-direction buffer size (i.e., the y-direction safety distance) is used to reserve space inside the pixel boundary in the y-axis direction to prevent the target from being too close to the clipping edge. The values of the horizontal and vertical safety buffer sizes are determined with reference to the size settings of the corresponding target patch. After extensive experimental verification, setting the horizontal safety buffer size to one-third of the horizontal length of the smallest bounding rectangle of the target patch and the vertical safety buffer size to one-third of the vertical length of the smallest bounding rectangle of the target patch can provide a sufficiently large effective clipping area while ensuring that the target patch is completely contained within the clipping window. This allows the position of the clipping window to have sufficient randomness, while also preventing the effective clipping area from becoming invalid.
[0043] S302, Perform the effective clipping region calculation operation, based on the four-to-pixel coordinates of the minimum bounding rectangle of the target patch and the clipping window size. Given a safety buffer size, calculate the four-to-one pixel coordinates of the effective cropping region. The effective cropping region is defined as a region within which any point, when used as the top-left corner of a cropping window, can completely contain the target patch, and the distance between the edge of the target patch and the corresponding edge of the cropping window is not less than the safety buffer size. (Refer to...) Figure 3 , Figure 3 This diagram illustrates a random cropping window generation strategy driven by vector patch, where red rectangles represent the effective cropping region, green rectangles represent the cropping window, and red pentagrams represent the target patch. The four-to-one pixel coordinates of the effective cropping region are calculated using the following formula: ; ; ; ; The parameters in the formula are defined as follows: It is the minimum value of the effective pixel range in the x-direction, that is, the left boundary of the effective region in the x-axis direction; It is the minimum value of the effective pixel range in the y-direction, that is, the upper boundary of the effective region in the y-axis direction; It represents the maximum value of the effective pixel range in the x-direction, i.e., the right boundary of the effective region in the x-axis direction; This represents the maximum effective pixel range in the y-direction, i.e., the lower boundary of the effective region along the y-axis. The horizontal and vertical safety buffer sizes are set to their respective ranges. The horizontal safety buffer size is greater than zero and less than half the difference between the horizontal size of the clipping window and the horizontal length of the minimum bounding rectangle of the target patch. The vertical safety buffer size is greater than zero and less than half the difference between the vertical size of the clipping window and the vertical length of the minimum bounding rectangle of the target patch. In other words, the buffer sizes in the x and y directions... The values can be independently selected (and may not be equal), while simultaneously satisfying the following constraints to avoid boundary overflow or invalid regions: ; ; The horizontal and vertical safety buffer sizes are set independently and do not affect each other. By setting these value ranges, situations where the effective cropping area is invalid can be avoided; that is, situations where the left boundary pixel coordinates are greater than the right boundary pixel coordinates or the top boundary pixel coordinates are greater than the bottom boundary pixel coordinates can be avoided. (Refer to...) Figures 4-1 to 4-4 , Figures 4-1 to 4-4 The diagram illustrates four extreme cases, showing four special cases when the safety buffer size is 0, in which case the clipping window is flush with the outer rectangle boundary of the target patch.
[0044] The above calculation method accurately determines the effective clipping region, ensuring that any point within this region, when used as the top-left corner of the clipping window, completely encompasses the target patch, and the distance between the edge of the target patch and the corresponding edge of the clipping window is not less than the safety buffer size. Furthermore, by setting the value ranges for the horizontal and vertical safety buffer sizes, invalid clipping regions can be avoided. The horizontal and vertical safety buffer sizes can be set independently without affecting each other, allowing for flexible adjustment based on the shape and size of different target patches. For example, for target patches with longer horizontal dimensions, the horizontal safety buffer size can be appropriately increased; for target patches with longer vertical dimensions, the vertical safety buffer size can be appropriately increased.
[0045] S400: Randomly select a point within the effective cropping area as the coordinates of the upper left corner of the cropping window to determine the pixel range of the cropping window.
[0046] In this embodiment of the invention, the specific execution process of S400 is as follows: S401, Perform a random point generation operation. Within the effective cropping area, generate a random point using a uniformly distributed random function. The x-coordinate of this random point lies between the left and right boundary pixel coordinates of the effective cropping area, and the y-coordinate lies between the upper and lower boundary pixel coordinates of the effective cropping area.
[0047] S402, perform the cropping window range determination operation. Using the generated random point as the coordinates of the top-left corner of the cropping window, and combining this with the preset cropping window size, determine the pixel coordinates of the four vertices of the cropping window, thus obtaining the pixel range of the cropping window. The pixel coordinates of the four vertices of the cropping window are: top-left (x, y), bottom-left (x, y + window_size), top-right (x + window_size, y), and bottom-right (x + window_size, y + window_size).
[0048] S500 directly reads the image data of the corresponding area from the large-size remote sensing image based on the pixel range of the cropping window. If the cropping window exceeds the boundary of the large-size remote sensing image, the excess part is truncated and filled to the preset size.
[0049] In this embodiment of the invention, the specific execution process of S500 is as follows: S501 performs a partial image reading operation. Based on the pixel range of the cropping window, it directly reads the image data of the corresponding area from the original large-scale remote sensing image file. This eliminates the need to load the entire large-scale remote sensing image into memory; instead, it directly reads the local data of the corresponding area from the large-size remote sensing image file using pixel coordinate indexing. Traditional image cropping methods require loading the entire large-scale remote sensing image into memory before performing the cropping operation. For large-scale remote sensing images with tens of thousands of pixels, this consumes a significant amount of memory resources and may even lead to memory overflow.
[0050] The embodiments of this application adopt a streaming reading method, which directly reads local data of the corresponding area from the original large-scale remote sensing image file through pixel coordinate index, without loading the entire image into memory, which greatly reduces the demand for memory resources and makes it possible to produce samples of ultra-large-format remote sensing images.
[0051] S502 performs an image parameter preservation operation, preserving the band number, data type, and geographic transformation parameters of the large-scale remote sensing image. This ensures that the cropped image patch retains all attribute information and geographic location information of the original image, facilitating subsequent geographic information processing and analysis.
[0052] S503 performs boundary processing. If a portion of the cropping window extends beyond the boundary of the large-scale remote sensing image, the excess portion is automatically truncated, and zero-value padding is used to fill the truncated area to the preset cropping window size. This ensures that all output image sample blocks are of consistent size, facilitating subsequent deep learning model training. Zero-value padding is a simple and effective boundary processing method that does not introduce additional noise information and has minimal impact on model training.
[0053] S600 calculates the corresponding geographic range based on the pixel range of the cropping window, constructs a geographic cropping box to spatially crop the original vector annotation file, and obtains a sub-vector file corresponding to the image data.
[0054] In this embodiment of the invention, the specific execution process of S600 is as follows: S601 performs a pixel-to-geographic-range conversion operation, converting the pixel range of the cropping window into its corresponding geographic coordinate range using the affine transformation parameters of the large-scale remote sensing image, thus obtaining the geographic boundary coordinates of the cropping window. This process of converting the pixel range of the cropping window into geographic coordinates is the reverse of the geographic-to-pixel coordinate conversion.
[0055] By using the affine transformation parameters of large-scale remote sensing imagery, pixel coordinates can be converted to geographic coordinates, and vice versa. By converting the pixel coordinates of the four vertices of the cropping window to geographic coordinates, the geographic boundaries of the cropping window can be obtained, thus constructing a rectangular geographic cropping box.
[0056] S602, perform a geographic clipping box construction operation, construct a rectangular geographic clipping box based on the geographic coordinates of the clipping window.
[0057] S603 performs a vector annotation clipping operation, performing spatial intersection on the original vector annotation file to extract all target polygons falling within the geographic clipping box; for target polygons crossing the geographic clipping box boundary, they are cut along the boundary of the geographic clipping box, retaining only the portion within the clipping box. (Refer to...) Figure 5 , Figure 5 This is a schematic diagram of the vector synchronous clipping effect, showing the effect of clipping a target patch that crosses the boundary of the clipping window. Only the part within the window is retained after clipping.
[0058] S604 performs vector file standardization, standardizing field names in the cropped sub-vector files and unifying them with standard names. It also inherits the spatial reference system of the original vector annotation files, ensuring strict spatial alignment between the sub-vector files and their corresponding image blocks. Standardizing field names in the cropped sub-vector files is crucial for unifying field names from different sources and preventing subsequent processing errors due to inconsistencies.
[0059] The S700 saves the cropped image data and corresponding sub-vector files according to a unified naming rule, forming a one-to-one corresponding training sample.
[0060] In this embodiment of the invention, the specific execution process of S700 is as follows: S701 executes the naming rule application operation, naming the cropped image data and corresponding sub-vector files according to the preset unified naming rules.
[0061] S702, perform a file saving operation, save the cropped image data as a GeoTIFF format file, save the corresponding sub-vector file as a Shapefile format file, and store them in the specified output directory to form a one-to-one corresponding training sample pair.
[0062] After generating one-to-one training samples, the process further includes converting the sub-vector files into corresponding annotation types based on model training requirements. These annotation types include single-channel grayscale label images required for semantic segmentation and annotation files required for object detection. Different deep learning models require different types of annotation data. Semantic segmentation models require single-channel grayscale label images, where the grayscale value of each pixel represents the corresponding land cover category; object detection models require annotation files containing the object category and bounding box coordinates. In this embodiment, after generating image-vector sample pairs, the sub-vector files can be converted into corresponding annotation types according to the needs of subsequent model training.
[0063] For example, for semantic segmentation tasks, the polygonal patches in the sub-vector file can be rasterized into single-channel grayscale label images, with the grayscale value corresponding to each patch indicating its category number. For object detection tasks, the coordinates and category information of the minimum bounding rectangle of each patch in the sub-vector file can be extracted to generate the corresponding annotation file. Through the above steps, the embodiments of this application can generate training data suitable for different deep learning models, exhibiting strong versatility and flexibility.
[0064] Based on the scheme in the embodiments of this application, an example is provided for illustrating the typical sparse terrain scenario of garbage dump identification. Garbage dump identification is an important task in urban environmental monitoring and management. Automatically identifying garbage dumps through remote sensing imagery can promptly detect illegal garbage dumping and improve the efficiency of urban environmental management. However, garbage dumps are extremely sparsely distributed in large-scale remote sensing images, with a very low proportion of effective target areas. Using traditional regular grid sliding window cropping methods generates a large number of background samples without targets, wasting computational and storage resources and leading to a severe imbalance in the ratio of positive to negative samples, making it difficult to train a high-precision garbage dump identification model. (Refer to...) Figure 6 and Figure 7 , Figure 6 This is a schematic diagram of the sliding window clipping method for regular grids. Figure 7 The illustration shows the effect of the overlapping sliding window cropping method. Traditional methods crop according to a preset window size regardless of whether a target exists, resulting in a large number of targetless areas being processed. (Refer to...) Figure 8 , Figure 8 This is a schematic diagram of the cropping method of the present invention. This solution generates a cropping window only around the known target patch, completely skipping areas without a target.
[0065] Using the scheme in this application embodiment, firstly, large-scale remote sensing images and corresponding garbage dump point vector annotation files are read to unify their spatial reference systems, ensuring strict spatial alignment between the images and annotations. Then, each garbage dump point patch in the vector annotation file is traversed, and the minimum bounding rectangle of each patch is calculated, converting its geographic coordinates to pixel coordinates. Next, based on the pixel coordinates of the patch, the preset clipping window size, and the safety buffer size, the effective clipping area is calculated. Clipping windows are randomly generated within the effective clipping area, each window completely containing a garbage dump point patch. Then, based on the pixel range of the clipping window, the image data of the corresponding area is directly read from the original image; if the window exceeds the image boundary, zero-value padding is performed. Simultaneously, based on the geographic range of the clipping window, the original vector annotation file is spatially clipped to obtain corresponding sub-vector files. Finally, the image data and sub-vector files are saved according to a unified naming rule, forming one-to-one training sample pairs.
[0066] In this example, the embodiment of this application generates a clipping window only around the garbage dump site patch, completely skipping the blank areas without targets, which can significantly reduce the generation of invalid background samples. Compared with the traditional method where the vast majority of samples generated are background samples without targets, each sample generated by this scheme contains a complete garbage dump site target, significantly increasing the proportion of effective samples and enabling the rapid accumulation of sufficient positive sample data, thus solving the problem of insufficient effective samples in garbage dump site identification tasks.
[0067] Meanwhile, by randomly generating multiple cropping windows at different locations within the effective cropping area, the spatial diversity of the training data is enhanced, which helps improve the model's ability to identify garbage dumps in different locations and contexts. Furthermore, the streaming approach eliminates the need to load the entire image into memory, significantly reducing hardware resource requirements and improving sample production efficiency. Simultaneous cropping and standardization of the image and vector annotations ensure strict spatial alignment between samples and annotations, further improving the quality of the training data.
[0068] This application discloses a vector-driven large-scale remote sensing image sample cropping system, referring to... Figure 9 ,include: The spatial alignment module 001 reads large-scale remote sensing images and corresponding vector annotation files and unifies the spatial reference system to align the remote sensing images and vector annotation files in space. The coordinate transformation module 002 traverses each target patch in the vector annotation file, calculates the minimum bounding rectangle of each target patch, obtains the geographic coordinates of the four boundaries of the minimum bounding rectangle, and converts them into the corresponding pixel coordinates by combining the affine transformation parameters of the remote sensing image. The effective area calculation module 003 calculates the effective cropping area based on the pixel coordinates of the minimum bounding rectangle of the target patch, the preset cropping window size, and the preset safety buffer size. Any point within the effective cropping area is used as the upper left corner to generate a cropping window that can completely contain the target patch, and the distance between the edge of the target patch and the corresponding edge of the cropping window is not less than the safety buffer size. The window generation module 004 randomly selects a point within the effective cropping area as the coordinates of the upper left corner of the cropping window to determine the pixel range of the cropping window; The image cropping module 005 reads the image data of the corresponding area directly from the large-size remote sensing image according to the pixel range of the cropping window. If the cropping window exceeds the boundary of the large-size remote sensing image, the excess part is truncated and filled to the preset size. The vector cropping module 006 calculates the corresponding geographic range based on the pixel range of the cropping window, constructs a geographic cropping box to spatially crop the original vector annotation file, and obtains a sub-vector file corresponding to the image data. The sample output module 007 saves the cropped image data and the corresponding sub-vector files according to a unified naming rule, forming a one-to-one corresponding training sample.
[0069] This application also discloses an electronic device, including a processor, wherein the processor runs a program for the vector-driven large-scale remote sensing image sample cropping method described in any one of the above embodiments.
[0070] This application also discloses a storage medium storing a program for the vector-driven large-scale remote sensing image sample cropping method described in any one of the above embodiments.
[0071] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A vector-driven method for cropping large-scale remote sensing image samples, characterized in that, include: Read large-scale remote sensing images and corresponding vector annotation files and unify the spatial reference system to align the remote sensing images and vector annotation files in space; Traverse each target patch in the vector annotation file, calculate the minimum bounding rectangle of each target patch, obtain the geographic coordinates of the four boundaries of the minimum bounding rectangle, and convert them into the corresponding pixel coordinates by combining the affine transformation parameters of the remote sensing image. Based on the pixel coordinates of the minimum bounding rectangle of the target patch, the preset clipping window size, and the preset safety buffer size, the effective clipping area is calculated. Any point within the effective clipping area is used as the top left corner to generate a clipping window that can completely contain the target patch, and the distance between the edge of the target patch and the corresponding edge of the clipping window is not less than the safety buffer size. Randomly select a point within the effective cropping area as the coordinates of the top left corner of the cropping window to determine the pixel range of the cropping window; Based on the pixel range of the cropping window, the image data of the corresponding area is read directly from the large-size remote sensing image. If the cropping window exceeds the boundary of the large-size remote sensing image, the excess part is truncated and filled to the preset size. Calculate the corresponding geographic range based on the pixel range of the cropping window, construct a geographic cropping box to spatially crop the original vector annotation file, and obtain a sub-vector file corresponding to the image data; The cropped image data and corresponding sub-vector files are saved according to a unified naming rule to form a one-to-one training sample.
2. The vector-driven large-scale remote sensing image sample cropping method according to claim 1, characterized in that, The steps for calculating the effective cropping area include: The left boundary pixel coordinates of the effective cropping area are obtained by subtracting the horizontal size of the cropping window from the right boundary pixel coordinates of the smallest bounding rectangle of the target patch, and then adding the preset horizontal safety buffer size. The upper boundary pixel coordinates of the effective cropping area are obtained by subtracting the vertical dimension of the cropping window from the lower boundary pixel coordinates of the smallest bounding rectangle of the target patch, and then adding the preset vertical safety buffer size. The right boundary pixel coordinates of the effective cropping area are obtained by subtracting the preset horizontal safety buffer size from the left boundary pixel coordinates of the smallest bounding rectangle of the target patch. The lower boundary pixel coordinates of the effective cropping area are obtained by subtracting the preset vertical safety buffer size from the upper boundary pixel coordinates of the smallest bounding rectangle of the target patch. Set the range of values for the horizontal and vertical safety buffer dimensions. The horizontal safety buffer dimension is greater than zero and less than half the difference between the horizontal dimension of the clipping window and the horizontal length of the minimum bounding rectangle of the target patch. The vertical safety buffer dimension is greater than zero and less than half the difference between the vertical dimension of the clipping window and the vertical length of the minimum bounding rectangle of the target patch. The horizontal and vertical safety buffer dimensions are set independently and do not affect each other.
3. The vector-driven large-scale remote sensing image sample cropping method according to claim 1, characterized in that, The step of directly reading image data of the corresponding region from a large-size remote sensing image based on the pixel range of the cropping window includes: There is no need to load the entire large-size remote sensing image into memory; local data of the corresponding area can be read directly from the large-size remote sensing image file by pixel coordinate index. Preserve the band count, data type, and geographic transformation parameters of large-size remote sensing images; If the cropping window exceeds the boundary of a large-size remote sensing image, zero-value fill is used to fill the truncated blank area to the preset cropping window size.
4. The vector-driven large-scale remote sensing image sample cropping method according to claim 3, characterized in that, The steps of constructing a geographic clipping box to spatially clip the original vector annotation file and obtain a sub-vector file corresponding to the image data include: The pixel range of the cropping window is converted into the corresponding geographic coordinate range through the affine transformation parameters of the remote sensing image, and a rectangular geographic cropping box is constructed. Spatial intersection operation is performed on the original vector annotation file to extract all target patches that fall within the geographic clipping box. For target patches that cross the clipping box boundary, they are cut along the clipping box boundary and the part inside the box is retained. The cropped sub-vector files are processed to standardize field names and inherit the spatial reference system of the original vector annotation files.
5. The vector-driven large-scale remote sensing image sample cropping method according to claim 4, characterized in that, After the step of forming a one-to-one correspondence of training samples, the following steps are also included: Based on the model training requirements, the sub-vector files are converted into corresponding annotation types, including single-channel grayscale label images required for semantic segmentation and annotation files required for object detection.
6. The vector-driven large-scale remote sensing image sample cropping method according to claim 1, characterized in that, The steps of traversing each target patch in the vector annotation file include: For a single target patch, generate multiple clipping windows at different locations within the effective clipping area; Each cropping window generates a separate set of training samples to enhance the spatial diversity of the training data.
7. The vector-driven large-scale remote sensing image sample cropping method according to claim 2, characterized in that, The steps for setting the range of values for the lateral and longitudinal safety buffer dimensions include: The values of the lateral and longitudinal safety buffer dimensions should be determined with reference to the size settings of the corresponding target patch. The horizontal safety buffer size is one-third of the horizontal length of the smallest bounding rectangle of the target patch, and the vertical safety buffer size is one-third of the vertical length of the smallest bounding rectangle of the target patch.
8. A vector-driven large-scale remote sensing image sample cropping system, characterized in that, include: The spatial alignment module reads large-scale remote sensing images and corresponding vector annotation files and unifies the spatial reference system to align the remote sensing images and vector annotation files in space. The coordinate transformation module iterates through each target patch in the vector annotation file, calculates the minimum bounding rectangle of each target patch, obtains the geographic coordinates of the four boundaries of the minimum bounding rectangle, and converts them into the corresponding pixel coordinates by combining the affine transformation parameters of the remote sensing image. The effective area calculation module calculates the effective clipping area based on the pixel coordinates of the minimum bounding rectangle of the target patch, the preset clipping window size, and the preset safety buffer size. Any point within the effective clipping area is used as the upper left corner to generate a clipping window that can completely contain the target patch, and the distance between the edge of the target patch and the corresponding edge of the clipping window is not less than the safety buffer size. The window generation module randomly selects a point within the effective cropping area as the coordinates of the top-left corner of the cropping window to determine the pixel range of the cropping window; The image cropping module reads the corresponding area image data directly from the large-size remote sensing image based on the pixel range of the cropping window. If the cropping window exceeds the boundary of the large-size remote sensing image, the excess part is truncated and filled to the preset size. The vector cropping module calculates the corresponding geographic range based on the pixel range of the cropping window, constructs a geographic cropping box to spatially crop the original vector annotation file, and obtains a sub-vector file corresponding to the image data. The sample output module saves the cropped image data and corresponding sub-vector files according to a unified naming rule, forming a one-to-one corresponding training sample.
9. An electronic device, characterized in that, Includes a processor, wherein the processor runs a program for a vector-driven large-scale remote sensing image sample cropping method as described in any one of claims 1-7.
10. A storage medium, characterized in that, The program stores a vector-driven large-scale remote sensing image sample cropping method as described in any one of claims 1-7.
Citation Information
Patent Citations
Unmanned aerial vehicle image data batch cutting method based on small pattern spots
CN110706240A
Remote sensing image semantic segmentation model sample set generation method and device
CN116486077A