Image segmentation method, device, electronic device and storage medium
By pre-segmenting the image and filtering similar conditions, an image mask with high similarity is generated, which solves the problem of insufficient image segmentation accuracy in the prior art and achieves more accurate segmentation results.
Patent Information
- Application Number
- CN202210475377.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2042-04-29
AI Technical Summary
The existing image segmentation method has shortcomings in segmentation accuracy and is difficult to effectively improve.
By pre-segmenting the image to be segmented, a plurality of first image masks are generated, and a second image mask that satisfies the high similarity is selected according to the preset similarity conditions to determine the final segmentation result.
Improve the accuracy of image segmentation, ensure that the segmentation result is closer to the actual segmentation target, and improve the segmentation accuracy.
Smart Images

Figure CN114862898B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of image processing, and particularly relates to an image segmentation method, apparatus, electronic device, and storage medium. Background Art
[0002] Image segmentation refers to the process of separating an image into several meaningful segmentation targets. For related image segmentation methods, the segmentation accuracy still needs to be improved when segmenting an image. Summary of the Invention
[0003] In view of the above problems, this application proposes an image segmentation method, apparatus, electronic device, and storage medium to solve the above problems.
[0004] In a first aspect, an embodiment of this application provides an image segmentation method, including: obtaining an image to be segmented; performing pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to a segmentation target included in the image to be segmented; generating multiple first image masks based on the pre-segmented image; obtaining a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask; and obtaining a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask.
[0005] In a second aspect, an embodiment of this application provides an image segmentation apparatus, including: an image acquisition unit for obtaining an image to be segmented; a processing unit for performing pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to a segmentation target included in the image to be segmented; a first mask acquisition unit for generating multiple first image masks based on the pre-segmented image; a second mask acquisition unit for obtaining a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask; and a result determination unit for obtaining a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask.
[0006] In a third aspect, an embodiment of this application provides an electronic device, including one or more processors and a memory; one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above method.
[0007] In a fourth aspect, an embodiment of this application provides a computer-readable storage medium, in which program code is stored, and when the program code runs, the above method is executed.
[0008] The embodiments of the present application provide an image segmentation method, apparatus, electronic device, and storage medium. First, an image to be segmented is obtained, and pre-segmentation processing is performed on the image to be segmented to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented. Then, based on the pre-segmented image, multiple first image masks are generated, and a first image mask that meets a preset similarity condition is obtained from the multiple first image masks as a second image mask. Finally, based on the second image mask, a target segmentation result corresponding to the segmentation target included in the image to be segmented is obtained. Through the above method, an image mask that meets the preset similarity condition can be selected from multiple image masks according to the preset similarity condition, image masks with a large difference from the segmentation target are excluded, and an image mask with a small difference from the segmentation target is obtained. Therefore, the final segmentation result of the image to be segmented can be determined by using the image mask with a small difference from the segmentation target, and the segmentation accuracy of the image to be segmented can be improved. Description of the Drawings
[0009] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative efforts.
[0010] Figure 1 Fig. shows a schematic diagram of an application scenario of an image segmentation method proposed in an embodiment of the present application;
[0011] Figure 2 Fig. shows a schematic diagram of an application scenario of an image segmentation method proposed in an embodiment of the present application;
[0012] Figure 3 Fig. shows a flowchart of an image segmentation method proposed in an embodiment of the present application;
[0013] Figure 4 Fig. shows a flowchart of an image segmentation method proposed in another embodiment of the present application;
[0014] Figure 5 Fig. shows a flowchart of step S240 in another embodiment of the present application;
[0015] Figure 6 Fig. shows a flowchart of an image segmentation method proposed in yet another embodiment of the present application;
[0016] Figure 7 Fig. shows a flowchart of an image segmentation method proposed in still another embodiment of the present application;
[0017] Figure 8 Fig. shows a structural block diagram of an image segmentation apparatus proposed in an embodiment of the present application;
[0018] Figure 9 The structural block diagram of an image segmentation device proposed in an embodiment of the present application is shown;
[0019] Figure 10 The schematic diagram of an image segmentation device proposed in an embodiment of the present application executing an image segmentation method is shown;
[0020] Figure 11 The structural block diagram of an electronic device or a server for executing the image segmentation method according to an embodiment of the present application in real time of the present application is shown;
[0021] Figure 12 The storage unit for storing or carrying the program code for implementing the image segmentation method according to an embodiment of the present application in real time of the present application is shown. Specific embodiments
[0022] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.
[0023] Image segmentation refers to the process of separating an image into several meaningful segmentation targets. At present, the application of image segmentation technology is very extensive. For example, through image segmentation technology, vehicles, pedestrians, and roads can be recognized in autonomous driving, and image segmentation technology ensures that the system can correctly identify which areas in front can be safely driven.
[0024] In related image segmentation methods, when segmenting an image, the segmentation accuracy of the image still needs to be improved.
[0025] Therefore, the inventors proposed the image segmentation method, device, electronic device, and storage medium in the present application. First, obtain the image to be segmented, perform pre-segmentation processing on the image to be segmented to obtain the pre-segmented image corresponding to the segmentation target included in the image to be segmented, then generate multiple first image masks based on the pre-segmented image, obtain the first image mask that meets the preset similarity condition from the multiple first image masks as the second image mask, and finally obtain the target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask. Through the above method, according to the preset similarity condition, the image mask that meets the preset similarity condition can be selected from multiple image masks, the image masks with a large difference from the segmentation target are excluded, and the image mask with a small difference from the segmentation target is obtained. Thus, the final segmentation result of the image to be segmented is determined by the image mask with a small difference from the segmentation target, and the segmentation accuracy of the image to be segmented can be improved.
[0026] In the embodiments of the present application, the provided image segmentation method can be executed by an electronic device. In this manner executed by the electronic device, all steps in the image segmentation method provided in the embodiments of the present application can be executed by the electronic device. For example, as Figure 1 shown, the processor of the electronic device 100 can obtain the image to be segmented; perform pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented; generate multiple first image masks based on the pre-segmented image; obtain a first image mask that meets the preset similarity condition from the multiple first image masks as the second image mask; and obtain a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask.
[0027] Furthermore, the image segmentation method provided in the embodiments of the present application can also be executed by a server (cloud). Correspondingly, in this manner executed by the server, the electronic device can obtain the image to be segmented and synchronously send the image to be segmented to the server, and then the server performs pre-segmentation processing in real time to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented; generates multiple first image masks based on the pre-segmented image; obtains a first image mask that meets the preset similarity condition from the multiple first image masks as the second image mask; and obtains a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask.
[0028] In addition, it can also be executed collaboratively by the electronic device and the server. In this manner executed collaboratively by the electronic device and the server, some steps in the image segmentation method provided in the embodiments of the present application are executed by the electronic device, while other steps are executed by the server.
[0029] Exemplarily, as Figure 2 shown, the electronic device 100 can execute the following steps included in the image segmentation method: obtain the image to be segmented; perform pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented, and then the server 200 executes generating multiple first image masks based on the pre-segmented image; obtaining a first image mask that meets the preset similarity condition from the multiple first image masks as the second image mask; and obtaining a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask.
[0030] It should be noted that, in this manner executed collaboratively by the electronic device and the server, the steps respectively executed by the electronic device and the server are not limited to the manner introduced in the above example. In actual applications, the steps respectively executed by the electronic device and the server can be dynamically adjusted according to the actual situation.
[0031] It should be noted that in addition to being a Figure 1 and Figure 2 smartphone shown in, the electronic device 100 may also be a vehicle-mounted device, a wearable device, a tablet computer, a laptop computer, a smart speaker, etc. The server 120 may be an independent physical server or a server cluster or a distributed system composed of multiple physical servers.
[0032] The embodiments of the present application will be specifically described below with reference to the accompanying drawings.
[0033] Please refer to Figure 3 , a method for image segmentation provided by an embodiment of the present application is applied to an electronic device or a server as shown in Figure 1 or Figure 2 . The method includes:
[0034] Step S110: Obtain an image to be segmented.
[0035] In the embodiment of the present application, the image to be segmented is an image for image segmentation, and the image to be segmented may include a preset segmentation target. Among them, the image to be segmented may include, but is not limited to, a three-dimensional image of computed tomography (CT) data, may also be an RGB image in an autonomous driving scenario, and may also be grayscale image data including, but not limited to, 32-bit precision magnetic resonance imaging (MRI). Specific limitations are not made here. In different application scenarios, the obtained image to be segmented is different. Exemplarily, for example, in an autonomous driving scenario, the obtained image to be segmented may be an RGB image in the autonomous driving scenario.
[0036] As a way, the image to be segmented may be an image pre-stored in a cloud server or an image obtained in real time.
[0037] As one of the ways, in the case where the image to be segmented is an image pre-stored in a cloud server, a large number of images need to be stored in the cloud server first. Then, when it is necessary to obtain the image to be segmented, an image acquisition request can be sent to the cloud server first. After the cloud server receives the image acquisition request, the image corresponding to the image acquisition request is returned as the image to be segmented. Among them, when storing the image, an image identifier can be set for each image first, and the corresponding relationship between the image identifier and the image is established. Thus, when sending an image acquisition request to the cloud server, the specified image identifier can be carried in the image acquisition request. After the cloud server receives the image acquisition request carrying the specified image identifier, the image corresponding to the specified image identifier can be returned as the image to be segmented. Optionally, when establishing the corresponding relationship between the image identifier and the image, an application scenario identifier can also be pre-divided for each image. Then, when establishing the corresponding relationship, the corresponding relationship of application scenario identifier - image identifier - image can be established, so that when obtaining the corresponding image to be segmented according to the application scenario, the corresponding application scenario identifier can be searched first, and then the corresponding image identifier can be searched, so as to find a specific image under a specific application scenario as the image to be segmented.
[0038] As another way, in the case where the image to be segmented is a real-time acquired image, when it is detected that a specified application program is started, the image acquisition device starts to acquire images in real time as the images to be segmented. Among them, the specified application program can be an application program with image processing functions; the image acquisition device can be a device with image acquisition functions such as a camera or a webcam. Exemplarily, when it is detected that a specified application program is started in an electronic device, the image acquisition device with image acquisition functions in the electronic device can be used to acquire images in real time as the images to be segmented.
[0039] Optionally, in the embodiments of the present application, the number of images to be segmented can be one or multiple. If the number of images to be segmented is multiple, then the multiple images to be segmented can be images including different segmentation targets or images including the same segmentation target, which is not specifically limited herein.
[0040] Step S120: Perform pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented.
[0041] As a way, the image to be segmented can be pre-segmented by a pre-trained image segmentation model to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented. Specifically, the image to be segmented can be input into the pre-trained image segmentation model to obtain the pre-segmented image corresponding to the segmentation target included in the image to be segmented output by the image segmentation model. Among them, the image segmentation model can be a convolutional neural network model with an encoder-decoder structure; the image segmentation model can also be a generative adversarial network model with a generator-discriminator; the image segmentation model can also be a watershed model; and the image segmentation model can also be an active contour model, which is not specifically limited here.
[0042] Among them, the watershed model is an image region segmentation model. During the process of segmenting the image to be segmented, it takes the similarity between the image to be segmented and neighboring pixels as an important reference basis, so as to connect pixel points that are close in spatial position and similar in gray value (gradient calculation) to form a closed contour.
[0043] The main principle of the active contour model is to construct an energy functional. Driven by the minimum value of the energy function, the contour curve gradually approaches the edge of the segmentation target, and finally the segmentation target is segmented.
[0044] In the embodiment of the present application, if there are multiple pre-set segmentation targets included in the image to be segmented, then there will be multiple segmentation targets included in the obtained image to be segmented.
[0045] Step S130: Generate multiple first image masks based on the pre-segmented image.
[0046] In the embodiment of the present application, the first image mask is an image mask corresponding to each segmentation target in the pre-segmented image. Among them, the image mask can be understood as an image obtained by using a selected image, graphic or object to block the pre-segmented image (all or part) to control the area of image processing or the processing process.
[0047] When generating multiple first image masks based on the pre-segmented image, each segmentation target included in the pre-segmented image can correspond to multiple first image masks. The number of segmentation targets included in the pre-segmented image determines the number of corresponding first image masks, which increases in multiples. Exemplarily, if each segmentation target corresponds to 5 first image masks, and if there are 5 segmentation targets included in the pre-segmented image, then there will be 25 corresponding first image masks.
[0048] As a way, multiple first image masks corresponding to the pre-segmented image can be obtained through a preset rule. Exemplarily, multiple first image masks corresponding to the pre-segmented image can be obtained through a neural network model.
[0049] Step S140: Obtain a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask.
[0050] In an embodiment of the present application, the preset similarity condition is the minimum similarity for obtaining the second image mask from multiple first image masks set in advance. Among them, the similarity characterizes the similarity between every two first image masks. Among them, the similarity between every two first image masks can be determined by IOU, Hausdorff distance, etc.
[0051] As a method, after obtaining multiple first image masks, the similarity between every two first image masks can be determined by IOU, Hausdorff distance, etc. to obtain multiple similarities. Thus, the multiple similarities can be compared with the minimum similarity, and the first image mask corresponding to the similarity greater than or equal to the minimum similarity is used as the second image mask.
[0052] Optionally, the minimum similarity can also be the similarity corresponding to the 75th percentile. Among them, the similarity corresponding to the 75th percentile is to first sort the multiple similarities in ascending order, then multiply the number of similarities n by 75% to get a number m, and then view the similarity at the mth position after sorting.
[0053] Step S150: Based on the second image mask, obtain a target segmentation result corresponding to the segmentation target included in the image to be segmented.
[0054] In an embodiment of the present application, the target segmentation result is the final segmentation image corresponding to the segmentation target included in the image to be segmented.
[0055] After obtaining the second image mask in the above manner, the final segmentation image corresponding to the segmentation target included in the image to be segmented can be obtained through the second image mask.
[0056] An image segmentation method provided by the present application can select an image mask that meets a preset similarity condition from multiple image masks according to the preset similarity condition, exclude the image masks with a large difference from the segmentation target, obtain an image mask with a small difference from the segmentation target, and thus determine the final segmentation result of the image to be segmented through the image mask with a small difference from the segmentation target, which can improve the segmentation accuracy of the image to be segmented.
[0057] Please refer to Figure 4 , an image segmentation method provided by an embodiment of the present application is applied to an electronic device or a server as shown in Figure 1 or Figure 2 shown, and the method includes:
[0058] Step S210: Obtain an image to be segmented.
[0059] Step S220: Perform pre-segmentation processing on the to-be-segmented image to obtain a pre-segmented image corresponding to the segmentation target included in the to-be-segmented image.
[0060] Step S230: Obtain a plurality of parameter combinations, each parameter combination including a corresponding dictionary, and the dictionary includes preset key-value pairs.
[0061] In the embodiments of the present application, a parameter combination refers to a set of multiple parameters required to generate a first image mask once, and a parameter combination is a dictionary. Among them, the multiple parameters refer to preset key-value pairs, and the preset key-value pairs can be sampling image index index, number of iterations n, number of smoothing times u, foreground regularization constraint coefficient λ1, background regularization constraint coefficient λ2, etc. That is, each dictionary includes a sampling image index index, number of iterations n, number of smoothing times u, foreground regularization constraint coefficient λ1, background regularization constraint coefficient λ2, etc., but in different dictionaries, the values of each key-value pair are different.
[0062] Among them, the sampling image index index: randomly sampled from {1, 2,..., N}, representing the indices of the to-be-segmented image and the pre-segmented image used in the Morphological Active Contours without Edge (MorphACWE) during the process of generating the first image mask once.
[0063] The number of iterations n: represents the number of iterations of the Morphological Active Contours without Edge model, randomly sampled from {1, 2,..., N iter}, where N iter represents the maximum number of iterations.
[0064] The number of smoothing times u: represents the number of times of morphological continuous linear operator smoothing operations in a single iteration, randomly sampled from {1, 2,..., N smooth}, where N smooth represents the maximum number of smoothing times.
[0065] The foreground regularization constraint coefficient λ1: represents the foreground regularization constraint coefficient in the ACWE closed curve equation.
[0066] The background regularization constraint coefficient λ2: represents the background regularization constraint coefficient in the ACWE closed curve equation.
[0067] Step S240: Based on the dictionaries included in the respective plurality of parameter combinations, determine corresponding Morphological Active Contours without Edge models, and input the pre-segmented image into the corresponding Morphological Active Contours without Edge models.
[0068] In the embodiments of the present application, based on multiple parameter combinations, the morphological edge-less active contour model can be run in a parallel or serial manner in scenarios including but not limited to single machine with single card, single machine with multiple cards, multiple machines with multiple cards, or other distributed system scenarios. Among them, single machine with single card means running the morphological edge-less active contour model on one host and one GPU, with very low running efficiency; single machine with multiple cards means running the morphological edge-less active contour model on one host and multiple GPUs, with relatively high running efficiency; multiple machines with multiple cards means running the morphological edge-less active contour model on multiple hosts and multiple GPUs, with even higher running efficiency.
[0069] Therefore, when calling the morphological edge-less active contour model based on each of the dictionaries composed of multiple parameters, the way to call the morphological edge-less active contour model can be selected according to the running efficiency.
[0070] As one way, as Figure 5 shown, step S240 may specifically include the following steps:
[0071] Step S241: Respectively obtain the sampling image indexes included in the dictionaries included in each of the multiple parameter combinations.
[0072] In the embodiments of the present application, the sampling image indexes included in the dictionaries included in each parameter combination may be different or the same. If the sampling image indexes included in the dictionaries included in each parameter combination are the same, then the other key-value pairs included in the dictionaries included in each parameter combination may be different. Optionally, it may be the number of iterations that is different, or the number of smoothing times that is different, which is not specifically limited herein.
[0073] Step S242: Respectively obtain the pre-segmented images corresponding to the sampling image indexes included in the dictionaries included in each of the multiple parameter combinations.
[0074] Step S243: Respectively determine the corresponding morphological edge-less active contour models based on the dictionaries included in each of the multiple parameter combinations, so as to input the pre-segmented images corresponding to the sampling image indexes included in the dictionaries included in each of the multiple parameter combinations into the corresponding morphological edge-less active contour models.
[0075] In the embodiment of the present application, for a certain dictionary among multiple parameter combinations, first, according to the sampling image index, an original image (image to be segmented) with a size of D*H*W*C (D represents the number of image layers of the image to be segmented. For example, if the image to be segmented is a 2D image, then D = 1; H represents the image height; W represents the image width; C represents the number of image channels. For example, if the image is a grayscale image, then C = 1, if the image is an RGB image, then C = 3, if the image is an RGBA image, then C = 4) for input to the edge - less active contour model based on morphology and the index - th pre - segmented image with a size of D*H*W*T (T represents the number of segmentation targets) are used as the initial level - set reference region input. The initial level - set reference region is the initial input of the edge - less active contour model based on morphology, that is, the set initial region, which can be regarded as the outer edge curve of the foreground region of the image to be segmented. For each segmentation target included in the pre - segmented image, for different channels, T edge - less active contour models based on morphology are determined using the preset key - value pairs in the dictionary. For the image masks output for different channels, set operations including but not limited to intersection and union are performed to obtain the final single first - image mask with a size of D*H*W*T.
[0076] Among them, the level set representing the closed - curve equation is: where u is the level - set function, is the gradient operator, k, v are constants, I is the pixel value of the original image, c1, c2 respectively represent the pixel means of the foreground region and the background region, and λ1, λ2 respectively represent the regularization constraint coefficients for the foreground region and the background region.
[0077] In the edge - less active contour model based on morphology, an iterative formula is used to replace the solution of the partial differential equation that requires a large amount of computing resources in the original active contour model. For the step of updating the contour of the segmentation target once, assuming the level - set function iteration at the t - th time, then from u t to u t+1 The iterative process can be divided into 3 steps:
[0078] 1) Morphological evolution
[0079] where D d is the dilation operation, E d is the erosion operation, v is the evolvable direction prior parameter that can be set, which is set to 0 in the embodiment of the present application, u t represents the intermediate variable generated in the edge - less active contour model based on morphology, x represents the image, and u(x) represents the level - set function.
[0080] 2) Active contour evolution
[0081] where \(u\) is the level set function, is the gradient operator, \(k\), \(v\) are constants, \(I\) is the pixel value of the original image, \(c_1\), \(c_2\) represent the pixel means of the foreground region and the background region respectively, and \(\lambda_1\), \(\lambda_2\) represent the regularization constraint coefficients for the foreground region and the background region respectively.
[0082] 3) Morphological continuous linear operator smoothing evolution
[0083] where represents the morphological continuous linear operator.
[0084] That is to say, the edge - less active contour model based on morphology is used to output a more accurate image mask for segmentation.
[0085] Step S250: Obtain the first image masks output by the corresponding edge - less active contour models based on morphology respectively to obtain multiple first image masks.
[0086] By the same method as above, traversing multiple parameter combinations, multiple first image masks with a size of \(D\times H\times W\times T\) can be obtained.
[0087] Step S260: Obtain the first image masks that meet the preset similarity conditions from the multiple first image masks as the second image masks.
[0088] Step S270: Based on the second image masks, obtain the target segmentation results corresponding to the segmentation targets included in the image to be segmented.
[0089] An image segmentation method provided by the present application can, by processing the pre - segmented image corresponding to the image to be segmented through an edge - less active contour model based on morphology, obtain an image mask closer to the segmentation target. Then, by screening the image masks based on the similarity between the image masks, the image masks with a large difference from the segmentation target can be excluded, and an image mask with a small difference from the segmentation target can be obtained. Thus, the final segmentation result of the image to be segmented is determined by the image mask with a small difference from the segmentation target, which can improve the segmentation accuracy of the image to be segmented.
[0090] Please refer to Figure 6 , an image segmentation method provided by an embodiment of the present application is applied to an electronic device or a server as shown in Figure 1 or Figure 2 shown, and the method includes:
[0091] Step S310: Obtain the image to be segmented.
[0092] Step S320: Perform pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented.
[0093] Step S330: Generate multiple first image masks based on the pre-segmented image.
[0094] Step S340: Obtain multiple similarities corresponding to each first image mask respectively, where the multiple similarities corresponding to the first image mask include the similarity between the first image mask and the target first image mask.
[0095] In the embodiments of the present application, the target first image mask can be any first image mask among the multiple first image masks, or can be other first image masks other than the first image mask itself among the multiple first image masks. That is to say, in the first method, it is necessary to calculate the similarity between each first image mask and all the first image masks to obtain multiple similarities; in the second method, it is not necessary to calculate the similarity between each first image mask and itself, and only the similarity between the first image mask and other first image masks other than itself needs to be calculated to obtain multiple similarities. Exemplarily, if the multiple first image masks include mask 1, mask 2, mask 3, and mask 4, to determine the multiple similarities corresponding to mask 1, the multiple similarities may include similarity 1 between mask 1 and mask 1, similarity 2 between mask 1 and mask 2, similarity 3 between mask 1 and mask 3, and similarity 4 between mask 1 and mask 4. Of course, the multiple similarities may also only include similarity 2 between mask 1 and mask 2, similarity 3 between mask 1 and mask 3, and similarity 4 between mask 1 and mask 4. Since the former method will calculate one more similarity than the latter method, if the number of first image masks is very large, it will increase the consumption of computing resources. Therefore, it is possible to select which method to use to calculate the multiple similarities corresponding to each first image mask according to the number of first image masks. Exemplarily, a preset number is set in advance. When the number of generated first image masks is greater than the preset number, the second method is selected to calculate the multiple similarities corresponding to each first image mask. When the number of generated first image masks is less than or equal to the preset number, either of the two methods can be used to calculate the multiple similarities corresponding to each first image mask.
[0096] As a method, the multiple similarities corresponding to each first image mask can be determined through a similarity evaluation formula, and the multiple similarities corresponding to each first image mask can form a similarity evaluation matrix. Taking the Dice coefficient as an example:
[0097] Among them, X represents the first image mask, and Y represents the target first image mask. The more similar the two masks are, the higher the Dice coefficient. When the two masks are exactly the same, the Dice coefficient is 1. Taking the first image masks in multiple first image masks as rows and the target first image mask as columns, a similarity evaluation matrix can be obtained. The similarity evaluation matrix is a real symmetric matrix with all diagonal elements equal to 1.
[0098] Exemplarily, as shown above, the multiple first image masks include mask 1, mask 2, mask 3, and mask 4. Then, taking the first image masks as rows and the target first image as columns, the following table can be obtained:
[0099]
[0100] Through the above table, the obtained similarity evaluation matrix is:
[0101]
[0102] Step S350: Based on the multiple similarities corresponding to each first image mask, determine the average similarity corresponding to each first image mask to obtain multiple average similarities.
[0103] In the embodiment of the present application, based on the multiple similarities corresponding to each first image, sum the similarity evaluation matrix by rows and then calculate the mean value to calculate the average similarity corresponding to each first image mask. Exemplarily, as in the above example, to determine the average similarity corresponding to mask 1, the formula can be used: (similarity(1, 1) + similarity(1, 2) + similarity(1, 3) + similarity(1, 4)) / 4 = average similarity 1, where average similarity 1 is the average similarity corresponding to mask 1. Similarly, in the same way, the average similarity 2 corresponding to mask 2, the average similarity 3 corresponding to mask 3, and the average similarity 4 corresponding to mask 4 can be calculated.
[0104] Optionally, when determining the average similarity corresponding to each first image mask, one highest similarity and one lowest similarity in the multiple similarities corresponding to each first image mask can be removed first, and then the corresponding average similarity can be determined based on the remaining similarities.
[0105] Step S360: Based on the multiple average similarities, obtain the first image masks that meet the preset similarity conditions from the multiple first image masks as the second image masks.
[0106] As a way, based on the multiple average similarities, obtaining a first image mask that meets the preset similarity condition from the multiple first image masks as a second image mask may include: taking the first image mask corresponding to the average similarity greater than the preset similarity among the multiple average similarities as the second image mask; or, obtaining a preset number of average similarities that meet the preset similarity condition from the multiple average similarities, and taking the first image masks corresponding to the preset number of average similarities as the second image masks.
[0107] Wherein, the preset similarity is the minimum average similarity corresponding to the first image mask when the first image mask can be determined as the second image mask. After determining the average similarity corresponding to each first image mask, the average similarity corresponding to each first image mask can be compared with the preset similarity respectively, and the first image mask with the corresponding average similarity greater than the preset similarity is determined as the second image mask.
[0108] Optionally, it is also possible to select a preset number of image masks as the second image masks according to a proportion from the first image masks with corresponding average similarities greater than the preset similarity.
[0109] Optionally, it is also possible to sort the multiple first image masks in descending or ascending order according to the average similarity to obtain the sorted multiple first image masks. Obtain the first image masks ranked at the specified position in the front or at the specified position in the back from the sorted multiple first image masks as the second image masks.
[0110] Step S370: Determine the uncertainty index corresponding to the image to be segmented based on the pixel values of the pixel points at the same position in the multiple second image masks.
[0111] In the embodiment of the present application, when selecting multiple second image masks from multiple first image masks, the uncertainty of the pixel points at the corresponding positions can be determined according to the standard deviation, variance or quantiles of the standard deviation and variance of the pixel values of the pixel points at the same position in each second image mask, so as to obtain the uncertainty corresponding to the image to be segmented.
[0112] Step S380: Determine the average value of the pixel values of the pixel points at the same position in the multiple second image masks.
[0113] In the embodiment of the present application, since multiple selected second image masks are included, when determining the final prediction result corresponding to the image to be segmented, the average value of the pixel values of the pixel points at the same position in the multiple second image masks can be calculated, so as to obtain the pixel value of the pixel points at the corresponding positions to obtain the final prediction result.
[0114] Step S390: Determine a target segmentation result corresponding to a segmentation target included in the to-be-segmented image based on the uncertainty index, the to-be-segmented image, and the average value.
[0115] In an embodiment of the present application, the uncertainty corresponding to the to-be-segmented image can be normalized to the interval [0, 1]. Specify a color or transparency, map the final prediction result to a color map according to the uncertainty index, and can be superimposed on the to-be-segmented image to obtain the target segmentation result. Exemplarily, for the foreground prediction result P ∈ R of an RGB image with length H and width W H*W , the uncertainty of each pixel point in the final prediction result is normalized to the interval [0, 1], and the method of mapping to the color map is to map the pixel points on [0, 1] to the pseudo-color interval.
[0116] Among them, the mapping method of mapping the final prediction result to the color map according to the uncertainty index can be a function or a mapping table (such as the 8-bit case). Of course, it can also be a pixel point uncertainty mapping method based on a threshold or a multi-segment function. Specifically, the method based on a threshold means that when the prediction result is less than a certain threshold, greater than a certain threshold, or within a certain threshold interval, the dependent variable of the mapping can be manually specified (for example, when the prediction result is greater than 0.9, it is dark red, when it is greater than 0.5 and less than or equal to 0.9, it is light red, and in other cases, it is blue); the method based on a multi-segment function means that the mapping function is manually specified (for example, when the prediction result is greater than 0.9, it is a gradual change from light red to dark red, when it is greater than 0.5 and less than or equal to 0.9, it is a gradual change from light blue to light red, and in other cases, it is a gradual change from white to blue).
[0117] An image segmentation method provided by the present application screens image masks based on the similarity between image masks, can exclude image masks with a large difference from the segmentation target, and obtains image masks with a small difference from the segmentation target. Thus, the uncertainty index corresponding to the to-be-segmented image can be determined based on the pixel values of the pixel points corresponding to the same position of the image mask with a small difference from the segmentation target, and then the final segmentation result of the to-be-segmented image can be determined based on the uncertainty index corresponding to the to-be-segmented image, improving the segmentation accuracy of the to-be-segmented image.
[0118] Please refer to Figure 7 , an image segmentation method provided by an embodiment of the present application is applied to an electronic device or a server as shown in Figure 1 or Figure 2 shown, and the method includes:
[0119] Step S410: Obtain a to-be-segmented image.
[0120] Step S420: Input the image to be segmented into multiple image segmentation models respectively, and obtain the pre-segmented images corresponding to the segmentation targets included in the image to be segmented output by each of the multiple image segmentation models, so as to obtain multiple pre-segmented images.
[0121] In the embodiments of the present application, the image to be segmented can be pre-segmented by one or more image segmentation models. Among them, the multiple image segmentation models can be multiple active contour models under different combinations of hyperparameters.
[0122] Among them, the number of pre-segmented images generated corresponds to the number of image segmentation models.
[0123] Assume that the size of the image to be segmented is D×H×W×C (D represents the number of image layers. For example, for a 2D image, D = 1; H represents the image height; W represents the image width; C represents the number of image channels. For example, for a grayscale image, C = 1, for an RGB image, C = 3, and for an RGBA image, C = 4). After inputting the image to be segmented into N image segmentation models, pre-segmented images with a tensor size of N×D×H×W×T (N is the number of pre-segmented images generated by the used image segmentation models, and T is the number of segmentation targets) can be obtained.
[0124] Step S430: Generate multiple first image masks corresponding to each of the multiple pre-segmented images based on the multiple pre-segmented images.
[0125] In the embodiments of the present application, multiple first image masks will be generated for each pre-segmented image.
[0126] Exemplarily, input the pre-segmented image with a tensor size of N×D×H×W×T into a morphological edge-less active contour model to generate a pre-segmented image with a tensor size of M×D×H×W×T (where M is the total number of candidate mask numbers that can be set, M≥N, and a total of M - N new image masks are generated).
[0127] Step S440: Obtain the first image masks that meet the preset similarity conditions from the multiple first image masks corresponding to each pre-segmented image, and use them as the second image masks corresponding to each pre-segmented image.
[0128] As a method, the second image masks corresponding to each pre-segmented image can be respectively obtained from the multiple first image masks corresponding to each pre-segmented image according to the preset similarity conditions. Exemplarily, if each pre-segmented image corresponds to 10 first image masks. If the pre-segmented images include Image 1, Image 2, and Image 3, then Image 1, Image 2, and Image 3 will each correspond to 10 first image masks, so that the second image masks corresponding to Image 1, Image 2, and Image 3 can be obtained according to the preset similarity conditions.
[0129] Step S450: Based on the second image mask corresponding to each pre-segmented image, obtain the target segmentation result corresponding to the segmentation target included in the image to be segmented.
[0130] After obtaining the second image mask corresponding to each pre-segmented image, the target segmentation result corresponding to each image segmentation model can also be obtained in the same manner as described above.
[0131] An image segmentation method provided in this application can select an image mask that meets the preset similarity condition from multiple image masks according to the preset similarity condition, exclude the image masks with large differences from the segmentation target, and obtain an image mask with small differences from the segmentation target. Thus, the final segmentation result of the image to be segmented can be determined through the image mask with small differences from the segmentation target, which can improve the segmentation accuracy of the image to be segmented.
[0132] Please refer to Figure 8 , an image segmentation device 500 provided in an embodiment of this application, the device 500 includes:
[0133] An image acquisition unit 510, configured to acquire an image to be segmented.
[0134] A processing unit 520, configured to perform pre-segmentation processing on the image to be segmented, and obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented.
[0135] Optionally, the processing unit 520 is specifically configured to input the image to be segmented into multiple image segmentation models respectively, and acquire the pre-segmented images corresponding to the segmentation target included in the image to be segmented output by the multiple image segmentation models respectively, so as to obtain multiple pre-segmented images.
[0136] A first mask acquisition unit 530, configured to generate multiple first image masks based on the pre-segmented image.
[0137] Optionally, the first mask acquisition unit 530 is specifically configured to acquire multiple parameter combinations, each parameter combination includes a corresponding dictionary, and the dictionary includes preset key-value pairs; respectively determine corresponding morphological edge-less active contour models based on the dictionaries included in the multiple parameter combinations respectively, so as to input the pre-segmented image into the corresponding morphological edge-less active contour model; respectively acquire the first image masks output by the corresponding morphological edge-less active contour models, so as to obtain multiple first image masks.
[0138] Optionally, the first mask acquisition unit 530 is further specifically configured to respectively acquire the sampling image indexes included in the dictionaries included in the respective multiple parameter combinations; respectively acquire the pre-segmented images corresponding to the sampling image indexes included in the dictionaries included in the respective multiple parameter combinations; respectively determine the morphological edge-less active contour models corresponding to the respective multiple parameter combinations based on the dictionaries included in the respective multiple parameter combinations, so as to input the pre-segmented images corresponding to the sampling image indexes included in the dictionaries included in the respective multiple parameter combinations into the corresponding morphological edge-less active contour models.
[0139] Optionally, the first mask acquisition unit 530 is further specifically configured to generate multiple first image masks corresponding to each of the pre-segmented images based on the multiple pre-segmented images.
[0140] The second mask acquisition unit 540 is configured to acquire a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask.
[0141] Optionally, the second mask acquisition unit 540 is specifically configured to respectively acquire multiple similarities corresponding to each first image mask, where the multiple similarities corresponding to the first image mask include the similarity between the first image mask and the target first image mask; respectively determine the average similarity corresponding to each first image mask based on the multiple similarities corresponding to each first image mask, so as to obtain multiple average similarities; based on the multiple average similarities, acquire a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask.
[0142] Optionally, the second mask acquisition unit 540 is further specifically configured to use, as the second image mask, the first image mask corresponding to the average similarity greater than a preset similarity among the multiple average similarities; or acquire a preset number of average similarities that meet the preset similarity condition from the multiple average similarities, and use the first image masks corresponding to the preset number of average similarities as the second image masks.
[0143] Optionally, the second mask acquisition unit 540 is further specifically configured to acquire a first image mask that meets a preset similarity condition from the multiple first image masks corresponding to each pre-segmented image as the second image mask corresponding to each pre-segmented image.
[0144] The result determination unit 550 is configured to obtain a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask.
[0145] Optionally, the result determination unit 550 is specifically configured to determine an uncertainty index corresponding to the image to be segmented based on pixel values of pixel points at the same position in multiple second image masks; determine an average value of pixel values of pixel points at the same position in multiple second image masks; and determine a target segmentation result corresponding to a segmentation target included in the image to be segmented based on the uncertainty index, the image to be segmented, and the average value.
[0146] Optionally, the result determination unit 550 is further specifically configured to obtain a target segmentation result corresponding to a segmentation target included in the image to be segmented based on a second image mask corresponding to each pre-segmented image.
[0147] Please refer to Figure 9 , an image segmentation device 600 provided in an embodiment of the present application, the device 600 includes an image pre-segmentation unit 610, a candidate mask generation unit 620, a candidate mask screening unit 630, an uncertainty evaluation unit 640, and an uncertainty display unit 650.
[0148] The image pre-segmentation unit 610 is configured to perform pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to a segmentation target included in the image to be segmented.
[0149] The candidate mask generation unit 620 is configured to generate multiple first image masks based on the pre-segmented image.
[0150] The candidate mask screening unit 630 is configured to obtain a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask.
[0151] The uncertainty evaluation unit 640 is configured to determine an uncertainty index corresponding to the image to be segmented based on pixel values of pixel points at the same position in multiple second image masks; and determine an average value of pixel values of pixel points at the same position in multiple second image masks.
[0152] The uncertainty display unit 650 is configured to determine a target segmentation result corresponding to a segmentation target included in the image to be segmented based on the uncertainty index, the image to be segmented, and the average value.
[0153] The specific steps for the above units to execute the image segmentation method can be as Figure 10 shown:
[0154] First, obtain the image input (the image to be segmented). The image pre-segmentation unit receives the image input (the image to be segmented) and outputs the pre-segmentation result of the segmentation target. Then, the candidate mask generation unit generates multiple candidate segmentation masks based on the pre-segmentation result and the image input, using the active contour model under different combinations of hyperparameters. The candidate mask screening unit then screens the candidate segmentation masks based on the similarity evaluation matrix. The uncertainty evaluation unit derives the final prediction result and the uncertainty index according to the multiple candidate segmentation masks. Finally, the uncertainty display unit visually displays the segmentation result and the uncertainty based on the image input (the image to be segmented), the final prediction result, and the uncertainty index.
[0155] It should be noted that the device embodiments in this application correspond to the foregoing method embodiments. The specific principles in the device embodiments can be referred to the content in the foregoing method embodiments and will not be elaborated here.
[0156] Next, Figure 11 an electronic device or a server provided by this application will be described.
[0157] Please refer to Figure 11 , based on the above image segmentation method and device, another electronic device or server 800 that can execute the foregoing image segmentation method is further provided in an embodiment of this application. The electronic device or server 800 includes one or more (only one is shown in the figure) processors 802, a memory 804, and a network module 806 that are coupled to each other. Among them, a program that can execute the content in the foregoing embodiments is stored in the memory 804, and the processor 802 can execute the program stored in the memory 804.
[0158] Among them, the processor 802 may include one or more processing cores. The processor 802 connects various parts within the entire server 800 through various interfaces and lines, and executes various functions of the server 800 and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 804, and by calling data stored in the memory 804. Optionally, the processor 802 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 802 may integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the displayed content; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 802 and may be implemented separately through a communication chip.
[0159] The memory 804 may include random access memory (RAM) and may also include read-only memory. The memory 804 can be used to store instructions, programs, code, code sets or instruction sets. The memory 804 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data created during the use of the electronic device or the server 800 (such as phone book, audio and video data, chat record data, etc.).
[0160] The network module 806 is used to receive and transmit electromagnetic waves, realizing the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices, such as communicating with an audio playback device. The network module 806 may include various existing circuit elements for performing these functions. For example, an antenna, a radio frequency transceiver, a digital signal processor, an encryption / decryption chip, a subscriber identity module (SIM) card, a memory, and the like. The network module 806 can communicate with various networks such as the Internet, an enterprise intranet, a wireless network or communicate with other devices through a wireless network. The above-mentioned wireless network may include a cellular phone network, a wireless local area network or a metropolitan area network. For example, the network module 806 can interact with a base station.
[0161] Please refer to Figure 12 , which shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application. Program code is stored in the computer-readable storage medium 900, and the program code can be called by a processor to execute the method described in the above method embodiment.
[0162] The computer-readable storage medium 900 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk or a ROM. Optionally, the computer-readable storage medium 900 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 900 has a storage space for the program code 910 for executing any method step in the above method. These program codes can be read out from one or more computer program products or written into these one or more computer program products. The program code 910 can be compressed in an appropriate form, for example.
[0163] An image segmentation method, device, electronic device and storage medium provided by the present application first obtain an image to be segmented, perform pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to a segmentation target included in the image to be segmented, and then generate multiple first image masks based on the pre-segmented image, obtain a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask, and finally obtain a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask. Through the above method, an image mask that meets the preset similarity condition can be selected from multiple image masks according to the preset similarity condition, image masks with a large difference from the segmentation target are excluded, and an image mask with a small difference from the segmentation target is obtained. Therefore, the final segmentation result of the image to be segmented can be determined by the image mask with a small difference from the segmentation target, and the segmentation accuracy of the image to be segmented can be improved.
[0164] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many forms without departing from the spirit of the present invention and the scope protected by the claims, and all of them fall within the protection scope of the present invention.
Claims
1. An image segmentation method, characterized in that, The method includes: Obtaining the image to be segmented; Performing pre-segmentation processing on the image to be segmented to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented; Generating multiple first image masks based on the pre-segmented image; Obtaining a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask; The step of obtaining a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask includes: Respectively obtaining multiple similarity degrees corresponding to each first image mask, where the multiple similarity degrees corresponding to a first image mask include the similarity degree between the first image mask and a target first image mask; Respectively determining the average similarity degree corresponding to each first image mask based on the multiple similarity degrees corresponding to each first image mask to obtain multiple average similarity degrees; Using the first image mask corresponding to the average similarity degree greater than the preset similarity degree among the multiple average similarity degrees as the second image mask; or Obtaining a preset number of average similarity degrees that meet the preset similarity condition from the multiple average similarity degrees, and using the first image masks corresponding to the preset number of average similarity degrees as the second image masks; Based on the second image mask, obtaining a target segmentation result corresponding to the segmentation target included in the image to be segmented.
2. The method according to claim 1, characterized in that, The step of generating multiple first image masks based on the pre-segmented image includes: Obtaining multiple parameter combinations, each parameter combination including a corresponding dictionary, and the dictionary including preset key-value pairs; Respectively determining a corresponding morphological edge-less active contour model based on the dictionaries included in the multiple parameter combinations, and inputting the pre-segmented image into the corresponding morphological edge-less active contour model; Respectively obtaining the first image masks output by the corresponding morphological edge-less active contour models to obtain multiple first image masks.
3. The method according to claim 2, wherein The step of respectively determining a corresponding morphological edge-less active contour model based on the dictionaries included in the multiple parameter combinations, and inputting the pre-segmented image into the corresponding morphological edge-less active contour model includes: Respectively obtaining the sampling image indexes included in the dictionaries included in the multiple parameter combinations; Respectively obtaining the pre-segmented images corresponding to the sampling image indexes included in the dictionaries included in the multiple parameter combinations; Respectively determining a corresponding morphological edge-less active contour model based on the dictionaries included in the multiple parameter combinations, and inputting the pre-segmented image corresponding to the sampling image index included in the dictionary included in each of the multiple parameter combinations into the corresponding morphological edge-less active contour model.
4. The method according to claim 1, wherein The second image mask includes multiple ones; the step of obtaining a target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask includes: Determining an uncertainty index corresponding to the image to be segmented based on the pixel values of the pixel points at the same position in the multiple second image masks; Determining the average value of the pixel values of the pixel points at the same position in the multiple second image masks; Based on the uncertainty index, the image to be segmented, and the average value, determine the target segmentation result corresponding to the segmentation target included in the image to be segmented.
5. The method according to claim 1, wherein The pre-segmenting the image to be segmented to obtain a pre-segmented image corresponding to the image to be segmented includes: Input the image to be segmented into multiple image segmentation models respectively, and obtain the pre-segmented images corresponding to the segmentation targets included in the image to be segmented output by each of the multiple image segmentation models, so as to obtain multiple pre-segmented images; The generating multiple first image masks based on the pre-segmented images includes: Generate multiple first image masks corresponding to each pre-segmented image based on the multiple pre-segmented images; The obtaining a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask includes: Obtain a first image mask that meets a preset similarity condition from the multiple first image masks corresponding to each pre-segmented image as the second image mask corresponding to each pre-segmented image; The obtaining the target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask includes: Based on the second image mask corresponding to each pre-segmented image, obtain the target segmentation result corresponding to the segmentation target included in the image to be segmented.
6. An image segmentation device, characterized in that, The device includes: An image acquisition unit, configured to acquire an image to be segmented; A processing unit, configured to pre-segment the image to be segmented to obtain a pre-segmented image corresponding to the segmentation target included in the image to be segmented; A first mask acquisition unit, configured to generate multiple first image masks based on the pre-segmented images; A second mask acquisition unit, configured to obtain a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask; The obtaining a first image mask that meets a preset similarity condition from the multiple first image masks as a second image mask includes: respectively obtaining multiple similarity degrees corresponding to each first image mask, where the multiple similarity degrees corresponding to a first image mask include the similarity degree between the first image mask and a target first image mask; respectively determining the average similarity degree corresponding to each first image mask based on the multiple similarity degrees corresponding to each first image mask, so as to obtain multiple average similarity degrees; using the first image mask corresponding to the average similarity degree greater than the preset similarity degree among the multiple average similarity degrees as the second image mask; or, obtaining a preset number of average similarity degrees that meet the preset similarity condition from the multiple average similarity degrees, and using the first image masks corresponding to the preset number of average similarity degrees as the second image masks; A result determination unit, configured to obtain the target segmentation result corresponding to the segmentation target included in the image to be segmented based on the second image mask.
7. An electronic device, characterized in that, Includes one or more processors; one or more programs are stored in a memory and are configured to be executed by the one or more processors to perform the method according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, Program code is stored in the computer-readable storage medium, wherein, when the program code is run by a processor, the method according to any one of claims 1-5 is executed.
Citation Information
Patent Citations
Semantic segmentation method and device based on few samples, electronic equipment and storage medium
CN112464943A
Foreground object detection
WO2018165148A1