Intelligent waterline extraction method and system based on unmanned aerial vehicle image
By constructing an EWUNet network model and combining it with a multi-layer feature-enhanced skip connection mechanism, the problem of low accuracy in water boundary line extraction in complex water and land environments by traditional methods is solved. This achieves automated, accurate, and efficient extraction of water boundary lines, and the generated data supports water resource management and ecological monitoring.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JINGJIANG HYDROLOGY & WATER RESOURCES SURVEY BUREAU OF CHANGJIANG WATER RESOURCES COMMISSION
- Filing Date
- 2025-12-25
- Publication Date
- 2026-04-24
AI Technical Summary
Traditional image processing methods and deep learning segmentation models struggle to accurately extract waterline boundaries in complex water and land environments, resulting in severe line breaks and low accuracy. These methods cannot be directly used for GIS analysis and fail to meet the operational needs of large-scale, routine river condition monitoring.
A smart waterline extraction method based on UAV imagery is adopted. By constructing an EWUNet network model and combining it with a multi-layer feature enhancement skip connection mechanism, waterline segmentation is performed. The segmentation results are then combined with the original coordinate information to generate a GeoTIFF format waterline raster file, achieving automated and accurate waterline extraction.
It achieves automated, precise, and efficient extraction of waterline lines, generates data with high spatial accuracy, supports batch applications in complex waterways, and provides scientific data support for water resource management and ecological monitoring.
Smart Images

