A lake image segmentation method and computer-readable storage medium

By improving the U-Net network and the compression-excitation attention module, the lake image is extracted in feature, combined with threshold-morphological processing and Scharr operator to optimize the contour lines, the problem of low accuracy of image segmentation in complex background lakes is solved, and efficient and automatic image segmentation is achieved.

CN119107334BActive Publication Date: 2025-04-11SUZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411596141.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-04-11
Estimated Expiration
2044-11-11

AI Technical Summary

Technical Problem

When the existing active contour model segments lake images with complex backgrounds, there are problems such as difficulty in extracting image features, low efficiency in manually setting initial contour lines, and low segmentation accuracy.

Method used

Feature extraction is performed on the image of the to-segment lake to be segmented, edge features are enhanced by using the compression-excitation attention module, initial contour lines are automatically set in combination with threshold-morphology processing, and data driver terms are obtained through the Scharr operator for contour optimization.

Benefits of technology

It improves the accuracy and efficiency of lake image segmentation, enhances the feature extraction ability of complex background images, reduces manual intervention, and improves the automation level of the segmentation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119107334B_ABST
    Figure CN119107334B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of image processing, and discloses a lake image segmentation method and a computer-readable storage medium. The method comprises the following steps: inputting a lake image to be segmented into a trained improved U-Net network, obtaining a grayscale value of a prediction map of the lake image to be segmented, processing the prediction map of the lake image to be segmented by using a threshold-morphological operation, calculating an initial level set function, setting the initial contour line, and no longer requiring manual setting of a rectangular frame to initialize the initial contour line in the lake image to be segmented, thereby improving the image segmentation efficiency; calculating the prediction map of the lake image to be segmented by using a Scharr operator, further extracting edge features of the lake image to be segmented, obtaining a data-driven item, iteratively updating the initial level set function, obtaining a target level set function, using the target contour line, and segmenting the lake image to be segmented, thereby improving the classification accuracy of lake images with complex backgrounds.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a lake image segmentation method and a computer-readable storage medium. Background Art

[0002] Image segmentation is an important branch in the fields of image analysis, pattern recognition and artificial intelligence, and is also the basis of computer vision and image processing research. This technology divides the image into regions by features such as grayscale, color or texture, thereby effectively separating specific targets from the background. As a basic task in image processing, the accuracy of image segmentation has a direct impact on the quality of subsequent image processing.

[0003] The active contour model is a type of image segmentation method based on energy function and level set theory. Its core idea is to use a continuous and smooth curve to represent the edge of the target; by defining an energy functional with the curve as the independent variable, the segmentation process is transformed into a task of solving the minimum value of the energy functional; when the energy functional reaches the minimum value, the corresponding curve is the final segmentation result. The active contour model provides a unified theoretical framework and solution for visual problems such as contour extraction, target detection and tracking, and is still one of the hot topics in image segmentation research.

[0004] In the scene of lake image segmentation, the complex background will interfere with the existing mainstream active contour model in image feature extraction and data-driven term calculation, making it difficult to extract the features of the lake image, thereby affecting the accuracy of segmentation. In addition, the current active contour model usually relies on manually set rectangular boxes to initialize the initial contour lines in the lake image to be segmented. This process is time-consuming and laborious when processing a large number of images, especially when segmenting lake images with multiple targets, which can easily cause the model to mis-segment non-target areas, further reducing the accuracy of segmentation. Summary of the invention

[0005] To this end, the technical problem to be solved by the present invention is to overcome the problems in the prior art of using the active contour model to segment lake images with complex backgrounds, such as difficulty in extracting image features, inefficiency in manually setting initial contour lines, and low segmentation accuracy.

[0006] In order to solve the above technical problems, the present invention provides a lake image segmentation method, comprising:

[0007] Input the lake image to be segmented into the trained improved U-Net network to obtain the grayscale value of the predicted image of the lake image to be segmented, including:

[0008] The lake image to be segmented is processed by the encoder and the maximum pooling layer to extract the pooling features;

[0009] The pooled features are input into the compression-excitation attention module, and the pooled features are sequentially subjected to maximum average pooling, sigmoid activation, linear transformation, ReLU activation and linear transformation, and the optimized features are output;

[0010] The optimized features are processed by the decoder and the prediction head, and the grayscale value of the prediction image of the lake image to be segmented is output;

[0011] Based on the grayscale value of the predicted image of the lake image to be segmented, the intensity value of the predicted image of the lake image to be segmented is obtained by using the threshold-morphological processing method, and an initial level set function is constructed;

[0012] Based on the gray value of the predicted image of the lake image to be segmented, the Scharr operator is used for detection to obtain the data-driven item;

[0013] The initial level set function is iteratively updated using the data-driven term until the difference between two adjacent updated level set functions is less than a preset threshold, thereby obtaining the target level set function.

[0014] The target level set function is used as the target contour line to segment the lake image.

[0015] Preferably, the training process of the U-Net network is improved, including:

[0016] Obtain lake images and their corresponding true value images to construct a dataset, and divide it into a training set and a test set;

