Method, device and product for extracting buildings from remote sensing images taking into account target regularity
Through the collaborative training of multi-scale feature extraction network and generative adversarial network, the problem of low accuracy of building contour extraction in remote sensing images is solved, the extraction accuracy and contour regularity are improved, and the generalization ability of the model is enhanced.
Patent Information
- Application Number
- CN202410923051.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-10-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
It is difficult to accurately extract building contours from remote sensing images. Existing methods have low extraction accuracy, weak model generalization capabilities, and the extracted contours are too smooth.
Using a multi-scale feature extraction network combined with self-supervised contrastive learning and a generative adversarial network, the accuracy of building extraction and the regularity of contours are improved through collaborative training of the feature extraction network, generator and discriminator.
It improves the accuracy of building extraction and the generalization ability of the model, enhances the regularity of building outlines, and ensures the stability and accuracy of the extraction results.
Smart Images

Figure CN118470542B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of deep learning technology, and in particular, to a remote sensing image building extraction method, device and product that take target regularity into account. Background Art
[0002] Since the 1960s, the rapid development of space technology and information technology has greatly promoted the progress of remote sensing technology. Humans have been able to observe the earth in all weather conditions, all day and all directions. The rapid acquisition of high-resolution remote sensing image data has made it play an increasingly important role in many fields such as environmental monitoring, disaster emergency response, land use, vegetation coverage, and crop growth. With the rapid expansion of data volume, how to extract useful information from remote sensing images in a timely and accurate manner, that is, how to quickly interpret remote sensing images, has become a problem that needs to be solved.
[0003] Building information occupies a very important position in remote sensing applications, and its extraction method has always been a hot topic of research. As a type of artificial landform, buildings have their own unique regularity, but due to the complexity of remote sensing image information, it is still very difficult to accurately extract the roof outline of the building from remote sensing images, and the accuracy of the extracted building outline is low. Summary of the invention
[0004] Based on the above technical problems, the embodiments of the present invention provide a remote sensing image building extraction method, device and product that take into account target regularity, aiming to improve the accuracy of building contour extraction in remote sensing images.
[0005] A first aspect of an embodiment of the present invention provides a remote sensing image building extraction method taking into account target regularity, the method comprising:
[0006] Inputting a sample image into a feature extraction network to be trained to obtain multi-scale features; the sample image is a remote sensing image containing a building, and the sample image carries a label;
[0007] Determine the building part and the background part corresponding to the multi-scale feature, calculate a first loss function based on the label corresponding to the multi-scale feature, and the building part and the background part corresponding to the multi-scale feature, and obtain a first loss value;
[0008] Based on the building part and the background part corresponding to the multi-scale feature, performing self-supervised contrast learning on the multi-scale feature to determine a contrast loss value;
[0009] Inputting the multi-scale features and the labels corresponding to the multi-scale features into a generator to be trained to obtain a generator result, and calculating a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value;
[0010] Input the generator result into the discriminator to be trained to obtain a discriminant loss value;
[0011] Based on the first loss value, the contrast loss value, the second loss value and the discriminant loss value, the feature extraction network to be trained, the generator to be trained and the discriminator to be trained are trained to obtain a trained feature extraction network, a trained generator and a trained discriminator; the trained generator is used as a building extraction model;
[0012] The remote sensing image to be processed is processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed.
[0013] Optionally, the labels include at least: a building label and a background label;
[0014] The determining the building part and the background part corresponding to the multi-scale feature, calculating a first loss function based on the label corresponding to the multi-scale feature and the building part and the background part corresponding to the multi-scale feature, and obtaining a first loss value includes:
[0015] Using a multi-layer perceptron to perform initial binary classification on the multi-scale features to obtain a building part and a background part corresponding to the multi-scale features;
[0016] The first loss function is calculated based on the building part corresponding to the multi-scale feature and the building label corresponding to the multi-scale feature, and the first loss function is calculated based on the background part corresponding to the multi-scale feature and the background label corresponding to the multi-scale feature to obtain the first loss value.
[0017] Optionally, performing self-supervised contrast learning on the multi-scale features based on the building part and the background part corresponding to the multi-scale features to determine the contrast loss value includes:
[0018] Based on the building part and the background part corresponding to the multi-scale feature, respectively selecting features corresponding to some pixels in the building part corresponding to the multi-scale feature and features corresponding to some pixels in the background part corresponding to the multi-scale feature as anchor features;
[0019] Calculate contrast loss between features corresponding to other pixels in the multi-scale features except the anchor point feature and the anchor point feature to obtain the contrast loss value;
[0020] The contrast loss constrains the extracted multi-scale features during the training process, so that the feature regions inside the building part are consistent, and the feature regions of the building part and the background part are different.
[0021] Optionally, the generator to be trained includes at least: a first encoder, a second encoder and a decoder;
[0022] The step of inputting the multi-scale features and the labels corresponding to the multi-scale features into a generator to be trained to obtain a generator result, and calculating a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value comprises:
[0023] Inputting the multi-scale features into the first encoder to obtain a first encoding result;
[0024] Inputting the label corresponding to the multi-scale feature into the second encoder to obtain a second encoding result;
[0025] Inputting the first encoding result and the second encoding result into the decoder to obtain a first generator result and a second generator result respectively;
[0026] The second loss function is calculated based on the first generator result and the label corresponding to the multi-scale feature, and the second loss function is calculated based on the second generator result and the label corresponding to the multi-scale feature to obtain the second loss value.
[0027] Optionally, the training of the feature extraction network to be trained, the generator to be trained, and the discriminator to be trained based on the first loss value, the contrast loss value, the second loss value, and the discriminant loss value to obtain a trained feature extraction network, a trained generator, and a trained discriminator includes:
[0028] In each round of training, the first loss value, the contrast loss value, and the second loss value are used as generator loss, and the discriminant loss value is used as discriminator loss, and network parameters of the generator to be trained and the feature extraction network to be trained are updated alternately, as well as network parameters of the discriminator to be trained are updated;
[0029] Until the discriminator to be trained cannot determine the difference between the generator result and the label corresponding to the multi-scale feature, the network parameters corresponding to the feature extraction network to be trained, the generator to be trained and the discriminator to be trained are fixed to obtain the trained feature extraction network, the trained generator and the trained discriminator.
[0030] Optionally, the method further comprises:
[0031] determining the sample image;
[0032] Acquire remote sensing image data related to the sample image, and use the mean and variance of the remote sensing image data as prior information;
[0033] Normalizing the sample image based on the prior information to obtain a normalized result;
[0034] Performing image enhancement processing on the normalized result to obtain an optimized sample image; wherein the image enhancement processing includes at least one or more of the following: random flipping, random scaling, random cropping, and spectral random enhancement;
[0035] The step of inputting the sample image into the feature extraction network to be trained to obtain multi-scale features includes:
[0036] The optimized sample image is input into the feature extraction network to be trained to obtain the multi-scale features.
[0037] Optionally, the processing of the remote sensing image to be processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed includes:
[0038] Inputting the remote sensing image to be processed into the trained feature extraction network to obtain multi-scale features corresponding to the remote sensing image to be processed;
[0039] The multi-scale features corresponding to the remote sensing image to be processed are input into the building extraction model to obtain the building outline corresponding to the remote sensing image to be processed.
[0040] A second aspect of an embodiment of the present invention provides a remote sensing image building extraction device that takes into account target regularity, the device comprising:
[0041] A feature extraction module, used to input a sample image into a feature extraction network to be trained to obtain multi-scale features; the sample image is a remote sensing image containing a building, and the sample image carries a label;
[0042] A first loss determination module, configured to determine a building part and a background part corresponding to the multi-scale feature, and calculate a first loss function based on a label corresponding to the multi-scale feature and a building part and a background part corresponding to the multi-scale feature to obtain a first loss value;
[0043] A second loss determination module is used to perform self-supervised contrast learning on the multi-scale features based on the building part and the background part corresponding to the multi-scale features to determine the contrast loss value;
[0044] a third loss determination module, configured to input the multi-scale features and the labels corresponding to the multi-scale features into a generator to be trained to obtain a generator result, and calculate a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value;
[0045] A fourth loss determination module, used for inputting the generator result into the discriminator to be trained to obtain a discriminant loss value;
[0046] A model training module, used for training the feature extraction network to be trained, the generator to be trained and the discriminator to be trained based on the first loss value, the contrast loss value, the second loss value and the discriminant loss value to obtain a trained feature extraction network, a trained generator and a trained discriminator; and using the trained generator as a building extraction model;
[0047] The contour extraction module is used to process the remote sensing image to be processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed.
[0048] Optionally, the labels include at least: a building label and a background label;
[0049] The first loss determination module includes:
[0050] A classification module, used for performing initial binary classification on the multi-scale features using a multi-layer perceptron to obtain a building part and a background part corresponding to the multi-scale features;
[0051] A first loss calculation module is used to calculate the first loss function based on the building part corresponding to the multi-scale feature and the building label corresponding to the multi-scale feature, and to calculate the first loss function based on the background part corresponding to the multi-scale feature and the background label corresponding to the multi-scale feature to obtain the first loss value.
[0052] Optionally, the second loss determination module includes:
[0053] An anchor point determination module, used for selecting features corresponding to some pixels in the building part corresponding to the multi-scale feature and features corresponding to some pixels in the background part corresponding to the multi-scale feature as anchor point features, based on the building part and the background part corresponding to the multi-scale feature;
[0054] A contrast loss determination module, used to calculate contrast losses of features corresponding to other pixels in the multi-scale features except the anchor point feature and the anchor point feature, respectively, to obtain the contrast loss value;
[0055] The contrast loss constrains the extracted multi-scale features during the training process, so that the feature regions inside the building part are consistent, and the feature regions of the building part and the background part are different.
[0056] Optionally, the generator to be trained includes at least: a first encoder, a second encoder and a decoder;
[0057] The third loss determination module comprises:
[0058] A first encoding module, configured to input the multi-scale features into the first encoder to obtain a first encoding result;
[0059] A second encoding module, used for inputting the label corresponding to the multi-scale feature into the second encoder to obtain a second encoding result;
[0060] A decoding module, used for inputting the first encoding result and the second encoding result into the decoder to obtain a first generator result and a second generator result respectively;
[0061] A second loss calculation module is used to calculate the second loss function based on the first generator result and the label corresponding to the multi-scale feature, and to calculate the second loss function based on the second generator result and the label corresponding to the multi-scale feature to obtain the second loss value.
[0062] Optionally, the model training module includes:
[0063] A parameter updating module, used for, in each round of training, using the first loss value, the contrast loss value, and the second loss value as the generator loss, using the discriminant loss value as the discriminator loss, and alternately updating the network parameters of the generator to be trained and the feature extraction network to be trained, and updating the network parameters of the discriminator to be trained;
[0064] A parameter fixing module is used to fix the network parameters corresponding to the feature extraction network to be trained, the generator to be trained and the discriminator to be trained until the discriminator to be trained cannot determine the difference between the generator result and the label corresponding to the multi-scale feature, so as to obtain the trained feature extraction network, the trained generator and the trained discriminator.
[0065] Optionally, the device further comprises:
[0066] A sample determination module, used to determine the sample image;
[0067] A priori information determination module, used to obtain remote sensing image data related to the sample image, and use the mean and variance of the remote sensing image data as priori information;
[0068] A normalization module, used for normalizing the sample image based on the prior information to obtain a normalized result;
[0069] An enhancement processing module, used for performing image enhancement processing on the normalized result to obtain an optimized sample image; wherein the image enhancement processing includes at least one or more of the following: random flipping, random scaling, random cropping, and spectral random enhancement;
[0070] The feature extraction module comprises:
[0071] The multi-scale extraction module is used to input the optimized sample image into the feature extraction network to be trained to obtain the multi-scale features.
[0072] Optionally, the contour extraction module includes:
[0073] A multi-scale feature processing module, used for inputting the remote sensing image to be processed into the trained feature extraction network to obtain multi-scale features corresponding to the remote sensing image to be processed;
[0074] The building outline extraction module is used to input the multi-scale features corresponding to the remote sensing image to be processed into the building extraction model to obtain the building outline corresponding to the remote sensing image to be processed.
[0075] A third aspect of an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the remote sensing image building extraction method taking into account target regularity as in the first aspect of an embodiment of the present invention is implemented.
[0076] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for extracting buildings from remote sensing images taking into account target regularity according to the first aspect of an embodiment of the present invention is implemented.
[0077] According to the remote sensing image building extraction method taking into account target regularity of the embodiment of the present invention, first, a sample image is input into a feature extraction network to be trained to obtain multi-scale features; secondly, the building part and the background part corresponding to the multi-scale features are determined, and a first loss value is calculated based on the label corresponding to the multi-scale features, and the building part and the background part corresponding to the multi-scale features; then, based on the building part and the background part corresponding to the multi-scale features, a self-supervised contrast learning method is performed on the multi-scale features to determine the contrast loss value; and the multi-scale features and the labels corresponding to the multi-scale features are input into a generator to be trained to obtain a generator result. A second loss value is calculated based on the generator result and the label corresponding to the multi-scale feature; then, the generator result is input into the discriminator to be trained to obtain the discriminant loss value; then, based on the first loss value, the contrast loss value, the second loss value and the discriminant loss value, the feature extraction network, the generator to be trained and the discriminator to be trained are trained to obtain a trained feature extraction network, a trained generator and a trained discriminator; the trained generator is used as a building extraction model; finally, the remote sensing image to be processed is processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed.
[0078] In this embodiment, multi-scale features are extracted from the sample image through the feature extraction network to be trained, and then the building part and the background part are determined based on the multi-scale features. The self-supervised contrastive learning and the generative adversarial network are integrated to perform collaborative training of the feature extraction network, the generator and the discriminator, so that the trained feature extraction network and the building extraction model are used to extract the building contour from the remote sensing image, which not only improves the accuracy of building extraction, but also enhances the generalization ability of the model and the regularity of the building contour. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0080] Figure 1 is a flow chart of a remote sensing image building extraction method taking into account target regularity, shown in one embodiment of the present invention;
[0081] Figure 2 is a flow chart of a method for extracting buildings from high-resolution remote sensing images taking into account target regularity, shown in one embodiment of the present invention;
[0082] Figure 3It is a structural block diagram of a remote sensing image building extraction device taking into account target regularity provided by an embodiment of the present invention;
[0083] Figure 4 It is a schematic diagram of an electronic device shown in an embodiment of the present invention. DETAILED DESCRIPTION
[0084] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0085] As mentioned above, with the development of artificial intelligence technology, deep learning technology has been applied to the extraction of high-resolution remote sensing image information for the extraction of useful information from remote sensing images, and significant progress has been made. However, for targets such as buildings that have strong regularity, the extraction effect is still insufficient. Among them, the regularity in the present invention refers to the linearity of the building outline, which can be understood as horizontal and vertical. At present, there are two obvious problems in the extraction of building outlines in remote sensing images: one is that the generalization ability of the model used is weak, and the other is that the extracted building outline is relatively smooth.
[0086] Therefore, in order to at least partially solve one or more of the above-mentioned problems and other potential problems, an embodiment of the present invention proposes a remote sensing image building extraction method that takes into account the regularity of the target. In this method, multi-scale features are extracted based on a feature extraction network, and based on multi-scale feature fusion contrast learning technology and generative adversarial networks, the accuracy of building extraction is improved while the generalization ability of the model and the regularity of the target contour are enhanced.
[0087] Please refer to Figure 1 , Figure 1 FIG. 1 is a flowchart of a method for extracting buildings from remote sensing images taking into account target regularity, according to an embodiment of the present invention. Figure 1 As shown, the method may include steps S11 to S17:
[0088] Step S11: inputting a sample image into a feature extraction network to be trained to obtain multi-scale features; the sample image is a remote sensing image containing a building, and the sample image carries a label.
[0089] The sample image of this embodiment is a remote sensing image containing buildings and carrying labels for model training. The feature extraction network to be trained can be a Transformer feature extraction network, which is used to extract multi-scale features of the image. In this embodiment, the sample image can be first input into the feature extraction network to be trained to obtain the multi-scale features of the sample image output by the feature extraction network to be trained. Among them, this embodiment does not impose any restrictions on the specific number of scales of the multi-scale features, for example, it can be features of 2 scales, features of 4 scales, features of 8 scales, features of 16 scales, and so on.
[0090] Furthermore, in an optional implementation, SegFormer-B5 can be used as a feature extraction network to be trained, and its hierarchical Transformer module can be used to extract multi-scale features of sample images. For example, the SegFormer-B5 can be divided into four modules to extract features of four scales: if the width and height of the original sample image are W and H, the extracted four feature dimensions are: 64*W / 4*H / 4, 128*W / 8*H / 8, 320*W / 16*H / 16, 512*W / 32*H / 32.
[0091] Step S12: determining the building part and the background part corresponding to the multi-scale feature, and calculating a first loss function based on the label corresponding to the multi-scale feature and the building part and the background part corresponding to the multi-scale feature to obtain a first loss value.
[0092] In this embodiment, after obtaining the multi-scale features output by the feature extraction network to be trained, the building part and the background part corresponding to the multi-scale features are determined, wherein the background part in this embodiment refers to the part other than the building part. Specifically, the multi-scale features may be spliced to obtain spliced features, and then the building part and the background part may be determined based on the spliced features.
[0093] After determining the building part and the background part corresponding to the multi-scale feature, a first loss function can be calculated based on the label corresponding to the multi-scale feature and the building part and the background part corresponding to the multi-scale feature to obtain a first loss value. The label corresponding to the multi-scale feature is the label of the sample image corresponding to the multi-scale feature.
[0094] Step S13: Based on the building part and the background part corresponding to the multi-scale feature, self-supervised contrast learning is performed on the multi-scale feature to determine the contrast loss value.
[0095] In this embodiment, after determining the building part and the background part corresponding to the multi-scale feature, self-supervised contrast learning can be performed on the multi-scale feature based on the building part and the background part corresponding to the multi-scale feature to determine the contrast loss value.
[0096] It should be noted that, in this embodiment, after obtaining the building part and the background part corresponding to the multi-scale feature, the execution order of "calculating the first loss function based on the label corresponding to the multi-scale feature, and the building part and the background part corresponding to the multi-scale feature to obtain the first loss value" in step S12 is not limited: for example, the "calculating the first loss function based on the label corresponding to the multi-scale feature, and the building part and the background part corresponding to the multi-scale feature to obtain the first loss value" in step S12 can be executed first, and then step S13 is executed; step S13 can be executed first and then step S12 "calculating the first loss function based on the label corresponding to the multi-scale feature, and the building part and the background part corresponding to the multi-scale feature to obtain the first loss value" can be executed; and step S12 "calculating the first loss function based on the label corresponding to the multi-scale feature, and the building part and the background part corresponding to the multi-scale feature to obtain the first loss value" and step S13 can also be executed simultaneously.
[0097] Step S14: input the multi-scale features and the labels corresponding to the multi-scale features into the generator to be trained to obtain a generator result, and calculate a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value.
[0098] In this embodiment, after obtaining the multi-scale features output by the feature extraction network to be trained, the multi-scale features and the labels corresponding to the multi-scale features can also be input into the generator to be trained in the generative adversarial network to obtain the generator results output by the generator to be trained; then, based on the generator results and the labels corresponding to the multi-scale features, the second loss function is calculated to obtain the second loss value. The second loss value of this embodiment can ensure the accuracy of the generated results.
[0099] It should be noted that this embodiment does not limit the execution order of step S12 and step S14: for example, step S12 may be executed first and then step S14, step S14 may be executed first and then step S12, or step S12 and step S14 may be executed simultaneously.
[0100] Step S15: Input the generator result to the discriminator to be trained to obtain a discriminant loss value.
[0101] In this embodiment, after obtaining the generator result, the generator result can be input into the discriminator to be trained in the generative adversarial network, and the discrimination loss value is calculated based on the discrimination result output by the discriminator to be trained. In this embodiment, after the iterative process of the generative adversarial network GAN, the discriminator can eventually be made unable to judge the difference between the image prediction result (i.e., the generator result) and the true value (i.e., the corresponding label), thus ensuring the regularity of the prediction result and the consistency of the true value.
[0102] It should be noted that this embodiment does not limit the execution order of step S14 "calculating the second loss function based on the labels corresponding to the generator result and the multi-scale features to obtain the second loss value" and step S15: for example, step S15 can be executed first and then step S14 "calculating the second loss function based on the labels corresponding to the generator result and the multi-scale features to obtain the second loss value" can be executed; step S14 "calculating the second loss function based on the labels corresponding to the generator result and the multi-scale features to obtain the second loss value" can be executed first and then step S15; step S15 and step S14 "calculating the second loss function based on the labels corresponding to the generator result and the multi-scale features to obtain the second loss value" can also be executed simultaneously.
[0103] Step S16: Based on the first loss value, the contrast loss value, the second loss value and the discriminant loss value, the feature extraction network to be trained, the generator to be trained and the discriminator to be trained are trained to obtain a trained feature extraction network, a trained generator and a trained discriminator; and the trained generator is used as a building extraction model.
[0104] In this embodiment, after obtaining the first loss value, the contrast loss value, the second loss value, and the discrimination loss value, the feature extraction network to be trained, the generator to be trained, and the discriminator to be trained can be collaboratively trained based on the first loss value, the contrast loss value, the second loss value, and the discrimination loss value to obtain a trained feature extraction network, a trained generator, and a trained discriminator, and the trained generator is used as a building extraction model. The trained feature extraction network is used to perform multi-scale feature extraction on remote sensing images, and the building extraction model is used to extract the building contour corresponding to the remote sensing image based on the multi-scale features of the remote sensing image.
[0105] Step S17: Processing the remote sensing image to be processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed.
[0106] In this embodiment, after the model is trained, the remote sensing image to be processed can be processed based on the trained feature extraction network and the building extraction model trained in collaboration with the trained feature extraction network to obtain the building contours corresponding to the remote sensing image to be processed output by the building extraction model, thereby achieving accurate extraction of the building contours in the remote sensing image.
[0107] In the remote sensing image building extraction method that takes into account the target regularity proposed in this embodiment, multi-scale features are extracted from the sample image through the feature extraction network to be trained, and then the building part and the background part are determined based on the multi-scale features. Self-supervised contrastive learning and generative adversarial networks are integrated to perform collaborative training of the feature extraction network, generator and discriminator, so that the trained feature extraction network and building extraction model are used to extract the building contour of the remote sensing image, which not only improves the accuracy of building extraction, but also enhances the generalization ability of the model and the regularity of the building contour.
[0108] In combination with the above embodiments, in one implementation, the present invention further provides a remote sensing image building extraction method taking into account target regularity. In the method, the above step S12 may specifically include steps S21 to S22:
[0109] Step S21: using a multi-layer perceptron to perform initial binary classification on the multi-scale features to obtain the building part and the background part corresponding to the multi-scale features.
[0110] In this embodiment, the labels carried by the sample image at least include: a building label and a background label, for example, a label value of 0 represents the background, and a label value of 1 represents the building. After obtaining the multi-scale features, a multi-layer perceptron (MLP) can be used to perform an initial binary classification on the multi-scale features to obtain a classification result: the building part and the background part corresponding to the multi-scale features. Specifically, after obtaining the multi-scale features, the multi-scale features can be spliced to obtain spliced features, and then the spliced features can be initially classified into two categories using a multi-layer perceptron to obtain the building part and the background part corresponding to the multi-scale features.
[0111] Step S22: Calculate the first loss function based on the building part corresponding to the multi-scale feature and the building label corresponding to the multi-scale feature, and calculate the first loss function based on the background part corresponding to the multi-scale feature and the background label corresponding to the multi-scale feature to obtain the first loss value.
[0112] In this embodiment, the first loss function may be calculated by combining the building part corresponding to the multi-scale feature with the building label corresponding to the multi-scale feature, and the first loss function may be calculated by combining the background part corresponding to the multi-scale feature with the background label corresponding to the multi-scale feature to obtain a first loss value.
[0113] In an optional example, the first loss function may be a cross entropy loss function, which may be to calculate the first loss function by using the building part corresponding to the multi-scale feature and the building label corresponding to the multi-scale feature to obtain a first building loss value; calculate the first loss function by using the background part corresponding to the multi-scale feature and the background label corresponding to the multi-scale feature to obtain a first background loss value; and then obtain the first loss value based on the first building loss value and the first background loss value.
[0114] In addition, in another embodiment, since the multi-scale features are features of multiple scales, the processing of the multi-scale features in this embodiment (such as multi-layer perceptron processing, self-supervised contrastive learning processing, and processing in the input generator) can be performed by splicing the multi-scale features to obtain spliced features, and then performing corresponding processing based on the spliced features.
[0115] In combination with the above embodiments, in one implementation, the present invention further provides a remote sensing image building extraction method taking into account target regularity. In the method, the above step S13 may specifically include step S31 and step S32:
[0116] Step S31: Based on the building part and the background part corresponding to the multi-scale feature, features corresponding to some pixels in the building part corresponding to the multi-scale feature and features corresponding to some pixels in the background part corresponding to the multi-scale feature are respectively selected as anchor features.
[0117] In this embodiment, using the self-supervised contrastive learning method, based on the building part and the background part corresponding to the multi-scale feature, the features corresponding to some pixels in the building part corresponding to the multi-scale feature can be selected across samples as anchor features, and the features corresponding to some pixels in the background part corresponding to the multi-scale feature can be selected as anchor features. That is, in this embodiment, the multi-scale features corresponding to some pixels in the building part and the background part corresponding to the multi-scale feature are selected as anchor features.
[0118] Step S32: calculating contrast loss of features corresponding to other pixels in the multi-scale features except the anchor point feature and the anchor point feature respectively to obtain the contrast loss value.
[0119] In this embodiment, after obtaining the anchor feature, each feature corresponding to other pixels in the multi-scale feature except the anchor feature can be respectively compared with the anchor feature to calculate the contrast loss to obtain the contrast loss value. Among them, the contrast loss of this embodiment can constrain the extracted multi-scale features during the model training process, so that the feature area inside the building part in the multi-scale feature is consistent, and the feature area of the building part and the background part in the multi-scale feature are different, thereby improving the feature difference between the building and the background, and also enhancing the stability and generalization ability of the extracted features.
[0120] In this embodiment, the Transformer feature extraction network is used to extract multi-scale features and contrastive learning technology is applied to building extraction, which can make the extracted features more concentrated and stable, thereby improving the generalization ability of the building extraction model.
[0121] In combination with the above embodiments, the present invention further provides a remote sensing image building extraction method taking into account target regularity. In the method, the above step S14 may specifically include steps S41 to S44:
[0122] Step S41: inputting the multi-scale features into the first encoder to obtain a first encoding result.
[0123] In this embodiment, the generator to be trained is a codec structure, and the generator to be trained includes at least: a first encoder, a second encoder and a decoder. Among them, the encoder of the generator to be trained includes two forms, namely, a first encoder corresponding to the multi-scale features of the remote sensing image, and a second encoder corresponding to the label remote sensing image. In other words, the first encoder is an encoder for encoding multi-scale features, and the second encoder is an encoder for encoding labels corresponding to the multi-scale features.
[0124] In this embodiment, the multi-scale features may be input into a first encoder, and the multi-scale features may be encoded by the first encoder to obtain a first encoding result.
[0125] Step S42: inputting the label corresponding to the multi-scale feature into the second encoder to obtain a second encoding result.
[0126] In this embodiment, the label corresponding to the multi-scale feature can be input into the second encoder, and the label corresponding to the multi-scale feature can be encoded by the second encoder to obtain a second encoding result. The first encoding result and the second encoding result of this embodiment can be encoding results of the same dimension.
[0127] Step S43: input the first encoding result and the second encoding result into the decoder to obtain a first generator result and a second generator result respectively.
[0128] In this embodiment, the first encoding result and the second encoding result can be input into the same decoder, and the first encoding result and the second encoding result can be decoded by the decoder to obtain the first generator result and the second generator result. The first generator result is the decoding result corresponding to the first encoding result, and the second generator result is the decoding result corresponding to the second encoding result.
[0129] Step S44: Calculate the second loss function based on the first generator result and the label corresponding to the multi-scale feature, and calculate the second loss function based on the second generator result and the label corresponding to the multi-scale feature to obtain the second loss value.
[0130] In this embodiment, the second loss function may be calculated using the first generator result and the label corresponding to the multi-scale feature, and the second loss function may be calculated using the second generator result and the label corresponding to the multi-scale feature to obtain a second loss value.
[0131] In an optional example, the second loss function may be a cross entropy loss function, which may be to calculate the second loss function using the first generator result (i.e., the decoding result of the multi-scale feature) and the label corresponding to the multi-scale feature to obtain a second feature loss value; calculate the second loss function using the second generator result (i.e., the decoding result of the label corresponding to the multi-scale feature) and the label corresponding to the multi-scale feature to obtain a second label loss value; and then obtain the second loss value based on the second feature loss value and the second label loss value.
[0132] In this embodiment, not only the first generator result obtained after the multi-scale feature is input into the generator, but also the second generator result obtained after the label corresponding to the multi-scale feature is input into the generator, and the label corresponding to the multi-scale feature is lost. In this way, the encoding and decoding result of the label and the label itself are used to calculate the second loss value, which further ensures the stability of the encoder in the generator.
[0133] In combination with the above embodiments, in one implementation, the present invention further provides a remote sensing image building extraction method taking into account target regularity. In the method, the above step S16 may specifically include steps S51 to S52:
[0134] Step S51: In each round of training, the first loss value, the contrast loss value, and the second loss value are used as the generator loss, and the discriminant loss value is used as the discriminator loss, and the network parameters of the generator to be trained and the feature extraction network to be trained are updated alternately, as well as the network parameters of the discriminator to be trained are updated.
[0135] In this embodiment, model training is performed in rounds. In each round of training, the obtained first loss value, contrast loss value, and second loss value can be used as generator loss, and the discriminant loss can be used as discriminant loss. The network parameters of the generator to be trained and the feature extraction network to be trained are updated alternately, as well as the network parameters of the discriminator to be trained are updated.
[0136] For example, in this round of training, the network parameters of the discriminator to be trained are fixed, and the network parameters of the generator to be trained and the network parameters of the feature extraction network to be trained are updated; in the next round of training, the network parameters of the generator to be trained and the network parameters of the feature extraction network to be trained are fixed, and the network parameters of the discriminator to be trained are updated, and so on.
[0137] Step S52: until the discriminator to be trained cannot determine the difference between the generator result and the label corresponding to the multi-scale feature, fix the network parameters corresponding to the feature extraction network to be trained, the generator to be trained and the discriminator to be trained, and obtain the trained feature extraction network, the trained generator and the trained discriminator.
[0138] In this embodiment, the training and testing of the generator to be trained and the feature extraction network to be trained, as well as the discriminator to be trained, are performed alternately until the discriminator to be trained cannot distinguish the difference between the generator result output by the generator and the label corresponding to the multi-scale feature, and the model training is determined to be completed, and the network parameters of the feature extraction network to be trained when the model training is completed are fixed to obtain the trained feature extraction network and output it; the network parameters of the generator to be trained when the model training is completed are fixed to obtain the trained generator and output it; and the network parameters of the discriminator to be trained when the model training is completed are fixed to obtain the trained discriminator. In this embodiment, the output trained generator can be determined as the building extraction model.
[0139] In this embodiment, by combining multi-scale features with the generative adversarial network (GAN), the regularity of the building outline is improved while ensuring the improvement of the building extraction accuracy.
[0140] In combination with the above embodiments, in one implementation, the present invention further provides a remote sensing image building extraction method taking into account target regularity. In the method, in addition to the above steps, steps S61 to S64 may also be included, and the "inputting the sample image into the feature extraction network to be trained to obtain multi-scale features" in the above step S11 may specifically include step S65:
[0141] Step S61: Determine the sample image.
[0142] In this embodiment, the sample image may be collected first to determine the sample image. For example, the size of the sample image may be 512*512*3.
[0143] Step S62: Acquire remote sensing image data related to the sample image, and use the mean and variance of the remote sensing image data as prior information.
[0144] Since the sample images are remote sensing images containing buildings with corresponding labels, the number may be limited, resulting in insufficient model training results. Based on this, the present embodiment can obtain remote sensing image data related to the sample image, for example, a large amount of remote sensing image data similar to the sample image can be obtained, and the mean and variance of the similar remote sensing image data can be statistically analyzed, and the mean and variance of the statistically analyzed remote sensing image data are used as prior information. The prior information of the present embodiment is used to perform image enhancement on the sample image.
[0145] Step S63: normalizing the sample image based on the prior information to obtain a normalized result.
[0146] In this embodiment, after obtaining the prior information, the sample image can be normalized based on the prior information to obtain a normalized result. For example, the three-band eight-bit image values of the sample image can be scaled to [-1.0, 1.0] based on the prior information to obtain a normalized result.
[0147] Step S64: performing image enhancement processing on the normalized result to obtain an optimized sample image.
[0148] In this embodiment, the obtained normalized result can be subjected to image enhancement processing, thereby achieving preprocessing of the sample image and obtaining an optimized sample image. The image enhancement processing of this embodiment includes at least one or more of the following: random flipping, random scaling (for example, a scaling factor of 0.5 to 2.0), random cropping, and spectral random enhancement.
[0149] Step S65: inputting the optimized sample image into the feature extraction network to be trained to obtain the multi-scale features.
[0150] In this embodiment, after obtaining the optimized sample image, model training is performed on the optimized sample image, that is, the optimized sample image is input into the feature extraction network to be trained to obtain the multi-scale features output by the feature extraction network to be trained.
[0151] In this embodiment, the sample image is scaled based on prior information and then image enhancement is performed, thereby optimizing the sample image to improve the effect of model training.
[0152] In combination with the above embodiments, in one implementation, the present invention further provides a remote sensing image building extraction method that takes into account target regularity. In this method, the above step S17 may specifically include step S71 and step S72:
[0153] Step S71: inputting the remote sensing image to be processed into the trained feature extraction network to obtain multi-scale features corresponding to the remote sensing image to be processed.
[0154] In this embodiment, the remote sensing image to be processed is a remote sensing image that needs to be subjected to building contour extraction. The remote sensing image to be processed can be first input into a trained feature extraction network, and the trained feature extraction network is used to extract multi-scale features from the remote sensing image to be processed, thereby obtaining multi-scale features corresponding to the remote sensing image to be processed.
[0155] Step S72: inputting the multi-scale features corresponding to the remote sensing image to be processed into the building extraction model to obtain the building outline corresponding to the remote sensing image to be processed.
[0156] Step S73: After obtaining the multi-scale features corresponding to the remote sensing image to be processed, the multi-scale features corresponding to the remote sensing image to be processed can be input into the building extraction model that is trained in collaboration with the trained feature extraction network to obtain the building contour corresponding to the remote sensing image to be processed output by the building extraction model, thereby completing the accurate extraction of the building contour in the remote sensing image.
[0157] In one embodiment, considering that buildings in high-resolution remote sensing images have significant regularity, the current deep learning building extraction methods are more based on semantic segmentation methods in the field of computer vision, and do not fully utilize the characteristics of the target itself. In order to improve the generalization ability of the model and enhance the regularity of the results, this embodiment proposes a high-resolution remote sensing image building extraction method that takes into account the regularity of the target.
[0158] like Figure 2 As shown, Figure 2 FIG. 1 is a flowchart of a method for extracting buildings from high-resolution remote sensing images taking into account target regularity, according to an embodiment of the present invention. Figure 2 In the method, the image (i.e., sample image) is first prepared, and then the sample image is preprocessed. For example, based on the prior mean and variance of image data similar to the sample image, the three-band eight-bit image pixel values of the sample image are scaled to [-1,1], and different image enhancement methods are performed to obtain the optimized sample image.
[0159] Then, the optimized sample image is input into the backbone network to be trained. The backbone network of this embodiment can be SegFormer-B5 to extract multi-scale features. After obtaining the multi-scale features, the multi-scale features can be initially classified into two categories based on the multi-layer perceptron to obtain result 1, and the cross entropy loss is calculated between result 1 and the label corresponding to the multi-scale features to obtain the cross entropy loss loss ce Next, based on result 1 and multi-scale features, the contrast loss loss is calculated through the self-supervised contrast learning method. cl .
[0160] And, after obtaining the multi-scale features, the multi-scale features and the labels corresponding to the multi-scale features can be respectively input into the encoder 1 and encoder 2 in the generator G to be trained, and the first encoding result and the second encoding result can be respectively obtained; then the first encoding result and the second encoding result are respectively input into the same decoder in the generator G, so as to obtain the output of the generator G: the result 2 corresponding to the multi-scale features, and the result 3 corresponding to the label corresponding to the multi-scale features. Then, the cross entropy loss is calculated for the result 2 and the label corresponding to the multi-scale features, and the cross entropy loss loss is obtained. g1 ; And, the result 3 calculates the cross entropy loss with the labels corresponding to the multi-scale features, and obtains the cross entropy loss loss g2 .
[0161] Next, the two results (result 2 and result 3) are input into the discriminator D to be trained, and the false (False) results and true (True) results discriminated by the discriminator D to be trained are obtained. Based on the labels corresponding to the multi-scale features and the false results and true results, the discrimination loss Loss is calculated. D .
[0162] Finally, the training and testing of the discriminator, the backbone network to be trained, and the generator network are performed alternately, where the generator loss is , the discriminator loss is , obtain and output the trained generator and backbone network, so as to extract the building contours from the remote sensing image based on the trained generator and backbone network.
[0163] In this embodiment, SegFormer-B5 is used to extract multi-scale features, a multi-layer perceptron (MLP) is used for initial classification, a self-supervised contrastive learning method is used for feature enhancement, and GAN is used to enhance contour regularity. In other words, the key technology of this embodiment is to extract multi-scale features based on the Transformer architecture, add contrast loss on the basis of traditional semantic segmentation, improve the stability of features, and integrate the GAN framework to make the extraction results tend to regularity. This embodiment has been fully verified in actual experiments, and stable and reliable results have been obtained in images such as BJ3 and WV.
[0164] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0165] Based on the same inventive concept, an embodiment of the present invention provides a remote sensing image building extraction device 300 that takes into account target regularity. Figure 3 , Figure 3 FIG. 1 is a structural block diagram of a remote sensing image building extraction device taking into account target regularity provided by an embodiment of the present invention. Figure 3 As shown, the device 300 includes:
[0166] The feature extraction module 301 is used to input a sample image into a feature extraction network to be trained to obtain multi-scale features; the sample image is a remote sensing image containing a building, and the sample image carries a label;
[0167] A first loss determination module 302 is used to determine the building part and the background part corresponding to the multi-scale feature, and calculate a first loss function based on the label corresponding to the multi-scale feature and the building part and the background part corresponding to the multi-scale feature to obtain a first loss value;
[0168] A second loss determination module 303 is used to perform self-supervised contrast learning on the multi-scale features based on the building part and the background part corresponding to the multi-scale features to determine the contrast loss value;
[0169] A third loss determination module 304 is used to input the multi-scale features and the labels corresponding to the multi-scale features into the generator to be trained to obtain a generator result, and calculate a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value;
[0170] A fourth loss determination module 305, used for inputting the generator result into the discriminator to be trained to obtain a discriminant loss value;
[0171] A model training module 306 is used to train the feature extraction network to be trained, the generator to be trained and the discriminator to be trained based on the first loss value, the contrast loss value, the second loss value and the discriminant loss value to obtain a trained feature extraction network, a trained generator and a trained discriminator; and use the trained generator as a building extraction model;
[0172] The contour extraction module 307 is used to process the remote sensing image to be processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed.
[0173] Optionally, the labels include at least: a building label and a background label;
[0174] The first loss determination module 302 includes:
[0175] A classification module, used for performing initial binary classification on the multi-scale features using a multi-layer perceptron to obtain a building part and a background part corresponding to the multi-scale features;
[0176] A first loss calculation module is used to calculate the first loss function based on the building part corresponding to the multi-scale feature and the building label corresponding to the multi-scale feature, and to calculate the first loss function based on the background part corresponding to the multi-scale feature and the background label corresponding to the multi-scale feature to obtain the first loss value.
[0177] Optionally, the second loss determination module 303 includes:
[0178] An anchor point determination module, used for selecting features corresponding to some pixels in the building part corresponding to the multi-scale feature and features corresponding to some pixels in the background part corresponding to the multi-scale feature as anchor point features, based on the building part and the background part corresponding to the multi-scale feature;
[0179] A contrast loss determination module, used to calculate contrast losses of features corresponding to other pixels in the multi-scale features except the anchor point feature and the anchor point feature, respectively, to obtain the contrast loss value;
[0180] The contrast loss constrains the extracted multi-scale features during the training process, so that the feature regions inside the building part are consistent, and the feature regions of the building part and the background part are different.
[0181] Optionally, the generator to be trained includes at least: a first encoder, a second encoder and a decoder;
[0182] The third loss determination module 304 includes:
[0183] A first encoding module, configured to input the multi-scale features into the first encoder to obtain a first encoding result;
[0184] A second encoding module, used for inputting the label corresponding to the multi-scale feature into the second encoder to obtain a second encoding result;
[0185] A decoding module, used for inputting the first encoding result and the second encoding result into the decoder to obtain a first generator result and a second generator result respectively;
[0186] A second loss calculation module is used to calculate the second loss function based on the first generator result and the label corresponding to the multi-scale feature, and to calculate the second loss function based on the second generator result and the label corresponding to the multi-scale feature to obtain the second loss value.
[0187] Optionally, the model training module 306 includes:
[0188] A parameter updating module, used for, in each round of training, using the first loss value, the contrast loss value, and the second loss value as the generator loss, using the discriminant loss value as the discriminator loss, and alternately updating the network parameters of the generator to be trained and the feature extraction network to be trained, and updating the network parameters of the discriminator to be trained;
[0189] A parameter fixing module is used to fix the network parameters corresponding to the feature extraction network to be trained, the generator to be trained and the discriminator to be trained until the discriminator to be trained cannot determine the difference between the generator result and the label corresponding to the multi-scale feature, so as to obtain the trained feature extraction network, the trained generator and the trained discriminator.
[0190] Optionally, the device 300 further includes:
[0191] A sample determination module, used to determine the sample image;
[0192] A priori information determination module, used to obtain remote sensing image data related to the sample image, and use the mean and variance of the remote sensing image data as priori information;
[0193] A normalization module, used for normalizing the sample image based on the prior information to obtain a normalized result;
[0194] An enhancement processing module, used for performing image enhancement processing on the normalized result to obtain an optimized sample image; wherein the image enhancement processing includes at least one or more of the following: random flipping, random scaling, random cropping, and spectral random enhancement;
[0195] The feature extraction module 301 includes:
[0196] The multi-scale extraction module is used to input the optimized sample image into the feature extraction network to be trained to obtain the multi-scale features.
[0197] Optionally, the contour extraction module 307 includes:
[0198] A multi-scale feature processing module, used for inputting the remote sensing image to be processed into the trained feature extraction network to obtain multi-scale features corresponding to the remote sensing image to be processed;
[0199] The building outline extraction module is used to input the multi-scale features corresponding to the remote sensing image to be processed into the building extraction model to obtain the building outline corresponding to the remote sensing image to be processed.
[0200] Based on the same inventive concept, another embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the remote sensing image building extraction method taking into account target regularity as described in any of the above embodiments of the present invention are implemented.
[0201] Based on the same inventive concept, another embodiment of the present invention provides an electronic device 400, such as Figure 4 shown. Figure 4 4 is a schematic diagram of an electronic device according to an embodiment of the present invention. The electronic device includes a memory 402, a processor 401, and a computer program stored in the memory and executable on the processor, and when executed by the processor, the steps of the remote sensing image building extraction method taking into account target regularity described in any of the above embodiments of the present invention are implemented.
[0202] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0203] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0204] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, embodiments of the present invention may take the form of complete hardware embodiments, complete software embodiments, or embodiments combining software and hardware. Furthermore, embodiments of the present invention may take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0205] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0206] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0207] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0208] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0209] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0210] The above is a detailed introduction to a remote sensing image building extraction method, device and product that takes into account target regularity provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A remote sensing image building extraction method taking into account target regularity, characterized in that: The method comprises: Inputting a sample image into a feature extraction network to be trained to obtain multi-scale features; the sample image is a remote sensing image containing a building, and the sample image carries a label; Determine the building part and the background part corresponding to the multi-scale feature, calculate a first loss function based on the label corresponding to the multi-scale feature, and the building part and the background part corresponding to the multi-scale feature, and obtain a first loss value; Based on the building part and the background part corresponding to the multi-scale feature, performing self-supervised contrast learning on the multi-scale feature to determine a contrast loss value; Inputting the multi-scale features and the labels corresponding to the multi-scale features into a generator to be trained to obtain a generator result, and calculating a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value; Input the generator result into the discriminator to be trained to obtain a discriminant loss value; Based on the first loss value, the contrast loss value, the second loss value and the discriminant loss value, the feature extraction network to be trained, the generator to be trained and the discriminator to be trained are trained to obtain a trained feature extraction network, a trained generator and a trained discriminator; the trained generator is used as a building extraction model; The remote sensing image to be processed is processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed.
2. The remote sensing image building extraction method taking into account target regularity according to claim 1, characterized in that: The labels at least include: building labels and background labels; The determining the building part and the background part corresponding to the multi-scale feature, calculating a first loss function based on the label corresponding to the multi-scale feature and the building part and the background part corresponding to the multi-scale feature, and obtaining a first loss value includes: Using a multi-layer perceptron to perform initial binary classification on the multi-scale features to obtain a building part and a background part corresponding to the multi-scale features; The first loss function is calculated based on the building part corresponding to the multi-scale feature and the building label corresponding to the multi-scale feature, and the first loss function is calculated based on the background part corresponding to the multi-scale feature and the background label corresponding to the multi-scale feature to obtain the first loss value.
3. The remote sensing image building extraction method taking into account target regularity according to claim 1, characterized in that: The step of performing self-supervised contrast learning on the multi-scale features based on the building part and the background part corresponding to the multi-scale features to determine the contrast loss value includes: Based on the building part and the background part corresponding to the multi-scale feature, respectively selecting features corresponding to some pixels in the building part corresponding to the multi-scale feature and features corresponding to some pixels in the background part corresponding to the multi-scale feature as anchor features; Calculate contrast loss between features corresponding to other pixels in the multi-scale features except the anchor point feature and the anchor point feature to obtain the contrast loss value; The contrast loss constrains the extracted multi-scale features during the training process, so that the feature regions inside the building part are consistent, and the feature regions of the building part and the background part are different.
4. The remote sensing image building extraction method taking into account target regularity according to claim 1, characterized in that: The generator to be trained includes at least: a first encoder, a second encoder and a decoder; The step of inputting the multi-scale features and the labels corresponding to the multi-scale features into a generator to be trained to obtain a generator result, and calculating a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value comprises: Inputting the multi-scale features into the first encoder to obtain a first encoding result; Inputting the label corresponding to the multi-scale feature into the second encoder to obtain a second encoding result; Inputting the first encoding result and the second encoding result into the decoder to obtain a first generator result and a second generator result respectively; The second loss function is calculated based on the first generator result and the label corresponding to the multi-scale feature, and the second loss function is calculated based on the second generator result and the label corresponding to the multi-scale feature to obtain the second loss value.
5. The remote sensing image building extraction method taking into account target regularity according to claim 1, characterized in that: The method of training the feature extraction network to be trained, the generator to be trained, and the discriminator to be trained based on the first loss value, the contrast loss value, the second loss value, and the discriminant loss value to obtain a trained feature extraction network, a trained generator, and a trained discriminator includes: In each round of training, the first loss value, the contrast loss value, and the second loss value are used as generator loss, and the discriminant loss value is used as discriminator loss, and network parameters of the generator to be trained and the feature extraction network to be trained are updated alternately, as well as network parameters of the discriminator to be trained are updated; Until the discriminator to be trained cannot determine the difference between the generator result and the label corresponding to the multi-scale feature, the network parameters corresponding to the feature extraction network to be trained, the generator to be trained and the discriminator to be trained are fixed to obtain the trained feature extraction network, the trained generator and the trained discriminator.
6. The remote sensing image building extraction method taking into account target regularity according to any one of claims 1 to 5, characterized in that: The method further comprises: determining the sample image; Acquire remote sensing image data related to the sample image, and use the mean and variance of the remote sensing image data as prior information; Normalizing the sample image based on the prior information to obtain a normalized result; Performing image enhancement processing on the normalized result to obtain an optimized sample image; wherein the image enhancement processing includes at least one or more of the following: random flipping, random scaling, random cropping, and spectral random enhancement; The step of inputting the sample image into the feature extraction network to be trained to obtain multi-scale features includes: The optimized sample image is input into the feature extraction network to be trained to obtain the multi-scale features.
7. The remote sensing image building extraction method taking into account target regularity according to any one of claims 1 to 5, characterized in that: The processing of the remote sensing image to be processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed includes: Inputting the remote sensing image to be processed into the trained feature extraction network to obtain multi-scale features corresponding to the remote sensing image to be processed; The multi-scale features corresponding to the remote sensing image to be processed are input into the building extraction model to obtain the building outline corresponding to the remote sensing image to be processed.
8. A remote sensing image building extraction device taking into account target regularity, characterized in that: The device comprises: A feature extraction module, used to input a sample image into a feature extraction network to be trained to obtain multi-scale features; the sample image is a remote sensing image containing a building, and the sample image carries a label; A first loss determination module, configured to determine a building part and a background part corresponding to the multi-scale feature, and calculate a first loss function based on a label corresponding to the multi-scale feature and a building part and a background part corresponding to the multi-scale feature to obtain a first loss value; A second loss determination module is used to perform self-supervised contrast learning on the multi-scale features based on the building part and the background part corresponding to the multi-scale features to determine the contrast loss value; a third loss determination module, configured to input the multi-scale features and the labels corresponding to the multi-scale features into a generator to be trained to obtain a generator result, and calculate a second loss function based on the generator result and the labels corresponding to the multi-scale features to obtain a second loss value; A fourth loss determination module, used for inputting the generator result into the discriminator to be trained to obtain a discriminant loss value; A model training module, used for training the feature extraction network to be trained, the generator to be trained and the discriminator to be trained based on the first loss value, the contrast loss value, the second loss value and the discriminant loss value to obtain a trained feature extraction network, a trained generator and a trained discriminator; and using the trained generator as a building extraction model; The contour extraction module is used to process the remote sensing image to be processed based on the trained feature extraction network and the building extraction model to obtain the building contour corresponding to the remote sensing image to be processed.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the computer program is executed by the processor, the method for extracting buildings from remote sensing images taking into account target regularity as claimed in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for extracting buildings from remote sensing images taking into account target regularity as claimed in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Self-distillation contrast learning method for remote sensing image scene classification
CN115019123A
Optical remote sensing image self-supervised contrast learning change detection method and device
CN117576517A
