A method and device for detecting farmland contours based on a generative adversarial network
By combining the generative adversarial network and the watershed transformation algorithm, the problem of low efficiency and accuracy of farmland contour detection is solved, and efficient and accurate detection is achieved under limited samples.
Patent Information
- Application Number
- CN202111393495.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-23
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2041-11-23
AI Technical Summary
The existing farmland contour detection methods have low detection efficiency and accuracy, especially when the training samples are limited, the deep learning model is not ideal.
The generative adversarial network model is used in combination with the watershed transformation algorithm, and the initial farmland contour detection results are generated by labeling and training the sample remote sensing image, and the watershed transformation algorithm is used to optimize the image boundary intensity to finally determine the target farmland contour detection results.
The efficiency and accuracy of farmland contour detection are improved, and efficient and accurate detection is achieved in the case of limited samples.
Smart Images

Figure CN114078213B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular, to a method and device for detecting farmland contours based on a generative adversarial network. Background Art
[0002] In recent years, deep learning networks have been widely applied to the task of farmland contour detection. Compared with other methods, deep learning methods can better learn and extract context features at different levels based on spatial information. However, deep learning models including fully convolutional neural networks theoretically require a large number of training samples to learn a general model, and this problem will have an adverse effect on the classification results. In the field of remote sensing, due to the large amount of training image information and rich geographical information, especially contour line information, it is neither practical nor time-consuming to label all training images.
[0003] In related patents and papers, farmland contour detection generally only uses a convolutional neural network for image segmentation. This method requires a large number of high-quality training samples. Therefore, in the case of limited samples, the effect of the convolutional neural network is not ideal.
[0004] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention
[0005] In view of this, an object of the present invention is to provide a method and device for detecting farmland contours based on a generative adversarial network, so as to alleviate the technical problems of low detection efficiency and accuracy of existing farmland contour detection methods.
[0006] In a first aspect, an embodiment of the present invention provides a method for detecting farmland contours based on a generative adversarial network, including: obtaining a sample remote sensing image, annotating target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are pixels representing the farmland contour in the sample remote sensing image; using the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model; after obtaining a to-be-detected remote sensing image, inputting the to-be-detected remote sensing image into the target generative adversarial network model to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the to-be-detected remote sensing image; using a watershed transformation algorithm to process the to-be-detected remote sensing image to obtain an image boundary intensity result of the to-be-detected remote sensing image; and determining a target farmland contour detection result based on the initial farmland contour detection result and the image boundary intensity result.
[0007] Furthermore, the generative adversarial network model includes: a generator and a discriminator. Using the target remote sensing image to train the generative adversarial network model to obtain a target generative adversarial network model, which includes: a first input step of inputting the target remote sensing image into the generator to obtain the edge information of the target remote sensing image; a second input step of inputting the edge information into the discriminator to obtain a sub-farmland contour detection result; a calculation step of calculating the adversarial loss between the generator and the discriminator based on the edge information, the sub-farmland contour detection result, and a preset loss function; if the adversarial loss does not converge within a preset range, updating the generator and the discriminator based on the adversarial loss to obtain an intermediate generator and an intermediate discriminator, determining the intermediate generator as the generator, and determining the intermediate discriminator as the discriminator, and repeating the execution of the first input step, the second input step, and the calculation step until the adversarial loss converges within the preset range, and constructing the target generative adversarial network model based on the intermediate generator and the intermediate discriminator corresponding to when the adversarial loss converges within the preset range.
[0008] Furthermore, using the watershed transformation algorithm to process the to-be-detected remote sensing image to obtain the image boundary intensity result of the to-be-detected remote sensing image, which includes: using the watershed transformation algorithm to classify the pixels in the to-be-detected remote sensing image to obtain a classification result; and determining the classification result as the image boundary intensity result of the to-be-detected remote sensing image.
[0009] Furthermore, based on the initial farmland contour detection result and the image boundary intensity result, determining a target farmland contour detection result, which includes: connecting the farmland contours in the initial farmland contour detection result to obtain a first sub-detection result; connecting the pixel points with the maximum gray value in the image boundary intensity result to obtain a second sub-detection result; and determining the first sub-detection result and the second sub-detection result as the target farmland contour detection result.
[0010] Second aspect, an embodiment of the present invention further provides a farmland contour detection device based on a generative adversarial network, including: an acquisition unit, a training unit, an input unit, a first processing unit, and a second processing unit, wherein, the acquisition unit is configured to acquire a sample remote sensing image, label target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are pixels in the sample remote sensing image that represent the farmland contour; the training unit is configured to use the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model; the input unit is configured to, after acquiring a remote sensing image to be detected, input the remote sensing image to be detected into the target generative adversarial network model to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the remote sensing image to be detected; the first processing unit is configured to use a watershed transformation algorithm to process the remote sensing image to be detected to obtain an image boundary intensity result of the remote sensing image to be detected; the second processing unit is configured to determine a target farmland contour detection result based on the initial farmland contour detection result and the image boundary intensity result.
[0011] Further, the generative adversarial network model includes: a generator and a discriminator, and the training unit is configured to perform the following steps: a first input step of inputting the target remote sensing image into the generator to obtain edge information of the target remote sensing image; a second input step of inputting the edge information into the discriminator to obtain a sub-farmland contour detection result; a calculation step of calculating an adversarial loss between the generator and the discriminator based on the edge information, the sub-farmland contour detection result, and a preset loss function; if the adversarial loss does not converge within a preset range, updating the generator and the discriminator based on the adversarial loss to obtain an intermediate generator and an intermediate discriminator, determining the intermediate generator as the generator, and determining the intermediate discriminator as the discriminator, and repeating the first input step, the second input step, and the calculation step until the adversarial loss converges within the preset range, and constructing the target generative adversarial network model based on the intermediate generator and the intermediate discriminator corresponding to when the adversarial loss converges within the preset range.
[0012] Further, the first processing unit is configured to: use the watershed transformation algorithm to classify pixels in the remote sensing image to be detected to obtain a classification result; and determine the classification result as the image boundary intensity result of the remote sensing image to be detected.
[0013] Further, the second processing unit is configured to: connect the farmland contours in the initial farmland contour detection result to obtain a first sub-detection result; connect the pixel points with the maximum gray value in the image boundary strength result to obtain a second sub-detection result; and determine the first sub-detection result and the second sub-detection result as the target farmland contour detection result.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory and a processor. The memory is used to store a program that supports the processor to execute the method described in the first aspect above, and the processor is configured to execute the program stored in the memory.
[0015] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored.
[0016] In the embodiment of the present invention, by obtaining a sample remote sensing image, annotating target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are pixels representing the farmland contour in the sample remote sensing image; using the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model; after obtaining a to-be-detected remote sensing image, inputting the to-be-detected remote sensing image into the target generative adversarial network model to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the to-be-detected remote sensing image; using a watershed transformation algorithm to process the to-be-detected remote sensing image to obtain an image boundary strength result of the to-be-detected remote sensing image; and determining a target farmland contour detection result based on the initial farmland contour detection result and the image boundary strength result, the purpose of accurately and efficiently detecting the farmland contour is achieved, thereby solving the technical problem that the detection efficiency and accuracy of the existing farmland contour detection methods are relatively low, and thus the technical effect of improving the detection efficiency and accuracy of the farmland contour detection method is realized.
[0017] Other features and advantages of the present invention will be described in the following description, and part of them will become obvious from the description, or will be understood by implementing the present invention. The objectives and other advantages of the present invention are achieved and obtained by the structures specifically pointed out in the description, the claims, and the drawings.
[0018] To make the above objectives, features, and advantages of the present invention more obvious and understandable, the following specific preferred embodiments are given in conjunction with the accompanying drawings for detailed description as follows. Description of the Drawings
[0019] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0020] Figure 1 It is a flowchart of a farmland contour detection method based on a generative adversarial network provided by an embodiment of the present invention;
[0021] Figure 2 It is a schematic diagram of a generator provided by an embodiment of the present invention;
[0022] Figure 3 It is a schematic diagram of a discriminator provided by an embodiment of the present invention;
[0023] Figure 4 It is a schematic diagram of a farmland contour detection device based on a generative adversarial network provided by an embodiment of the present invention;
[0024] Figure 5 It is a schematic diagram of an electronic device provided by an embodiment of the present invention. Specific Embodiments
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions of the present invention with reference to the drawings. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments of the present invention belong to the scope of protection of the present invention.
[0026] Embodiment 1:
[0027] According to an embodiment of the present invention, an embodiment of a farmland contour detection method based on a generative adversarial network is provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0028] Figure 1 It is a flowchart of a farmland contour detection method based on a generative adversarial network according to an embodiment of the present invention. As Figure 1 shown, the method includes the following steps:
[0029] Step S102: Obtain a sample remote sensing image, label the target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are the pixels in the sample remote sensing image that represent the contour of the farmland.
[0030] Specifically, after obtaining the sample remote sensing image, manually label the farmland contour. The labeling result is a binary image. Label the pixels representing the farmland contour in the sample remote sensing image as 1, and label the pixels in the farmland area that are not the contour as 0, so as to obtain the target remote sensing image.
[0031] Step S104: Use the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model.
[0032] Step S106: After obtaining the remote sensing image to be detected, input the remote sensing image to be detected into the target generative adversarial network model to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the remote sensing image to be detected.
[0033] Step S108: Use the watershed transformation algorithm to process the remote sensing image to be detected to obtain the image boundary intensity result of the remote sensing image to be detected.
[0034] Step S110: Based on the initial farmland contour detection result and the image boundary intensity result, determine the target farmland contour detection result.
[0035] In the embodiment of the present invention, by obtaining a sample remote sensing image, labeling the target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are the pixels in the sample remote sensing image that represent the contour of the farmland; using the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model; after obtaining the remote sensing image to be detected, inputting the remote sensing image to be detected into the target generative adversarial network model to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the remote sensing image to be detected; using the watershed transformation algorithm to process the remote sensing image to be detected to obtain the image boundary intensity result of the remote sensing image to be detected; based on the initial farmland contour detection result and the image boundary intensity result, determining the target farmland contour detection result, the purpose of accurately and efficiently detecting the farmland contour is achieved, and further the technical problem of the low detection efficiency and accuracy of the existing farmland contour detection method is solved, thereby realizing the technical effect of improving the detection efficiency and accuracy of the farmland contour detection method.
[0036] In the embodiment of the present invention, as Figure 2 andFigure 3 As shown in the figure, the generative adversarial network model includes: a generator and a discriminator. Step S104 includes the following steps:
[0037] The first input step: input the target remote sensing image into the generator to obtain the edge information of the target remote sensing image;
[0038] The second input step: input the edge information into the discriminator to obtain the sub-farmland contour detection result;
[0039] The calculation step: based on the edge information, the sub-farmland contour detection result and a preset loss function, calculate the adversarial loss between the generator and the discriminator;
[0040] If the adversarial loss does not converge within a preset range, update the generator and the discriminator based on the adversarial loss to obtain an intermediate generator and an intermediate discriminator. Determine the intermediate generator as the generator and the intermediate discriminator as the discriminator, and repeat the execution of the first input step, the second input step and the calculation step until the adversarial loss converges within the preset range. Construct the target generative adversarial network model based on the intermediate generator and the intermediate discriminator corresponding to when the adversarial loss converges within the preset range.
[0041] In the embodiments of the present invention, a specific generative adversarial network structure is designed. The generator is an encoder-decoder model designed to extract contour information from the input, the discriminator is a classification neural network that calculates the contour result loss based on the sample true value, and the loss function is used to constrain the error between the generator and the recognizer during the training process.
[0042] The structure of the generator is as Figure 2 shown. The generator (encoder-decoder model) is used to extract the edge information of the input image.
[0043] The encoder is a series of convolutional networks. The network consists of a convolutional layer, a pooling layer and a BatchNormalization layer. The convolutional layer is responsible for obtaining the local features of the image through convolutional calculation, specifically the feature matrix corresponding to a specific convolutional kernel. The pooling layer samples the image and passes the scale-invariant features to the next layer. The BatchNormalization layer is mainly used to normalize the distribution of the training images to accelerate learning.
[0044] The decoder performs upsampling on the feature image and then performs convolutional processing on the upsampled image, aiming to improve the geometric shape of the object and make up for the detail loss caused by the shrinkage of the object by the pooling layer in the encoder.
[0045] The encoder downsamples the input image through the max - pooling layer, and the decoder upsamples the feature map calculated by the last layer of the encoder. The convolution layer is transposed to obtain a mapping to ensure consistency with the input size, and each convolution layer in the encoder is connected to the corresponding convolution layer in the decoder.
[0046] The structure of the discriminator is as Figure 3 shown. The discriminator (classification neural network) is used to distinguish the generated contour from the ground truth:
[0047] The discriminator includes a classification network to distinguish the predicted contour from the ground truth. It consists of 9 convolution layers with a kernel of 3×3, and the channel depth increases by a factor of 2 from 64 to 512. After each layer is a batch normalization layer and is activated by ReLU. After the last layer are two fully - connected layers, and the last layer is activated by the sigmoid function to retrieve the classification probability.
[0048] After obtaining the generator and the discriminator, it is necessary to design the objective method and the loss function to constrain the training processes of the generator and the discriminator:
[0049] The objective method is to input the training image I into the generator, then input the result into the discriminator, calculate the loss of the adversarial training process, and continuously update the network training alternately in this way. The termination condition for the training processes of the generator and the discriminator is that as the model is trained, the loss function gradually converges to a certain range.
[0050]
[0051] Among them, I and C represent the original input image and the label respectively, D and G represent the discriminator and the generator network for solving the adversarial minimum problem, G θG and D θD represent the continuously updated generator and discriminator during this training process.
[0052] The entire loss function consists of content loss, adversarial loss, and regularization:
[0053]
[0054] The content loss value is a per - pixel value that calculates the weights of positive and negative pixels (edges and non - edges), and the classification loss is implemented using binary cross - entropy.
[0055]
[0056] Among them, C and respectively represent the original contour and the monitoring result of the generator - detected contour, and γ and β represent the weights of non - edge pixels and edge pixels respectively.
[0057] The adversarial loss estimates the similarity between the predicted contour and the available contour information. Therefore, if the discriminator can distinguish the predicted contour from the ground truth, as shown by the following formula, the adversarial loss will continuously increase.
[0058]
[0059] Where ∝ represents the weight of the adversarial loss, which can be modified through different datasets.
[0060] Through the target remote sensing image, the generator and the discriminator are trained until the adversarial loss between the generator and the discriminator converges within a preset range, thus achieving the target generative adversarial network model. Compared with the existing contour detection methods, the generative adversarial network and the convolutional neural network are introduced and combined with each other, and good farmland contour recognition effects can also be obtained in the case of limited samples.
[0061] In the embodiment of the present invention, step S108 includes the following steps:
[0062] Using the watershed transformation algorithm, classify the pixels in the to-be-detected remote sensing image to obtain a classification result;
[0063] Determine the classification result as the image boundary intensity result of the to-be-detected remote sensing image.
[0064] In the embodiment of the present invention, first, all the pixels in the to-be-detected remote sensing image are classified according to the gray value, and a distance threshold is set.
[0065] Determine the pixel point with the smallest gray value (by default marked as the lowest point of value), and let the distance threshold start to increase from the minimum value, with the pixel point with the smallest gray value as the starting point.
[0066] During the increasing process, if the distance from the neighborhood pixels around the pixel point with the smallest gray value to the starting point (the lowest point of gray value) is less than the set threshold, then these pixels are set as the same class, otherwise new classes are set on these pixels, thus completing the classification of the neighborhood pixels.
[0067] As the classification progresses, more new classes will be set until the maximum value of the gray value, and all regions meet on the watershed line, which classifies the entire to-be-detected remote sensing image to obtain a classification result, and determines the classification result as the image boundary intensity result of the to-be-detected remote sensing image.
[0068] Compared with the traditional boundary detection method, using the watershed transformation combined with the generative adversarial network for the segmentation result of the to-be-detected remote sensing image optimizes the recognition result of the generative adversarial network and improves the usability and final recognition accuracy of the result.
[0069] In an embodiment of the present invention, step S110 includes the following steps:
[0070] Connect the farmland contours in the initial farmland contour detection result to obtain a first sub-detection result;
[0071] Connect the pixel points with the maximum gray value in the image boundary strength result to obtain a second sub-detection result;
[0072] Determine the first sub-detection result and the second sub-detection result as the target farmland contour detection result.
[0073] In an embodiment of the present invention, the initial farmland contour detection results are connected, and the pixels with the maximum gray value of the image boundary strength are used as boundary pixels for connection, and finally the target farmland contour detection results are output.
[0074] Embodiment 2:
[0075] The embodiment of the present invention also provides a farmland contour detection device based on a generative adversarial network. The farmland contour detection device based on a generative adversarial network is used to execute the farmland contour detection method based on a generative adversarial network provided in the above content of the embodiment of the present invention. The following is a specific introduction to the farmland contour detection device based on a generative adversarial network provided in the embodiment of the present invention.
[0076] As Figure 4 shown, Figure 4 is a schematic diagram of the above-mentioned farmland contour detection device based on a generative adversarial network. The farmland contour detection device based on a generative adversarial network includes: an acquisition unit 10, a training unit 20, an input unit 30, a first processing unit 40, and a second processing unit 50.
[0077] The acquisition unit is used to acquire a sample remote sensing image, label the target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are the pixels representing the farmland contour in the sample remote sensing image;
[0078] The training unit is used to train the generative adversarial network model with the target remote sensing image to obtain a target generative adversarial network model;
[0079] The input unit is used to input the to-be-detected remote sensing image into the target generative adversarial network model after the to-be-detected remote sensing image is acquired, to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the to-be-detected remote sensing image;
[0080] The first processing unit is used to process the to-be-detected remote sensing image by using a watershed transformation algorithm to obtain the image boundary strength result of the to-be-detected remote sensing image;
[0081] The second processing unit is configured to determine a target farmland contour detection result based on the initial farmland contour detection result and the image boundary intensity result.
[0082] In an embodiment of the present invention, by obtaining a sample remote sensing image, annotating target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are pixels representing the farmland contour in the sample remote sensing image; using the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model; after obtaining a remote sensing image to be detected, inputting the remote sensing image to be detected into the target generative adversarial network model to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the remote sensing image to be detected; using a watershed transformation algorithm to process the remote sensing image to be detected to obtain an image boundary intensity result of the remote sensing image to be detected; and determining a target farmland contour detection result based on the initial farmland contour detection result and the image boundary intensity result, the purpose of accurately and efficiently detecting the farmland contour is achieved, thereby solving the technical problem that the detection efficiency and accuracy of the existing farmland contour detection method are relatively low, and thus the technical effect of improving the detection efficiency and accuracy of the farmland contour detection method is realized.
[0083] Further, the generative adversarial network model includes: a generator and a discriminator, and the training unit is configured to perform the following steps: a first input step of inputting the target remote sensing image into the generator to obtain edge information of the target remote sensing image; a second input step of inputting the edge information into the discriminator to obtain a sub-farmland contour detection result; a calculation step of calculating an adversarial loss between the generator and the discriminator based on the edge information, the sub-farmland contour detection result, and a preset loss function; if the adversarial loss does not converge within a preset range, updating the generator and the discriminator based on the adversarial loss to obtain an intermediate generator and an intermediate discriminator, determining the intermediate generator as the generator, and determining the intermediate discriminator as the discriminator, and repeating the first input step, the second input step, and the calculation step until the adversarial loss converges within the preset range, and constructing the target generative adversarial network model based on the intermediate generator and the intermediate discriminator corresponding to when the adversarial loss converges within the preset range.
[0084] Further, the first processing unit is configured to: classify pixels in the remote sensing image to be detected by using the watershed transformation algorithm to obtain a classification result; and determine the classification result as the image boundary intensity result of the remote sensing image to be detected.
[0085] Further, the second processing unit is configured to: connect the farmland contours in the initial farmland contour detection result to obtain a first sub-detection result; connect the pixel points with the maximum gray value in the image boundary strength result to obtain a second sub-detection result; and determine the first sub-detection result and the second sub-detection result as the target farmland contour detection result.
[0086] Embodiment 3:
[0087] The embodiment of the present invention further provides an electronic device, including a memory and a processor. The memory is used to store a program that supports the processor to execute the method described in Embodiment 1 above, and the processor is configured to execute the program stored in the memory.
[0088] See Figure 5 , the embodiment of the present invention further provides an electronic device 100, including: a processor 60, a memory 61, a bus 62, and a communication interface 63. The processor 60, the communication interface 63, and the memory 61 are connected through the bus 62. The processor 60 is used to execute an executable module stored in the memory 61, such as a computer program.
[0089] Among them, the memory 61 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 63 (which can be wired or wireless), a communication connection is realized between this system network element and at least one other network element, and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used.
[0090] The bus 62 may be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 5 only a bidirectional arrow is used in
[0091] Among them, the memory 61 is used to store a program. After receiving an execution instruction, the processor 60 executes the program. The method executed by the device defined by the flow process disclosed in any one of the foregoing embodiments of the present invention can be applied to the processor 60 or implemented by the processor 60.
[0092] The processor 60 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor 60 or the instructions in the form of software. The above-mentioned processor 60 may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by the combination of the hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 61, and the processor 60 reads the information in the memory 61 and combines its hardware to complete the steps of the above method.
[0093] Embodiment 4:
[0094] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the method described in Embodiment 1 above.
[0095] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installation", "connection", and "connection" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be a direct connection or an indirect connection through an intermediate medium, and it may be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.
[0096] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation of the present invention. In addition, the terms "first", "second", "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.
[0097] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some communication interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.
[0098] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0099] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.
[0100] Finally, it should be noted that the above-described embodiments are only specific embodiments of the present invention, used to illustrate the technical solutions of the present invention, rather than limiting them. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed by the present invention can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or make equivalent replacements for some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A method for detecting farmland contours based on a generative adversarial network, characterized in that, Including: Obtain a sample remote sensing image, label the target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are the pixels in the sample remote sensing image that represent the contour of farmland; Use the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model. The generative adversarial network model includes: a generator and a discriminator; the generator is an encoder-decoder model for extracting the edge information of the input image. The encoder is a series of convolutional networks, and the convolutional network consists of a convolutional layer, a pooling layer, and a BatchNormalization layer. The decoder performs upsampling on the feature image and then performs convolutional processing on the upsampled image to improve the geometric shape of the object and make up for the detail loss caused by the shrinkage of the object by the pooling layer in the encoder; the discriminator is a classification neural network for distinguishing the generated contour from the ground truth; After obtaining the remote sensing image to be detected, input the remote sensing image to be detected into the target generative adversarial network model to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the remote sensing image to be detected; Use the watershed transform algorithm to process the remote sensing image to be detected to obtain the image boundary strength result of the remote sensing image to be detected; Based on the initial farmland contour detection result and the image boundary strength result, determine the target farmland contour detection result, including: connecting the farmland contours in the initial farmland contour detection result to obtain a first sub-detection result; connecting the pixel points with the largest gray value in the image boundary strength result to obtain a second sub-detection result; determine the first sub-detection result and the second sub-detection result as the target farmland contour detection result.
2. The method according to claim 1, characterized in that Use the target remote sensing image to train a generative adversarial network model to obtain a target generative adversarial network model, including: The first input step: input the target remote sensing image into the generator to obtain the edge information of the target remote sensing image; The second input step: input the edge information into the discriminator to obtain a sub-farmland contour detection result; The calculation step: based on the edge information, the sub-farmland contour detection result, and a preset loss function, calculate the adversarial loss between the generator and the discriminator; If the adversarial loss does not converge within a preset range, update the generator and the discriminator based on the adversarial loss to obtain an intermediate generator and an intermediate discriminator. Determine the intermediate generator as the generator and the intermediate discriminator as the discriminator, and repeat the first input step, the second input step, and the calculation step until the adversarial loss converges within the preset range. Construct the target generative adversarial network model based on the intermediate generator and the intermediate discriminator corresponding to when the adversarial loss converges within the preset range.
3. The method according to claim 1, wherein Using the watershed transformation algorithm, process the to-be-detected remote sensing image to obtain the image boundary intensity result of the to-be-detected remote sensing image, including: Using the watershed transformation algorithm, classify the pixels in the to-be-detected remote sensing image to obtain a classification result; Determine the classification result as the image boundary intensity result of the to-be-detected remote sensing image.
4. A farmland contour detection device based on a generative adversarial network, characterized in that, Including: An acquisition unit, a training unit, an input unit, a first processing unit, and a second processing unit, where The acquisition unit is used to acquire a sample remote sensing image, label the target pixels in the sample remote sensing image to obtain a target remote sensing image, where the target pixels are the pixels representing the farmland contour in the sample remote sensing image; The training unit is used to train a generative adversarial network model using the target remote sensing image to obtain a target generative adversarial network model. The generative adversarial network model includes: a generator and a discriminator; the generator is an encoder-decoder model used to extract the edge information of the input image. The encoder is a series of convolutional networks, and the convolutional network consists of a convolutional layer, a pooling layer, and a BatchNormalization layer. The decoder performs upsampling on the feature image and then performs convolutional processing on the upsampled image to improve the geometric shape of the object and make up for the detail loss caused by the shrinkage of the object by the pooling layer in the encoder; the discriminator is a classification neural network used to distinguish the generated contour from the ground truth; The input unit is used to input the to-be-detected remote sensing image into the target generative adversarial network model after acquiring the to-be-detected remote sensing image to obtain an initial farmland contour detection result, where the initial farmland contour detection result is used to distinguish the farmland contour and the ground truth in the to-be-detected remote sensing image; The first processing unit is used to process the to-be-detected remote sensing image using the watershed transformation algorithm to obtain the image boundary intensity result of the to-be-detected remote sensing image; The second processing unit is used to determine a target farmland contour detection result based on the initial farmland contour detection result and the image boundary intensity result; The second processing unit is used to: connect the farmland contours in the initial farmland contour detection result to obtain a first sub-detection result; connect the pixel points with the maximum gray value in the image boundary intensity result to obtain a second sub-detection result; determine the first sub-detection result and the second sub-detection result as the target farmland contour detection result.
5. The device according to claim 4, characterized in that, The training unit is used to perform the following steps: The first input step: input the target remote sensing image into the generator to obtain the edge information of the target remote sensing image; The second input step: input the edge information into the discriminator to obtain a sub-farmland contour detection result; The calculation step: calculate the adversarial loss between the generator and the discriminator based on the edge information, the sub-farmland contour detection result, and a preset loss function; If the adversarial loss does not converge to a preset range, update the generator and the discriminator based on the adversarial loss to obtain an intermediate generator and an intermediate discriminator, determine the intermediate generator as the generator, and determine the intermediate discriminator as the discriminator. Repeat the execution of the first input step, the second input step, and the calculation step until the adversarial loss converges to the preset range. Construct the target generative adversarial network model based on the intermediate generator and the intermediate discriminator corresponding to when the adversarial loss converges to the preset range.
6. The device according to claim 4, wherein The first processing unit is configured to: Use the watershed transformation algorithm to classify the pixels in the remotely sensed image to be detected, and obtain a classification result; Determine the classification result as the image boundary intensity result of the remotely sensed image to be detected.
7. An electronic device, characterized in that, It includes a memory and a processor. The memory is used to store a program that supports the processor to execute the method according to any one of claims 1 to 3, and the processor is configured to execute the program stored in the memory.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is run by the processor, it executes the steps of the method according to any one of claims 1 to 3 above.