[0017] The lake image is input into the encoder of the improved U-Net network for multiple convolutions, and the convolution features are output; the convolution features are max-pooled, and the pooled features are output; the pooled features are input into the compression-excitation attention module, and the maximum average pooling, ReLU activation, linear transformation, sigmoid activation and linear transformation are performed in sequence, and the optimized features are output; the decoder performs multiple upsampling on the optimized features and outputs the prediction map; the prediction map is input into the prediction head, and the grayscale value of the prediction map of the lake image is output;

[0018] A joint loss function is constructed based on the binary cross loss between the predicted image output by the decoder and the corresponding true image, as well as the grayscale value of the predicted image and the grayscale value of the true image;

[0019] The improved U-Net network is trained using the training set until the joint loss function converges to obtain the trained improved U-Net network.

[0020] Preferably, the joint loss function is expressed as:

[0021] ;

[0022] in, The input image represents the decoder output The prediction graph of For the input image The true value image of is the binary cross entropy loss; is a weight parameter greater than zero; For the input image The average gray value of is the true value image The average gray value of For the input image The variance of the gray value, is the true value image The variance of the gray value, For the input image and the true value image The covariance of the gray values; and All are preset parameters greater than zero.

[0023] Preferably, the grayscale value of the predicted image of the lake image to be segmented is used to obtain the intensity value of the predicted image of the lake image to be segmented by using a threshold-morphological processing method to construct an initial level set function, including:

[0024] Grayscale value of the predicted image of the segmented lake image , perform morphological processing and obtain the morphological intensity value , expressed as:

[0025] ;

[0026] Based on morphological intensity values With preset intensity value , perform threshold processing on the grayscale value of the predicted image of the segmented lake image to obtain the target intensity value , expressed as:

[0027] ;

[0028] Based on the target strength value , construct the initial level set function of the lake image to be segmented , expressed as:

[0029] ;

[0030] Among them, the gray value of the predicted image of the lake image to be segmented is expressed as , is the vector pixel point in the lake image to be segmented, For the prediction head; Represents the corrosion operator symbol, Represents the expansion operator symbol, represents a square structure element with side length b, Indicates a preset intensity value greater than zero.

[0031] Preferably, the grayscale value of the prediction image based on the lake image to be segmented is detected using the Scharr operator to obtain the data-driven item, including:

[0032] Use the Scharr operator to detect the gray value of the predicted image of the lake image to be segmented and obtain the edge computing result , expressed as:

[0033] ;

[0034] Calculate data-driven items based on edge computing results and softsign function , expressed as:

[0035] ;

[0036] in, represents the convolution kernel of the Scharr operator in the horizontal direction, represents the convolution kernel of the Scharr operator in the vertical direction, Represents the convolution operation symbol; Represents the weight parameter for adjusting the value range of the data-driven item; Represents the constant of the auxiliary level set function to determine the evolution direction. When the average gray value of the vector pixel points inside the initial contour line is not greater than the average gray value of the vector pixel points outside the initial contour line, The value of is 1; otherwise, The value of is -1; represents the softsign function, represents the calculation variable of the softsign function, Represents the absolute value calculation symbol.

[0037] Preferably, obtaining the target level set function includes:

[0038] The level set function is iteratively updated using the level set update iterative formula to obtain the level set function after n iterations of the initial level set function. , expressed as:

[0039] ;

[0040] Until the absolute value of the difference between two consecutive updated level set functions Less than the preset threshold , obtain the currently updated level set function as the target level set function;

[0041] in, Represents the vector pixel points in the lake image to be segmented, It means that the initial level set function passes through The level set function after the update; Indicates the window size is The mean filter, is a constant greater than zero; is a constant greater than zero, Represents the time step.

[0042] Preferably, the lake image to be segmented is processed by an encoder and a maximum pooling layer to extract pooling features, including:

[0043] The lake image to be segmented is input into the encoder for multiple convolutions, and the convolution features are output. , expressed as:

[0044] ;

[0045] Convolutional features Perform maximum pooling and output pooling features , expressed as:

[0046] ;

[0047] in, The input image extracted by the 4th convolutional layer of the encoder The fourth convolution feature of is the input image extracted by the 3rd convolutional layer of the encoder The third convolution feature of is the input image extracted by the second convolutional layer of the encoder The second convolution feature, is the input image extracted by the first layer of the encoder The first convolution feature of is the maximum pooling layer;

[0048] The convolutional layer is represented as: , The expansion rate is The dilated convolution, for Activation function.

[0049] Preferably, the pooled features are input into the compression-excitation attention module, and the pooled features are sequentially subjected to maximum average pooling, sigmoid activation, linear transformation, ReLU activation and linear transformation, and the optimized features are output, which are expressed as:

[0050] ;

[0051] in, represents the optimization feature; is the linear transformation function, for Activation function, for Activation function, is the maximum average pooling layer.

[0052] Preferably, the step of processing the optimized features through a decoder and a prediction head to output the grayscale value of the prediction map of the lake image to be segmented includes:

[0053] The optimized features are input into the decoder, and after multiple upsampling, the prediction graph is output. , expressed as:

[0054] ;

[0055] The prediction graph Input the prediction head and output the grayscale value of the predicted image of the lake image to be segmented, expressed as: ;

[0056] in, To optimize the features The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, The input image represents the decoder output Prediction graph of For the prediction head;

[0057] The upsampling operation is expressed as: , is the convolution operation, For image stitching operations, is the deconvolution operation.

