Image segmentation method, system and device based on diffusion model and medium

Through the image segmentation method based on the diffusion model, the problem of noise insensitive to the prior art is solved, and a more accurate and stable image segmentation effect is achieved.

CN119600042APending Publication Date: 2025-03-11SHENZHEN FUSEN IMAGING TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411660620.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The existing image segmentation method is insensitive to non-uniformly distributed noise, resulting in poor segmentation effect.

Method used

Using an image segmentation method based on diffusion model, the horizontal set expression set is obtained and the final predicted segmentation mask is output by constructing an image pyramid, feature encoding, downsampling and diffusion module.

Benefits of technology

It improves the sensitivity of image segmentation to noise and enhances the accuracy and stability of segmentation effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600042A_ABST
    Figure CN119600042A_ABST
Patent Text Reader

Abstract

The invention relates to an image processing technology, and discloses an image segmentation method based on a diffusion model, which comprises the following steps: constructing a first image pyramid and a second image pyramid according to an image to be processed through twice multi-scale decomposition, and carrying out convolution on the second image pyramid to obtain a feature image pyramid; performing feature coding and down-sampling on the first image pyramid and the feature image pyramid to obtain double-pyramid coded data, obtaining a level set expression set according to the double-pyramid coded data, solving a zero level set position of the level set expression set by utilizing multiple iterations of a diffusion model, and obtaining a zero level set expression set; and calculating the zero level set position and the mean square error between the corresponding level set plane and the manually labeled mask, obtaining an image segmentation model according to the mean square error optimization model, and carrying out image segmentation on the to-be-segmented image by using the image segmentation model to obtain an image segmentation result. The invention further provides an image segmentation system and device based on the diffusion model and a medium. According to the invention, the image segmentation effect can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an image segmentation method, system, device and medium based on a diffusion model. Background Art

[0002] With the rapid development of artificial intelligence technology, medical image segmentation has become a key task in the field of medical image processing and analysis. Medical image segmentation aims to segment parts with specific meanings in medical images and extract relevant features to provide a reliable basis for clinical diagnosis and pathological research, and assist doctors in making more accurate diagnoses, especially in the fields of tumor identification, organ boundary positioning and lesion detection. Existing medical image segmentation technologies mainly rely on deep learning models and traditional image processing methods. Among them, the more common technologies include segmentation methods such as U-Net and Transformer. Traditional methods include image segmentation methods based on level set evolution.

[0003] At present, many deep learning-based medical image segmentation algorithms rely on the convolutional neural network (CNN) architecture. Although these methods can achieve high-precision image segmentation to a certain extent, due to their data-driven nature, they often rely on a large amount of labeled data and a complex training process. At the same time, these models are prone to under-segmentation or over-segmentation when dealing with blurred boundaries, local inhomogeneities, and complex structures, resulting in inaccurate boundary control. Medical image segmentation algorithms based on level set evolution gradually approach the target boundary in the image through evolution curves. This type of algorithm has a solid theoretical foundation and performs well in dealing with complex shapes and topological changes. However, traditional level set methods are sensitive to noise and are easily affected by irregular intensity changes in the image, resulting in the inability to accurately control the boundary. In addition, this type of method usually depends on the initialization position and has a strong dependence on the initial conditions, which may lead to local optimality of the segmentation results rather than global optimality. Summary of the invention

[0004] The present invention provides an image segmentation method, system, device and medium based on a diffusion model, the main purpose of which is to solve the problem that the existing image segmentation method is insensitive to non-uniformly distributed noise, resulting in poor segmentation effect.

[0005] To achieve the above object, the present invention provides an image segmentation method based on a diffusion model, comprising:

[0006] An image pyramid is constructed according to the pre-acquired image to be processed through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid;

[0007] Using a pre-built model, a convolution operation is performed on the second image pyramid to obtain a feature image pyramid, and feature encoding and down-sampling are performed on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data;

[0008] Using the model to obtain a level set expression set according to the dual pyramid encoding data;

[0009] Outputting a final predicted segmentation mask according to the level set expression set using a diffusion module of the model;

[0010] Respectively calculating the mean square errors of the level set expression set and the final predicted segmentation mask and the preset manual annotation mask to obtain a first mean square error and a second mean square error;

[0011] Optimizing the model according to the first mean square error and the second mean square error, and confirming that an image segmentation model is obtained after the optimization of the model reaches a preset number of iterations;

[0012] The image segmentation model is used to perform image segmentation on the image to be segmented to obtain an image segmentation result.

