Image segmentation method, device, electronic device and storage medium
By extracting and combining edge feature vectors in different directions, the accuracy problem of image segmentation in complex edges and backgrounds is solved, and higher image segmentation accuracy is achieved.
Patent Information
- Application Number
- CN202110570239.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-25
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-05-25
AI Technical Summary
When the image edges are complex and the background is complex, the accuracy of image segmentation in the existing technology is not high, and it is easy to segment the pixels of the image background into the pixels of the target object.
Through feature extraction of the image to be segmented, edge feature vectors in different directions are obtained, and the original multi-scale feature map and edge compression network are combined to perform cascade operations and bilinear interpolation to extract first edge features and second edge features with different directions. , and then perform image segmentation.
The accuracy of image segmentation is significantly improved, the image edges can be segmented more accurately, and the extraction effect of target object contours is improved.
Smart Images

Figure CN113192060B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image segmentation method, device, electronic device and storage medium. Background Art
[0002] Image segmentation is the process of dividing an image into several specific regions with unique properties and extracting the objects of interest. The extracted objects can be applied to image semantic recognition, image search and other fields.
[0003] The related art provides an image segmentation method based on edge detection. The basic idea of this method is to use the feature inconsistency between regions to detect the edge points in the image, and then connect all the points into lines according to a predetermined strategy until a closed area is formed.
[0004] However, when the edge is complex, especially when the image background is complex, it is easy to segment the pixels that originally belong to the image background as pixels of the target object, and the segmentation accuracy is not high. Summary of the invention
[0005] The embodiments of the present disclosure at least provide a method, device, electronic device and storage medium for image segmentation, so that image edges can be segmented more accurately with higher segmentation accuracy.
[0006] In a first aspect, an embodiment of the present disclosure provides a method for image segmentation, the method comprising:
[0007] Performing feature extraction on the image to be segmented to obtain a feature map of the image to be segmented;
[0008] Performing edge feature extraction on the obtained feature map to obtain a first edge feature and a second edge feature for the image to be segmented; the directions of a feature vector corresponding to the first edge feature and a feature vector corresponding to the second edge feature are different;
[0009] An image segmentation result of the image to be segmented is determined based on the first edge feature, the second edge feature, and a feature map of the image to be segmented.
[0010] By adopting the above-mentioned image segmentation method, when the image to be segmented is obtained, feature extraction can be performed on the image to be segmented, and then edge feature extraction can be performed on the extracted feature map to obtain a first edge feature and a second edge feature whose feature vectors have different directions. Image segmentation is performed by combining two edge features (i.e., the first edge feature and the second edge feature) and the feature map of the image to be segmented, which can facilitate highlighting the edge contour of the target object from the image to be segmented, thereby improving the accuracy of image segmentation.
[0011] In a possible implementation, performing feature extraction on the image to be segmented to obtain a feature map of the image to be segmented includes:
[0012] Perform feature extraction on the image to be segmented to obtain an original multi-scale feature map; the original multi-scale feature map includes feature maps of multiple scales;
[0013] Selecting a feature map with the largest scale from the feature maps of the multiple scales as the bottom-level single-scale feature map;
[0014] The extracting edge features from the obtained feature map to obtain the first edge features and the second edge features for the image to be segmented comprises:
[0015] Performing a sum operation on the original multi-scale feature map and the bottom single-scale feature map to obtain a first sum feature map;
[0016] Perform edge feature extraction on the first sum feature graph to obtain the first edge feature and the second edge feature.
[0017] The original multi-scale feature map obtained here can represent the characteristics of the target object at each scale. Different scales can be used for target objects of different sizes to maximize the segmentation accuracy. In addition, the underlying single-scale feature map can reflect shallower image features, such as edges. Here, the sum operation of the above two feature maps is combined to realize the extraction of two edge features, which has better feature expression ability.
[0018] In a possible implementation, performing edge feature extraction on the first sum feature graph to obtain the first edge feature and the second edge feature includes:
[0019] Performing a cascade operation based on the first sum feature map and the original multi-scale feature map to obtain a cascade feature map;
[0020] Inputting the cascade feature map into different convolutional layers of the edge compression network to extract edge features, and obtaining two feature vectors with different directions;
[0021] A bilinear interpolation operation is performed on the first sum feature map based on the two feature vectors to obtain the first edge feature and the second edge feature.
[0022] Here, two edge features can be extracted based on the bilinear interpolation operation between two feature vectors in different directions and the first sum feature map. One of the two extracted edge features can highlight the related dilation operation, and the other can highlight the related erosion operation, so that the contour of the target object can be effectively extracted, further improving the accuracy of subsequent segmentation results.
[0023] In a possible implementation, determining an image segmentation result of the image to be segmented based on the first edge feature, the second edge feature, and a feature map of the image to be segmented includes:
[0024] Performing a sum operation on the first edge feature, the second edge feature, and the original multi-scale feature map to obtain a second sum feature map;
[0025] The image to be segmented is segmented based on the second sum feature map to obtain an image segmentation result.
[0026] Here, two edge features and the original multi-scale feature map are combined to achieve the relevant image segmentation. Since the edge features can highlight the outline of the target object, the determined image segmentation result is more accurate.
[0027] In a possible implementation, edge feature extraction of the obtained feature map is performed by an edge compression network in the neural network; image segmentation of the image to be segmented based on the second sum feature map is performed by a main segmentation network in the neural network;
[0028] The neural network is trained as follows:
[0029] Acquire multiple image samples and original annotation information for each of the image samples;
[0030] Extracting features from the image samples to obtain a sample feature map;
[0031] The neural network is trained based on the extracted sample feature map and the original annotation information of the image sample.
[0032] In a possible implementation, the training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes:
[0033] Performing image segmentation on the extracted sample feature map using the neural network, outputting an image segmentation result, and comparing the image segmentation result with the original annotation information of the image sample;
[0034] Based on the comparison result, a network parameter value of at least one of the main segmentation network and the edge compression network is adjusted.
[0035] Here, network adjustment can be achieved based on the comparison result between the image segmentation result output by the main segmentation network and the original annotation information of the image sample, and the operation is simple.
[0036] In a possible implementation, the method further includes:
[0037] Based on the original annotation information of each of the image samples, first object annotation information, second object annotation information, and third object annotation information of the target object included in the image sample are determined; the first object annotation information is used to indicate that the annotation value of the edge pixel point of the target object is different from the annotation value of other non-edge pixel points, the second object annotation information is used to indicate that the annotation value of the corresponding corrosion area in the target object is different from the annotation value of other non-corrosion areas, and the third object annotation information is used to indicate that the annotation value of the corresponding expansion area outside the target object is different from the annotation value of other non-expansion areas;
[0038] The neural network also includes a first sub-segmentation network, a second sub-segmentation network and a third sub-segmentation network;
[0039] The training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes:
[0040] Performing edge feature extraction on the sample feature map to obtain a first sample edge feature and a second sample edge feature; the directions of a feature vector corresponding to the first sample edge feature and a feature vector corresponding to the second sample edge feature are different;
[0041] The neural network is trained based on the first sample edge feature, the second sample edge feature, the first object annotation information, the second object annotation information, and the third object annotation information of the target object included in the image sample.
[0042] In a possible implementation, the training of the neural network based on the first sample edge feature, the second sample edge feature, the first object annotation information, the second object annotation information, and the third object annotation information of the target object included in the image sample includes:
[0043] Performing a sum operation on the first sample edge feature and the second sample edge feature, inputting the obtained sum edge feature into the first secondary segmentation network, obtaining a first object segmentation result for the target object output by the first secondary segmentation network, and comparing the first object segmentation result with the first object annotation information of the target object included in the image sample; and
[0044] Inputting the first sample edge feature into the second sub-segmentation network, obtaining a second object segmentation result for the target object output by the second sub-segmentation network, and comparing the second object segmentation result with the second object annotation information of the target object included in the image sample; and
[0045] Inputting the second sample edge feature into the third sub-segmentation network, obtaining a third object segmentation result for the target object output by the third sub-segmentation network, and comparing the third object segmentation result with the third object annotation information of the target object included in the image sample;
[0046] If any comparison results corresponding to each sub-segmentation network and the main segmentation network are inconsistent, the network parameter values of the main segmentation network, the edge compression network, and at least one of the three sub-segmentation networks are adjusted until the comparison results are consistent, thereby obtaining a trained neural network.
[0047] Here, the network training can be realized by combining the joint training of the secondary segmentation network. The secondary segmentation network here constrains the edge pixels of the target object, the corresponding expansion area outside the target object, and the corresponding corrosion area outside the target object, so as to assist the main segmentation network to accurately segment the target object from the image sample with high segmentation accuracy.
[0048] In a possible implementation, the neural network further includes a target detection network; and the training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes:
[0049] Using the target detection network to perform target detection on the extracted sample feature map, output a target detection result, and compare the target detection result with the original annotation information of the image sample;
[0050] Based on the comparison result, a network parameter value of at least one of the main segmentation network, the edge compression network, and the object detection network is adjusted.
[0051] In a possible implementation, extracting features from the image sample to obtain a sample feature map includes:
[0052] Extracting sample feature maps of multiple scales from the image samples;
[0053] The training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes:
[0054] Selecting a sample feature map with the largest scale from the sample feature maps of the multiple scales; and selecting a corresponding sample feature map from the sample feature maps of the multiple scales based on the pre-annotated scale of the target object in the image sample;
[0055] The neural network is trained based on the two selected sample feature maps and the original annotation information of the image samples.
[0056] In a second aspect, an embodiment of the present disclosure further provides an image segmentation device, the device comprising:
[0057] A first extraction module is used to extract features of the image to be segmented to obtain a feature map of the image to be segmented;
[0058] A second extraction module is used to extract edge features from the obtained feature map to obtain a first edge feature and a second edge feature for the image to be segmented; the directions of the feature vector corresponding to the first edge feature and the feature vector corresponding to the second edge feature are different;
[0059] A segmentation module is used to determine an image segmentation result of the image to be segmented based on the first edge feature, the second edge feature and a feature map of the image to be segmented.
[0060] In the third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of the image segmentation method as described in the first aspect and any of its various embodiments are performed.
[0061] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the image segmentation method as described in the first aspect and any of its various embodiments are executed.
[0062] For a description of the effects of the above-mentioned image segmentation device, electronic device, and computer-readable storage medium, please refer to the description of the above-mentioned image segmentation method, which will not be repeated here.
[0063] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0065] Figure 1 A flow chart of an image segmentation method provided by an embodiment of the present disclosure is shown;
[0066] FIG. 2( a ) shows a flow chart of a specific method for edge feature extraction in the image segmentation method provided by an embodiment of the present disclosure;
[0067] FIG2( b ) shows a flow chart of a specific method for edge feature extraction in the image segmentation method provided by an embodiment of the present disclosure;
[0068] Figure 3 A flowchart of a specific method of network training in an image segmentation method provided by an embodiment of the present disclosure is shown;
[0069] Figure 4 A schematic diagram of an image segmentation device provided by an embodiment of the present disclosure is shown;
[0070] Figure 5 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0071] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0072] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0073] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0074] Research has found that the basic idea of the image segmentation method based on edge detection provided in the relevant technology is to use the feature inconsistency between regions to detect the edge points in the image, and then connect all the points into lines according to the established strategy until a closed area is formed.
[0075] However, when the edge is complex, especially when the image background is complex, it is easy to segment the pixels that originally belong to the image background as pixels of the target object, and the segmentation accuracy is not high.
[0076] Based on the above research, the present disclosure provides a method, device, electronic device and storage medium for image segmentation, which enable image edges to be segmented more accurately with higher segmentation accuracy.
[0077] To facilitate understanding of the present embodiment, a method for image segmentation disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the method for image segmentation provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the method for image segmentation can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0078] See also Figure 1 FIG. 1 is a flowchart of an image segmentation method provided by an embodiment of the present disclosure, the method comprising steps S101 to S103, wherein:
[0079] S101: extracting features from the image to be segmented to obtain a feature map of the image to be segmented;
[0080] S102: extracting edge features from the obtained feature map to obtain a first edge feature and a second edge feature for the image to be segmented; the directions of the feature vector corresponding to the first edge feature and the feature vector corresponding to the second edge feature are different;
[0081] S103: Determine an image segmentation result of the image to be segmented based on the first edge feature, the second edge feature and the feature map of the image to be segmented.
[0082] In order to facilitate understanding of the image segmentation method provided by the embodiment of the present disclosure, the application scenario of the method is first described below. The above-mentioned image segmentation method can be mainly applied to the field of computer vision technology, such as video security, industrial vision, medical treatment, intelligent driving vision, etc. based on video applications. In the relevant technical field, the requirement of image segmentation is to accurately locate the edges of scenes and characters, and classify the categories in the scene according to the requirements of the task.
[0083] However, for some images with complex edges, especially when the image background is complex, the image segmentation scheme in the related art tends to segment the pixels that originally belong to the image background into the pixels of the target object, and the segmentation accuracy is not high.
[0084] Precisely to solve the above problems, the disclosed embodiment provides a solution for image segmentation by combining edge features and its own image features. This solution highlights the edge contours of the target object from two levels: image erosion and image expansion, thereby improving the accuracy of segmentation.
[0085] The image to be segmented here may be an image obtained in the above-mentioned various application scenarios. The image to be segmented obtained in different application scenarios is also different. For example, it may be an image related to sky and airplane elements, or it may be an image related to people and lawn.
[0086] For the image to be segmented, the embodiments of the present disclosure can use various feature extraction methods to extract feature maps. For example, features can be extracted from the image to be segmented through image processing, or feature maps can be extracted using a trained feature extraction network.
[0087] Considering that the feature extraction network can mine deeper image features, the feature extraction network can be used to extract feature maps in the disclosed embodiments. The feature extraction network here can be a convolutional neural network (CNN). In specific applications, a CNN model such as Feature Pyramid Networks (FPN) can be used to efficiently extract features of each dimension in the image to achieve feature map extraction.
[0088] In the disclosed embodiment, two edge features with different vector directions can be extracted based on the edge compression network. In practical applications, the above two edge features (the first edge feature and the second edge feature) can be extracted using the boundary compression network (BCN), and the directions of the corresponding feature vectors can be opposite to further enhance the features at the edge position of the target object. For example, the two edge features can be compressed from the outside to the inside and from the inside to the outside, respectively.
[0089] It can be seen that the embodiment of the present disclosure compresses the edge features of the image by learning feature vectors in two different directions through an edge compression network. In this way, the segmentation achieved by combining the feature map of the image to be segmented can effectively find the boundary of the target object, that is, the approximate outline of the target object can be obtained, thereby significantly improving the performance of image segmentation.
[0090] In the process of extracting the feature map, the embodiment of the present disclosure can extract the original multi-scale feature map based on the above FPN, and the original multi-scale feature map includes feature maps of multiple scales. The FPN here can include multiple connected convolutional layers and a pooling layer corresponding to each convolutional layer.
[0091] When the image to be segmented is input into FPN, the sample convolution features output by multiple connected convolutional layers can be obtained. In this way, for each pooling layer, the pooling features output by the previous pooling layer of the pooling layer and the convolution features output by the convolutional layer corresponding to the pooling layer are determined. Finally, based on the pooling features output by each pooling layer, the feature map of the image to be segmented is determined.
[0092] For the convolution layer, a bottom-to-top pathway can be formed, which corresponds to a process of concentrating the expression features layer by layer from bottom to top. Among them, the lower layers reflect the shallower image information features, such as edges, etc., and the higher layers reflect the deeper image features, such as object contours and even categories; for the pooling layer, a top-to-bottom pathway can be formed. When processing the information of each pooling layer, the high-level information of the previous layer will be referred to as input to obtain feature maps of various scales (corresponding to the original multi-scale feature map).
[0093] Here, in order to improve the accuracy of subsequent edge feature extraction to a certain extent, a feature map with the largest scale can be selected from multiple scale feature maps as the underlying single-scale feature map. This is mainly because the underlying single-scale feature map can represent shallower image information features, such as edge features, which facilitates the extraction of edge features.
[0094] When the original multi-scale feature map and the underlying single-scale feature map are obtained, a sum operation can be performed first, and then edge features can be extracted based on the obtained first sum feature map and the trained edge compression network. This can be achieved by the following steps:
[0095] Step 1: Perform a cascade operation based on the first sum feature map and the original multi-scale feature map to obtain a cascade feature map;
[0096] Step 2: Input the cascade feature map into different convolutional layers of the edge compression network to extract edge features, and obtain two feature vectors with different directions;
[0097] Step three: perform bilinear interpolation operation on the first sum feature map based on the two feature vectors to obtain a first edge feature and a second edge feature.
[0098] Here, first, based on the cascade operation of the first sum feature map and the original multi-scale feature map, a cascade feature map can be obtained, and then two feature vectors with different directions are determined by using different convolutional layers of the edge compression network. Finally, based on the bilinear interpolation operation, two interpolated features are obtained and used as two edge features.
[0099] The above-mentioned cascade operation may be a cascade on a channel, which is different from the above-mentioned sum operation. The above-mentioned sum operation may be an addition and fusion operation of eigenvalues of corresponding dimensions.
[0100] In order to further illustrate the above edge feature extraction process, we can combine Figure 2 ( a ) and Figure 2(b) for further explanation.
[0101] As shown in Figure 2(a), the original multi-scale feature map F RoI and the underlying single-scale feature map F RoI 'After performing the sum operation (corresponding to the "+" operation), the first sum feature graph F can be obtained sum , the first sum feature map can be obtained through two layers of convolution operation to obtain the first sum feature map F' after convolution sum For the first sum feature graph F' sum For example, BCN can be used to realize two edge features (F con and F exp ) extraction. Next, the edge feature extraction process can be specifically described through Figure 2(b).
[0102] As shown in Figure 2(b), the first sum feature map F' after convolution sum and the original multi-scale feature map F RoIFirst, a cascade operation (corresponding to the "C" operation) is performed, and then a 3×3 convolution layer is used to learn one of the two feature vectors with different directions, corresponding to one dimension of the 14×14×2 feature vector. Then, based on the above feature vector, a bilinear interpolation operation is performed on the first sum feature map to obtain the interpolated feature F squ , the interpolated feature can be used as the above-mentioned edge feature.
[0103] Here, after performing a sum operation on the first edge feature, the second edge feature and the original multi-scale feature map, image segmentation of the image to be segmented can be achieved based on the obtained second sum feature map to obtain an image segmentation result. In a specific application, the above image segmentation process can be implemented using a main segmentation network.
[0104] In a specific application, the sum operation between the first edge feature and the second edge feature may be performed first to obtain the sum edge feature F bou , as shown in Figure 2(b), the edge feature and value are then summed with the original multi-scale feature map, and the final sum result is input into the main segmentation network to determine the image segmentation result. It can be seen that the first edge feature and the second edge feature can respectively highlight the characteristics of the edge from the expansion angle and the corrosion angle to improve the accuracy of the final segmentation result.
[0105] Considering the key role of the training process of each network in the image segmentation method provided by the embodiment of the present disclosure, the following description will focus on the training process of each network.
[0106] Here, the edge compression network and the main segmentation network can be used as sub-networks of the neural network to implement the training of the neural network together.
[0107] The training process of the neural network can be achieved through the following steps:
[0108] Step 1: Obtain multiple image samples and original annotation information for each image sample;
[0109] Step 2: Extract features from image samples to obtain sample feature maps;
[0110] Step 3: Train the neural network based on the extracted sample feature map and the original annotation information of the image samples.
[0111] Here, we can first obtain image samples with original annotation information, and then perform feature extraction on each image sample to obtain a sample feature map. In this way, we can perform network training using the extracted sample feature map and the original annotation information of the image sample, and thus obtain a trained main segmentation network and an edge compression network.
[0112] The relevant image samples may be images acquired in combination with specific application scenarios, and details may refer to the acquisition operation of the above-mentioned image to be segmented, which will not be described in detail here.
[0113] In the embodiment of the present disclosure, the extraction of the sample feature map can also be obtained by using the feature extraction network. Similarly, sample feature maps of multiple scales can be extracted from the image sample. In the process of neural network training, the embodiment of the present disclosure can be combined with the regional feature aggregation method to realize the extraction of the sample feature map.
[0114] The regional feature aggregation method here may correspond to the ROI Align method, which is an improved method of the ROI Pooling method. This method cancels the quantization operation and uses the bilinear interpolation method to obtain the image feature values at the pixel points whose coordinates are floating point numbers, thereby converting the entire feature aggregation process into a continuous operation. Here, a sample feature map of the corresponding scale can be selected from the sample feature maps of the above multiple scales based on the pre-annotated scale of the target object, and then the training of the neural network can be realized in combination with the sample feature map of the largest scale.
[0115] In the embodiment of the present disclosure, the network training process of the main segmentation network and the edge compression network can be implemented by the following steps:
[0116] Step 1: Use a neural network to perform image segmentation on the extracted sample feature map, output the image segmentation result, and compare the image segmentation result with the original annotation information of the image sample;
[0117] Step 2: Based on the comparison result, adjust the network parameter value of at least one of the main segmentation network and the edge compression network.
[0118] Here, the network parameter values can be adjusted based on the comparison results between the image segmentation results output by the main segmentation network and the original annotation information of the image samples.
[0119] In the disclosed embodiment, considering the key influence of the two edge features on the accuracy of the segmentation results, the influence of the above edge features can be enhanced by different supervisory signals. In the process of training the main segmentation network and the edge compression network, the three sub-segmentation networks in the neural network can be trained synchronously. Through the joint action of the three sub-segmentation networks, the segmentation accuracy of the main segmentation network can be further improved.
[0120] Before performing joint training of the three sub-segmentation networks, first object labeling information, second object labeling information, and third object labeling information of the target object included in the image sample may be determined based on original labeling information of each image sample.
[0121] Among them, the first object labeling information is used to indicate that the labeling value of the edge pixel point of the target object is different from the labeling value of other non-edge pixel points, the second object labeling information is used to indicate that the labeling value of the corresponding corrosion area in the target object is different from the labeling value of other non-corrosion areas, and the third object labeling information is used to indicate that the labeling value of the corresponding expansion area outside the target object is different from the labeling value of other non-expansion areas.
[0122] Then, the training of the neural network including each sub-network can be carried out according to the following steps:
[0123] Step 1: extract edge features from the sample feature map to obtain a first sample edge feature and a second sample edge feature; the directions of the feature vector corresponding to the first sample edge feature and the feature vector corresponding to the second sample edge feature are different;
[0124] Step 2: training a neural network based on the first sample edge feature, the second sample edge feature, the first object annotation information, the second object annotation information and the third object annotation information of the target object included in the image sample.
[0125] Here, the process of extracting edge features from the sample feature map can refer to the above-mentioned process of extracting edge features from the feature map, which will not be repeated here.
[0126] In the embodiment of the present disclosure, the training of each network can be implemented based on the extracted two sample edge features and three object annotation information according to the following steps:
[0127] Step 1: Perform a sum operation on the first sample edge feature and the second sample edge feature, input the obtained sum edge feature into the first sub-segmentation network, obtain a first object segmentation result for the target object output by the first sub-segmentation network, and compare the first object segmentation result with the first object annotation information of the target object included in the image sample; and, input the first sample edge feature into the second sub-segmentation network, obtain a second object segmentation result for the target object output by the second sub-segmentation network, and compare the second object segmentation result with the second object annotation information of the target object included in the image sample; and, input the second sample edge feature into the third sub-segmentation network, obtain a third object segmentation result for the target object output by the third sub-segmentation network, and compare the third object segmentation result with the third object annotation information of the target object included in the image sample;
[0128] Step 2: If any comparison results corresponding to the sub-segmentation networks and the main segmentation network are inconsistent, adjust the network parameter values of the main segmentation network, the edge compression network, and at least one of the three sub-segmentation networks until the comparison results are consistent, thereby obtaining a trained neural network.
[0129] Here, different object annotation information can be combined to realize constraints for different sub-segmentation networks. For the first sub-segmentation network, constraints can be implemented by comparing the first object segmentation result output by the first sub-segmentation network corresponding to the sum edge feature between the first sample edge feature and the second sample edge feature with the first object annotation information of the highlighted edge pixel point; for the second sub-segmentation network, constraints can be implemented by comparing the second object segmentation result output by the second sub-segmentation network corresponding to the first sample edge feature with the second object annotation information of the corresponding eroded area in the highlighted target object; for the third sub-segmentation network, constraints can be implemented by comparing the third object segmentation result output by the third sub-segmentation network corresponding to the second sample edge feature with the third object annotation information of the corresponding dilated area outside the highlighted target object.
[0130] Here, no matter which network in the secondary segmentation network and the main segmentation network corresponds to the inconsistent comparison results, each network can be adjusted, and finally a trained neural network can be obtained.
[0131] When the image to be segmented is input into the trained edge compression network, two edge features can be obtained. The main segmentation network can be used to combine the edge features and the feature map of the image to be segmented to achieve fast and accurate image segmentation.
[0132] The neural network in the disclosed embodiment also includes a target detection network, so that during the network training process, the target detection network can be used to perform target detection on the extracted sample feature map, output the target detection result, and compare the target detection result with the original annotation information of the image sample. Based on this comparison result, the network parameter value of at least one of the main segmentation network, the edge compression network and the target detection network can be adjusted.
[0133] It should be noted that the training of the neural network in the image segmentation method provided in the embodiment of the present disclosure may be the training of multiple sub-networks combined. Information such as which sub-network or sub-networks to adjust and the specific values of the adjusted network parameters can be determined based on specific training needs and no specific restrictions are made here.
[0134] In order to further understand the above network training process, we can combine Figure 3 Further explanation.
[0135] like Figure 3 The sample feature map shown in the figure can obtain the original multi-scale feature map F of the sample feature map after the feature extraction network and RoIAlign operation. RoI At the same time, based on the RoIAlign operation and the Conv operation, the underlying single-scale feature map F can be obtainedRoI After the edge compression network, we can get two sample edge features (i.e., F con and F exp ).
[0136] After summing the edge features of the two samples, we can get the sum edge feature F bou , the sum edge feature and the original multi-scale feature map F RoI The common input to the main segmentation network can determine the first loss function value Lseg (corresponding to the image segmentation result output by the main segmentation network). At the same time, the sum edge feature F bou , two sample edge features F exp and F con Corresponding to the input of three sub-segmentation networks (corresponding to the first sub-segmentation network, the second sub-segmentation network and the third sub-segmentation network), three loss function values (corresponding to the second loss function value Lbou, the third loss function value Lcon, and the fourth loss function value Lexp) can be determined. By combining the above four loss function values for network training, the trained networks can be obtained.
[0137] In the disclosed embodiment, while performing the image segmentation task, the target detection task can also be performed simultaneously. Here, the target detection can be performed on the feature map based on the trained target detection network to determine the detection information of the target object in the image to be segmented. The detection information here can be embodied in the form of a target frame, so that the position, size and other information of the target object in the image to be segmented can be determined.
[0138] The target detection network here can be trained synchronously during the training of the main segmentation network and the edge compression network, such as Figure 3 As shown, the predicted box of the target object (corresponding to the fifth loss function value Ldet) can be determined, and the predicted box is compared with the real box, and then the training of the target detection network can be realized.
[0139] It should be noted that the image segmentation method provided in the embodiment of the present disclosure can be directly applied in some application scenarios of segmentation tasks, such as portrait segmentation and cutout. In addition, the edge compression network in the embodiment of the present disclosure can be applied separately to any semantic segmentation and instance segmentation model to further improve the segmentation effect.
[0140] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0141] Based on the same inventive concept, an image segmentation device corresponding to the image segmentation method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned image segmentation method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0142] Reference Figure 4 FIG. 4 is a schematic diagram of an image segmentation device provided by an embodiment of the present disclosure, the device comprising: a first extraction module 401, a second extraction module 402, and a segmentation module 403; wherein,
[0143] The first extraction module 401 is used to extract features of the image to be segmented to obtain a feature map of the image to be segmented;
[0144] A second extraction module 402 is used to extract edge features from the obtained feature map to obtain a first edge feature and a second edge feature for the image to be segmented; the directions of the feature vector corresponding to the first edge feature and the feature vector corresponding to the second edge feature are different;
[0145] The segmentation module 403 is used to determine the image segmentation result of the image to be segmented based on the first edge feature, the second edge feature and the feature map of the image to be segmented.
[0146] By using the above-mentioned image segmentation device, when the image to be segmented is obtained, feature extraction can be performed on the image to be segmented, and then edge feature extraction can be performed on the extracted feature map to obtain a first edge feature and a second edge feature whose feature vectors have different directions. Image segmentation is performed by combining two edge features (i.e., the first edge feature and the second edge feature) and the feature map of the image to be segmented, which can facilitate highlighting the edge contour of the target object from the image to be segmented, thereby improving the accuracy of image segmentation.
[0147] In a possible implementation, the first extraction module 401 is used to extract features of the image to be segmented according to the following steps to obtain a feature map of the image to be segmented:
[0148] Perform feature extraction on the image to be segmented to obtain an original multi-scale feature map; the original multi-scale feature map includes feature maps of multiple scales;
[0149] Select a feature map with the largest scale from feature maps of multiple scales as the underlying single-scale feature map;
[0150] The second extraction module 402 is used to extract edge features from the obtained feature map according to the following steps to obtain first edge features and second edge features for the image to be segmented:
[0151] Perform a sum operation on the original multi-scale feature map and the underlying single-scale feature map to obtain a first sum feature map;
[0152] Edge features are extracted from the first sum feature map to obtain a first edge feature and a second edge feature.
[0153] In a possible implementation, the second extraction module 402 is configured to extract edge features from the first sum feature graph according to the following steps to obtain a first edge feature and a second edge feature:
[0154] Performing a cascade operation based on the first sum feature map and the original multi-scale feature map to obtain a cascade feature map;
[0155] The cascade feature map is input into different convolutional layers of the edge compression network to extract edge features, and two feature vectors with different directions are obtained;
[0156] A bilinear interpolation operation is performed on the first sum feature map based on the two feature vectors to obtain a first edge feature and a second edge feature.
[0157] In a possible implementation, the segmentation module 403 is configured to determine an image segmentation result of the image to be segmented based on the first edge feature, the second edge feature, and the feature map of the image to be segmented according to the following steps:
[0158] Performing a sum operation on the first edge feature, the second edge feature, and the original multi-scale feature map to obtain a second sum feature map;
[0159] The image to be segmented is segmented based on the second sum feature map to obtain an image segmentation result.
[0160] In a possible implementation, edge feature extraction of the obtained feature map is performed by an edge compression network in the neural network; image segmentation of the image to be segmented based on the second sum feature map is performed by a main segmentation network in the neural network; and a training module 404 is also included;
[0161] The training module 404 is used to train the neural network according to the following steps:
[0162] Acquire multiple image samples and original annotation information for each image sample; extract features from the image samples to obtain a sample feature map; and train a neural network based on the extracted sample feature map and the original annotation information of the image samples.
[0163] In a possible implementation, the training module 404 is used to train the neural network based on the extracted sample feature map and the original annotation information of the image sample according to the following steps:
[0164] Use a neural network to perform image segmentation on the extracted sample feature map, output the image segmentation result, and compare the image segmentation result with the original annotation information of the image sample;
[0165] Based on the comparison result, a network parameter value of at least one of the main segmentation network and the edge compression network is adjusted.
[0166] In a possible implementation, the neural network further includes a first sub-segmentation network, a second sub-segmentation network, and a third sub-segmentation network; and a training module 404 is configured to train the neural network based on the extracted sample feature map and the original annotation information of the image sample according to the following steps:
[0167] Based on the original annotation information of each image sample, first object annotation information, second object annotation information and third object annotation information of the target object included in the image sample are determined; the first object annotation information is used to indicate that the annotation value of the edge pixel point of the target object is different from the annotation value of other non-edge pixel points, the second object annotation information is used to indicate that the annotation value of the corresponding corrosion area in the target object is different from the annotation value of other non-corrosion areas, and the third object annotation information is used to indicate that the annotation value of the corresponding expansion area outside the target object is different from the annotation value of other non-expansion areas; and
[0168] Extracting edge features from the sample feature graph to obtain a first sample edge feature and a second sample edge feature; the directions of a feature vector corresponding to the first sample edge feature and a feature vector corresponding to the second sample edge feature are different;
[0169] The neural network is trained based on the first sample edge feature, the second sample edge feature, the first object annotation information, the second object annotation information, and the third object annotation information of the target object included in the image sample.
[0170] In a possible implementation, the training module 404 is configured to train the neural network based on the first sample edge feature, the second sample edge feature, the first object annotation information, the second object annotation information, and the third object annotation information of the target object included in the image sample according to the following steps:
[0171] Performing a sum operation on the first sample edge feature and the second sample edge feature, inputting the obtained sum edge feature into the first secondary segmentation network, obtaining a first object segmentation result for the target object output by the first secondary segmentation network, and comparing the first object segmentation result with the first object annotation information of the target object included in the image sample; and
[0172] Inputting the first sample edge feature into the second sub-segmentation network, obtaining a second object segmentation result for the target object output by the second sub-segmentation network, and comparing the second object segmentation result with the second object annotation information of the target object included in the image sample; and
[0173] Inputting the second sample edge feature into the third sub-segmentation network, obtaining a third object segmentation result for the target object output by the third sub-segmentation network, and comparing the third object segmentation result with the third object annotation information of the target object included in the image sample;
[0174] If any comparison results corresponding to each sub-segmentation network and the main segmentation network are inconsistent, the network parameter values of the main segmentation network, the edge compression network, and at least one of the three sub-segmentation networks are adjusted until the comparison results are consistent to obtain a trained neural network.
[0175] In a possible implementation, the neural network further includes a target detection network; a training module 404, configured to train the neural network based on the extracted sample feature map and the original annotation information of the image sample according to the following steps:
[0176] Use the target detection network to perform target detection on the extracted sample feature map, output the target detection result, and compare the target detection result with the original annotation information of the image sample;
[0177] Based on the comparison result, a network parameter value of at least one of the main segmentation network, the edge compression network, and the target detection network is adjusted.
[0178] In a possible implementation, the training module 404 is configured to train the neural network based on the extracted sample feature map and the original annotation information of the image sample according to the following steps:
[0179] Extracting sample feature maps of multiple scales from image samples;
[0180] Selecting a sample feature map with the largest scale from the sample feature maps of multiple scales; and selecting a corresponding sample feature map from the sample feature maps of multiple scales based on the pre-annotated scale of the target object in the image sample;
[0181] The neural network is trained based on the two selected sample feature maps and the original annotation information of the image samples.
[0182] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0183] The present disclosure also provides an electronic device, such as Figure 5, which is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure, includes: a processor 501, a memory 502, and a bus 503. The memory 502 stores machine-readable instructions executable by the processor 501 (for example, Figure 4 The execution instructions corresponding to the first extraction module 401, the second extraction module 402, and the segmentation module 403 in the device, etc.), when the electronic device is running, the processor 501 communicates with the memory 502 through the bus 503, and the machine-readable instructions are executed by the processor 501 to perform the following processing:
[0184] Perform feature extraction on the image to be segmented to obtain a feature map of the image to be segmented;
[0185] Performing edge feature extraction on the obtained feature map to obtain a first edge feature and a second edge feature for the image to be segmented; the directions of the feature vector corresponding to the first edge feature and the feature vector corresponding to the second edge feature are different;
[0186] An image segmentation result of the image to be segmented is determined based on the first edge feature, the second edge feature, and the feature map of the image to be segmented.
[0187] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the image segmentation method described in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0188] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the image segmentation method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0189] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0190] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0191] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0192] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0193] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0194] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for image segmentation, characterized in that: The method comprises: Perform feature extraction on the image to be segmented to obtain an original multi-scale feature map; the original multi-scale feature map includes feature maps of multiple scales; Selecting a feature map with the largest scale from the feature maps of the multiple scales as the bottom-level single-scale feature map; Performing a sum operation on the original multi-scale feature map and the bottom single-scale feature map to obtain a first sum feature map; Performing a cascade operation based on the first sum feature map and the original multi-scale feature map to obtain a cascade feature map; Inputting the cascade feature map into different convolutional layers of an edge compression network to extract edge features, thereby obtaining two feature vectors with different directions; Performing bilinear interpolation operation on the first sum feature map based on the two feature vectors respectively to obtain the first edge feature and the second edge feature; The directions of the feature vector corresponding to the first edge feature and the feature vector corresponding to the second edge feature are different; An image segmentation result of the image to be segmented is determined based on the first edge feature, the second edge feature, and a feature map of the image to be segmented.
2. The method according to claim 1, characterized in that The determining, based on the first edge feature, the second edge feature and the feature map of the image to be segmented, an image segmentation result of the image to be segmented includes: Performing a sum operation on the first edge feature, the second edge feature, and the original multi-scale feature map to obtain a second sum feature map; The image to be segmented is segmented based on the second sum feature map to obtain an image segmentation result.
3. The method according to claim 2, characterized in that The edge feature extraction of the obtained feature map is performed by the edge compression network in the neural network; the image segmentation of the image to be segmented based on the second sum feature map is performed by the main segmentation network in the neural network; The neural network is trained as follows: Acquire multiple image samples and original annotation information for each of the image samples; Extracting features from the image samples to obtain a sample feature map; The neural network is trained based on the extracted sample feature map and the original annotation information of the image sample.
4. The method according to claim 3, characterized in that The training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes: Performing image segmentation on the extracted sample feature map using the neural network, outputting an image segmentation result, and comparing the image segmentation result with the original annotation information of the image sample; Based on the comparison result, a network parameter value of at least one of the main segmentation network and the edge compression network is adjusted.
5. The method according to claim 4, characterized in that The method further comprises: Based on the original annotation information of each of the image samples, first object annotation information, second object annotation information, and third object annotation information of the target object included in the image sample are determined; the first object annotation information is used to indicate that the annotation value of the edge pixel point of the target object is different from the annotation value of other non-edge pixel points, the second object annotation information is used to indicate that the annotation value of the corresponding corrosion area in the target object is different from the annotation value of other non-corrosion areas, and the third object annotation information is used to indicate that the annotation value of the corresponding expansion area outside the target object is different from the annotation value of other non-expansion areas; The neural network also includes a first sub-segmentation network, a second sub-segmentation network and a third sub-segmentation network; The training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes: Performing edge feature extraction on the sample feature map to obtain a first sample edge feature and a second sample edge feature; the directions of a feature vector corresponding to the first sample edge feature and a feature vector corresponding to the second sample edge feature are different; The neural network is trained based on the first sample edge feature, the second sample edge feature, the first object annotation information, the second object annotation information, and the third object annotation information of the target object included in the image sample.
6. The method according to claim 5, characterized in that The training of the neural network based on the first sample edge feature, the second sample edge feature, the first object annotation information, the second object annotation information, and the third object annotation information of the target object included in the image sample includes: Performing a sum operation on the first sample edge feature and the second sample edge feature, inputting the obtained sum edge feature into the first secondary segmentation network, obtaining a first object segmentation result for the target object output by the first secondary segmentation network, and comparing the first object segmentation result with the first object annotation information of the target object included in the image sample; and Inputting the first sample edge feature into the second sub-segmentation network, obtaining a second object segmentation result for the target object output by the second sub-segmentation network, and comparing the second object segmentation result with the second object annotation information of the target object included in the image sample; and Inputting the second sample edge feature into the third sub-segmentation network, obtaining a third object segmentation result for the target object output by the third sub-segmentation network, and comparing the third object segmentation result with the third object annotation information of the target object included in the image sample; If any comparison results corresponding to each sub-segmentation network and the main segmentation network are inconsistent, the network parameter values of the main segmentation network, the edge compression network, and at least one of the three sub-segmentation networks are adjusted until the comparison results are consistent, thereby obtaining a trained neural network.
7. The method according to any one of claims 4 to 6, characterized in that: The neural network also includes a target detection network; the training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes: Using the target detection network to perform target detection on the extracted sample feature map, output a target detection result, and compare the target detection result with the original annotation information of the image sample; Based on the comparison result, a network parameter value of at least one of the main segmentation network, the edge compression network, and the object detection network is adjusted.
8. The method according to any one of claims 3 to 6, characterized in that: The step of extracting features from the image samples to obtain a sample feature map includes: Extracting sample feature maps of multiple scales from the image samples; The training of the neural network based on the extracted sample feature map and the original annotation information of the image sample includes: Selecting a sample feature map with the largest scale from the sample feature maps of the multiple scales; and selecting a corresponding sample feature map from the sample feature maps of the multiple scales based on the pre-annotated scale of the target object in the image sample; The neural network is trained based on the two selected sample feature maps and the original annotation information of the image samples.
9. An image segmentation device, characterized in that: The device comprises: A first extraction module is used to perform feature extraction on the image to be segmented to obtain an original multi-scale feature map; the original multi-scale feature map includes feature maps of multiple scales; a feature map with the largest scale is selected from the feature maps of the multiple scales as the bottom single-scale feature map; A second extraction module is used to perform a sum operation on the original multi-scale feature map and the bottom single-scale feature map to obtain a first sum feature map; perform a cascade operation based on the first sum feature map and the original multi-scale feature map to obtain a cascade feature map; input the cascade feature map into different convolutional layers of an edge compression network to extract edge features to obtain two feature vectors with different directions; perform a bilinear interpolation operation on the first sum feature map based on the two feature vectors to obtain the first edge feature and the second edge feature; the direction of the feature vector corresponding to the first edge feature is different from that of the feature vector corresponding to the second edge feature; A segmentation module is used to determine an image segmentation result of the image to be segmented based on the first edge feature, the second edge feature and a feature map of the image to be segmented.
10. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the image segmentation method as described in any one of claims 1 to 8 are performed.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image segmentation method according to any one of claims 1 to 8 are executed.