[0058] This embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the lake image segmentation method described above are implemented.

[0059] The above technical solution of the present invention has the following beneficial effects compared with the prior art:

[0060] The lake image segmentation method of the present invention extracts features from the lake image to be segmented by constructing an improved U-Net network, performs global average pooling on the image using a compression-excitation attention mechanism to obtain global information of each channel, generates a weight vector corresponding to the feature channel, and processes the vector with a sigmoid activation function to obtain the attention weight of each channel, multiplies the attention weight with the original feature map, realizes adaptive adjustment of the features, enhances the edge features, and further improves the network prediction accuracy. At the same time, after obtaining the prediction map of the lake image to be segmented using the target improved U-Net network, the prediction map of the lake image to be segmented is processed using a threshold-morphological operation, and the initial level set function is calculated based on the processing result, so that the initial contour line can be automatically set in the lake image to be segmented, and there is no need to manually set a rectangular frame to initialize the initial contour line in the lake image to be segmented, thereby improving the image segmentation efficiency. At the same time, the prediction map of the lake image to be segmented is calculated using the Scharr operator, a data-driven item is obtained, the initial level set function is iteratively updated, the contour line is optimized, and the edge features of the lake image to be segmented are further extracted, thereby improving the classification accuracy of the lake image containing a complex background.

[0061] The present invention constructs a joint loss function based on the binary cross loss between the predicted image output by the decoder and the corresponding true image, as well as the grayscale values ​​of the predicted image and the true image, and optimizes and trains the improved U-Net network, thereby improving the prediction accuracy of the improved U-Net network and the stability of the network when extracting features for lake images with complex backgrounds, thereby improving the accuracy of lake image segmentation. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:

[0063] Figure 1 It is a flow chart of the steps of the lake image segmentation method provided by the present invention;

[0064] Figure 2 It is a method framework diagram of the lake image segmentation method provided by the present invention;

[0065] Figure 3It is a schematic diagram comparing the initial contour line of the first image and the image segmentation results of different models provided by the present invention;

[0066] Figure 4 It is a schematic diagram comparing the initial contour line of the second image and the image segmentation results of different models provided by the present invention;

[0067] Figure 5 It is a schematic diagram comparing the initial contour line of the third image and the image segmentation results of different models provided by the present invention;

[0068] Figure 6 It is a schematic diagram comparing the initial contour line of the fourth image and the image segmentation results of different models provided by the present invention;

[0069] Figure 7 It is a schematic diagram comparing the initial contour line of the fifth image and the image segmentation results of different models provided by the present invention;

[0070] Figure 8 It is a schematic diagram comparing the initial contour line of the sixth image and the image segmentation results of different models provided by the present invention. DETAILED DESCRIPTION

[0071] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.

[0072] Reference Figure 1 As shown, the flow chart of the lake image segmentation method provided by the present invention includes the following specific steps:

[0073] S101: Input the lake image to be segmented into the trained improved U-Net network to obtain the grayscale value of the predicted image of the lake image to be segmented, including:

[0074] S101-1: Process the lake image to be segmented through an encoder and a maximum pooling layer to extract pooling features;

[0075] S101-2: Input the pooled features into the compression-excitation attention module, perform maximum average pooling, sigmoid activation, linear transformation, ReLU activation and linear transformation on the pooled features in sequence, and output the optimized features;

[0076] S101-3: Processing the optimized features through a decoder and a prediction head, and outputting the grayscale value of the prediction image of the lake image to be segmented;

[0077] S102: Based on the grayscale value of the prediction image of the lake image to be segmented, using a threshold-morphological processing method, obtaining the intensity value of the prediction image of the lake image to be segmented, and constructing an initial level set function;

[0078] S103: Based on the gray value of the prediction image of the lake image to be segmented, the Scharr operator is used to perform detection to obtain a data-driven item;

[0079] S104: using the data-driven term to iteratively update the initial level set function until the difference between two adjacent updated level set functions is less than a preset threshold, thereby obtaining a target level set function;

[0080] S105: Segment the lake image using the target level set function as the target contour line.

[0081] Specifically, in step S102, the construction of the initial level set function includes:

[0082] S102-1: Grayscale value of the predicted image of the lake image to be segmented , perform morphological processing and obtain the morphological intensity value , expressed as:

[0083] ;

[0084] S102-2: Based on morphological intensity values With preset intensity value , perform threshold processing on the grayscale value of the predicted image of the segmented lake image to obtain the target intensity value , expressed as:

[0085] ;

[0086] S102-3: Based on target strength value , construct the initial level set function of the lake image to be segmented , expressed as:

[0087] ;

[0088] Among them, the gray value of the predicted image of the lake image to be segmented is expressed as , is the vector pixel point in the lake image to be segmented, For the prediction head; Represents the corrosion operator symbol, Represents the expansion operator symbol, represents a square structure element with side length b, Indicates a preset intensity value greater than zero.

[0089] Specifically, in step S103, the acquisition of data-driven items includes:

[0090] S103-1: Use the Scharr operator to detect the gray value of the predicted image of the lake image to be segmented and obtain the edge computing result , expressed as: ;

[0091] S103-2: Calculate data-driven items based on edge computing results and softsign function , expressed as: ;