[0013] Optionally, constructing an image pyramid according to a pre-acquired image to be processed by performing two multi-scale decompositions to obtain a first image pyramid and a second image pyramid includes:

[0014] Convert the image to be processed into a floating point data format to obtain a floating point format image;

[0015] Performing an operation of intercepting odd and even rows and columns on the floating-point format image to obtain an odd-numbered row and column set and an even-numbered row and column set;

[0016] Downsampling the odd-numbered row and column sets multiple times to obtain data of multiple different scales, and constructing a first image pyramid according to the downsampling set results;

[0017] The even-numbered row and column sets are downsampled multiple times to obtain data of multiple different scales, and a second image golden character is constructed according to the downsampled set results.

[0018] Optionally, the using a pre-built model to perform a convolution operation on the second image pyramid to obtain a feature image pyramid includes:

[0019] Using the convolution kernel to slide in the second pyramid image according to a preset step size;

[0020] Extracting local convolution information of the area covered by the convolution kernel on the second pyramid image after each sliding, to obtain a local convolution information collection set;

[0021] The feature image pyramid is constructed according to the local convolution information set.

[0022] Optionally, the obtaining a level set expression set according to the dual pyramid encoding data using the model includes:

[0023] Using the convolution module and the multi-head attention mechanism module of the model to perform feature encoding on the dual pyramid encoded data to obtain a feature encoding result set;

[0024] Performing feature fusion on all feature encoding results of the feature encoding result set to obtain a feature fusion result;

[0025] Using the decoding layer of the model to perform feature decoding on the feature fusion node to obtain a feature decoding result;

[0026] The feature decoding results are subjected to feature fusion to obtain a level set expression set.

[0027] Optionally, performing feature fusion on all feature encoding results of the feature encoding result set to obtain a feature fusion result includes:

[0028] Taking out the elements in the feature code set in pairs to obtain a data pair set;

[0029] The feature sampling attention mechanism module of the model is used to extract the attention matrix of each data pair in the data pair set through convolution operation and average pooling operation to obtain a matrix set;

[0030] Multiply each data pair in the data pair set by its corresponding attention matrix in the matrix set to obtain an element matrix;

[0031] All elements in the element matrix are added together to obtain a feature fusion result.

[0032] Optionally, the using the diffusion module of the model to output a final predicted segmentation mask according to the level set expression set comprises:

[0033] Dividing the feature fusion result into a plurality of batch samples of size 4×4 to obtain a batch sample set;

[0034] Using a convolution kernel of size 1×1 to perform a convolution operation on each batch sample in the batch sample set to obtain batch sample features;

[0035] Encoding the level set expression set using two convolution kernels of size 1×1 to obtain a position information encoding result;

[0036] Superimposing the position information encoding knot and the batch sample feature in a second dimension to obtain a superposition result, and performing a convolution operation on the superposition result to obtain a zero level set bias;

[0037] Adding the level set expression set to the zero level set bias to obtain a predicted zero level set position;

[0038] Determine whether the current number of iterations reaches the preset target number of iterations;

[0039] If the current number of iterations does not reach the target number of iterations, the step of dividing the feature fusion result into a plurality of batch samples of a size of 4 times 4 to obtain a batch sample set is re-executed.

[0040] The predicted zero level set position is compared with the level set expression set, and the values ​​in the level set expression set that are greater than the predicted zero level set position are set to 1, and the values ​​of the remaining positions are set to 0, to obtain a final predicted segmentation mask.

[0041] Optionally, respectively calculating the mean square errors of the level set expression set and the final predicted segmentation mask with a preset manually labeled mask to obtain a first mean square error and a second mean square error includes:

[0042] The first mean square error and the second mean square error are calculated using the following formula:

[0043]

[0044] Wherein, M1 is the first mean square error, M2 is the second mean square error, n is the number of samples in the level set expression set, x i represents the i-th sample in the level set expression set, y i represents the i-th sample in the final predicted segmentation mask, z i represents the i-th sample in the manually labeled mask.

[0045] In order to solve the above problems, the present invention further provides an image segmentation system based on a diffusion model, the system comprising:

[0046] An image pyramid construction module is used to construct an image pyramid according to a pre-acquired image to be processed by performing two multi-scale decompositions to obtain a first image pyramid and a second image pyramid;

[0047] A data encoding module, configured to perform a convolution operation on the second image pyramid using a pre-built model to obtain a feature image pyramid, and perform feature encoding and down-sampling on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data;

[0048] A data prediction module, used to obtain a level set expression set according to the dual pyramid encoding data using the model, and output a final predicted segmentation mask according to the level set expression set using a diffusion module of the model;