Figure CN121921678A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water conservancy information technology, and in particular to a method and system for intelligent extraction of waterline based on UAV imagery. Background Technology
[0002] The waterline is a crucial spatial boundary information reflecting changes in river morphology, water resource distribution, and flood evolution, playing a key role in river condition monitoring, flood warning, and bank stability assessment. In some typical meandering rivers, the aquatic and terrestrial environments are extremely complex: blurred boundaries, high sediment content, and turbidity result in low contrast in the optical characteristics of the water-land boundary, and numerous gradually changing tidal flats exist; significant disturbances occur due to land features, with ships and floating objects commonly seen on the river surface, and protective forests, reed beds, and wave-breaking forests on the banks casting shadows on the water, causing substantial disturbance; and diverse landforms include various geomorphic units such as mid-channel bars, river islands, eroded banks, and silted banks, each with distinct shapes.
[0003] Traditional image processing methods (such as thresholding and edge detection operators) suffer from severe line breaks and low accuracy in such complex environments, rendering them completely impractical. Existing general-purpose deep learning segmentation models (such as UNet) have simple skip connection mechanisms, which cannot effectively optimize and fuse features from different levels. They lack the ability to suppress the aforementioned complex interferences, are prone to misjudgments, and have the following engineering defects: the models usually process pure image formats (PNG / JPG), losing valuable geographic coordinates and projection information of the original images during processing. This results in the extraction results being unable to be directly located, requiring tedious and error-prone manual post-registration before they can be used for GIS analysis, severely restricting production efficiency and failing to meet the operational needs of large-scale, routine river condition monitoring. Summary of the Invention
[0004] Therefore, it is necessary for the present invention to provide a method, system and medium for intelligent extraction of waterline based on UAV imagery, in order to solve at least one of the above-mentioned technical problems.
[0005] To achieve the above objectives, a method for intelligent extraction of waterline based on UAV imagery includes the following steps: Step S1: Obtain the UAV orthophoto file in GeoTIFF format for the target area, extract the coordinate system definition and affine transformation parameters, generate a JSON configuration file, and convert the UAV orthophoto file into a PNG image; Step S2: Construct an EWUNet network model including an encoder, decoder, and a multi-layer feature enhancement skip connection mechanism; input the PNG image into the EWUNet network model and output a binarized waterline segmentation PNG image; Step S3: Write the segmented PNG image of the waterline into the first band, and at the same time assign the coordinate system type string in the JSON configuration file to the coordinate system property, and assign the affine transformation parameters to the affine transformation property, thereby creating a GeoTIFF format waterline raster file; Step S4: Perform connected component detection and boundary tracing on the waterline raster file to obtain the row and column number sequences of the boundary pixels; calculate the actual geographic coordinates based on the row and column number sequences of the boundary pixels and the affine transformation parameters; construct the actual geographic coordinates into a vector polygon and output it in GeoJSON format.
[0006] This invention also provides a waterline intelligent extraction system based on UAV imagery, used to execute the above-described waterline intelligent extraction method based on UAV imagery, wherein the waterline intelligent extraction system based on UAV imagery includes: The image preprocessing module is used to acquire GeoTIFF format UAV orthophoto files of the target area, extract the coordinate system definition and affine transformation parameters, generate a JSON configuration file, and convert the UAV orthophoto files into PNG images. The waterline segmentation module is used to construct an EWUNet network model that includes an encoder, a decoder, and a multi-layer feature enhancement skip connection mechanism; it takes a PNG image as input to the EWUNet network model and outputs a binarized waterline segmented PNG image. The georeference module is used to write the waterline segmented PNG image into the first band, and at the same time assign the coordinate system type string in the JSON configuration file to the coordinate system property, and assign the affine transformation parameters to the affine transformation property, thereby creating a GeoTIFF format waterline raster file. The vectorization conversion module is used to perform connected component detection and boundary tracing on the waterline raster file to obtain the row and column number sequences of the boundary pixels; calculate the actual geographic coordinates based on the row and column number sequences of the boundary pixels and the affine transformation parameters; and construct the actual geographic coordinates into a vector polygon and output it in GeoJSON format.
[0007] This invention achieves automated, accurate, and efficient waterline extraction by combining high-resolution UAV orthophotos with the deep learning segmentation model EWUNet. In this method, the GeoTIFF images acquired by the UAV, after preprocessing and coordinate information parsing, can generate high-quality PNG images while maintaining the original geographic reference. This provides standardized input for subsequent deep learning models, avoiding inconsistencies from manual cropping and annotation. The EWUNet network extracts multi-scale spatial features through an encoder, and the decoder, combined with a multi-layer feature-enhanced skip connection mechanism, fuses low-level spatial details with high-level semantic information, significantly improving the ability to distinguish between water and non-water boundaries. This enables accurate segmentation of boundary contours in complex water bodies, maintaining high precision even with complex textures or water colors close to the background. After model training, the method can quickly input new UAV images into the model to generate binarized waterline segmentation maps, achieving high-throughput processing and saving significant time spent on manual identification and drawing of vector boundaries.
[0008] In the georeference module, the segmentation results are combined with the original coordinate information to generate a GeoTIFF raster file with geographic information, ensuring the spatial accuracy of the data and providing a reliable foundation for further spatial analysis and water area management. Subsequently, through connected component detection and boundary tracking, the raster boundaries are accurately converted into GeoJSON vector polygons, which facilitates visualization in the GIS platform and the calculation of spatial indicators such as area and length, supporting decision analysis. The overall method automates the entire process from UAV image acquisition to water boundary vectorization output, improving the accuracy and stability of water boundary extraction. It also features high processing efficiency, good repeatability, and ease of batch application. Furthermore, it provides highly adaptable extraction solutions for various types of water areas, such as complex rivers and lakes, providing scientific and reliable data support for water resource management, ecological monitoring, and water conservancy project planning. Attached Figure Description
[0009] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is a schematic diagram of the steps of the intelligent waterline extraction method based on UAV imagery of the present invention; Figure 2 This is a schematic diagram of the intelligent waterline extraction system based on UAV imagery of the present invention. Figure 3 This is a diagram of the EWUNet network structure according to an embodiment of the present invention; Figure 3 This is a comparison diagram of the waterline extraction effect according to an embodiment of the present invention. Detailed Implementation
[0010] The technical method of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0011] Furthermore, the accompanying drawings are merely illustrative of the invention and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor methods and / or microcontroller methods.
[0012] It should be understood that although the terms "first," "second," etc., may be used herein to describe various units, these units should not be limited by these terms. These terms are used merely to distinguish one unit from another. For example, without departing from the scope of the exemplary embodiments, a first unit may be referred to as a second unit, and similarly, a second unit may be referred to as a first unit. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0013] To achieve the above objectives, please refer to Figures 1 to 4 This invention provides a method for intelligent extraction of waterline based on UAV imagery, the method comprising the following steps: Step S1: Obtain the UAV orthophoto file in GeoTIFF format for the target area, extract the coordinate system definition and affine transformation parameters, generate a JSON configuration file, and convert the UAV orthophoto file into a PNG image; Step S2: Construct an EWUNet network model including an encoder, decoder, and a multi-layer feature enhancement skip connection mechanism; input the PNG image into the EWUNet network model and output a binarized waterline segmentation PNG image; Step S3: Write the waterline segmented PNG image into the first band, and at the same time assign the coordinate system type string in the JSON configuration file to the coordinate system property, and assign the affine transformation parameters to the affine transformation property, thereby creating a GeoTIFF format waterline raster file; Step S4: Perform connected component detection and boundary tracing on the waterline raster file to obtain the row and column number sequences of the boundary pixels; calculate the actual geographic coordinates based on the row and column number sequences of the boundary pixels and the affine transformation parameters; construct the actual geographic coordinates into a vector polygon and output it in GeoJSON format.
[0014] Furthermore, step S1 includes the following steps: Step S11: Obtain the UAV orthophoto file in GeoTIFF format for the target area; In one embodiment, UAV orthophoto files (GeoTIFF format) of the target area can be obtained via a file system interface or a network storage interface. This acquisition process includes locating the image file path or URL, verifying file integrity (e.g., through file header or checksum checks), and ensuring the file is in GeoTIFF format (checking the file extension and header identifiers).
[0015] For example, you can look for files ending with .tif or .tiff in the local disk directory / data / uav / ortho / , read the file metadata to confirm that it is GeoTIFF; if the file is stored on a remote server, it is first downloaded to the local temporary directory via HTTP or SFTP and its integrity is verified.
[0016] Step S12: Open the UAV orthophoto file, locate the geographic tag group in the file header, and read the coordinate system definition string and six affine transformation parameters from the tag group. The six affine transformation parameters are: x-direction pixel resolution, first rotation coefficient, upper left x-coordinate, second rotation coefficient, y-direction pixel resolution, and upper left y-coordinate. In one embodiment, the UAV orthophoto file is opened, and the geographic tag group in the file header (e.g., GeoKeyDirectoryTag, GeoAsciiParamsTag, ModelPixelScaleTag, and ModelTiepointTag in GeoTIFF) is located. From this, the coordinate system definition string (CRS) and six affine transformation parameters are read. Specifically, this includes parsing the coordinate reference system identifier (such as WKT, EPSG code, or PROJ string) to obtain the CRS text, and reading the affine transformation parameter sequence (in the following order: x-axis pixel resolution, first rotation coefficient, top-left x-coordinate, second rotation coefficient, y-axis pixel resolution, and top-left y-coordinate).
[0017] For example, the file header can be opened using a standard image read / write library and the ModelPixelScale (to get the pixel resolution) and ModelTiepoint (to get the top-left corner coordinates) can be read, or the transform array can be read directly to get the six parameters; if the image contains rotation, the corresponding rotation coefficients (first and second rotation coefficients) will also be read and saved.
[0018] Step S13: Store the coordinate system definition string with the key name crs, store the six affine transformation values as an array with the key name transform, and record the width and height of the image in pixels to form a JSON configuration file. In one embodiment, the read coordinate system definition string is stored as the key name `crs`, the six affine transformation values are stored as an array with the key name `transform`, and the width and height of the image in pixels are recorded simultaneously, ultimately forming a standardized JSON configuration file. An example structure of the JSON configuration file includes a string value corresponding to the key `crs`, a numerical array of length 6 corresponding to the key `transform`, and integer pixel dimensions corresponding to the keys `width` and `height`. Optional metadata such as `source_filename` and `creation_date` can also be added for traceability.
[0019] For example, generate the following JSON structure: {"crs":"EPSG:4326","transform":[0.3,0.0,100.0,0.0,-0.3,20.0],"width":4096,"height":3072}, and save this JSON as a file with the same name as the image but with the .json extension.
[0020] Step S14: Read the pixel data of the red, green and blue bands sequentially from the UAV orthophoto file, and write them into a PNG format file in RGB order to obtain a PNG image.
[0021] In one embodiment, pixel data of the red (R), green (G), and blue (B) bands are read sequentially from an orthophoto file of a UAV, and written into a PNG format file in RGB order to obtain a PNG image for subsequent segmentation. Specifically, the process involves first confirming that the source image contains independent R, G, and B bands or multi-band data. Then, the pixel values of each band are read row by row or block by block. The three-band data are merged into a three-channel pixel matrix (width × height × 3) according to the pixel format of the target PNG, and the pixel value range is normalized (e.g., scaling or cropping 16-bit data to an 8-bit range of 0–255 if necessary).
[0022] For example, for a GeoTIFF file with a width of 4096, a height of 3072, and 16 bits per band, the pixels of the three bands are read line by line, and the pixel values are mapped to an 8-bit range through linear mapping or histogram stretching, and then ortho_RGB.png is written out using a PNG encoder.
[0023] Furthermore, step S2 includes the following steps: Step S21: Initialize the EWUNet network structure, set the input size to 512×512 pixels, and the number of input channels to 3, corresponding to the three RGB bands of the PNG image; In one embodiment, the EWUNet network structure is initialized and the size and number of channels of the input tensor are configured. Specifically, the input size is set to 512×512 pixels and the number of input channels is set to 3 to match the RGB three bands of the preprocessed PNG image.
[0024] For example, during model initialization, a default weight initialization method (e.g., He initialization) is set for each convolutional layer, a default bias initial value of 0 is set, and the network is specified to accept input tensors of shape (3,512,512) or (512,512,3) (depending on the channel order of the frame) so that pixels can be read directly from the output of the PNG decoder.
[0025] Step S22: Construct the encoder by setting up five sequentially connected convolutional downsampling units. Each unit includes two 3×3 convolutional layers and one 2×2 max pooling layer. The five units output the first to fifth layer encoded feature maps in sequence. The first layer encoded feature map has a height and width of 256×256 pixels and 64 channels, containing the richest low-level spatial details. The fifth layer encoded feature map has a height and width of 16×16 pixels and 512 channels, containing the highest level semantic information. In one embodiment, the encoder portion is constructed by setting up five sequentially connected convolutional downsampling units, each containing two 3×3 convolutional layers (typically with a batch normalization layer and a non-linear activation function, such as ReLU, between the two convolutions) and a 2×2 max pooling layer for spatial downsampling.
[0026] For example, the first coding unit outputs a size of 256×256×64 (height and width are half of the input, and the number of channels is 64). The second, third, and fourth coding units increase the number of channels by a factor of 2 to 128, 256, and 512, respectively, and reduce the spatial size to 128×128, 64×64, and 32×32. The fifth layer, as the deepest coding layer, outputs 16×16×512 to preserve the highest level semantic information.
[0027] It should be noted that, in order to avoid information loss, each 3×3 convolution can be padded appropriately (padding='same') to maintain spatial alignment before and after the convolution. When hardware is limited, depthwise separable convolution or group convolution can be used as a lightweight alternative without changing the overall hierarchical structure.
[0028] Step S23: Construct the decoder by setting up five sequentially connected upsampling units that correspond to the five units of the encoder. Each upsampling unit includes a bilinear interpolation upsampling layer and two 3×3 convolutional layers, which progressively enlarge the height and width of the feature map to twice that of the previous layer.
[0029] In one embodiment, the decoder part is constructed by setting up five upsampling units corresponding to the encoder. Each upsampling unit first uses bilinear interpolation to upsample the feature map (doubles the height and width of the previous layer), and then refines and compresses the upsampled features through two 3×3 convolutional layers (which can also be combined with batch normalization and ReLU).
[0030] For example, the fifth-layer decoding unit receives the deepest 16×16×512 features, amplifies them to 32×32 through bilinear interpolation, and outputs a feature map after being convolved with the fourth-layer encoded features. Then, it restores the spatial resolution to 64×64, 128×128, 256×256, and even 512×512 layer by layer to reconstruct fine-grained boundary information.
[0031] Furthermore, step S2 also includes the following steps: Step S24: Establish cross-level feature fusion rules between the encoder and decoder as a multi-level feature enhancement skip connection mechanism; In one embodiment, a cross-level feature fusion rule is established between the encoder and decoder as a skip connection mechanism for multi-level feature enhancement, so as to simultaneously fuse features of different semantic levels during the decoding process to enhance boundary and detail representation.
[0032] For example, according to the established rules: the fifth layer decoding unit receives the bridge layer features and the fifth layer coding feature map; each unit of the fourth to second layer decoding units receives three features - the output of the previous decoding unit is amplified by bilinear interpolation, the output of the coding unit at the same level, and the output of the coding unit with the layer number reduced by 1 is reduced by 2×2 max pooling, and the three are concatenated in the channel dimension; the first layer decoding unit receives the amplified output of the second layer decoding unit and the first layer coding feature map, and the two are concatenated and then compressed in the channel by 3×3 convolution.
[0033] It should be noted that after channel splicing, it is advisable to perform channel compression and fusion through 1×1 or 3×3 convolutional layers to control the number of parameters and eliminate inconsistencies in channel dimensions.
[0034] Step S25: Connect a 1×1 convolutional layer and a sigmoid activation function layer after the first layer decoding unit. The 1×1 convolutional layer compresses the number of channels to 1, and the sigmoid activation function layer maps the value of each pixel to between 0 and 1 as the waterline probability value to obtain the output layer. In one embodiment, a 1×1 convolutional layer and a sigmoid activation function layer are connected after the first decoding unit to generate the final output layer. The 1×1 convolution compresses the number of channels to 1 to obtain a single-channel probability map, and the sigmoid function maps each pixel to a range of 0 to 1 to represent the probability that the pixel is water.
[0035] For example, the final output size of the decoder is 512×512×C (C is the number of channels), which becomes 512×512×1 after 1×1 convolution, and then a continuous probability value map P(x,y)∈(0,1) is obtained by Sigmoid.
[0036] Step S26: Train the EWUNet network model using the preprocessed PNG image dataset and its corresponding binary labeled samples. The EWUNet network model consists of the EWUNet network structure, encoder, decoder, multi-layer feature enhancement skip connection mechanism, and output layer. In one embodiment, the EWUNet model is trained using a preprocessed PNG image dataset and its corresponding binary labeled samples. The training process includes data loading, optional data augmentation (such as random cropping, rotation, mirroring, brightness / contrast adjustment), forward propagation to calculate the predicted probability map, calculation of the total loss based on the weighted sum of cross-entropy loss and Dice loss, backpropagation to calculate the gradient and updating the network parameters using the Adam optimizer, and validation set evaluation and model checkpoint saving to prevent overfitting.
[0037] For example, the batch size can be set to 16, the initial learning rate to 1e-4, and the number of training epochs to 100. A learning rate decay or early stopping strategy can be adopted when the validation set metric (such as the validation set Dice coefficient) no longer increases. The weight ratio of cross-entropy to Dice can be set to 0.5:0.5 or adjusted according to the imbalance of samples.
[0038] It should be noted that since waterline data usually has extremely imbalanced classes (low proportion of boundary pixels), the use of Dice loss and sampling / enhancement strategies can effectively alleviate this problem; during training, the model's random seed and normalization parameters should also be saved to ensure reproducibility.
[0039] Step S27: Input the PNG image into the EWUNet network model and output a binarized waterline segmentation PNG image.
[0040] In one embodiment, the PNG image to be processed is input into a pre-trained EWUNet model to perform forward propagation, and a single-channel waterline probability map is obtained. The probability map is then thresholded to form a binarized segmentation map.
[0041] For example, a threshold of 0.5 is used to set pixels with a probability greater than 0.5 to 1 (representing water bodies) and otherwise to 0 (representing non-water bodies). The binary array is then encoded in PNG format and saved as waterline_mask.png for subsequent georeferencing and vectorization.
[0042] It should be noted that the threshold can be adjusted according to the specific task requirements and the precision-recall tradeoff on the validation set, and the segmentation results can be further purified in the post-processing stage (such as morphological opening and closing operations or small connected component filtering) to eliminate isolated noise or fill small holes.
[0043] Furthermore, the cross-level feature fusion rule in step S24 is as follows: The fifth-layer decoding unit receives the bridge layer features and the fifth-layer coding feature map; In one embodiment, the bridging layer features represent the global semantic information retained after multi-layer encoding and compression, while the fifth-layer encoded feature map contains richer spatial details of that layer. The fifth-layer decoding unit first concatenates the two sets of feature maps along the channel dimension to fuse global semantics and hierarchical detail information. Then, it performs feature compression and smoothing through a 3×3 convolutional layer, so that the fused features retain the main target contour while reducing redundant feature channels and improving the feature expression efficiency of the decoding stage.
[0044] For example, when the input image is a 512×512 medical CT image, the feature map size of the bridging layer can be 16×16×512, the feature map size of the coding layer can be 16×16×256, and after stitching, it is compressed to 16×16×256 by a 3×3 convolutional layer so that subsequent layer-by-layer upsampling can restore the spatial resolution.
[0045] Each of the fourth, third, and second layer decoding units receives three feature maps: the first is the output feature map of the previous decoding unit, which is magnified by two times through bilinear interpolation; the second is the output feature map of the same level coding unit; and the third is the output feature map of the coding unit with the layer number reduced by 1, which is reduced by half through 2×2 window max pooling. In one embodiment, the fourth, third, and second layer decoding units have similar structures, with each unit receiving three input feature maps. The first input is the feature map output from the previous layer decoding unit, which is upsampled using bilinear interpolation to double its size and recover higher resolution spatial information. The second input is the feature map output from the encoding unit corresponding to the current decoding layer, used to supplement local spatial details. The third input is the feature map output from the encoding unit with the layer number reduced by one, which is halved in size after 2×2 window max pooling to introduce low-level edge contour information and suppress noise. The three input feature maps are concatenated along the channel dimension and then fed into a 3×3 convolutional layer for fusion and channel compression.
[0046] For example, if the size of the previous layer's decoding output is 64×64×256, after upsampling, the size becomes 128×128×256; the corresponding third layer encoding output is 128×128×128; and the second layer encoding output, after max pooling, is 64×64×128. After concatenation, these are processed by convolution to generate a 128×128×256 fused feature map.
[0047] The first-layer decoding unit receives the amplified output of the second-layer decoding unit and the first-layer encoded feature map; In one embodiment, the first-layer decoding unit receives the magnified output feature map from the second-layer decoding unit and the first-layer encoded feature map. This unit is mainly used for the final high-resolution restoration and detail restoration. Specifically, the second-layer decoding output is magnified by a factor of two using bilinear interpolation to match the first-layer encoded feature map in spatial dimensions, and then concatenated along the channel dimension to comprehensively utilize the shallow edge features from the encoding stage and the high-level semantic information from the decoding stage. The concatenated features are then channel-compressed through a 3×3 convolutional layer to generate a high-resolution fused feature map, which serves as the final output of the decoding network.
[0048] For example, when the output size of the second layer decoding is 256×256×128, after upsampling, a feature map of 512×512×128 is obtained. After concatenation with the first layer encoding feature of 512×512×64, it is compressed into 512×512×64 by convolution, which provides input for subsequent prediction layers (such as 1×1 convolution output classification map or segmentation mask).
[0049] Each decoding unit concatenates the received feature maps along the channel dimension and then compresses the number of channels through a 3×3 convolutional layer.
[0050] In one embodiment, each decoding unit performs the same fusion strategy after receiving multiple feature maps, namely, concatenating feature maps from different sources along the channel dimension to achieve multi-layer complementarity of spatial and semantic information. The concatenated high-dimensional features are then processed by a 3×3 convolutional layer for channel compression and feature integration, thereby improving the compactness and discriminativeness of feature representation.
[0051] For example, in the third-layer decoding unit, if the number of channels in the concatenated feature map is 512, it can be reduced to 256 through convolutional compression, thereby reducing the amount of computation without losing the main semantics.
[0052] See Figure 3 The EWUNet network structure diagram shown illustrates the complete architecture design of the EWUNet network model in the intelligent waterline extraction method: the left-hand encoding stage presents a layer-by-layer downsampling process of five encoding units from top to bottom. The input image is a 512×512×3 three-channel PNG image (corresponding to the RGB three bands of UAV orthophoto). The first layer encoding output is a 256×256×64 feature map, containing the richest low-level spatial details; the second layer encoding output is 128×128×128; the third layer encoding output is 64×64×256; the fourth layer encoding output is 32×32×512; and the fifth layer encoding output is 16×16×512, containing the highest-level semantic information. Each encoding unit consists of two 3×3 convolutional layers (marked with blue squares) and one 2×2 max-pooling layer (marked with orange squares).
[0053] The central bridging layer is located between the encoder and decoder, and completes feature integration through a 1×1 convolutional layer.
[0054] The decoding stage on the right shows five corresponding upsampling units, which gradually restore spatial resolution through 2×2 upsampling (marked by black squares) and 3×3 convolutional layers. The key lies in the multi-layer feature enhancement skip connection mechanism (copy connections represented by yellow dashed lines), which allows each layer in the decoding process to fuse feature information from different levels of the encoder, enhancing boundary and detail representation. The final output is a 512×512×C feature map, which, after 1×1 convolutional compression and sigmoid activation, yields a 512×512×1 waterline probability map.
[0055] Furthermore, step S26 includes the following steps: Step S261: Obtain the labeled PNG image training dataset and its corresponding binary labeled sample set; In one embodiment, the PNG image training dataset can be derived from river images obtained through drone aerial photography, satellite remote sensing, or terrestrial photogrammetry. The image content includes river water, banks, vegetation, buildings, and background areas. Each image corresponds to a binary labeled sample, where the waterline area is labeled as 1 and other areas are labeled as 0, to form clear foreground and background segmentation labels.
[0056] For example, in the task of extracting the water boundary of a river channel, 500 river channel images with a resolution of 512×512 pixels can be selected as the training sample set, and the water boundary can be manually and accurately labeled using image annotation tools (such as LabelMe or CVAT) to generate the corresponding binary mask sample set.
[0057] Step S262: Input the PNG image training dataset into the EWUNet network structure to perform forward propagation. The data passes through the five encoding units of the encoder, the bridging layer, the five decoding units of the decoder, the cross-layer connection, and the output layer in sequence to obtain the predicted waterline probability map. In one embodiment, a PNG image training dataset is input into the EWUNet network structure for forward propagation. Specifically, each input image is first standardized to normalize pixel values to the [0,1] interval before being input into the EWUNet network. This network structure consists of an encoder, bridging layers, and a decoder. The encoder contains five encoding units, used to extract multi-scale features layer by layer and reduce spatial resolution. The bridging layers integrate features between encoding and decoding. The decoder, through five decoding units and multiple skip connections, gradually restores spatial resolution and fuses high- and low-level features. Finally, the output layer uses 1×1 convolutions to generate a waterline probability map of the same size as the input image, where the value of each pixel represents the probability that the pixel belongs to the waterline.
[0058] For example, when the input image size is 512×512×3, EWUNet outputs a 512×512×1 probability map, where the closer the pixel value is to 1, the more likely it is to be a water boundary point.
[0059] Step S263: Calculate the weighted sum of the cross-entropy loss and Dice loss between the waterline probability map and the corresponding binary labeled sample set as the total loss function value; In one embodiment, a loss function is calculated between the waterline probability map and the corresponding binary labeled sample set. Specifically, the weighted sum of cross-entropy loss and Dice loss is used as the total loss function value. Cross-entropy loss measures the classification accuracy of each pixel and can effectively guide the model to distinguish between foreground and background; Dice loss measures the degree of overlap between the prediction and the real area and can improve the recognition accuracy of small target areas (such as narrow waterlines) when the samples are imbalanced.
[0060] For example, if the waterline area in the prediction graph is thin and accounts for less than 5%, the cross-entropy weight can be set to 0.4 and the Dice loss weight to 0.6 to enhance the focus on the edge area.
[0061] Step S264: Perform backpropagation based on the total loss function value to calculate the gradients of the weight and bias parameters of all convolutional layers in the EWUNet network structure, and use the Adam optimizer to update the weight and bias parameters according to the gradients to obtain the EWUNet network model.
[0062] In one embodiment, backpropagation is performed based on the total loss function to update the EWUNet network parameters. Specifically, the gradients of the weight and bias parameters of all convolutional layers in the network are calculated using the backpropagation algorithm, and then the parameters are iteratively updated using the Adam optimizer based on the set learning rate and momentum factor. The Adam optimizer combines an adaptive gradient adjustment mechanism with a momentum update strategy, which can accelerate the convergence process while maintaining training stability.
[0063] For example, the initial learning rate can be set to , , After each iteration (epoch), the learning rate is dynamically adjusted based on the validation set loss. Once the total loss function steadily decreases and converges on the validation set, the trained EWUNet network model is obtained, which can then be used for subsequent automatic extraction of river waterline.
[0064] Of particular importance are the implementation details of the EWUNet network model, including: Backbone: The encoder uses ResNet-34 pre-trained on ImageNet.
[0065] Enhanced skip connections: A spatial attention module is integrated into each skip connection path, with the following structure: encoder features → global average pooling → fully connected layer → ReLU → fully connected layer → Sigmoid → output weight map → multiplied with the original features.
[0066] Hyperparameters: initial learning rate 0.0001, Adam optimizer used, batch size set to 4, loss function is cross-entropy loss function.
[0067] Furthermore, step S27 specifically includes: The PNG image is input into the EWUNet network model to perform forward propagation, and the output single-channel water edge probability map is obtained. A threshold of 0.5 is set for each pixel value in the probability map. Pixels with values greater than the threshold are marked as 1 to represent water bodies, and pixels with values less than or equal to the threshold are marked as 0 to represent non-water bodies, thus forming a binarized water edge segmentation PNG image.
[0068] In one embodiment, the PNG image to be processed is preprocessed and then fed into a pre-trained EWUNet network model for forward inference, and the single-channel waterline probability map output by the network is thresholded to obtain a binary segmentation map.
[0069] The specific process is as follows: First, read the PNG image to be inferred (if the image size is not 512×512, crop or fill it to 512×512 pixels using the same slicing / filling strategy as during training, or perform block inference using a sliding window method and then stitch it back to the original size). Perform the same normalization or standardization processing on the pixel values as during training. Then, input the normalized image tensor into the EWUNet model and perform forward propagation to obtain the output single-channel probability map (the value of each pixel is between 0 and 1, representing the probability of belonging to a water body / waterline). Next, apply a fixed threshold of 0.5 to each pixel of the probability map - when the pixel probability is greater than 0.5, mark it as 1 (representing a water body), otherwise mark it as 0 (representing a non-water body), thus obtaining a binary waterline segmentation array. Finally, write the binary array into a binary segmentation file in PNG format (usually mapping 1 to 255 and 0 to 0 and saving it as an 8-bit unsigned integer), and save it with the naming rules corresponding to the input image for subsequent georeferencing and vectorization processing.
[0070] For example, ortho_RGB.png can be read, sliced into 512×512 blocks for inference, and stitched back to the original size in memory. The thresholded mask is then saved as waterline_mask.png for use in steps S31 to S34.
[0071] Importantly, a threshold of 0.5 is the commonly used default value, but it can be adjusted according to the tradeoff between precision and recall on the validation set. In addition, in practical engineering, morphological filtering (such as opening and closing operations), small connected component removal, or hole filling are often performed on the binary mask after thresholding to reduce noise and false contours. However, these post-processing steps should be performed without changing the original pixel-geographic correspondence, and the spatial alignment between the mask and the original image should be ensured before writing to GeoTIFF.
[0072] Furthermore, step S3 includes the following steps: Step S31: Extract the coordinate system definition string with the key "crs" and the array containing six affine transformation parameters with the key "transform" from the JSON configuration file; In one embodiment, coordinate and spatial reference information is extracted from a previously generated JSON configuration file. Specifically, the system first opens the JSON configuration file and parses its key-value pairs, reading the coordinate system definition string with the key "crs" and the array of six affine transformation parameters with the key "transform". The coordinate system definition string is generally represented in WKT (Well-Known Text) or EPSG encoding format and is used to define the spatial reference system, such as EPSG:4490 (CGCS2000 geographic coordinate system) or EPSG:32650 (WGS84 / UTM projected coordinate system). The affine transformation parameter array contains six key values, in the following order: x-axis pixel resolution, first rotation factor, top-left x-coordinate, second rotation factor, y-axis pixel resolution, and top-left y-coordinate.
[0073] For example, if the array content is [0.1,0.0,345678.0,0.0,-0.1,3845672.0], it means that each pixel in the image represents a ground unit with a resolution of 0.1 meters, and the actual geographic coordinates of the upper left corner of the image are (345678.0,3845672.0).
[0074] Step S32: Load the 0 or 1 value of each pixel in the waterline segmentation PNG image into a two-dimensional pixel array; In one embodiment, the pixel information of the waterline segmentation PNG image is loaded and formed into a two-dimensional pixel array. Specifically, the system first calls an image reading interface (such as gdal.Open() in the GDAL library or Image.open() function in the Pillow library of Python) to load the binarized waterline PNG image output by the EWUNet model into memory. This image is a single-channel image, where each pixel value is 0 or 1, representing non-water areas and water areas respectively. The system reads the pixel matrix of this image into a two-dimensional array so that it can be directly written to a GeoTIFF format file later.
[0075] For example, if the image size is 512×512 pixels, the output two-dimensional array matrix will be [512,512], and its array elements will be 0 or 1.
[0076] Step S33: Create a GeoTIFF format file, set the file's coordinate system attribute to a coordinate system definition string, set the file's affine transformation attribute to an array of six affine transformation parameters, and set the file to contain one band and have an 8-bit unsigned integer data type. In one embodiment, a GeoTIFF format file is created and georeferenced attributes are configured. Specifically, the system creates a new GeoTIFF file object using the GDAL or Rasterio library and sets the file's key spatial attributes: first, the file's coordinate system attribute (Projection) is set to the coordinate system definition string extracted in step S31; second, the file's affine transformation attribute (GeoTransform) is set to an array of six affine transformation parameters; finally, the number of data bands in the file is set to 1, and the data type is defined as an 8-bit unsigned integer to match the 0 / 1 pixel values of a PNG image.
[0077] For example, the file can be created by calling the rasterio.open("waterline_result.tif", "w",driver="GTiff",height=512,width=512,count=1,dtype=rasterio.uint8,crs=crs,transform=transform) directive from the Rasterio library.
[0078] Step S34: Write the two-dimensional pixel array into the first band of the GeoTIFF format file to obtain a waterline raster file with geographic coordinate information.
[0079] In one embodiment, the GeoTIFF file object created in step S33 is opened, two-dimensional array data is written to the first band (Band 1), and the file handle is closed to save the result after the write operation is performed. When the written GeoTIFF file is opened in GIS software (such as ArcGIS or QGIS), it can automatically perform spatial matching with the base map and be displayed as a waterline area with real geographic coordinates.
[0080] For example, when writing a two-dimensional array named "mask_array" to a band, the data storage can be achieved by calling the dataset.write(mask_array,1) statement.
[0081] Furthermore, step S4 includes the following steps: Step S41: Perform connected component detection on the two-dimensional pixel array in the water edge raster file to identify all connected regions with a pixel value of 1. Perform boundary tracing on each connected region and record the row and column numbers of the boundary pixels along the edge of the region to form a boundary pixel row and column number sequence. In one embodiment, connected component detection is performed on the waterline raster file, and the boundary pixel sequence of each water body region is extracted. Specifically, the GeoTIFF format waterline raster file is loaded, and its two-dimensional pixel array is read. In this array, regions with a pixel value of 1 represent water bodies or waterline regions, and regions with a pixel value of 0 represent non-water bodies. The system uses a connected component labeling (CCL) algorithm to identify all connected regions with a pixel value of 1, and can choose between 4-neighbor or 8-neighbor criteria, with 8-neighbor more accurately capturing the curve features of the waterline. Each detected connected region is assigned a unique identifier. Subsequently, boundary tracing is performed on each connected region, using a contour tracing algorithm (such as Moore-Neighbor Tracing or Suzuki–Abe algorithm) to record the row and column numbers of boundary points pixel by pixel along the outer edge of the region until a closed, complete boundary path is formed.
[0082] For example, for a raster image of size 512×512, if three connected regions are detected, three boundary pixel row and column number sequences are output respectively. For example, the first set of boundary sequences is [(122,305), (122,306), (123,307), (124,308)...].
[0083] Step S42: Traverse each pixel in the boundary pixel row and column number sequence, and calculate the actual geographic x-coordinate of the pixel as the pixel resolution in the x-direction. Column number First rotation coefficient Line number, calculate the actual geographic y-coordinate equal to the second rotation factor. Column number y-direction pixel resolution line number The y-coordinate of the top left corner forms the actual geographic coordinates; In one embodiment, the row and column number sequence of boundary pixels is converted into an actual geographic coordinate sequence. Each boundary pixel obtained in step S41 is traversed, and its corresponding geographic coordinate position is calculated based on the affine transformation parameters. The calculation formulas are: geographic x-coordinate = x-direction pixel resolution × column number + first rotation coefficient × row number + top-left x-coordinate; geographic y-coordinate = second rotation coefficient × column number + y-direction pixel resolution × row number + top-left y-coordinate. Through this linear affine transformation, the pixel coordinates (row, column) can be accurately mapped to the actual position point (x, y) in the projected coordinate system.
[0084] For example, if a point has row number 200, column number 300, and affine parameters [x resolution = 0.1, first rotation factor = 0, top-left corner x = 345678.0, second rotation factor = 0, y resolution = -0.1, top-left corner y = 3845672.0], then the calculated geographic coordinates of that point are x = 345678.0 + 0.1 × 300 = 345708.0, y = 3845672.0 − 0.1 × 200 = 3845652.0. The system calculates the row and column numbers of each pixel and converts them sequentially into actual geographic coordinates, thus obtaining the true geographic shape of the corresponding boundary.
[0085] Step S43: Write the actual geographic coordinates as the vertex coordinates of the polygon into the geometry field of the file, set the coordinate system property of the file to the coordinate system definition string, and output a GeoJSON file containing the waterline vector polygon.
[0086] In one embodiment, the calculated geographic coordinate sequence is written into a vector file to generate georeferenced waterline vector data. Specifically, the system creates a GeoJSON format file object and defines a Feature type structure for it. The geometry field stores the polygon coordinate information of the waterline, and the properties field records additional attribute information such as region number, area, and perimeter. The system writes the actual geographic coordinates sequentially into the geometry field, organizing the vertex data using the "Polygon" type in the GeoJSON standard format. Subsequently, the system sets the file's coordinate system attribute to a coordinate system definition string (e.g., EPSG:32650) to ensure that the output vector data is spatially consistent with the input raster file.
[0087] For example, if the geographic boundary points of a connected region are [(345708.0,3845652.0), (345710.0,3845653.5), (345712.0,3845655.0)...], then in the GeoJSON file, it will be stored as a closed polygon in the form of a "coordinates" array. Finally, the GeoJSON file output by the system can be directly overlaid and displayed in GIS software (such as QGIS or ArcGIS), achieving a seamless conversion from waterline raster to vector polygon.
[0088] It should be noted that if multiple connected domains are adjacent or nested (e.g., the main river channel and island regions), the outer ring and inner ring should be distinguished according to the GeoJSON standard structure to ensure the correctness of the topology and the accuracy of the visualization results.
[0089] See Figure 4 The image shows a comparison of the waterline extraction results, demonstrating the segmentation performance of the proposed method in a practical application. The left side is the original image, showing a typical water scene (white ships against a green water background), representing real input data based on UAV orthophotos. The middle image is the labeled image, with water areas marked white (pixel value 1) and non-water areas marked black (pixel value 0), used for model training and comparison with real labels. The right side is the predicted image, showing the binarized waterline segmentation result output by the EWUNet network model after processing the input image. Comparing the labeled and predicted images in the middle and right sides, it can be seen that the proposed method can accurately identify the boundary between water and shoreline, effectively extracting detailed features of the waterline, thus verifying the effectiveness and robustness of this intelligent extraction method.
[0090] See Figure 2 The present invention also provides a waterline intelligent extraction system 100 based on UAV imagery, used to execute the above-described waterline intelligent extraction method based on UAV imagery, wherein the waterline intelligent extraction system 100 based on UAV imagery includes: The image preprocessing module 101 is used to acquire the UAV orthophoto file in GeoTIFF format for the target area, extract the coordinate system definition and affine transformation parameters, generate a JSON configuration file, and convert the UAV orthophoto file into a PNG image. The waterline segmentation module 102 is used to construct an EWUNet network model that includes an encoder, a decoder, and a multi-layer feature enhancement skip connection mechanism; it inputs a PNG image into the EWUNet network model and outputs a binarized waterline segmented PNG image. The georeference module 103 is used to write the waterline segmented PNG image into the first band, and at the same time assign the coordinate system type string in the JSON configuration file to the coordinate system property, and assign the affine transformation parameters to the affine transformation property, thereby creating a GeoTIFF format waterline raster file. The vectorization conversion module 104 is used to perform connected component detection and boundary tracing on the waterline raster file to obtain the row and column number sequences of the boundary pixels; calculate the actual geographic coordinates based on the row and column number sequences of the boundary pixels and the affine transformation parameters; and construct the actual geographic coordinates into a vector polygon and output it in GeoJSON format.
[0091] Therefore, the embodiments should be considered as exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, it is intended that all variations falling within the meaning and scope of the equivalents of the application be incorporated into the invention.
[0092] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features of the invention herein.
Claims
1. A method for intelligent extraction of waterline based on UAV imagery, characterized in that, Includes the following steps: Step S1: Obtain the UAV orthophoto file in GeoTIFF format for the target area, extract the coordinate system definition and affine transformation parameters, generate a JSON configuration file, and convert the UAV orthophoto file into a PNG image; Step S2: Construct an EWUNet network model including an encoder, decoder, and a multi-layer feature enhancement skip connection mechanism; input the PNG image into the EWUNet network model and output a binarized waterline segmentation PNG image; Step S3: Write the segmented PNG image of the waterline into the first band, and at the same time assign the coordinate system type string in the JSON configuration file to the coordinate system property, and assign the affine transformation parameters to the affine transformation property, thereby creating a GeoTIFF format waterline raster file; Step S4: Perform connected component detection and boundary tracing on the waterline raster file to obtain the row and column number sequences of the boundary pixels; calculate the actual geographic coordinates based on the row and column number sequences of the boundary pixels and the affine transformation parameters; construct the actual geographic coordinates into a vector polygon and output it in GeoJSON format.
2. The intelligent waterline extraction method based on UAV imagery according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Obtain the UAV orthophoto file in GeoTIFF format for the target area; Step S12: Open the UAV orthophoto file, locate the geographic tag group in the file header, and read the coordinate system definition string and six affine transformation parameters from the tag group. The six affine transformation parameters are: x-direction pixel resolution, first rotation coefficient, upper left x-coordinate, second rotation coefficient, y-direction pixel resolution, and upper left y-coordinate. Step S13: Store the coordinate system definition string with the key name crs, store the six affine transformation values as an array with the key name transform, and record the width and height of the image in pixels to form a JSON configuration file. Step S14: Read the pixel data of the red, green and blue bands sequentially from the UAV orthophoto file, and write them into a PNG format file in RGB order to obtain a PNG image.
3. The intelligent waterline extraction method based on UAV imagery according to claim 2, characterized in that, Step S2 includes the following steps: Step S21: Initialize the EWUNet network structure, set the input size to 512×512 pixels, and the number of input channels to 3, corresponding to the three RGB bands of the PNG image; Step S22: Construct the encoder by setting up five sequentially connected convolutional downsampling units. Each unit includes two 3×3 convolutional layers and one 2×2 max pooling layer. The five units output the first to fifth layer encoded feature maps in sequence. The first layer encoded feature map has a height and width of 256×256 pixels and 64 channels, containing the richest low-level spatial details. The fifth layer encoded feature map has a height and width of 16×16 pixels and 512 channels, containing the highest level semantic information. Step S23: Construct the decoder by setting up five sequentially connected upsampling units that correspond to the five units of the encoder. Each upsampling unit includes a bilinear interpolation upsampling layer and two 3×3 convolutional layers, which progressively enlarge the height and width of the feature map to twice that of the previous layer.
4. The intelligent waterline extraction method based on UAV imagery according to claim 3, characterized in that, Step S2 also includes the following steps: Step S24: Establish cross-level feature fusion rules between the encoder and decoder as a multi-level feature enhancement skip connection mechanism; Step S25: Connect a 1×1 convolutional layer and a Sigmoid activation function layer after the first layer decoding unit. The 1×1 convolutional layer compresses the number of channels to 1, and the Sigmoid activation function layer maps the value of each pixel to between 0 and 1 as the waterline probability value to obtain the output layer. Step S26: Train the EWUNet network model using the preprocessed PNG image dataset and its corresponding binary labeled samples. The EWUNet network model consists of the EWUNet network structure, encoder, decoder, multi-layer feature enhancement skip connection mechanism, and output layer. Step S27: Input the PNG image into the EWUNet network model and output a binarized waterline segmentation PNG image.
5. The intelligent waterline extraction method based on UAV imagery according to claim 4, characterized in that, The cross-level feature fusion rules in step S24 are as follows: The fifth-layer decoding unit receives the bridge layer features and the fifth-layer coding feature map; Each of the fourth, third, and second layer decoding units receives three feature maps: the first is the output feature map of the previous decoding unit, which is magnified by two times through bilinear interpolation; the second is the output feature map of the same level coding unit; and the third is the output feature map of the coding unit with the layer number reduced by 1, which is reduced by half through 2×2 window max pooling. The first-layer decoding unit receives the amplified output of the second-layer decoding unit and the first-layer encoded feature map; Each decoding unit concatenates the received feature maps along the channel dimension and then compresses the number of channels through a 3×3 convolutional layer.
6. The intelligent waterline extraction method based on UAV imagery according to claim 5, characterized in that, Step S26 includes the following steps: Step S261: Obtain the labeled PNG image training dataset and its corresponding binary labeled sample set; Step S262: Input the PNG image training dataset into the EWUNet network structure to perform forward propagation. The data passes through the five encoding units of the encoder, the bridging layer, the five decoding units of the decoder, the cross-layer connection, and the output layer in sequence to obtain the predicted waterline probability map. Step S263: Calculate the weighted sum of the cross-entropy loss and Dice loss between the waterline probability map and the corresponding binary labeled sample set as the total loss function value; Step S264: Perform backpropagation based on the total loss function value to calculate the gradients of the weight and bias parameters of all convolutional layers in the EWUNet network structure, and use the Adam optimizer to update the weight and bias parameters according to the gradients to obtain the EWUNet network model.
7. The intelligent waterline extraction method based on UAV imagery according to claim 6, characterized in that, Step S27 is as follows: The PNG image is input into the EWUNet network model to perform forward propagation, and the output single-channel water edge probability map is obtained. A threshold of 0.5 is set for each pixel value in the probability map. Pixels with values greater than the threshold are marked as 1 to represent water bodies, and pixels with values less than or equal to the threshold are marked as 0 to represent non-water bodies, thus forming a binarized water edge segmentation PNG image.
8. The intelligent waterline extraction method based on UAV imagery according to claim 7, characterized in that, Step S3 includes the following steps: Step S31: Extract the coordinate system definition string with the key "crs" and the array containing six affine transformation parameters with the key "transform" from the JSON configuration file; Step S32: Load the 0 or 1 value of each pixel in the waterline segmentation PNG image into a two-dimensional pixel array; Step S33: Create a GeoTIFF format file, set the file's coordinate system attribute to a coordinate system definition string, set the file's affine transformation attribute to an array of six affine transformation parameters, and set the file to contain one band and have an 8-bit unsigned integer data type. Step S34: Write the two-dimensional pixel array into the first band of the GeoTIFF format file to obtain a waterline raster file with geographic coordinate information.
9. The intelligent waterline extraction method based on UAV imagery according to claim 7, characterized in that, Step S4 includes the following steps: Step S41: Perform connected component detection on the two-dimensional pixel array in the water edge raster file to identify all connected regions with a pixel value of 1. Perform boundary tracing on each connected region and record the row and column numbers of the boundary pixels along the edge of the region to form a boundary pixel row and column number sequence. Step S42: Traverse each pixel in the boundary pixel row and column number sequence, and calculate the actual geographic x-coordinate of that pixel as the pixel resolution in the x-direction. Column number First rotation coefficient Line number, calculate the actual geographic y-coordinate equal to the second rotation factor. Column number y-direction pixel resolution line number The y-coordinate of the top left corner forms the actual geographic coordinates; Step S43: Write the actual geographic coordinates as the vertex coordinates of the polygon into the geometry field of the file, set the coordinate system property of the file to the coordinate system definition string, and output a GeoJSON file containing the waterline vector polygon.
10. A smart waterline extraction system based on UAV imagery, characterized in that, For performing the intelligent waterline extraction method based on UAV imagery as described in claim 1, the intelligent waterline extraction system based on UAV imagery comprises: The image preprocessing module is used to acquire GeoTIFF format UAV orthophoto files of the target area, extract the coordinate system definition and affine transformation parameters, generate a JSON configuration file, and convert the UAV orthophoto files into PNG images. The waterline segmentation module is used to construct an EWUNet network model that includes an encoder, a decoder, and a multi-layer feature enhancement skip connection mechanism; it takes a PNG image as input to the EWUNet network model and outputs a binarized waterline segmented PNG image. The georeference module is used to write the waterline segmented PNG image into the first band, and at the same time assign the coordinate system type string in the JSON configuration file to the coordinate system property, and assign the affine transformation parameters to the affine transformation property, thereby creating a GeoTIFF format waterline raster file. The vectorization conversion module is used to perform connected component detection and boundary tracing on the waterline raster file to obtain the row and column number sequences of the boundary pixels; calculate the actual geographic coordinates based on the row and column number sequences of the boundary pixels and the affine transformation parameters; and construct the actual geographic coordinates into a vector polygon and output it in GeoJSON format.