[0092] in, represents the convolution kernel of the Scharr operator in the horizontal direction, represents the convolution kernel of the Scharr operator in the vertical direction, Represents the convolution operation symbol; Represents the weight parameter for adjusting the value range of the data-driven item; Represents the constant of the auxiliary level set function to determine the evolution direction. When the average gray value of the vector pixel points inside the initial contour line is not greater than the average gray value of the vector pixel points outside the initial contour line, The value of is 1; otherwise, The value of is -1; represents the softsign function, represents the calculation variable of the softsign function, Represents the absolute value calculation symbol.

[0093] Specifically, in step S104, the acquisition of the target level set function includes:

[0094] S104-1: Use the level set update iteration formula to iteratively update the level set function to obtain the level set function after n iterations of the initial level set function. , expressed as:

[0095] ;

[0096] S104-2: until the absolute value of the difference between two consecutive updated level set functions Less than the preset threshold , obtain the currently updated level set function as the target level set function;

[0097] in, Represents the vector pixel points in the lake image to be segmented, It means that the initial level set function passes through The level set function after the update; Indicates the window size is The mean filter, is a constant greater than zero; is a constant greater than zero, Represents the time step.

[0098] The lake image segmentation method of the present invention extracts features from the lake image to be segmented by constructing an improved U-Net network, performs global average pooling on the image using a compression-excitation attention mechanism to obtain global information of each channel, generates a weight vector corresponding to the feature channel, and processes the vector with a sigmoid activation function to obtain the attention weight of each channel, multiplies the attention weight with the original feature map, realizes adaptive adjustment of the features, enhances the edge features, and further improves the network prediction accuracy. At the same time, after obtaining the prediction map of the lake image to be segmented using the target improved U-Net network, the prediction map of the lake image to be segmented is processed using a threshold-morphological operation, and the initial level set function is calculated based on the processing result, so that the initial contour line can be automatically set in the lake image to be segmented, and there is no need to manually set a rectangular frame to initialize the initial contour line in the lake image to be segmented, thereby improving the image segmentation efficiency. At the same time, the prediction map of the lake image to be segmented is calculated using the Scharr operator, a data-driven item is obtained, the initial level set function is iteratively updated, the contour line is optimized, and the edge features of the lake image to be segmented are further extracted, thereby improving the classification accuracy of the lake image containing a complex background.

[0099] Based on the above embodiment, the training process of the U-Net network is improved in this embodiment, including:

[0100] Obtain lake images and their corresponding true value images to construct a dataset, and divide it into a training set and a test set;

[0101] The lake image is input into the encoder of the improved U-Net network for multiple convolutions, and the convolution features are output; the convolution features are max-pooled, and the pooled features are output; the pooled features are input into the compression-excitation attention module, and the maximum average pooling, ReLU activation, linear transformation, sigmoid activation and linear transformation are performed in sequence, and the optimized features are output; the decoder performs multiple upsampling on the optimized features and outputs the prediction map; the prediction map is input into the prediction head, and the grayscale value of the prediction map of the lake image is output;

[0102] A joint loss function is constructed based on the binary cross loss between the predicted image output by the decoder and the corresponding true image, as well as the grayscale value of the predicted image and the grayscale value of the true image;

[0103] The improved U-Net network is trained using the training set until the joint loss function converges to obtain the trained improved U-Net network.

[0104] Wherein, the joint loss function is expressed as:

[0105] ;

[0106] in, The input image represents the decoder output The prediction graph of For the input image The true value image of is the binary cross entropy loss; is a weight parameter greater than zero; For the input image The average gray value of is the true value image The average gray value of For the input image The variance of the gray value, is the true value image The variance of the gray value, For the input image and the true value image The covariance of the gray values; and All are preset parameters greater than zero.

[0107] Specifically, the improved U-Net network includes the following networks connected in series in the forward propagation direction:

[0108] ① Encoder, which performs multiple convolutions on the input lake image and outputs the convolution features, expressed as: ;in, The input image extracted by the 4th convolutional layer of the encoder The fourth convolution feature of is the input image extracted by the 3rd convolutional layer of the encoder The third convolution feature of is the input image extracted by the second convolutional layer of the encoder The second convolution feature, is the input image extracted by the first layer of the encoder The first convolution feature of is the maximum pooling layer; the convolutional layer is expressed as: , The expansion rate is The dilated convolution, for Activation function;

[0109] ②Maximum pooling layer, which performs maximum pooling on the convolutional features and outputs the pooled features , expressed as: ;

[0110] ③Compression-excitation attention module, which performs maximum average pooling, sigmoid activation, linear transformation, ReLU activation and linear transformation on the pooled features in turn, and outputs the optimized features, which are expressed as: ;in, represents the optimization feature; is the linear transformation function, for Activation function, for Activation function, is the maximum average pooling layer;

[0111] ④Decoder, upsample the optimized features multiple times, output the fused feature map to the prediction head, predict the fused feature map, and output the grayscale value of the predicted map, including: input the optimized features into the decoder, upsample multiple times, and output the predicted map , expressed as: ; The prediction graph Input the prediction head and output the grayscale value of the predicted image of the lake image to be segmented, expressed as: ;in, To optimize the features The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, The input image represents the decoder output Prediction graph of For the prediction head;