[0049] A model iteration module, used to respectively calculate the mean square error between the level set expression set and the final predicted segmentation mask and a preset manually labeled mask to obtain a first mean square error and a second mean square error, optimize the model according to the first mean square error and the second mean square error, and confirm that the image segmentation model is obtained after the optimization of the model reaches a preset number of iterations;

[0050] The image segmentation module is used to perform image segmentation on the image to be segmented using the image segmentation model to obtain an image segmentation result.

[0051] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:

[0052] at least one processor;

[0053] and, a memory communicatively coupled to the at least one processor;

[0054] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the above-mentioned diffusion model-based image segmentation method.

[0055] In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned image segmentation method based on the diffusion model.

[0056] The embodiment of the present invention constructs an image pyramid according to a pre-acquired image to be processed through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid, performs a convolution operation on the second image pyramid using a pre-constructed model to obtain a feature image pyramid, performs feature encoding and downsampling on the first image pyramid and the feature image pyramid to obtain dual pyramid encoding data, obtains a level set expression set according to the dual pyramid encoding data using the model, outputs a final predicted segmentation mask according to the level set expression set using the diffusion module of the model, calculates the mean square error between the level set expression set and the final predicted segmentation mask and a preset manual annotation mask respectively, obtains a first mean square error and a second mean square error, optimizes the model according to the first mean square error and the second mean square error, confirms that an image segmentation model is obtained after the optimization of the model reaches a preset number of iterations, and uses the image segmentation model to perform image segmentation on the image to be segmented to obtain an image segmentation result. Therefore, the image segmentation method, system, electronic device and computer-readable storage medium based on the diffusion model proposed by the present invention can solve the problem that the existing image segmentation method is insensitive to non-uniformly distributed noise, resulting in poor segmentation effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 A schematic diagram of a flow chart of an image segmentation method based on a diffusion model provided by an embodiment of the present invention;

[0058] Figure 2 A functional module diagram of an image segmentation system based on a diffusion model provided by an embodiment of the present invention;

[0059] Figure 3 A schematic diagram of the structure of an electronic device for implementing the diffusion model-based image segmentation method provided by an embodiment of the present invention;

[0060] Figure 4 A model flow structure diagram provided for an embodiment of the present invention;

[0061] Figure 5 A structural diagram of a convolution module, a multi-head attention mechanism module, and a feature sampling attention module provided in one embodiment of the present invention;

[0062] Figure 6 This is an image segmentation result diagram provided by an embodiment of the present invention.

[0063] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0064] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0065] The embodiment of the present application provides an image segmentation method based on a diffusion model. The execution subject of the image segmentation method based on the diffusion model includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided in the embodiment of the present application. In other words, the image segmentation method based on the diffusion model can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.

[0066] Reference Figure 1 FIG. 1 is a flow chart of an image segmentation method based on a diffusion model provided by an embodiment of the present invention. In this embodiment, the image segmentation method based on a diffusion model includes:

[0067] S1. Constructing an image pyramid according to a pre-acquired image to be processed through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid.

[0068] In an embodiment of the present invention, the image pyramid is constructed according to the pre-acquired image to be processed by two multi-scale decompositions, and the image pyramid is obtained by converting the image to be processed into multiple images of different scales, and then combining the images of different scales into a pyramid structure according to the size of the image scale. In an embodiment of the present invention, the image pyramid is constructed according to the pre-acquired image to be processed by two multi-scale decompositions to obtain a first image pyramid and a second image pyramid, including:

[0069] Convert the image to be processed into a floating point data format to obtain a floating point format image;

[0070] Performing an operation of intercepting odd and even rows and columns on the floating-point format image to obtain an odd-numbered row and column set and an even-numbered row and column set;

[0071] Downsampling the odd-numbered row and column sets multiple times to obtain data of multiple different scales, and constructing a first image pyramid according to the downsampling set results;

[0072] The even-numbered row and column sets are downsampled multiple times to obtain data of multiple different scales, and a second image golden character is constructed according to the downsampled set results.

[0073] In detail, the converting the floating point data format of the image to be processed may be converting the image to be processed into a 32-bit floating point data format.

[0074] In detail, the floating-point format image is subjected to an operation of truncating odd and even rows and columns to obtain an odd row and column set and an even row and column set. Each operation reduces the length and width of the image by half. After multiple operations, images of different scales are obtained. Therefore, the odd row and column set and the even row and column set are both sets containing images of different scales.

