Building extraction method and device for complex building area and computer equipment
By using the AFL U-Net model and an improved self-prediction mechanism for Focal_Loss loss function parameters, the loss function parameters are dynamically adjusted, solving the problem of imbalance between positive and negative samples in building extraction from remote sensing images, and achieving efficient and accurate building extraction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG INST OF SURVEYING & MAPPING SCI & TECH
- Filing Date
- 2026-05-12
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies suffer from an imbalance of positive and negative samples in building extraction tasks from remote sensing images. This causes the model to favor easily classified negative samples while ignoring difficult-to-classify positive samples. Furthermore, the existing loss function parameters lack adaptive adjustment capabilities, failing to effectively improve the accuracy of building extraction.
The AFL U-Net model is adopted, and sampling is optimized by extending the spatial particle swarm optimization algorithm. Combined with the improved Focal_Loss loss function parameter self-prediction mechanism, the loss function parameters are dynamically adjusted to optimize the learning efficiency of hard-to-classify samples, and representative samples are selected for training.
It significantly improves the accuracy and efficiency of building extraction, optimizes the model's focus on difficult-to-classify samples, reduces the weight of easily distinguishable samples, and solves the problems of positive/negative sample imbalance and class imbalance.
Smart Images

Figure CN122176537A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of remote sensing image processing technology, and more specifically to methods, apparatus and computer equipment for extracting buildings in complex building areas. Background Technology
[0002] Buildings, as core locations for human social activities, are crucial for accurate extraction from remote sensing images, particularly for urban planning and land management. However, with the increasing application of deep learning, especially convolutional neural networks, in remote sensing image processing, a major challenge in building extraction is the extreme imbalance between positive and negative samples. Specifically, in a single remote sensing image, buildings occupy only a small area, while the background dominates the vast majority of the space. This imbalance leads to model training bias towards easily classified negative samples, neglecting difficult-to-classify positive samples and reducing overall model performance. To address this issue, researchers have attempted to mitigate the negative impact of sample imbalance by improving the loss function, such as introducing a dynamic scaling factor into the cross-entropy loss function.
[0003] While existing representative sample selection methods, such as random sampling and stratified sampling, can improve the generalization ability of models to some extent, these methods are usually based on simple statistical distributions or predefined categories, making it difficult to fully capture the complex spatial features and semantic information of buildings in urban environments. Furthermore, the high spatial heterogeneity of urban environments means that building characteristics differ significantly between different regions, a point that existing sample selection methods often fail to consider, and cannot dynamically adjust the sample distribution according to the characteristics of each region. Therefore, constructing a training sample set that is both representative and reflects the diverse characteristics of urban buildings is crucial to improving model performance. Another noteworthy issue is the significant limitations of current loss function parameter configuration schemes used for semantic segmentation of building rooftops in remote sensing imagery. Since buildings typically constitute a small proportion of remote sensing images, this further exacerbates the problems of positive / negative sample imbalance and class imbalance. Although some improved loss functions, such as Focal Loss, have alleviated these problems to some extent, their parameters are usually statically set and lack adaptive adjustment capabilities.
[0004] Therefore, it is necessary to design a new method that can adaptively predict loss function parameters, which can not only optimize the model's focus on difficult-to-classify samples, but also effectively improve the accuracy of overall building extraction. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method, apparatus and computer equipment for extracting buildings in complex building areas.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: a method for extracting buildings in complex building areas, comprising:
[0007] Acquire remote sensing images of the building to be extracted;
[0008] The remote sensing image of the building to be extracted is input into the AFL U-Net model for building identification, and the identification result is converted into roof data in vector form;
[0009] The training process of the AFL U-Net model includes:
[0010] Collect and process high-resolution remote sensing images and Sentinel-2 satellite images, resample them to a uniform resolution, and calculate the urban building index for each grid cell;
[0011] Using an extended spatial particle swarm optimization algorithm, representative samples are selected based on grid cell locations and the urban building index.
[0012] The U-Net model is trained using the representative samples and an improved Focal_Loss loss function parameter self-prediction mechanism to optimize the learning efficiency of hard-to-classify samples, thus forming the AFL U-Net model.
[0013] The further technical solution is as follows: The collection and processing of high-resolution remote sensing images and Sentinel-2 satellite images, resampling them to a uniform resolution, and calculating the urban building index for each grid cell includes:
[0014] Sentinel-2 L2A satellite imagery with clear skies, no clouds, and no snow accumulation, as well as high-resolution remote sensing imagery, were selected as data sources.
[0015] All bands of the Sentinel-2 L2A satellite imagery were uniformly resampled and registered with high-resolution remote sensing imagery to obtain the registered data source.
[0016] Based on the registered data source, a square grid is constructed within the target city area. Each grid serves as a sampling unit, with the spatial coordinates of its center point representing the grid unit's location. The urban building index within each grid is then calculated.
[0017] The further technical solution is as follows: Based on the registered data source, a square grid is constructed within the target city area, with each grid serving as a sampling unit. The spatial coordinates of its center point represent the location of the grid unit, and the urban building index within each grid is calculated, including:
[0018] Using the high-resolution remote sensing imagery from the registered data source as a reference, a grid is established within the target city area. All grids are used as sampling units, and the spatial coordinates of the center point of each sampling unit are used as the spatial location of each grid. The urban building index within each cell is calculated, wherein the formula for calculating the urban building index includes: ; ; ; Among them, SWIR is the short infrared band Band 11, NIR is the near infrared band Band 8, Red is the red band Band 4, and Green is the green band Band 3. This is the building adjustment coefficient. For non-building weight adjustment factors, the values of NDBI, NDVI, and NDWI are all between (-1, 1), while the value of BUI is between (0, 1).
[0019] The further technical solution is as follows: The extended spatial particle swarm optimization algorithm is used to perform optimized sampling based on grid cell locations and the urban building index, selecting representative samples, including:
[0020] Spatial optimization sampling is performed based on grid cell location and building index. This spatial optimization sampling is an extension of the spatial particle swarm algorithm to select representative samples.
[0021] Its further technical solution is as follows: the spatial optimization sampling based on grid cell location and building index is an extension of the spatial particle swarm optimization algorithm, selecting representative samples, including:
[0022] A fitness function for the spatial particle swarm optimization algorithm is defined, based on grid cell positions and building indices. Velocity update formulas and position update formulas are defined to guide particle movement in the algorithm. Parameters involved include inertia weight, individual learning factor, and social learning factor, which control the particle's tendency to maintain its current state, its speed of approaching its individual optimal position, and its speed of approaching the swarm's optimal position, respectively.
[0023] Initialize all relevant parameters, including individual learning factor, social learning factor, and inertia weight;
[0024] The entire sample set is initialized to the population size of the particle swarm, and each sample unit is regarded as a particle, whose initial position and velocity are calculated based on the spatial position and building index of the sample unit.
[0025] Before the predetermined number of iterations or the number of consecutive rejections reaches a threshold, the spatial position of the particle is randomly selected, and its fitness value is calculated based on the fitness function, and set as the initial individual optimal position and global optimal position.
[0026] The selected samples are perturbed to generate a new sample set, and the fitness values of the new and old sample sets are compared. If the fitness of the new sample set is better, the original sample set is replaced.
[0027] Compare the fitness of the new sample set with the global optimum. If it is better than the existing global optimum, then update the global optimum to the position of the current sample set.
[0028] When the predetermined number of iterations or the number of consecutive rejections reaches a threshold, the high-resolution remote sensing image corresponding to the output sample location is matched and uniformly cropped into a regular image with a pixel size that meets the requirements. The corresponding image label file is then created to obtain representative samples.
[0029] Its further technical solution is as follows: The U-Net model is trained using the representative samples through an improved Focal_Loss loss function parameter self-prediction mechanism to optimize the learning efficiency of hard-to-classify samples, forming an AFL U-Net model, including:
[0030] Based on the self-prediction of parameters of the Focal_Loss loss function using least squares, the U-Net model is trained according to the Focal_Loss loss function, and a binary linear regression model is established according to the optimization strategy of the Focal_Loss function parameters guided by F1, thus obtaining the AFL U-Net model; wherein, Focal_Loss dynamically reduces the weight of easily distinguishable samples during training through a dynamic scaling factor.
[0031] The further technical solution is as follows: The parameters of the Focal_Loss loss function based on least squares are self-predicted; the U-Net model is trained according to the Focal_Loss loss function; and a binary linear regression model is established according to the F1-oriented optimization strategy for the Focal_Loss function parameters to obtain the AFL U-Net model; wherein, Focal_Loss dynamically reduces the weights of easily distinguishable samples during training through a dynamic scaling factor, including:
[0032] Establish a binary linear regression model with F1 score as the dependent variable, parameters that suppress the imbalance between positive and negative samples, and parameters that control for the imbalance between simple and complex samples as independent variables.
[0033] Initialize the coefficients of the binary linear regression model before the number of iterations or consecutive rejections reaches a preset threshold;
[0034] Generate an array of initial values for the independent variable based on a given step size, including taking points down and taking points up;
[0035] Based on the initial value array of the independent variables, the coefficients of the binary linear regression model are re-initialized;
[0036] Refine the range of independent variables by increasing the initial value by specifying a step size to form a new array of data points;
[0037] Substitute the current independent variable value into the F1 formula to verify its correlation with the dependent variable in order to obtain the analysis results;
[0038] Update the values of the independent variables based on the analysis results;
[0039] Iterate through all combinations and gradually adjust the number of parameter iterations or consecutive rejections to reach a preset threshold, recording the F1 score during the process;
[0040] When the number of iterations or consecutive rejections reaches a preset threshold, the optimal sum configuration that leads to the highest F1 score is determined based on the recorded F1 score to obtain the optimal parameter configuration. The optimal parameter configuration is then used to train the U-Net model using the Focal Loss loss function parameter self-prediction based on the least squares method, and the weights of easily distinguishable samples are dynamically adjusted to obtain the AFLU-Net model.
[0041] The further technical solution is as follows: inputting the remote sensing image of the building to be extracted into the AFL U-Net model for building identification, and converting the identification result into vector-form roof data, includes:
[0042] The remote sensing images of the buildings to be extracted were cropped according to the research scope using ArcGIS Pro, and the data was enhanced using the Albumentations library to export standard images that meet the requirements.
[0043] Set the processing window size and sliding step size to obtain the partitioning parameters;
[0044] Starting from the upper left corner of the standard image, the window is moved according to the set step size in the division parameters, and the mean and standard deviation of each standard image are standardized to obtain the division result;
[0045] The AFL U-Net model is used to perform forward propagation on the partitioning results to generate a building probability map;
[0046] For the same pixel location spanning multiple windows, the average predicted probability is calculated based on the building probability map to obtain a binarized result;
[0047] A medium filter is applied to the binarization result to remove noise points and retain continuous building areas to obtain the filtered result;
[0048] The filtered results are used to generate a binary image of the building using the Sigmoid function. This image is then overlaid with a high-resolution image for verification. The binary image is then converted into a polygon vector file using GDAL to obtain the roof data in vector form.
[0049] The present invention also provides a building extraction device for complex building areas, comprising:
[0050] The acquisition unit is used to acquire remote sensing images of the building to be extracted;
[0051] The identification and conversion unit is used to input the remote sensing image of the building to be extracted into the AFL U-Net model for building identification, and convert the identification result into roof data in vector form;
[0052] This also includes training units, including:
[0053] The computational sub-unit is used to collect and process high-resolution remote sensing imagery and Sentinel-2 satellite imagery, resample them to a uniform resolution, and calculate the urban building index for each grid cell.
[0054] The optimized sampling unit is used to perform optimized sampling based on the grid cell location and the urban building index using an extended spatial particle swarm optimization algorithm, and to select representative samples.
[0055] The model training subunit is used to train the U-Net model using the representative samples through an improved Focal_Loss loss function parameter self-prediction mechanism, thereby optimizing the learning efficiency of hard-to-classify samples and forming an AFL U-Net model.
[0056] This invention also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method. The beneficial effects of this invention compared to existing technologies are as follows: This invention collects and processes high-resolution remote sensing images and Sentinel-2 satellite images, calculates the urban building index for each grid cell, and utilizes an extended spatial particle swarm optimization algorithm based on sample spatial distribution and BUI to optimize sampling and select the most representative training samples. Specifically, an improved Focal_Loss loss function parameter adaptive prediction mechanism is used to train the U-Net model. This mechanism can dynamically adjust the loss function parameters according to the difficulty of the samples, thereby enhancing the focus on difficult-to-classify samples while reducing the weight of easily distinguishable samples, effectively solving the problems of positive / negative sample imbalance and class imbalance. This method not only optimizes the model's learning efficiency but also significantly improves the accuracy of overall building extraction, enabling efficient building identification and vectorization under conditions of a small number of representative training samples.
[0057] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. Attached Figure Description
[0058] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 A flowchart illustrating the method for extracting buildings in complex building areas provided in an embodiment of the present invention;
[0060] Figure 2 A schematic diagram of a sub-process of the method for extracting buildings in complex building areas provided in an embodiment of the present invention;
[0061] Figure 3 A schematic block diagram of a building extraction device for complex building areas provided in an embodiment of the present invention;
[0062] Figure 4 A schematic block diagram of a computer device provided for an embodiment of the present invention. Detailed Implementation
[0063] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0065] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0066] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0067] Please see Figure 1 , Figure 1 This is a flowchart illustrating the building extraction method for complex building areas provided in this embodiment of the invention. This method is applied to a server. It optimizes the sampling strategy by integrating an extended spatial particle swarm optimization algorithm, calculates the urban building index, and selects representative samples. It then trains the AFL U-Net model using an improved Focal Loss parameter self-prediction mechanism, thus optimizing the learning efficiency for difficult-to-classify samples. Specifically, a binary linear regression model is established based on least squares and an F1 score-oriented optimization strategy, dynamically adjusting the weights of easily distinguishable samples to enhance the model's learning ability for complex samples. Furthermore, a multi-step image processing and analysis process is employed, including remote sensing image preprocessing, parameter setting, standardization, AFL U-Net model forward propagation, building probability map generation, and post-processing. This effectively improves the accuracy of building extraction and transforms the identification results into vector-based roof data, thereby achieving an efficient and accurate building extraction method for complex building areas. This method not only adaptively adjusts the loss function parameters to optimize model performance but also improves the accuracy and reliability of the final building extraction.
[0068] Figure 1 This is a schematic flowchart of the method for extracting buildings in complex building areas provided in an embodiment of the present invention. Figure 1 As shown, the method includes the following steps S110 to S120.
[0069] S110. Obtain remote sensing images of the building to be extracted.
[0070] In this embodiment, the remote sensing image of the building to be extracted refers to high-resolution image data used to identify and extract building information in complex building areas. Specifically, this image data includes Sentinel-2 L2A satellite imagery under clear, cloudless, and snow-free conditions, as well as corresponding high-resolution remote sensing imagery. The main purpose of acquiring these images is to ensure accurate identification and extraction of building features, especially roof information.
[0071] First, suitable Sentinel-2 L2A satellite imagery for analysis needs to be acquired. This type of imagery provides data across multiple bands, which is crucial for calculating the Building Index (BUI). By selecting specific bands (such as short infrared Band 11, near infrared Band 8, red band Band 4, and green band Band 3), a Building Index reflecting the characteristics of the urban environment can be constructed, thereby aiding in the building identification process.
[0072] Next, all bands of the Sentinel-2 satellite imagery were resampled to a spatial resolution of 10m and registered with high-resolution remote sensing imagery. This step ensures that data from different sources can accurately correspond in spatial location, providing accurate data support for subsequent calculations of the urban building index and selection of representative samples.
[0073] Then, a square grid with sides of 1 kilometer is established within the target city area, with each grid serving as a sampling unit. The spatial coordinates of these grid units are used as their spatial locations, and the Building Urban Index (BUI) within each cell is calculated based on the image data processed in the previous steps. The calculation of the BUI involves the combination and computation of specific band data, aiming to quantify the presence and density of buildings within each grid unit.
[0074] Ultimately, the remote sensing images of the buildings to be extracted, obtained through this series of steps, not only contain rich spectral information but have also undergone preprocessing to meet further analytical needs, such as sample selection and training of the adaptive parameter U-Net model. The aim is to improve the accuracy of building extraction in complex building areas while reducing reliance on a large number of training samples, thus enhancing the model's generalization ability and robustness.
[0075] S120. Input the remote sensing image of the building to be extracted into the AFL U-Net model for building identification, and convert the identification result into roof data in vector form.
[0076] In this embodiment, the vector form of roof data refers to converting the identified building roof boundaries into editable and analyzable polygon vector files in a geographic information system (GIS).
[0077] In one embodiment, step S120 described above may include steps S121 to S127.
[0078] S121. Using ArcGIS Pro, the remote sensing image of the building to be extracted is cropped according to the research scope, and the data is enhanced through the Albumentations library to export a standard image that meets the requirements.
[0079] In this embodiment, a standard image refers to a remote sensing image that has been cropped and data-enhanced to meet specific format requirements (such as resolution, projection coordinate system, etc.).
[0080] First, the remote sensing images of the buildings to be extracted are cropped using ArcGIS Pro tools according to the study area (such as administrative boundaries or specific regions) to remove irrelevant areas. Next, data augmentation processing is performed on the cropped images using the Albumentations library, including geometric transformations (such as rotation and flipping), color transformations (such as contrast adjustment), and noise addition, to increase the diversity of the training data and improve the model's generalization ability. Finally, a standard image conforming to the requirements is exported according to a specific projection coordinate system and image resolution.
[0081] S122. Set the processing window size and sliding step size to obtain the division parameters.
[0082] In this embodiment, the segmentation parameters refer to window size and sliding step size, which are used to guide how to segment the entire image into multiple sub-image blocks for subsequent processing.
[0083] The processing window size was set to 512×512 pixels, and the sliding step size was set to 256 pixels. These parameters were chosen to improve computational efficiency while preserving detailed information.
[0084] S123. Starting from the upper left corner of the standard image, move the window according to the set step size in the division parameters, and standardize the mean and standard deviation of each standard image to obtain the division result.
[0085] In this embodiment, the segmentation result refers to the image block within each window that has been processed by removing the mean and dividing by the standard deviation, and is ready to be sent into the model for forward propagation.
[0086] Starting from the top left corner of the standard image, the window is moved according to the set step size, and the image blocks in each window are normalized (mean and standard deviation are standardized) to ensure that the data distribution of different image blocks is consistent, which is beneficial to model learning.
[0087] S124. The partitioning results are forward propagated using the AFL U-Net model to generate a building probability map.
[0088] In this embodiment, the building probability map refers to the result of the model prediction, which shows the probability that each location in the image is a building.
[0089] The pre-trained adaptive Focal_Loss loss function U-Net (AFL U-Net) model is used to perform forward propagation on each standardized image patch, and outputs a building probability map with a size of 512×512, representing the probability that each pixel belongs to a building.
[0090] S125. For the same pixel position spanning multiple windows, calculate the average predicted probability based on the building probability map to obtain a binarized result.
[0091] In this embodiment, the binarization result refers to the result after probability averaging, where each pixel is labeled as either a building or a non-building.
[0092] For the same pixel location spanning multiple windows, the average of its predicted probability is calculated based on the building probability maps of each window, resulting in the final binarized result. This step helps reduce edge effects caused by window segmentation.
[0093] S126. Apply a medium filter to the binarization result to remove noise points and retain continuous building areas to obtain the filtering result.
[0094] In this embodiment, the filtering result refers to the image after median filtering, which removes small areas of noise and preserves the main building structure.
[0095] A 3×3 median filter is applied to the binarization result to remove isolated small noise points while preserving continuous building areas, thus obtaining a cleaner and more accurate building outline.
[0096] S127. The filtered result is used to generate a binary image of the building using the Sigmoid function. This image is then overlaid with a high-resolution image for verification. The binary image is then converted into a polygon vector file using GDAL to obtain the roof data in vector form.
[0097] Finally, the filtered result is converted into a binary image (i.e., a black and white image) using the Sigmoid activation function, where the white areas represent buildings. This binary image is then overlaid onto a high-resolution remote sensing image for visual verification, and finally converted into a polygon vector file using the GDAL tool, enabling accurate extraction of buildings in complex building areas.
[0098] Vector-format roof data refers to the resulting polygonal vector file containing information about the building's roof, which can be easily used for Geographic Information System (GIS) analysis or other applications.
[0099] In this embodiment, firstly, ArcGIS Pro tools are used to crop the remote sensing imagery according to the study area (e.g., administrative boundaries or specific vector polygons) to remove irrelevant areas. Then, the data is augmented using the Albumentations library, increasing the dataset's diversity through geometric transformations, color adjustments, and noise addition, ensuring the model can learn a wider range of features during training. All processed images are exported according to a specific projected coordinate system and image resolution.
[0100] The window size was set to 512×512 pixels, and the sliding step size was set to 256 pixels. This setting allows the model to effectively cover the entire image area while maintaining sufficient contextual information.
[0101] Starting from the top left corner of the image, a sliding window is used to normalize the image patch within each window (based on the mean and standard deviation) at a predetermined step size. This step ensures that the data input to the U-Net model has a uniform scale, thereby improving the model's performance and stability.
[0102] The trained U-Net model is used to perform forward propagation on the normalized image patches, outputting building probability maps of size 512×512. These probability maps represent the probability that each pixel belongs to a building.
[0103] For the same pixel (such as pixel A) located in two overlapping windows, their predicted probabilities are averaged (for example, if the predicted probability is 0.6 in window 1 and 0.5 in window 2, the fused probability is (0.6+0.5) / 2=0.55) to reduce boundary effects and improve the accuracy of the final result.
[0104] A 3×3 median filter kernel is applied to process the binarized result to remove isolated noise points smaller than 5×5 pixels while preserving continuous building areas. This process helps improve the sharpness and integrity of building edges.
[0105] Finally, the probability map was converted into a binary map using the Sigmoid activation function, representing the presence or absence of buildings. This binary map was then overlaid onto the original high-resolution remote sensing image for visual inspection and verification. After confirmation, the GDAL vectorization tool was used to convert the binary image into a polygon vector file, completing the accurate extraction of buildings in complex building areas.
[0106] In one embodiment, please refer to Figure 2 The training process of the AFL U-Net model includes steps S131 to S133.
[0107] S131. Collect and process high-resolution remote sensing images and Sentinel-2 satellite images, resample them to a uniform resolution, and calculate the urban building index for each grid cell.
[0108] In this embodiment, the urban building index is a quantitative indicator calculated by combining Sentinel-2 satellite imagery data in the short infrared, near infrared, red band, and green band, and adjusting it with building adjustment coefficients and non-building weight adjustment coefficients. It is used to characterize the presence and intensity of buildings in the urban environment.
[0109] In one embodiment, step S131 described above may include steps S1311 to S1313.
[0110] S1311. Sentinel-2 L2A satellite imagery with clear skies, no clouds, and no snow accumulation, as well as high-resolution remote sensing imagery, were selected as the data source.
[0111] First, Sentinel-2 L2A satellite imagery with clear skies, no clouds, and no snow accumulation, along with corresponding high-resolution remote sensing imagery, were selected as the data source. This step ensured that the imagery used had good visual clarity and quality, thereby improving the accuracy of subsequent analysis.
[0112] S1312. Resample all bands of the Sentinel-2 L2A satellite imagery and ensure that it is registered with the high-resolution remote sensing imagery to obtain the registered data source.
[0113] In this embodiment, all bands of Sentinel-2 L2A satellite imagery are uniformly resampled to a spatial resolution of 10m, and these imagery are precisely registered with selected high-resolution remote sensing imagery. This process ensures that all imagery in use has the same spatial reference system and resolution, which is crucial for subsequent multi-source data fusion.
[0114] S1313. Based on the registered data source, a square grid is constructed within the target city area. Each grid serves as a sampling unit, with the spatial coordinates of its center point representing the grid unit's location. The urban building index within each grid is then calculated.
[0115] Specifically, using the high-resolution remote sensing imagery from the registered data source as a reference, a grid is established within the target city area, and all grids are used as sampling units. The spatial coordinates of the center point of each sampling unit are used as the spatial location of each grid, and the urban building index within each cell is calculated. The formula for calculating the urban building index includes: ; ; ; Among them, SWIR is the short infrared band Band 11, NIR is the near infrared band Band 8, Red is the red band Band 4, and Green is the green band Band 3. This is the building adjustment coefficient. For non-building weight adjustment factors, the values of NDBI, NDVI, and NDWI are all between (-1, 1), while the value of BUI is between (0, 1).
[0116] To achieve the above steps, the selected remote sensing images must first be preprocessed, including but not limited to cloud removal, geometric correction, and radiometric correction, to ensure that the image quality meets the requirements. Then, the indices for each band are calculated according to the formulas defined above, and the Building Indices (BUI) are calculated in conjunction with adjustment coefficients. This series of operations not only helps to select the most representative training samples from massive amounts of data but also lays the foundation for subsequent building extraction based on the adaptive parameter U-Net model. Finally, through optimized sample selection and improved loss function strategies, the accuracy and efficiency of building extraction in complex building areas can be significantly improved.
[0117] S132. Using the extended spatial particle swarm optimization algorithm, optimize sampling based on grid cell location and the urban building index to select representative samples.
[0118] In this embodiment, representative samples refer to those highly representative and informative samples selected from the entire dataset through a specific optimization algorithm. These samples not only accurately reflect the characteristics of the overall dataset but also effectively improve the model training effect and generalization ability. Specifically, this process is based on the location of grid cells and the calculated Building Index (BUI) for spatial optimization sampling, which is an extension of the traditional spatial particle swarm optimization algorithm.
[0119] Specifically, spatial optimization sampling is performed based on grid cell location and building index. This spatial optimization sampling is an extension of the spatial particle swarm algorithm to select representative samples.
[0120] In one embodiment, step S132 may include steps S1321 to S1327.
[0121] S1321. Define the fitness function of the spatial particle swarm optimization algorithm. The fitness function is based on the grid cell position and building index. Define velocity update formulas and position update formulas to guide particle movement in the spatial particle swarm optimization algorithm. The parameters involved include inertia weight, individual learning factor, and social learning factor, which respectively control the particle's tendency to maintain its current state, the speed at which it approaches its individual optimal position, and the speed at which it approaches the group's optimal position.
[0122] First, a fitness function is defined for the spatial particle swarm optimization algorithm, based on the position and building index (BUI) of each grid cell. Additionally, velocity and position update formulas are defined to guide particle movement in the search space. These parameters include inertia weights, individual learning factors, and social learning factors, which control the particle's tendency to maintain its current state, its speed of approaching its individual optimal position, and its speed of approaching the swarm optimal position, respectively.
[0123] Specifically, The fitness of the spatial particle swarm algorithm ,Will As the velocity update formula for the spatial particle swarm optimization algorithm, This serves as the position update formula for the spatial particle swarm optimization algorithm. The spatial location of each grid cell, The building index for each grid cell; For particles exist The speed of time Inertial weights control the inertia that allows particles to maintain their current state of motion. For particles exist The speed of time and Individual learning factors and social learning factors are used to control the particle's trajectory toward the individual's optimal position. and the optimal position of the group The speed at which they approach each other. and for Random numbers between For particles The optimal position of an individual. The optimal position globally. For particles exist Location at any given moment For particles exist The location at any given moment.
[0124] S1322. Initialize all relevant parameters, including individual learning factor, social learning factor, and inertia weight.
[0125] Before starting, all relevant parameters need to be initialized, including but not limited to individual learning factors, social learning factors, and inertia weights, to ensure that the particle swarm algorithm can run normally.
[0126] Specifically, initializing individual learning factors and social learning factors. and inertia weight .
[0127] S1323. Initialize the entire sample set to the population size of the particle swarm, and treat each sample unit as a particle, whose initial position and velocity are calculated based on the spatial position and building index of the sample unit.
[0128] In this embodiment, the entire sample set is initialized to the swarm size of a particle swarm, and each sample unit is treated as an independent particle. The initial position and velocity of each particle are calculated based on the spatial position and building index of its corresponding sample unit.
[0129] Specifically, the entire sample set Initialize the swarm size N to the particle swarm size, and treat each sample unit as a particle. Calculate the spatial position and building index of each particle, which are used as the position of each particle. and speed .
[0130] S1324. Before the predetermined number of iterations or the number of consecutive rejections reaches the threshold, randomly select the spatial position of the particle, calculate its fitness value based on the fitness function, and set it as the initial individual optimal position and global optimal position.
[0131] In this embodiment, during the iteration process, the spatial position of a particle is randomly selected, and its fitness value is calculated based on a previously defined fitness function. The first calculated fitness value is set as the initial individual optimal position and the global optimal position of that particle.
[0132] Randomly select samples Spatial location, calculate the first wheel adaptability and take it as the individual's optimal position. and global optimal position .
[0133] S1325. Perturb the selected samples to generate a new sample set, and compare the fitness values of the new and old sample sets. If the fitness of the new sample set is better, then replace the original sample set.
[0134] In this embodiment, the selected samples are perturbed to generate a new sample set, and its fitness value is compared with that of the old sample set. If the fitness of the new sample set is better, the original sample set is replaced with the new sample set.
[0135] Perturb the currently drawn sample to generate a new sample set. Use its fitness and individual optimal position Compare, if Then the sample set used Replace the original sample set .
[0136] S1326. Compare the fitness of the new sample set with the global optimum. If it is better than the existing global optimum, then update the global optimum to the position of the current sample set.
[0137] In this embodiment, the fitness value of the new sample set is compared with the current global optimum. If the performance of the new sample set is better than the existing global optimum, the global optimum position is updated to the position of the current sample set.
[0138] For the currently drawn sample, use its fitness. and global optimal position Compare, if Then the sample set used Replace the optimal sample set .
[0139] S1327. When the predetermined number of iterations or the number of consecutive rejections reaches the threshold, the high-resolution remote sensing image corresponding to the output sample location is matched and uniformly cropped into a regular image with a pixel size that meets the requirements. The corresponding image label file is then created to obtain representative samples.
[0140] In this embodiment, the algorithm terminates when the predetermined number of iterations or the number of consecutive rejections reaches a threshold. At this point, the high-resolution remote sensing images corresponding to the output sample locations are matched and uniformly cropped into images with regular pixel sizes that meet the requirements. Label files for the corresponding images are then created, ultimately yielding a representative sample set.
[0141] Update particle position and speed Repeat steps S1324 to S1327 until the number of iterations reaches a threshold or the number of consecutive rejections reaches a threshold, at which point the algorithm terminates and outputs the selected sample set. The optimal sample set is selected using the spatial particle swarm optimization algorithm. High-resolution remote sensing images of the output sample locations are matched, and these images are uniformly cropped to a regular image size of 512*512 pixels. Label files for the corresponding images are created through manual annotation.
[0142] By following the steps above, a small number of the most representative samples can be effectively selected from massive amounts of data. This not only reduces sample costs but also improves the model's generalization ability and accuracy.
[0143] S133. Using the representative samples, the U-Net model is trained through the improved Focal_Loss loss function parameter self-prediction mechanism to optimize the learning efficiency of hard-to-classify samples and form the AFL U-Net model.
[0144] In this embodiment, the parameters of the Focal_Loss loss function are self-predicted based on least squares. The U-Net model is trained according to the Focal_Loss loss function, and a binary linear regression model is established according to the F1-oriented optimization strategy of the Focal_Loss function parameters to obtain the AFL U-Net model. The Focal_Loss dynamically reduces the weight of easily distinguishable samples during training through a dynamic scaling factor.
[0145] In this embodiment, a parameter self-prediction mechanism based on the least squares Focal_Loss loss function is used to train the U-Net model, and a binary linear regression model is established according to an F1 score-oriented optimization strategy, thus obtaining an adaptive loss function U-Net model (Adaptive Focal_Loss U-Net, AFL U-Net). This process aims to dynamically adjust the weights of easily distinguishable samples to improve the model's learning efficiency for difficult-to-classify samples.
[0146] In one embodiment, step S133 described above may include steps S1331 to S1339.
[0147] S1331. Establish a binary linear regression model with F1 score as the dependent variable, parameters that suppress the imbalance between positive and negative samples, and parameters that control for the imbalance between simple and complex samples as independent variables.
[0148] First, a binary linear regression model is established with the F1 score as the dependent variable and parameters that suppress the imbalance between positive and negative sample sizes and control for the imbalance between simple and complex sample sizes as independent variables.
[0149] S1332. Before the number of iterations or consecutive rejections reaches a preset threshold, initialize the coefficients of the binary linear regression model.
[0150] Before the number of iterations or consecutive rejections reaches a preset threshold, the coefficients of the binary linear regression model are initialized to prepare for subsequent parameter optimization.
[0151] S1333. Generate an array of initial values for the independent variables based on a given step size, including taking points downwards and upwards.
[0152] In this embodiment, an array of initial values for the independent variables is generated based on a given step size. For example, for a parameter, an array can be formed by taking 3 data points downwards and 4 data points upwards with a step size of 0.25. Similarly, for a parameter, an array can be formed by taking 3 data points downwards and 4 data points upwards with a step size of 0.5.
[0153] S1334. Based on the initial value array of the independent variables, re-initialize the coefficients of the binary linear regression model.
[0154] In this embodiment, the coefficients of the binary linear regression model are re-initialized based on the generated array of initial values of independent variables to ensure that the model can accurately reflect the relationship under the current values of independent variables.
[0155] S1335. Refine the range of independent variables by increasing the starting value by specifying the step size to form a new array of data points.
[0156] In this embodiment, to find the optimal solution more accurately, the range of the independent variables is refined. For example, for the parameter, it starts at 0.24 and increases to 0.28 in steps of 0.005; for the parameter, it starts at 1.5 and increases to 2 in steps of 0.05. The purpose of this is to generate a new array of data points for a more refined parameter search.
[0157] S1336. Substitute the current independent variable value into the F1 formula to verify its correlation with the dependent variable in order to obtain the analysis results.
[0158] In this embodiment, the analysis result refers to the score calculated by substituting the current independent variable values into the F1 formula. This score is used to evaluate the correlation between these independent variable values and the dependent variable, thereby guiding parameter optimization to improve model performance. In short, the analysis result is an indicator of model performance under specific parameter configurations, aiming to find the optimal parameter combination to maximize the F1 score.
[0159] Substitute the current independent variable value into the F1 formula to calculate and verify its correlation with the dependent variable. The analysis results will be used to guide the next step of parameter updates.
[0160] S1337. Update the values of the independent variables based on the analysis results.
[0161] In this embodiment, based on the analysis results of the previous step, the values of the independent variables are updated to gradually approach the optimal solution.
[0162] S1338. Traverse all combinations and gradually adjust the number of parameter iterations or the number of consecutive rejections to reach a preset threshold, and record the F1 score during the process.
[0163] In this embodiment, all possible combinations of independent variables are traversed, parameters are adjusted step by step, and the F1 score is recorded after each iteration. This process continues until the number of iterations or the number of consecutive rejections reaches a preset threshold.
[0164] S1339. When the number of iterations or consecutive rejections reaches a preset threshold, determine the optimal configuration that leads to the highest F1 score based on the recorded F1 score to obtain the optimal parameter configuration. Then, use the optimal parameter configuration to train the U-Net model using the Focal Loss loss function parameter self-prediction based on the least squares method, and dynamically adjust the weights of easily distinguishable samples to obtain the AFL U-Net model.
[0165] In this embodiment, when the number of iterations or consecutive rejections reaches a preset threshold, the optimal configuration leading to the highest F1 score is determined based on the recorded F1 scores. Using these optimal parameter configurations, the U-Net model is trained using the FocalLoss loss function parameters based on least squares, dynamically adjusting the weights of easily distinguishable samples, and finally obtaining the optimized AFL U-Net model.
[0166] The above steps effectively optimize the training process of the U-Net model, particularly for difficult-to-classify samples, improving the accuracy of building extraction. This method not only solves the problems existing in traditional static loss functions but also significantly improves the overall performance and generalization ability of the model.
[0167] In this embodiment, based on the self-prediction of the Focal_Loss loss function parameters using least squares, Focal_Loss dynamically reduces the weights of easily distinguishable samples during training through a dynamic scaling factor, thereby quickly focusing the attention on those difficult-to-distinguish samples. The U-Net model is trained according to the Focal_Loss loss function, and an optimization strategy based on F1 score is established, with F1 score as the dependent variable. , For a binary linear regression model with independent variables, an adaptive loss function U-Net model (Adaptive Focal_Loss U-Net, AFL U-Net) was obtained. The F1 formula is shown below: ;
[0168] The specific implementation process of training the U-Net model based on the self-prediction of parameters of the Focal_Loss loss function using least squares is as follows:
[0169] Will F1 is the dependent variable. , This is a bivariate linear regression model with independent variables. To suppress the imbalance between the number of positive and negative samples, It controls the imbalance between the number of simple and complex samples.
[0170] Initialize the coefficients of the bivariate linear regression model Will be A step size of 0.25 is used to take 3 data points downwards to form an array and 4 data points upwards to form an array. ,in Initialize the coefficients of the bivariate linear regression model. Will be =1.50, where 0.50 is the step size for taking 3 data points downwards to form an array and 4 data points upwards to form an array. ,in For the currently generated and The value, using and The generated values, when substituted into the F1 formula, can be used to test... , As a whole, the independent variables do indeed correlate with the dependent variable. Update the model's independent variables. and .renew Starting with 0.24, and increasing in increments of 0.005 until reaching 0.28, the resulting array is... . Starting with 1.5, and increasing to 2 in increments of 0.05, we obtain the array. Maintain in each round Unchanged, Cyclic to Solve the equation Iterate to End, obtain array A series of dependent variable values.
[0171] Repeat all the steps in the previous section until the number of iterations reaches a threshold or the number of consecutive rejections reaches a threshold, at which point the calculation terminates. For the desired series of F1 dependent variable values, only... Corresponding and That is, the optimal and Configuration scheme. The U-Net model is trained using self-prediction of parameters based on the Focal_Loss loss function (least squares), and then... Corresponding and This configuration can solve the problems of imbalance between positive and negative samples and class imbalance that easily occur during model training. It dynamically reduces the weight of easily distinguishable samples during training, thereby quickly focusing the attention on those difficult-to-distinguish samples.
[0172] The method in this embodiment is specifically designed for building extraction in complex building areas. With a limited number of training samples, this method achieves a building extraction accuracy of up to 89.14%, significantly improving model performance under resource-constrained conditions.
[0173] First, this embodiment proposes a novel urban building index that uses multi-band data from Sentinel-2 satellite imagery to characterize urban environmental features. Combining the spatial distribution of samples with BUI values, a multi-objective particle swarm optimization algorithm is employed to filter the samples. This method can select a small number of the most representative training samples from a large dataset, significantly reducing the cost of sample collection and enhancing the model's generalization ability when faced with new data.
[0174] Secondly, regarding the loss function design, this embodiment introduces a least-squares-based Focal_Loss parameter adaptive prediction mechanism, improving upon the traditional U-Net model. This mechanism allows the model to dynamically adjust the parameters of the loss function based on the actual situation during training, effectively addressing the problems of positive / negative sample imbalance and class imbalance. Specifically, by reducing the weights of easily distinguishable samples, it enables the model to focus more on those difficult-to-classify samples, further improving the model's performance and robustness.
[0175] In summary, the method presented in this embodiment provides an efficient and accurate approach for building extraction in complex building areas through innovative sample selection strategies and adaptive loss function adjustment techniques, making it particularly suitable for scenarios where sample acquisition is difficult or costly. These improvements not only significantly enhance the accuracy of building extraction but also open up new directions for research and applications in related fields.
[0176] This embodiment's method utilizes an urban building index constructed from Sentinel-2 imagery to accurately characterize urban geographical features. It combines sample spatial distribution and BUI with a multi-objective particle swarm optimization algorithm to select a small number of more representative training data from a large dataset. Furthermore, this embodiment's method employs a least-squares Focal_Loss loss function parameter self-predictive training model, resolving the issues of imbalanced positive and negative samples and class imbalance during model training, thus achieving high-precision building extraction in complex building areas. This invention achieves accurate building extraction in complex building areas through representative sample selection and an adaptive parameter U-Net model.
[0177] The aforementioned method for extracting buildings in complex building areas collects and processes high-resolution remote sensing imagery and Sentinel-2 satellite imagery, calculates the urban building index for each grid cell, and utilizes an extended spatial particle swarm optimization algorithm to select the most representative training samples based on the spatial distribution of the samples and the Building Identity Indicator (BUI). Specifically, an improved Focal_Loss loss function parameter adaptive prediction mechanism is employed to train the U-Net model. This mechanism dynamically adjusts the loss function parameters according to the difficulty of the samples, thereby enhancing the focus on difficult-to-classify samples while reducing the weight of easily distinguishable samples, effectively solving the problems of positive / negative sample imbalance and class imbalance. This method not only optimizes the model's learning efficiency but also significantly improves the overall accuracy of building extraction, enabling efficient building identification and vectorization under conditions of a small number of representative training samples.
[0178] Figure 3 This is a schematic block diagram of a building extraction device 300 for complex building areas provided in an embodiment of the present invention. Figure 3 As shown, corresponding to the above-described method for extracting buildings in complex building areas, the present invention also provides a building extraction device 300 for complex building areas. This building extraction device 300 includes a unit for performing the above-described method for extracting buildings in complex building areas, and the device can be configured in a server. Specifically, please refer to... Figure 3 The complex building extraction device 300 includes an acquisition unit 301 and an identification and conversion unit 302.
[0179] The acquisition unit 301 is used to acquire remote sensing images of the building to be extracted; the recognition and conversion unit 302 is used to input the remote sensing images of the building to be extracted into the AFL U-Net model for building recognition, and convert the recognition results into roof data in vector form.
[0180] The system also includes a training unit, comprising: a computation subunit for collecting and processing high-resolution remote sensing images and Sentinel-2 satellite images, resampling them to a uniform resolution, and calculating the urban building index for each grid cell; an optimization sampling unit for using an extended spatial particle swarm optimization algorithm to perform optimized sampling based on the grid cell location and the urban building index, selecting representative samples; and a model training subunit for using the representative samples to train the U-Net model through an improved Focal_Loss loss function parameter self-prediction mechanism, optimizing the learning efficiency for hard-to-classify samples, and forming an AFL U-Net model.
[0181] In one embodiment, the calculation subunit is used to establish a grid within the target city area based on the high-resolution remote sensing image in the registered data source, and to use all grids as sampling units, with the spatial coordinates of the center point of each sampling unit as the spatial location of each grid, and to calculate the urban building index within each cell, wherein the calculation formula for the urban building index includes: ; ; ; Among them, SWIR is the short infrared band Band 11, NIR is the near infrared band Band 8, Red is the red band Band 4, and Green is the green band Band 3. This is the building adjustment coefficient. For non-building weight adjustment factors, the values of NDBI, NDVI, and NDWI are all between (-1, 1), while the value of BUI is between (0, 1).
[0182] In one embodiment, the optimized sampling unit is used to perform spatial optimized sampling based on the grid cell location and building index. The spatial optimized sampling is an extension of the spatial particle swarm algorithm to select representative samples.
[0183] In one embodiment, the optimized sampling unit includes:
[0184] The function definition module defines the fitness function of the spatial particle swarm optimization algorithm. This fitness function is based on grid cell positions and building indices, and defines velocity and position update formulas to guide particle movement in the algorithm. Parameters involved include inertia weight, individual learning factor, and social learning factor, which control the particle's tendency to maintain its current state, its speed of approaching its individual optimal position, and its speed of approaching the swarm's optimal position, respectively. The parameter initialization module initializes all relevant parameters, including the individual learning factor, social learning factor, and inertia weight. The sample initialization module initializes the entire sample set to the swarm size, treating each sample cell as a particle, with its initial position and velocity calculated based on the sample cell's spatial position and building index. The random selection module randomly selects the spatial position of particles before reaching a predetermined number of iterations or a threshold of consecutive rejections, based on the fitness value. The function calculates the fitness value of the selected samples and sets it as the initial individual optimal position and the global optimal position. The perturbation module is used to perturb the selected samples to generate a new sample set and compare the fitness values of the new and old sample sets. If the fitness of the new sample set is better, the original sample set is replaced. The comparison module is used to compare the fitness of the new sample set with the global optimal position. If it is better than the existing global optimal position, the global optimal position is updated to the position of the current sample set. The matching module is used to match the high-resolution remote sensing image corresponding to the sample position when a predetermined number of iterations or a threshold number of consecutive rejections is reached. The image is then uniformly cropped into a regular image with a pixel size that meets the requirements, and a label file for the corresponding image is created to obtain representative samples.
[0185] In one embodiment, the model training subunit is used to self-predict the parameters of the Focal_Loss loss function based on least squares, train the U-Net model according to the Focal_Loss loss function, and establish a binary linear regression model according to the F1-oriented optimization strategy of the Focal_Loss function parameters to obtain the AFL U-Net model; wherein, Focal_Loss dynamically reduces the weight of easily distinguishable samples during training through a dynamic scaling factor.
[0186] In one embodiment, the model training subunit includes:
[0187] The model building module is used to build a binary linear regression model with the F1 score as the dependent variable and parameters that suppress the imbalance between positive and negative samples and control the imbalance between simple and complex samples as independent variables. The coefficient initialization module is used to initialize the coefficients of the binary linear regression model before the number of iterations or consecutive rejections reaches a preset threshold. The array generation module is used to generate an array of initial values for the independent variables based on a given step size, including downward and upward point selection. The re-initialization module is used to re-initialize the coefficients of the binary linear regression model based on the array of initial values for the independent variables. The refinement module is used to refine the range of independent variables by specifying a step size. The system employs several mechanisms: First, it adds an initial value to form a new array of data points. Second, it uses a validation module to substitute the current independent variable value into the F1 formula to verify its correlation with the dependent variable, thus obtaining the analysis results. Third, it uses an update module to update the independent variable value based on the analysis results. Fourth, it uses a recording module to iterate through all combinations and gradually adjust the number of parameter iterations or consecutive rejections to reach a preset threshold, recording the F1 score during the process. Fifth, it uses a determination module to determine the optimal parameter configuration that leads to the highest F1 score when the number of iterations or consecutive rejections reaches the preset threshold, obtaining the optimal parameter configuration. This optimal parameter configuration is then used to train a U-Net model using the Focal Loss loss function parameter self-prediction based on the least squares method, dynamically adjusting the weights of easily distinguishable samples to obtain the AFL U-Net model.
[0188] In one embodiment, the identification and conversion unit 302 includes:
[0189] The system comprises the following sub-units: a standardization sub-unit, which uses ArcGIS Pro to crop the remote sensing imagery of the buildings to be extracted according to the research scope, and enhances the data using the Albumentations library to export a standard image that meets the requirements; a setting sub-unit, which sets the processing window size and sliding step size to obtain the partitioning parameters; a partitioning sub-unit, which moves the window from the upper left corner of the standard imagery according to the set step size in the partitioning parameters, and standardizes each standard imagery by mean and standard deviation to obtain the partitioning result; a forward propagation sub-unit, which uses the AFL U-Net model to perform forward propagation on the partitioning result to generate a building probability map; a calculation sub-unit, which calculates the average predicted probability based on the building probability map for the same pixel position spanning multiple windows to obtain a binarized result; a filtering sub-unit, which applies a medium-range filter to the binarized result to remove noise points and retain continuous building areas to obtain a filtered result; and a transformation sub-unit, which uses the Sigmoid function to generate a building binary map from the filtered result, overlays it with a high-resolution imagery for verification, and uses GDAL to convert the binary map into a polygon vector file to obtain vector roof data.
[0190] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned complex building area building extraction device 300 and each unit can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.
[0191] The aforementioned building extraction device 300 for complex building areas can be implemented as a computer program, which can, for example... Figure 4 It runs on the computer device shown.
[0192] Please see Figure 4 , Figure 4 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 can be a server, wherein the server can be a standalone server or a server cluster composed of multiple servers.
[0193] See Figure 4 The computer device 500 includes a processor 502, a memory, and a network interface 505 connected via a system bus 501. The memory may include a non-volatile storage medium 503 and internal memory 504.
[0194] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions that, when executed, cause the processor 502 to perform a method for extracting buildings in a complex building area.
[0195] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0196] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can perform a method for extracting buildings in a complex building area.
[0197] This network interface 505 is used for network communication with other devices. Those skilled in the art will understand that... Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0198] The processor 502 is used to run a computer program 5032 stored in a memory to implement all the steps of the complex building area extraction method.
[0199] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0200] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0201] Therefore, the present invention also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein when executed by a processor, the computer program causes the processor to perform all the steps of the complex building area extraction method.
[0202] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0203] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0204] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0205] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the device of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0206] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0207] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for extracting buildings in complex building areas, characterized in that, include: Acquire remote sensing images of the building to be extracted; The remote sensing image of the building to be extracted is input into the AFL U-Net model for building identification, and the identification result is converted into roof data in vector form; The training process of the AFL U-Net model includes: Collect and process high-resolution remote sensing images and Sentinel-2 satellite images, resample them to a uniform resolution, and calculate the urban building index for each grid cell; Using an extended spatial particle swarm optimization algorithm, representative samples are selected based on grid cell locations and the urban building index. The U-Net model is trained using the representative samples and an improved Focal_Loss loss function parameter self-prediction mechanism to optimize the learning efficiency of hard-to-classify samples, thus forming the AFL U-Net model.
2. The method for extracting buildings in complex building areas according to claim 1, characterized in that, The process of collecting and processing high-resolution remote sensing imagery and Sentinel-2 satellite imagery, resampling them to a uniform resolution, and calculating the urban building index for each grid cell includes: Sentinel-2 L2A satellite imagery with clear skies, no clouds, and no snow accumulation, as well as high-resolution remote sensing imagery, were selected as data sources. All bands of the Sentinel-2 L2A satellite imagery were uniformly resampled and registered with high-resolution remote sensing imagery to obtain the registered data source. Based on the registered data source, a square grid is constructed within the target city area. Each grid serves as a sampling unit, with the spatial coordinates of its center point representing the grid unit's location. The urban building index within each grid is then calculated.
3. The method for extracting buildings in complex building areas according to claim 2, characterized in that, Based on the registered data source, a square grid is constructed within the target city area, with each grid serving as a sampling unit. The spatial coordinates of its center point represent the location of the grid unit, and the urban building index within each grid is calculated, including: Using the high-resolution remote sensing imagery from the registered data source as a reference, a grid is established within the target city area. All grids are used as sampling units, and the spatial coordinates of the center point of each sampling unit are used as the spatial location of each grid. The urban building index within each cell is calculated, wherein the formula for calculating the urban building index includes: ; ; ; Among them, SWIR is the short infrared band Band 11, NIR is the near infrared band Band 8, Red is the red band Band 4, and Green is the green band Band 3. This is the building adjustment coefficient. For non-building weight adjustment factors, the values of NDBI, NDVI, and NDWI are all between (-1, 1), while the value of BUI is between (0, 1).
4. The method for extracting buildings in complex building areas according to claim 1, characterized in that, The method utilizes an extended spatial particle swarm optimization algorithm to perform optimized sampling based on grid cell locations and the urban building index, selecting representative samples, including: Spatial optimization sampling is performed based on grid cell location and building index. This spatial optimization sampling is an extension of the spatial particle swarm algorithm to select representative samples.
5. The method for extracting buildings in complex building areas according to claim 4, characterized in that, The spatial optimization sampling based on grid cell location and building index is an extension of the spatial particle swarm optimization algorithm, selecting representative samples, including: A fitness function for the spatial particle swarm optimization algorithm is defined, which is based on the grid cell position and building index. A velocity update formula and a position update formula are defined to guide particle movement in the spatial particle swarm optimization algorithm. The parameters involved include inertia weight, individual learning factor and social learning factor, which control the particle's tendency to maintain its current state, the speed at which it moves toward its individual optimal position and the speed at which it moves toward the group's optimal position, respectively. Initialize all relevant parameters, including individual learning factor, social learning factor, and inertia weight; The entire sample set is initialized to the population size of the particle swarm, and each sample unit is regarded as a particle, whose initial position and velocity are calculated based on the spatial position and building index of the sample unit. Before the predetermined number of iterations or the number of consecutive rejections reaches a threshold, the spatial position of the particle is randomly selected, and its fitness value is calculated based on the fitness function, and set as the initial individual optimal position and global optimal position. The selected samples are perturbed to generate a new sample set, and the fitness values of the new and old sample sets are compared. If the fitness of the new sample set is better, the original sample set is replaced. Compare the fitness of the new sample set with the global optimum. If it is better than the existing global optimum, then update the global optimum to the position of the current sample set. When the predetermined number of iterations or the number of consecutive rejections reaches a threshold, the high-resolution remote sensing image corresponding to the output sample location is matched and uniformly cropped into a regular image with a pixel size that meets the requirements. The corresponding image label file is then created to obtain representative samples.
6. The method for extracting buildings in complex building areas according to claim 1, characterized in that, The process of training the U-Net model using the representative samples through an improved Focal_Loss loss function parameter self-prediction mechanism to optimize the learning efficiency of hard-to-classify samples and form an AFL U-Net model includes: Based on the self-prediction of parameters of the Focal_Loss loss function using least squares, the U-Net model is trained according to the Focal_Loss loss function, and a binary linear regression model is established according to the optimization strategy of the Focal_Loss function parameters guided by F1, thus obtaining the AFL U-Net model; wherein, Focal_Loss dynamically reduces the weight of easily distinguishable samples during training through a dynamic scaling factor.
7. The method for extracting buildings in complex building areas according to claim 6, characterized in that, The least squares-based Focal_Loss loss function parameter self-prediction is used to train the U-Net model based on the Focal_Loss loss function. Furthermore, a binary linear regression model is established based on an F1-oriented Focal_Loss function parameter optimization strategy, resulting in the AFL U-Net model. The Focal_Loss loss function dynamically reduces the weights of easily distinguishable samples during training through a dynamic scaling factor, including: Establish a binary linear regression model with F1 score as the dependent variable, parameters that suppress the imbalance between positive and negative samples, and parameters that control for the imbalance between simple and complex samples as independent variables. Initialize the coefficients of the binary linear regression model before the number of iterations or consecutive rejections reaches a preset threshold; Generate an array of initial values for the independent variable based on a given step size, including taking points down and taking points up; Based on the initial value array of the independent variables, the coefficients of the binary linear regression model are re-initialized; Refine the range of independent variables by increasing the initial value by specifying a step size to form a new array of data points; Substitute the current independent variable value into the F1 formula to verify its correlation with the dependent variable in order to obtain the analysis results; Update the values of the independent variables based on the analysis results; Iterate through all combinations and gradually adjust the number of parameter iterations or consecutive rejections to reach a preset threshold, recording the F1 score during the process; When the number of iterations or consecutive rejections reaches a preset threshold, the optimal sum configuration that leads to the highest F1 score is determined based on the recorded F1 score to obtain the optimal parameter configuration. The optimal parameter configuration is then used to train the U-Net model using the FocalLoss loss function parameter self-prediction based on the least squares method, and the weights of easily distinguishable samples are dynamically adjusted to obtain the AFL U-Net model.
8. The method for extracting buildings in complex building areas according to claim 1, characterized in that, The step of inputting the remote sensing image of the building to be extracted into the AFL U-Net model for building identification, and converting the identification result into vector-form roof data, includes: The remote sensing images of the buildings to be extracted were cropped according to the research scope using ArcGIS Pro, and the data was enhanced using the Albumentations library to export standard images that meet the requirements. Set the processing window size and sliding step size to obtain the partitioning parameters; Starting from the upper left corner of the standard image, the window is moved according to the set step size in the division parameters, and the mean and standard deviation of each standard image are standardized to obtain the division result; The AFL U-Net model is used to perform forward propagation on the partitioning results to generate a building probability map; For the same pixel location spanning multiple windows, the average predicted probability is calculated based on the building probability map to obtain a binarized result; A medium filter is applied to the binarization result to remove noise points and retain continuous building areas to obtain the filtered result; The filtered results are used to generate a binary image of the building using the Sigmoid function. This image is then overlaid with a high-resolution image for verification. The binary image is then converted into a polygon vector file using GDAL to obtain the roof data in vector form.
9. A building extraction device for complex building areas, characterized in that, include: The acquisition unit is used to acquire remote sensing images of the building to be extracted; The identification and conversion unit is used to input the remote sensing image of the building to be extracted into the AFL U-Net model for building identification, and convert the identification result into roof data in vector form; This also includes training units, including: The computational sub-unit is used to collect and process high-resolution remote sensing imagery and Sentinel-2 satellite imagery, resample them to a uniform resolution, and calculate the urban building index for each grid cell. The optimized sampling unit is used to perform optimized sampling based on the grid cell location and the urban building index using an extended spatial particle swarm optimization algorithm, and to select representative samples. The model training subunit is used to train the U-Net model using the representative samples through an improved Focal_Loss loss function parameter self-prediction mechanism, thereby optimizing the learning efficiency of hard-to-classify samples and forming an AFL U-Net model.
10. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any one of claims 1 to 8.