[0112] The upsampling operation is expressed as: , is the convolution operation, For image stitching operations, is the deconvolution operation.

[0113] The present invention constructs a joint loss function based on the binary cross loss between the predicted image output by the decoder and the corresponding true image, as well as the grayscale values ​​of the predicted image and the true image, and optimizes and trains the improved U-Net network, thereby improving the prediction accuracy of the improved U-Net network and the stability of the network when extracting features for lake images with complex backgrounds, thereby improving the accuracy of lake image segmentation.

[0114] Based on the above embodiment, in the embodiment of the present invention, the present invention is used to set specific parameters for the network, segment the lake image, obtain the image segmentation result, and refer to Figure 2 As shown in the figure, it is a method framework diagram of the lake image segmentation method, and the specific steps include:

[0115] S201: Obtain lake images, create image segmentation datasets, and divide them into training sets and test sets;

[0116] In this embodiment, 80% of the acquired lake images are randomly selected as training sets, and the remaining images are used as test sets. The training set is used for training the encoder and decoder networks, and the test set is used for image segmentation.

[0117] S202: Construct encoder and decoder networks based on compression-excitation attention mechanism and joint loss function;

[0118] S202-1: training set images As the input of the network, its size is ;in, is the batch size, is the number of channels, and are the height and width of the image;

[0119] In this embodiment, The value range of is [2, 6], The value of is 3;

[0120] S202-2: Setting the input image The encoder for feature extraction is expressed as:

[0121] ;

[0122] in, Image extracted by the 4th layer encoder Features, The image extracted by the 3rd layer encoder Features, The image extracted by the second layer encoder Features, The image extracted by the first layer encoder Features; is an encoder layer consisting of a dilated convolution and an activation function, where The expansion rate is In this embodiment, The value range of is [1,3], and the value range of the window side length of the dilated convolution is [1,5]; for Activation function; is the maximum pooling layer. In this embodiment, the window side length of the maximum pooling layer ranges from [1,3];

[0123] S202-3: Set the image extracted by the encoder Features The intermediate layer for further processing is expressed as:

[0124] ;

[0125] in, The image after being processed by the intermediate layer Features;

[0126] S202-4: Set the image after processing the middle layer Features Enhanced compression-incentive attention mechanism , the expression is:

[0127] ;

[0128] in, is the linear transformation function, for Activation function, is the maximum average pooling layer;

[0129] S202-5: Set the decoder for obtaining the prediction image. The expression is:

[0130] ;

[0131] in, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, is the output feature map obtained by the last convolution layer of the decoder, that is, the prediction map of the input image; is the upsampling operation, where For image stitching operations, It is a deconvolution operation. In this embodiment, the range of the window side length of the deconvolution is [1, 3], and the range of the step length is [1, 3];

[0132] S202-6: Setting the joint loss function , the expression is:

[0133] ;

[0134] in, is the binary cross entropy loss, For images The true value image, is a weight parameter greater than zero. In this embodiment, The value range of is [0.1,1]; For images The average gray value of For images The average gray value of For images The variance of the gray value, For images The variance of the gray value, For images and images The covariance of the gray values, and are all parameters greater than zero. In this embodiment, the parameters The value range of is [0,0.05], and the parameter The value range of is [0,0.05];

[0135] S202-7: Set the grayscale value of the predicted image obtained by the detection head of the encoder and decoder network to detect the image to be segmented , the expression is:

[0136] ;

[0137] in, is the vector pixel point in the lake image to be segmented, are the prediction heads of the encoder and decoder networks.

[0138] S203: configuring relevant training parameters of the encoder and decoder networks, inputting the training set into the encoder and decoder networks for training, using the prediction heads of the trained encoder and decoder networks to predict the lake images to be segmented in the test set, and outputting the prediction graph;

[0139] In this embodiment, the number of channels of the compression-excitation attention mechanism of the encoder and decoder networks ranges from [256, 1024], the channel compression coefficient of the compression-excitation attention mechanism ranges from [12, 20], the learning rate of the network ranges from [0.001, 0.01], and the number of iterations of network training ranges from [20, 250].

[0140] S204: Using the threshold-morphological processing method to treat the gray value of the predicted image of the segmented lake image Processing is performed to obtain an initial level set function, and an initial contour line is set in the lake image to be segmented according to the initial level set function, specifically including:

[0141] S204-1: Setting threshold - morphological processing method is:

[0142] ;

[0143] in, Represents the intensity value of the predicted image after morphological processing, Represents the intensity value of the predicted image after threshold processing, represents a threshold greater than zero. In this embodiment, The value range of is [80,120]; represents a square structure element with a side length of b. In this embodiment, the side length b ranges from [3,7]; Represents the corrosion operator symbol, Represents the expansion operator symbol.

[0144] S204-2: Set the initial level set function to:

[0145] ;

[0146] When the vector pixel points of the lake image to be segmented correspond to When the value is 1, the value of the initial level set function is -1; when the vector pixel point of the lake image to be segmented corresponds to When the value is 0, the value of the initial level set function is 1.

[0147] S205: Use the Scharr operator to calculate the predicted image of the lake image to be segmented in the test set, obtain the data-driven term, and use the data-driven term to iteratively update the initial level set function to obtain the final contour line, which specifically includes:

[0148] S205-1: The calculation result obtained by setting the Scharr operator to process the prediction image of the lake image to be segmented in the test set , expressed as:

[0149] ;

[0150] in, represents the convolution kernel of the Scharr operator in the horizontal direction, represents the convolution kernel of the Scharr operator in the vertical direction, Represents the convolution operation symbol;

[0151] S205-2: Setting data-driven items It is expressed as:

[0152] ;

[0153] in, represents a weight parameter for adjusting the value range of the data-driven item. In this embodiment, The value range of is [0.5,1.5]; Represents the constant of the auxiliary level set function to determine the evolution direction. When the average gray value of the vector pixel points inside the initial contour line is less than or equal to the average gray value of the vector pixel points outside the initial contour line, The value of is 1; otherwise, The value of is -1.

[0154] S205-3: Set the update iteration formula of the initial level set function to:

[0155] ;

[0156] in, Represents the vector pixel points in the lake image to be segmented, represents the level set function after the nth iteration of the initial level set function, It means that the initial level set function passes through The level set function after iterations is: Indicates the window size is The mean filter, represents a constant greater than zero. In this embodiment, The value range of is [3,7]; represents the softsign function, represents the calculation variable of the softsign function, Indicates the absolute value calculation symbol; represents a constant greater than zero. In this embodiment, The value range of is [8,12]; represents the time step. In this embodiment, The value range is [0.1,2].

[0157] S205-4: Set the iteration stop condition of the level set function to:

[0158] when When , the level set function stops iterating; where, is a constant greater than zero. In this embodiment, The value range is .

[0159] S206: Use the level set function obtained from the last iteration The final contour line is used as the segmentation curve of the lake image to be segmented.

[0160] The present invention constructs an encoder and decoder network to extract features from the lake image to be segmented, enhances the edge features of the image through a compression-excitation attention mechanism, and trains and optimizes the network in combination with a joint loss function, thereby improving the stability of the network when extracting features from lake images with complex backgrounds. At the same time, the predicted image of the lake image to be segmented is processed using a threshold-morphological operation, and the initial level set function is calculated based on the calculation result, which can automatically set the initial contour line in the lake image to be segmented, thereby improving the cumbersome process of manually setting a rectangular frame to initialize the initial contour line in the lake image to be segmented. The Scharr operator is used to calculate the predicted image of the lake image to be segmented in the test set, and the calculation result is used as a data-driven item, which can further enhance the edge features of the lake image to be segmented, thereby improving the accuracy of the image segmentation method of the present invention in segmenting such lake images.

[0161] Based on the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the lake image segmentation method as described above are implemented.

[0162] Based on the above embodiments, in order to further illustrate the effect of the lake image segmentation method provided by the present invention, in this embodiment, the lake image segmentation method provided by the present invention and the existing APFJDACM (adaptive pre-fitting function Jeffreys divergence active contour model), LPPFACM (local pre-piecewise fitting active contour model), and ODBCACM (optimized denoised bias correction active contour model) three active contour models are used to carry out image segmentation simulation experiments, and the experimental results are compared.

[0163] Specifically, the encoder and decoder networks of the present invention are implemented on the Python-based deep learning framework Pytorch2.4.0. The GPU model used for network training is NIVIDIA GeForce RTX 4090. The network parameters are set as follows: batch size B=4, dilation rate d=2 of dilated convolution, window side length of dilated convolution is 3, window side length of maximum pooling layer is 2, window side length of deconvolution is 2, step size of deconvolution is 2, weight parameter of joint loss function is , , , the number of channels of the compression-excitation attention mechanism is 512, the channel compression factor of the compression-excitation attention mechanism is 16, the learning rate of the network is 0.001, the number of iterations of network training is 50, the threshold value of threshold processing T=100, and the side length of the morphological square structure element b=5;

[0164] All image segmentation experiments were implemented in MATLAB 2017b on a 2.3GHz Intel Core i7 personal computer. The training set images, test set images, and lake images to be segmented used in all experiments were from the Qinghai-Tibet Plateau Lake Semantic Segmentation Dataset provided by the National Glacier, Frozen, and Desert Science Data Center and Lanzhou University. In all experiments, the green solid line represents the initial contour line, and the red solid line represents the final segmentation curve. In all experiments, the two evaluation indicators DSC (Dice SimilariyCoefficient) and IoU (Intersection of Union) were used to quantitatively compare the segmentation accuracy of each model. DSC is defined as , IoU is defined as ,in, is the target area segmented by each model in the experiment, It is the standard target area provided in the Qinghai-Tibet Plateau lake semantic segmentation dataset. The closer the DSC and IOU values ​​are to 1, the higher the segmentation accuracy. Set the parameter values ​​of the image segmentation method of the present invention: , , , , . Set the maximum number of iterations N of the image segmentation method of the present invention.