[0075] In detail, the operation of truncating the even and odd rows and columns of the floating-point format image to obtain an odd row and column set and an even row and column set refers to respectively extracting pixel points whose row and column numbers are both odd and even in the floating-point format image to obtain a scaled image, and then re-truncating the even and odd rows and columns of the scaled image to finally obtain four image sets of different scales based on all pixel points whose row and column numbers are odd, and obtain four image sets of different scales based on all pixel points whose row and column numbers are even.

[0076] In detail, the odd-numbered row and column set is downsampled multiple times to obtain data of multiple scales, and the first image pyramid is constructed according to the downsampled set results, which is to construct images of different scales in the odd-numbered row and column set into a pyramid structure according to the scale size to obtain a first pyramid image.

[0077] In detail, the even-numbered row and column set is downsampled multiple times to obtain data of multiple scales, and the second image pyramid is constructed according to the downsampled set results, which is to construct the images of different scales in the even-numbered row and column set into a pyramid structure according to the scale size to obtain a Dier pyramid image.

[0078] In the embodiment of the present invention, an image pyramid is constructed according to a pre-acquired image to be processed through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid, thereby improving the efficiency of subsequent acquisition of dual-pyramid coded data.

[0079] S2. Perform a convolution operation on the second image pyramid using a pre-built model to obtain a feature image pyramid, and perform feature encoding and down-sampling on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data.

[0080] In an embodiment of the present invention, the model is a model with a dual encoding model structure, including an encoding module, a decoding module, a convolution module, a multi-head attention mechanism module, a feature sampling attention module and a diffusion module.

[0081] In detail, the encoding module includes 4 convolution modules, 4 multi-head attention mechanism modules and 4 feature sampling attention modules.

[0082] In detail, the convolution module includes a 3x3 convolution layer, an activation layer, and a batch normalization layer.

[0083] In detail, the decoding module includes 4 convolution modules, 4 multi-head attention mechanism modules and 4 feature sampling attention modules.

[0084] In detail, the multi-head attention mechanism module includes 2 3×3 convolutional layers, 3 fully connected linear layers, and a multi-head attention structure.

[0085] In detail, the feature sampling attention model includes two parallel convolution structures, a global average pooling layer, and two parallel linear fully connected layers.

[0086] In detail, the diffusion module includes 4 convolution modules, each of which includes a 3×3 convolution layer, an activation layer, and a batch normalization layer.

[0087] In the embodiment of the present invention, the feature encoding is a process of converting raw data into a more representative and distinguishable feature representation, which can reduce the data dimension and enhance the feature expression capability.

[0088] In the embodiment of the present invention, downsampling is a process of lowering the data sampling rate, that is, reducing the amount of data while maintaining the main features of the data, which can reduce the amount of data calculation and prevent data overfitting.

[0089] In the embodiment of the present invention, the feature encoding and downsampling of the first image pyramid and the feature image pyramid to obtain the dual pyramid encoded data is to send the first image pyramid and the feature image pyramid to the four convolution layers of the model for feature encoding and downsampling, so the dual pyramid encoded data also has four layers, wherein each convolution layer includes the convolution kernel and a maximum pooling layer, and each convolution layer extracts local features of the image by using the convolution kernel.

[0090] In the embodiment of the present invention, the step of performing a convolution operation on the second image pyramid using a pre-built model to obtain a feature image pyramid includes:

[0091] Using the convolution kernel to slide in the second pyramid image according to a preset step size;

[0092] Extracting local convolution information of the area covered by the convolution kernel on the second pyramid image after each sliding, to obtain a local convolution information collection set;

[0093] The feature image pyramid is constructed according to the local convolution information set.

[0094] In detail, the convolution kernel is a matrix of size 3 by 3.

[0095] In an embodiment of the present invention, a convolution operation is performed on the second image pyramid using a pre-built model to obtain a feature image pyramid, thereby improving the efficiency of subsequently obtaining dual-pyramid encoded data, and feature encoding and down-sampling are performed on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data, thereby improving the efficiency of subsequently obtaining a level set expression set.

[0096] S3. Using the model to obtain a level set expression set according to the dual pyramid encoding data.

[0097] In an embodiment of the present invention, the level set expression set is the final output result of the model. The model outputs an implicit surface function, and the surface function is composed of a set of several 2D plane functions. The level refers to a fixed value of the surface function, that is, the position of the 0 level, which can be used for image boundary segmentation.

[0098] In the embodiment of the present invention, the step of obtaining a level set expression set according to the dual pyramid coded data using the model includes:

[0099] Using the convolution module and the multi-head attention mechanism module of the model to perform feature encoding on the dual pyramid encoded data to obtain a feature encoding result set;

[0100] Performing feature fusion on all feature encoding results of the feature encoding result set to obtain a feature fusion result;

[0101] Using the decoding layer of the model to perform feature decoding on the feature fusion node to obtain a feature decoding result;

[0102] The feature decoding results are subjected to feature fusion to obtain a level set expression set.

[0103] In detail, the feature fusion is performed on all the feature encoding results of the feature encoding result set to obtain the feature fusion result, which is to use the attention mechanism to extract the high-attention parts of different features, and then fuse the high-attention parts.

[0104] In detail, the multi-head attention mechanism module is the core component of the model, which obtains the attention distribution of different subspaces of the input sequence by running multiple independent attention mechanisms in parallel, thereby more comprehensively capturing the potential multiple semantic associations in the sequence.

[0105] In the embodiment of the present invention, the step of performing feature fusion on all feature encoding results of the feature encoding result set to obtain a feature fusion result includes:

[0106] Taking out the elements in the feature code set in pairs to obtain a data pair set;

[0107] The feature sampling attention mechanism module of the model is used to extract the attention matrix of each data pair in the data pair set through convolution operation and average pooling operation to obtain a matrix set;

[0108] Multiply each data pair in the data pair set by its corresponding attention matrix in the matrix set to obtain an element matrix;

[0109] All elements in the element matrix are added together to obtain a feature fusion result.

[0110] In detail, the feature sampling attention mechanism module is an attention mechanism in deep learning, which improves the performance and efficiency of the model by focusing on the key information in the input feature map. The feature sampling attention mechanism can help the model identify key areas in the image, such as in the target detection task. By giving higher weights to important features, the model can more accurately locate and identify the target object.

[0111] In the embodiment of the present invention, by using the model to obtain a level set expression set according to the dual pyramid encoding data, the accuracy of the subsequent output of the final predicted segmentation mask is improved.

[0112] S4. Utilize the diffusion module of the model to output a final predicted segmentation mask according to the level set expression set.

[0113] In an embodiment of the present invention, the step of using the diffusion module of the model to output a final predicted segmentation mask according to the level set expression set includes:

[0114] Dividing the feature fusion result into a plurality of batch samples of size 4×4 to obtain a batch sample set;

[0115] Using a convolution kernel of size 1×1 to perform a convolution operation on each batch sample in the batch sample set to obtain batch sample features;

[0116] Encoding the level set expression set using two convolution kernels of size 1×1 to obtain a position information encoding result;

[0117] Superimposing the position information encoding knot and the batch sample feature in a second dimension to obtain a superposition result, and performing a convolution operation on the superposition result to obtain a zero level set bias;

[0118] Adding the level set expression set to the zero level set bias to obtain a predicted zero level set position;

[0119] Determine whether the current number of iterations reaches the preset target number of iterations;

[0120] If the current number of iterations does not reach the target number of iterations, the step of dividing the feature fusion result into a plurality of batch samples of a size of 4 times 4 to obtain a batch sample set is re-executed.

[0121] The predicted zero level set position is compared with the level set expression set, and the values ​​in the level set expression set that are greater than the predicted zero level set position are set to 1, and the values ​​of the remaining positions are set to 0, to obtain a final predicted segmentation mask.

[0122] In detail, superimposing the position information encoding knot and the batch sample feature in the second dimension refers to superimposing the position information encoding knot and the batch sample feature in the channel dimension.

[0123] In detail, the method of using the diffusion module to predict the zero level set position according to the level set expression set output is to initialize the number of iterations, the output of the decoding module, and the predicted zero level set position, encode the zero level set position through two linear layers and concatenate it with the output of the decoding module after mean pooling encoding, add it to the number of iterations, and finally output the predicted zero level set position through a linear layer. After multiple iterations, the predicted zero level set position is output.

[0124] In the embodiment of the present invention, the diffusion module of the model is used to output the final predicted segmentation mask according to the level set expression set, thereby improving the efficiency of subsequent calculation of the mean square error.

[0125] S5. Calculate the mean square error between the level set expression set and the final predicted segmentation mask and the preset manual annotation mask respectively to obtain a first mean square error and a second mean square error.

[0126] In the embodiment of the present invention, the first mean square error and the second mean square error are numerical values ​​representing the difference between the level set expression set and the final predicted segmentation mask and a preset manually labeled mask.

[0127] In the embodiment of the present invention, the preset manual annotation mask refers to accurate annotation information of the segmented area of ​​the image to be processed.

[0128] In the embodiment of the present invention, respectively calculating the mean square errors of the level set expression set and the final predicted segmentation mask and the preset manual annotation mask to obtain the first mean square error and the second mean square error includes:

[0129] The first mean square error and the second mean square error are calculated using the following formula:

[0130]

[0131] Wherein, M1 is the first mean square error, M2 is the second mean square error, n is the number of samples in the level set expression set, x i represents the i-th sample in the level set expression set, y i represents the i-th sample in the final predicted segmentation mask, z i represents the i-th sample in the manually labeled mask.

[0132] In the embodiment of the present invention, by respectively calculating the mean square errors between the level set expression set and the final predicted segmentation mask and the preset manually labeled mask, a first mean square error and a second mean square error are obtained, thereby improving the efficiency of subsequent optimization of the model.

[0133] S6. Optimize the model according to the first mean square error and the second mean square error. When the optimization of the model reaches a preset number of iterations, confirm that the image segmentation model is obtained.

[0134] In an embodiment of the present invention, optimizing the model according to the first mean square error and the second mean square error is performed by calculating the mean between the first mean square error and the second mean square error, and optimizing the hyperparameters of the model according to the mean using a back propagation algorithm until a preset number of optimization iterations is reached.

[0135] In detail, each time after the hyperparameters of the model are optimized using the back propagation algorithm according to the mean, a new image to be processed is obtained as a training sample, and the steps of finally calculating the first mean square error and the second mean square error according to the image to be processed are re-executed.

[0136] In detail, the preset number of optimization iterations may be 100.

[0137] For details, refer to Figure 4 As shown, a model process structure diagram is provided for an embodiment of the present invention.

[0138] In detail, the parameters Figure 5 As shown, a structural diagram of a convolution module, a multi-head attention mechanism module, and a feature sampling attention module is provided for an embodiment of the present invention.

[0139] In an embodiment of the present invention, by optimizing the model according to the first mean square error and the second mean square error, when the model is optimized for a preset number of iterations, it is confirmed that an image segmentation model is obtained, thereby improving the effect of subsequent image segmentation.

[0140] S7. Perform image segmentation on the image to be segmented using the image segmentation model to obtain an image segmentation result.

[0141] In an embodiment of the present invention, the image segmentation model is used to perform image segmentation on the image to be segmented to obtain an image segmentation result, which is achieved by constructing an image pyramid according to the image to be processed to obtain a first image pyramid and a second image pyramid, performing a convolution operation on the second image pyramid to obtain a feature image pyramid, performing feature encoding and downsampling on the first image pyramid and the feature image pyramid to obtain dual pyramid encoding data, obtaining a level set expression set according to the dual pyramid encoding data, outputting a predicted zero level set position according to the level set expression set, outputting a final prediction area by combining the level set expression set and the predicted zero level set position, and performing image segmentation according to the final prediction area.

[0142] Reference Figure 6 The figure shows an image segmentation result diagram provided by an embodiment of the present invention (from left to right: input sample, predicted segmentation result, manual annotation result).

[0143] In the embodiment of the present invention, the image segmentation model is used to perform image segmentation on the image to be segmented to obtain an image segmentation result, thereby improving the effect of image segmentation.

[0144] like Figure 2 , which is a functional module diagram of an image segmentation system based on a diffusion model provided by an embodiment of the present invention.

[0145] The image segmentation system 100 based on the diffusion model of the present invention can be installed in an electronic device. According to the functions to be implemented, the image segmentation system 100 based on the diffusion model can include a pyramid construction module 101, a data encoding module 102, a data prediction module 103, a model iteration module 104 and an image segmentation module 105. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by a processor of an electronic device and can complete fixed functions, which are stored in the memory of the electronic device.

[0146] In this embodiment, the functions of each module / unit are as follows:

[0147] The image pyramid construction module 101 is used to construct an image pyramid according to the pre-acquired to-be-processed image through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid;

[0148] The data encoding module 102 is used to perform a convolution operation on the second image pyramid using a pre-built model to obtain a feature image pyramid, and perform feature encoding and down-sampling on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data;

[0149] The data prediction module 103 is used to obtain a level set expression set according to the dual pyramid coded data using the model, and output a final predicted segmentation mask according to the level set expression set using the diffusion module of the model;

[0150] The model iteration module 104 is used to respectively calculate the mean square error between the level set expression set and the final predicted segmentation mask and the preset manual annotation mask to obtain a first mean square error and a second mean square error, optimize the model according to the first mean square error and the second mean square error, and confirm that the image segmentation model is obtained after the optimization of the model reaches a preset number of iterations;

[0151] The image segmentation module 105 is used to perform image segmentation on the image to be segmented using the image segmentation model to obtain an image segmentation result.