[0165] Six images are selected from the Qinghai-Tibet Plateau lake semantic segmentation dataset and numbered 1 to 6. Then, the six images are segmented using APFJDACM, LPPFACM, ODBCACM and the image segmentation method of the present invention, respectively. The results are shown in the figure. Figures 3 to 8 shown. Figures 3 to 8The following are schematic diagrams comparing the initial contour lines of images numbered 1 to 6 and the image segmentation results of different models. Figures 3 to 8 The first column in the figure shows the lake image to be segmented and the initial contour line, the second column shows the segmentation results of APFJDACM, the third column shows the segmentation results of LPPFACM, the fourth column shows the segmentation results of ODBCACM, and the fifth column shows the segmentation results of the image segmentation method of the present invention. Figure 3 It can be seen that when segmenting the image numbered 1, when the initial contour is set in the non-target area, ODBCACM has the phenomenon of mis-segmenting the non-target area. Figure 5 , 7 8, it can be seen that when segmenting images numbered 3, 5, and 6, APFJDACM, LPPFACM, and ODBCACM all have the phenomenon of mis-segmenting non-target areas or under-segmenting target areas. However, the image segmentation method of the present invention obtains ideal segmentation results for these 6 images.

[0166] Furthermore, the DSC and IoU of the six lake images segmented using APFJDACM, LPPFACM, ODBCACM and the image segmentation method of the present invention are compared, and the comparison results are shown in Table 1. As can be seen from Table 1, for these six lake images, the image segmentation method of the present invention has advantages in both segmentation accuracy indicators.

[0167] Table 1. DSC and IoU comparison table (DSC / IoU) of lake images in the Qinghai-Tibet Plateau lake semantic segmentation dataset segmented by APFJDACM, LPPFACM, ODBCACM and the method of the present invention

[0168] Image number APFJDACM LPPFACM ODBCACM The present invention 1 0.9178 / 0.8481 0.8420 / 0.7272 0.9204 / 0.8525 0.9360 / 0.8796 2 0.9296 / 0.8685 0.9234 / 0.8577 0.9147 / 0.8428 0.9482 / 0.9016 3 0.8999 / 0.8180 0.8433 / 0.7291 0.8472 / 0.7349 0.9354 / 0.8786 4 0.9412 / 0.8889 0.9465 / 0.8984 0.9452 / 0.8962 0.9478 / 0.9008 5 0.9202 / 0.8521 0.9217 / 0.8547 0.9247 / 0.8599 0.9300 / 0.8691 6 0.8893 / 0.8007 0.9086 / 0.8325 0.8868 / 0.7966 0.9106 / 0.8359

[0169] The lake image segmentation method of the present invention extracts features from the lake image to be segmented by constructing an improved U-Net network, performs global average pooling on the image using a compression-excitation attention mechanism to obtain global information of each channel, generates a weight vector corresponding to the feature channel, and processes the vector with a sigmoid activation function to obtain the attention weight of each channel, multiplies the attention weight with the original feature map, realizes adaptive adjustment of the features, enhances the edge features, and further improves the network prediction accuracy. At the same time, after obtaining the prediction map of the lake image to be segmented using the target improved U-Net network, the prediction map of the lake image to be segmented is processed using a threshold-morphological operation, and the initial level set function is calculated based on the processing result, so that the initial contour line can be automatically set in the lake image to be segmented, and there is no need to manually set a rectangular frame to initialize the initial contour line in the lake image to be segmented, thereby improving the image segmentation efficiency. At the same time, the prediction map of the lake image to be segmented is calculated using the Scharr operator, a data-driven item is obtained, the initial level set function is iteratively updated, the contour line is optimized, and the edge features of the lake image to be segmented are further extracted, thereby improving the classification accuracy of the lake image containing a complex background. The present invention constructs a joint loss function based on the binary cross loss between the predicted image output by the decoder and the corresponding true image, as well as the grayscale values ​​of the predicted image and the true image, and optimizes and trains the improved U-Net network, thereby improving the prediction accuracy of the improved U-Net network and the stability of the network when extracting features for lake images with complex backgrounds, thereby improving the accuracy of lake image segmentation.

[0170] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0171] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0172] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0173] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0174] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.

Claims

1. A lake image segmentation method, characterized in that: include: Input the lake image to be segmented into the trained improved U-Net network to obtain the grayscale value of the predicted image of the lake image to be segmented, including: The lake image to be segmented is processed by the encoder and the maximum pooling layer to extract the pooling features; The pooled features are input into the compression-excitation attention module, and the pooled features are sequentially subjected to maximum average pooling, sigmoid activation, linear transformation, ReLU activation and linear transformation, and the optimized features are output; The optimized features are processed by the decoder and the prediction head, and the grayscale value of the prediction image of the lake image to be segmented is output; Based on the grayscale value of the predicted image of the lake image to be segmented, the intensity value of the predicted image of the lake image to be segmented is obtained by using the threshold-morphological processing method, and an initial level set function is constructed; Based on the gray value of the predicted image of the lake image to be segmented, the Scharr operator is used for detection to obtain the data-driven item; The initial level set function is iteratively updated using the data-driven term until the difference between two adjacent updated level set functions is less than a preset threshold, thereby obtaining the target level set function. The target level set function is used as the target contour line to segment the lake image; Among them, the training process of the U-Net network is improved, including: Obtain lake images and their corresponding true value images to construct a dataset, and divide it into a training set and a test set; The lake image is input into the encoder of the improved U-Net network for multiple convolutions, and the convolution features are output; the convolution features are max-pooled, and the pooled features are output; the pooled features are input into the compression-excitation attention module, and the maximum average pooling, ReLU activation, linear transformation, sigmoid activation and linear transformation are performed in sequence, and the optimized features are output; the decoder performs multiple upsampling on the optimized features and outputs the prediction map; the prediction map is input into the prediction head, and the grayscale value of the prediction map of the lake image is output; A joint loss function is constructed based on the binary cross loss between the predicted image output by the decoder and the corresponding true image, as well as the grayscale value of the predicted image and the grayscale value of the true image; The improved U-Net network is trained using the training set until the joint loss function converges to obtain the trained improved U-Net network.