[0152] In detail, each module described in the diffusion model-based image segmentation system 100 in the embodiment of the present invention is used in the same manner as described above. Figure 1 The image segmentation method based on the diffusion model described in the invention has the same technical means and can produce the same technical effect, so it will not be repeated here.

[0153] like Figure 3 , which is a schematic diagram of the structure of an electronic device of an image segmentation method based on a diffusion model provided in an embodiment of the present invention.

[0154] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as an image segmentation program based on a diffusion model.

[0155] In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 10 is the control core (ControlUnit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as image segmentation programs based on diffusion models, etc.) stored in the memory 11, and calls data stored in the memory 11 to execute various functions of the electronic device and process data.

[0156] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device, such as the code of an image segmentation program based on a diffusion model, but may also be used to temporarily store data that has been output or is to be output.

[0157] The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.

[0158] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in this embodiment, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.

[0159] The figure only shows an electronic device with components. Those skilled in the art will understand that the structure shown in the figure does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0160] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0161] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0162] The image segmentation program based on the diffusion model stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:

[0163] An image pyramid is constructed according to the pre-acquired image to be processed through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid;

[0164] Using a pre-built model, a convolution operation is performed on the second image pyramid to obtain a feature image pyramid, and feature encoding and down-sampling are performed on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data;

[0165] Using the model to obtain a level set expression set according to the dual pyramid encoding data;

[0166] Outputting a final predicted segmentation mask according to the level set expression set using a diffusion module of the model;

[0167] Respectively calculating the mean square errors of the level set expression set and the final predicted segmentation mask and the preset manual annotation mask to obtain a first mean square error and a second mean square error;

[0168] Optimizing the model according to the first mean square error and the second mean square error, and confirming that an image segmentation model is obtained after the optimization of the model reaches a preset number of iterations;

[0169] The image segmentation model is used to perform image segmentation on the image to be segmented to obtain an image segmentation result.

[0170] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.

[0171] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0172] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:

[0173] An image pyramid is constructed according to the pre-acquired image to be processed through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid;

[0174] Using a pre-built model, a convolution operation is performed on the second image pyramid to obtain a feature image pyramid, and feature encoding and down-sampling are performed on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data;

[0175] Using the model to obtain a level set expression set according to the dual pyramid encoding data;

[0176] Outputting a final predicted segmentation mask according to the level set expression set using a diffusion module of the model;

[0177] Respectively calculating the mean square errors of the level set expression set and the final predicted segmentation mask and the preset manual annotation mask to obtain a first mean square error and a second mean square error;

[0178] Optimizing the model according to the first mean square error and the second mean square error, and confirming that an image segmentation model is obtained after the optimization of the model reaches a preset number of iterations;

[0179] The image segmentation model is used to perform image segmentation on the image to be segmented to obtain an image segmentation result.

[0180] In the embodiments provided by the present invention, it should be understood that the disclosed devices, systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

[0181] The modules described as separate components may or may not be physically separated, and the components shown as modules 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0182] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0183] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0184] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0185] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0186] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

[0187] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. An image segmentation method based on a diffusion model, characterized in that: The method comprises: An image pyramid is constructed according to the pre-acquired image to be processed through two multi-scale decompositions to obtain a first image pyramid and a second image pyramid; Using a pre-built model, a convolution operation is performed on the second image pyramid to obtain a feature image pyramid, and feature encoding and down-sampling are performed on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data; Using the model to obtain a level set expression set according to the dual pyramid encoding data; Outputting a final predicted segmentation mask according to the level set expression set using a diffusion module of the model; Respectively calculating the mean square errors of the level set expression set and the final predicted segmentation mask and the preset manual annotation mask to obtain a first mean square error and a second mean square error; Optimizing the model according to the first mean square error and the second mean square error, and confirming that an image segmentation model is obtained after the optimization of the model reaches a preset number of iterations; The image segmentation model is used to perform image segmentation on the image to be segmented to obtain an image segmentation result.

2. The image segmentation method based on diffusion model according to claim 1, characterized in that: The method of constructing an image pyramid according to the pre-acquired to-be-processed image by two multi-scale decompositions to obtain a first image pyramid and a second image pyramid includes: Convert the image to be processed into a floating point data format to obtain a floating point format image; Performing an operation of intercepting odd and even rows and columns on the floating-point format image to obtain an odd-numbered row and column set and an even-numbered row and column set; Downsampling the odd-numbered row and column sets multiple times to obtain data of multiple different scales, and constructing a first image pyramid according to the downsampling set results; The even-numbered row and column sets are downsampled multiple times to obtain data of multiple different scales, and a second image golden character is constructed according to the downsampled set results.

3. The image segmentation method based on diffusion model according to claim 2, characterized in that: The using the pre-built model to perform a convolution operation on the second image pyramid to obtain a feature image pyramid includes: Using the convolution kernel to slide in the second pyramid image according to a preset step size; Extracting local convolution information of the area covered by the convolution kernel on the second pyramid image after each sliding, to obtain a local convolution information collection set; The feature image pyramid is constructed according to the local convolution information set.

4. The image segmentation method based on diffusion model according to claim 1, characterized in that: The step of using the model to obtain a level set expression set according to the dual pyramid encoding data includes: Using the convolution module and the multi-head attention mechanism module of the model to perform feature encoding on the dual pyramid encoded data to obtain a feature encoding result set; Performing feature fusion on all feature encoding results of the feature encoding result set to obtain a feature fusion result; Using the decoding layer of the model to perform feature decoding on the feature fusion node to obtain a feature decoding result; The feature decoding results are subjected to feature fusion to obtain a level set expression set.

5. The image segmentation method based on diffusion model according to claim 1, characterized in that: The step of performing feature fusion on all feature encoding results of the feature encoding result set to obtain a feature fusion result includes: Taking out the elements in the feature code set in pairs to obtain a data pair set; The feature sampling attention mechanism module of the model is used to extract the attention matrix of each data pair in the data pair set through convolution operation and average pooling operation to obtain a matrix set; Multiply each data pair in the data pair set by its corresponding attention matrix in the matrix set to obtain an element matrix; All elements in the element matrix are added together to obtain a feature fusion result.

6. The image segmentation method based on diffusion model according to claim 1, characterized in that: The method of using the diffusion module of the model to output a final predicted segmentation mask according to the level set expression set includes: Dividing the feature fusion result into a plurality of batch samples of size 4×4 to obtain a batch sample set; Using a convolution kernel of size 1×1 to perform a convolution operation on each batch sample in the batch sample set to obtain batch sample features; Encoding the level set expression set using two convolution kernels of size 1×1 to obtain a position information encoding result; Superimposing the position information encoding knot and the batch sample feature in a second dimension to obtain a superposition result, and performing a convolution operation on the superposition result to obtain a zero level set bias; Adding the level set expression set to the zero level set bias to obtain a predicted zero level set position; Determine whether the current number of iterations reaches the preset target number of iterations; If the current number of iterations does not reach the target number of iterations, the step of dividing the feature fusion result into a plurality of batch samples of a size of 4 times 4 to obtain a batch sample set is re-executed. The predicted zero level set position is compared with the level set expression set, and the values ​​in the level set expression set that are greater than the predicted zero level set position are set to 1, and the values ​​of the remaining positions are set to 0, to obtain a final predicted segmentation mask.

7. The image segmentation method based on diffusion model according to claim 6, characterized in that: The step of respectively calculating the mean square errors of the level set expression set and the final predicted segmentation mask and the preset manually labeled mask to obtain a first mean square error and a second mean square error includes: The first mean square error and the second mean square error are calculated using the following formula: Wherein, M1 is the first mean square error, M2 is the second mean square error, n is the number of samples in the level set expression set, x i represents the i-th sample in the level set expression set, y i represents the i-th sample in the final predicted segmentation mask, z i represents the i-th sample in the manually labeled mask.

8. An image segmentation system based on a diffusion model, characterized in that: The system comprises: An image pyramid construction module is used to construct an image pyramid according to a pre-acquired image to be processed by performing two multi-scale decompositions to obtain a first image pyramid and a second image pyramid; A data encoding module, configured to perform a convolution operation on the second image pyramid using a pre-built model to obtain a feature image pyramid, and perform feature encoding and down-sampling on the first image pyramid and the feature image pyramid to obtain dual-pyramid encoded data; A data prediction module, used to obtain a level set expression set according to the dual pyramid encoding data using the model, and output a final predicted segmentation mask according to the level set expression set using a diffusion module of the model; A model iteration module, used to respectively calculate the mean square error between the level set expression set and the final predicted segmentation mask and a preset manually labeled mask to obtain a first mean square error and a second mean square error, optimize the model according to the first mean square error and the second mean square error, and confirm that the image segmentation model is obtained after the optimization of the model reaches a preset number of iterations; The image segmentation module is used to perform image segmentation on the image to be segmented using the image segmentation model to obtain an image segmentation result.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the diffusion model-based image segmentation method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the diffusion model-based image segmentation method according to any one of claims 1 to 7 is implemented.