2. The lake image segmentation method according to claim 1, characterized in that: The joint loss function is expressed as: ; in, The input image represents the decoder output The prediction graph of For the input image The true value image of is the binary cross entropy loss; is a weight parameter greater than zero; For the input image The average gray value of is the true value image The average gray value of For the input image The variance of the gray value, is the true value image The variance of the gray value, For the input image and the true value image The covariance of the gray values; and All are preset parameters greater than zero.

3. The lake image segmentation method according to claim 1, characterized in that: The method uses a threshold-morphological processing method based on the grayscale value of the predicted image of the lake image to be segmented to obtain the intensity value of the predicted image of the lake image to be segmented, and constructs an initial level set function, including: Grayscale value of the predicted image of the segmented lake image , perform morphological processing and obtain the morphological intensity value , expressed as: ; Based on morphological intensity values With preset intensity value , perform threshold processing on the grayscale value of the predicted image of the segmented lake image to obtain the target intensity value , expressed as: ; Based on the target strength value , construct the initial level set function of the lake image to be segmented , expressed as: ; Among them, the gray value of the predicted image of the lake image to be segmented is expressed as , is the vector pixel point in the lake image to be segmented, For the prediction head; Represents the corrosion operator symbol, Represents the expansion operator symbol, represents a square structure element with side length b, Indicates a preset intensity value greater than zero.

4. The lake image segmentation method according to claim 3, characterized in that: The grayscale value of the prediction image based on the lake image to be segmented is detected using the Scharr operator to obtain data-driven items, including: Use the Scharr operator to detect the gray value of the predicted image of the lake image to be segmented and obtain the edge computing result , expressed as: ; Calculate data-driven items based on edge computing results and softsign function , expressed as: ; in, represents the convolution kernel of the Scharr operator in the horizontal direction, represents the convolution kernel of the Scharr operator in the vertical direction, Represents the convolution operator symbol; Represents the weight parameter for adjusting the value range of the data-driven item; Represents the constant of the auxiliary level set function to determine the evolution direction. When the average gray value of the vector pixel points inside the initial contour line is not greater than the average gray value of the vector pixel points outside the initial contour line, The value of is 1; otherwise, The value of is -1; represents the softsign function, represents the calculation variable of the softsign function, Represents the absolute value calculation symbol.

5. The lake image segmentation method according to claim 4, characterized in that: Obtaining the target level set function, including: The level set function is iteratively updated using the level set update iterative formula to obtain the level set function after n iterations of the initial level set function. , expressed as: ; Until the absolute value of the difference between two consecutive updated level set functions Less than the preset threshold , obtain the currently updated level set function as the target level set function; in, Represents the vector pixel points in the lake image to be segmented, It means that the initial level set function passes through The level set function after the update; Indicates the window size is The mean filter, is a constant greater than zero; is a constant greater than zero, Represents the time step.

6. The lake image segmentation method according to claim 1, characterized in that: The lake image to be segmented is processed by an encoder and a maximum pooling layer to extract pooling features, including: The lake image to be segmented is input into the encoder for multiple convolutions, and the convolution features are output. , expressed as: ; Convolutional features Perform maximum pooling and output pooling features , expressed as: ; in, The input image extracted by the 4th convolutional layer of the encoder The fourth convolution feature of is the input image extracted by the 3rd convolutional layer of the encoder The third convolution feature of is the input image extracted by the second convolutional layer of the encoder The second convolution feature, is the input image extracted by the first layer of the encoder The first convolution feature of is the maximum pooling layer; The convolutional layer is represented as: , The expansion rate is The dilated convolution, for Activation function.

7. The lake image segmentation method according to claim 6, characterized in that: The pooled features are input into the compression-excitation attention module, and the pooled features are sequentially subjected to maximum average pooling, sigmoid activation, linear transformation, ReLU activation and linear transformation, and the optimized features are output, which are expressed as: ; in, represents the optimized feature; is the linear transformation function, for Activation function, for Activation function, is the maximum average pooling layer.

8. The lake image segmentation method according to claim 7, characterized in that: The step of processing the optimized features through a decoder and a prediction head and outputting the grayscale value of the prediction image of the lake image to be segmented includes: The optimized features are input into the decoder, and after multiple upsampling, the prediction graph is output. , expressed as: ; The prediction graph Input the prediction head and output the grayscale value of the predicted image of the lake image to be segmented, expressed as: ; in, To optimize the features The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, for The feature map obtained after upsampling operation, The input image represents the decoder output Prediction graph of For the prediction head; The upsampling operation is expressed as: , is the convolution operation, For image stitching operations, is the deconvolution operation.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the lake image segmentation method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Image segmentation method, electronic equipment and computer readable storage medium

    CN115984312A

  • Method for segmenting forest and lake along railway based on remote sensing image

    CN117058377A