Disclosure of Invention
The invention solves the problem of providing a method for segmenting the foreground in the three-dimensional image, which is simple to realize and can quickly and stably extract the foreground in the three-dimensional medical image.
In order to solve the above problems, the present invention provides a method for segmenting a foreground in a three-dimensional image, comprising the following steps:
(1) inputting the three-dimensional image, and calculating the image constraint foreground probability of each pixel point in the three-dimensional image; recording the foreground mask of the three-dimensional image as M, M(1)Is an initial foreground mask;
(2) based on the current foreground mask M(k)Calculating the shape constraint foreground probability of each pixel point in the three-dimensional imageWherein k is iteration times, and k is more than or equal to 1;
(3) constraining the foreground probability based on the image and shapeGet the next foreground mask M(k+1);
(4) If the current foreground mask M(k)And the next foreground mask M(k+1)Is less than a predetermined value or number of iterationsk is equal to the predetermined maximum number of iterations, the iteration is ended, and the current foreground mask M(k)Namely the foreground to be segmented; otherwise, the step (2) is returned, and k is increased by 1.
In the method for segmenting the foreground in the three-dimensional image, the image constraint foreground probability p of each pixel point in the three-dimensional image is calculated1(X)The process comprises the following steps: 1) binarizing the three-dimensional image to obtain a binarized image; 2) carrying out spatial filtering and transformation on the binary image to obtain the image constraint foreground probability p1(X)。
In the method for segmenting the foreground in the three-dimensional image, the image constraint foreground probability p is obtained1(X)The formula of (1) is:
<math>
<mrow>
<msub>
<mi>p</mi>
<mrow>
<mn>1</mn>
<mrow>
<mo>(</mo>
<mi>X</mi>
<mo>)</mo>
</mrow>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi>g</mi>
<mn>1</mn>
</msub>
<mrow>
<mo>(</mo>
<msub>
<mi>G</mi>
<msub>
<mi>σ</mi>
<mn>1</mn>
</msub>
</msub>
<mo>⊗</mo>
<msub>
<mi>I</mi>
<mi>b</mi>
</msub>
<mo>)</mo>
</mrow>
</mrow>
</math>
wherein X represents the spatial position of any pixel point in the three-dimensional image; g1Is a transformation function;is a spatial filter operator;representing a convolution operation; i isbAnd obtaining the binary image.
The method for segmenting the foreground in the three-dimensional image comprises the following stepsComputing the shape constrained foreground probabilityThe formula of (1) is:
<math>
<mrow>
<msubsup>
<mi>p</mi>
<mrow>
<mn>2</mn>
<mrow>
<mo>(</mo>
<mi>X</mi>
<mo>)</mo>
</mrow>
</mrow>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
<mo>)</mo>
</mrow>
</msubsup>
<mo>=</mo>
<msub>
<mi>g</mi>
<mn>2</mn>
</msub>
<mrow>
<mo>(</mo>
<msub>
<mi>G</mi>
<msub>
<mi>σ</mi>
<mn>2</mn>
</msub>
</msub>
<mo>⊗</mo>
<msup>
<mi>M</mi>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>)</mo>
</mrow>
</msup>
<mo>)</mo>
</mrow>
</mrow>
</math>
wherein, g2Is a transformation function;is a spatial filter operator;representing a convolution operation; k is the number of iterations; and X represents the spatial position of any pixel point in the three-dimensional image.
In the method for segmenting the foreground in the three-dimensional image, the next foreground mask M is obtained(k+1)The process comprises the following steps:
1) constraining the image to a foreground probability p1(X)And the shape constrained foreground probabilityCombining to obtain each pixel point in the three-dimensional imageProbability of becoming foreground
2) For the foreground probabilityCarrying out binarization to obtain a temporary foreground mask;
3) carrying out spatial smoothing filtering and binarization on the temporary foreground mask to obtain the next foreground mask M(k+1)。
The method for segmenting the foreground in the three-dimensional image, wherein the formula of the combination isWherein w is the foreground probabilityIn (c) p1(X)0 < w < 1.
The method for segmenting the foreground in the three-dimensional image, wherein the formula of the combination is
In the method for segmenting the foreground in the three-dimensional image, the next foreground mask M is obtained(k+1)The formula of (1) is:
<math>
<mrow>
<msup>
<mi>M</mi>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
<mo>)</mo>
</mrow>
</msup>
<mo>=</mo>
<mi>I</mi>
<mo>[</mo>
<mrow>
<mo>(</mo>
<msub>
<mi>G</mi>
<msub>
<mi>σ</mi>
<mn>3</mn>
</msub>
</msub>
<mo>⊗</mo>
<mi>I</mi>
<mo>[</mo>
<msup>
<mi>p</mi>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
<mo>)</mo>
</mrow>
</msup>
<mo>></mo>
<msub>
<mi>t</mi>
<mn>2</mn>
</msub>
<mo>]</mo>
<mo>)</mo>
</mrow>
<mo>></mo>
<msub>
<mi>t</mi>
<mn>3</mn>
</msub>
<mo>]</mo>
</mrow>
</math>
wherein,is a spatial filter operator;representing a convolution operation; i is an index function, when inequalities in variables of the index function are satisfied, the value is 1, otherwise, the value is 0; t is t2And t3Is a predetermined threshold.
The method for segmenting the foreground in the three-dimensional image, wherein the value range of the preset value is 0.000001-0.001.
The method for segmenting the foreground in the three-dimensional image, wherein the value range of the preset maximum iteration number is 10-20.
Compared with the prior art, the whole process of the invention can be completed by carrying out spatial filtering and simple arithmetic operation after the image is binarized, and compared with an active contour model, the method has low complexity and high calculation speed;
further, based on shape constraints and region growing, the feature of the image itself and the shape feature of the mask are used simultaneously, and therefore higher stability is achieved.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. This invention may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein, but rather construed as limited to the embodiments set forth herein.
Next, the present invention is described in detail by using schematic diagrams, and when the embodiments of the present invention are described in detail, the schematic diagrams are only examples for convenience of description, and the scope of the present invention should not be limited herein.
The following describes a method for segmenting the foreground in the three-dimensional image in detail with reference to the accompanying drawings and embodiments. As shown in fig. 1, the method for segmenting the foreground in the three-dimensional image according to the embodiment of the present invention first executes step S1, and inputs the three-dimensional image and the initial foreground mask M(1). Wherein M is a foreground mask of the three-dimensional image. In this embodiment, the input three-dimensional image is a CT abdominal image, and the foreground of the required segmentation is the liver (or spleen) of the CT image.
Then, step S2 is executed to calculate an image constraint foreground probability p of each pixel point in the three-dimensional image1(X). Wherein p is1(X)=p1(X)(O ═ 1| X), X is the spatial position of any pixel in the three-dimensional image,specifically, calculating the image constraint foreground probability p of any pixel point p in the three-dimensional image1(X)The process comprises the following steps: 1) binarizing the three-dimensional image by methods of setting a threshold value, a K-means clustering algorithm and the like to obtain a binarized image, namely extracting pixel points of gray values in an interested gray value interval in the three-dimensional image; 2) carrying out spatial filtering and transformation on the binary image, and obtaining the image constraint foreground probability p through a formula (1)1(X)The formula (1) is:
<math>
<mrow>
<msub>
<mi>p</mi>
<mrow>
<mn>1</mn>
<mrow>
<mo>(</mo>
<mi>X</mi>
<mo>)</mo>
</mrow>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi>g</mi>
<mn>1</mn>
</msub>
<mrow>
<mo>(</mo>
<msub>
<mi>G</mi>
<msub>
<mi>σ</mi>
<mn>1</mn>
</msub>
</msub>
<mo>⊗</mo>
<msub>
<mi>I</mi>
<mi>b</mi>
</msub>
<mo>)</mo>
</mrow>
</mrow>
</math>
wherein X represents the spatial position of any pixel point in the three-dimensional image; g1Is a transformation function;is a spatial filter operator;representing a convolution operation; i isbAnd obtaining the binary image.
In this embodiment, first, a threshold method is used to binarize a CT abdominal image, and pixel points in the CT abdominal image whose gray values belong to a liver gray value interval are extracted to obtain a binarized image. And then, carrying out spatial filtering and transformation on the binary image through the formula (1) to obtain the image constraint foreground probability of each pixel point in the CT abdominal image. Wherein,width σ in three-dimensional direction for moving average filter1=[2,2,2]mm, transformation function of g1(t)=t。
Next, step S3 is executed to obtain the current foreground mask M(k)Calculating the shape constraint foreground probability of each pixel point in the three-dimensional imageWherein k is iteration number, k is more than or equal to 1, and when k is 1, the foreground mask M(1)The initial foreground mask entered in step S1. Specifically, the foreground mask M is masked by formula (2)(k)Performing spatial filtering and transformation to obtain shape constraint foreground probabilityThe formula (2) is:
<math>
<mrow>
<msubsup>
<mi>p</mi>
<mrow>
<mn>2</mn>
<mrow>
<mo>(</mo>
<mi>X</mi>
<mo>)</mo>
</mrow>
</mrow>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
<mo>)</mo>
</mrow>
</msubsup>
<mo>=</mo>
<msub>
<mi>g</mi>
<mn>2</mn>
</msub>
<mrow>
<mo>(</mo>
<msub>
<mi>G</mi>
<msub>
<mi>σ</mi>
<mn>2</mn>
</msub>
</msub>
<mo>⊗</mo>
<msup>
<mi>M</mi>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>)</mo>
</mrow>
</msup>
<mo>)</mo>
</mrow>
</mrow>
</math>
wherein, g2Is a transformation function;is a spatial filter operator;representing a convolution operation; k is the number of iterations; and X represents the spatial position of any pixel point in the three-dimensional image.
In the present embodiment, for the liver in the CT abdomen image, the initial foreground mask M is applied to the inputted liver according to the formula (2)(1)Performing spatial filtering and transformation, namely performing first region increase (first iteration) on the initial foreground mask to obtain shape constraint foreground probability of performing first region increase on any pixel point in the CT abdominal imageThe function of the transformation is g1(t)=t2。
Next, step S4 is executed to constrain foreground probability and shape based on the imageGet the next foreground mask M(k+1). Specifically, the next foreground mask M is obtained(k+1)As shown in fig. 2, first, step S201 is executed to constrain the image to a foreground probability p1(X)And the shape constrained foreground probabilityCombining to obtain the probability that each pixel point in the three-dimensional image becomes foregroundIn particular, by means of a linear opinion pool, i.e. formulaConstraining the foreground probability p to the image1(X)And shape constrained foreground probabilityCombining, wherein w is the foreground probabilityIn (c) p1(X)0 < w < 1; or by pools of logarithmic opinions, i.e. formulae Constraining the foreground probability p to the image1(X)And shape constrained foreground probabilityAnd (4) combining. In the present embodiment, the foreground probability p is constrained to the image obtained in step S2 by the logarithm opinion pool1(X)And the shape-constrained foreground probability obtained in step S3Combining to obtain the probability that any pixel point in the first region increase CT abdominal image belongs to the liver
Then, step S202 is executed to determine the foreground probabilityAnd carrying out binarization to obtain a temporary foreground mask. Specifically, all foreground probabilities are combinedAnd comparing the value with a preset threshold, if the value is larger than the preset threshold, assigning the value to be 1, and if the value is smaller than or equal to the preset threshold, assigning the value to be 0. In the present embodiment, the probability of becoming foreground in step S201And assigning the value of the pixel point larger than 0.5 to be 1, and assigning the value of the rest pixel points to be 0, so that the temporary foreground mask for the first region increase is obtained.
Next, step S203 is executed to perform spatial smoothing filtering and binarization on the temporary foreground mask to obtain the next foreground mask M(k+1)I.e. by
<math>
<mrow>
<msup>
<mi>M</mi>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
<mo>)</mo>
</mrow>
</msup>
<mo>=</mo>
<mi>I</mi>
<mo>[</mo>
<mrow>
<mo>(</mo>
<msub>
<mi>G</mi>
<msub>
<mi>σ</mi>
<mn>3</mn>
</msub>
</msub>
<mo>⊗</mo>
<mi>I</mi>
<mo>[</mo>
<msubsup>
<mi>p</mi>
<mrow>
<mo>(</mo>
<mi>X</mi>
<mo>)</mo>
</mrow>
<mrow>
<mo>(</mo>
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
<mo>)</mo>
</mrow>
</msubsup>
<mo>></mo>
<msub>
<mi>t</mi>
<mn>2</mn>
</msub>
<mo>]</mo>
<mo>)</mo>
</mrow>
<mo>></mo>
<msub>
<mi>t</mi>
<mn>3</mn>
</msub>
<mo>]</mo>
</mrow>
</math>
Wherein,is a spatial filter operator;representing a convolution operation; i is an index function, when inequalities in variables of the index function are satisfied, the value is 1, otherwise, the value is 0; t is t2And t3Is a predetermined threshold.
In this embodiment, the temporary foreground mask obtained in step S203 is subjected to spatial smoothing filtering, and the smoothed foreground mask is binarized, that is, the value of the pixel value of the smoothed temporary foreground mask greater than 0.5 is assigned to 1, and the other pixel values are assigned to 0, where the binarized image is the foreground mask M(2)。
Next, step S5 is executed to compare the foreground mask M(k)And a foreground mask M(k+1)Or comparing the iteration number k with a predetermined maximum iteration number, if the current foreground mask M is(k)And the next foreground mask M(k+1)Is less than a predetermined value or k is equal to a predetermined maximum number of iterations, step S6 is executed, the iteration is ended, and the current foreground mask M(k)The foreground to be segmented is obtained; if the current foreground mask M(k)And the next foreground mask M(k+1)If the change is equal to or greater than the predetermined value or k is smaller than the predetermined maximum number of iterations, the process returns to step S3, and the number of iterations k is increased by 1. Wherein, the change between the foreground masks can be an absolute value of the relative volume change of the foreground masks and the foreground masks; the value range of the preset value is 0.000001-0.001; the predetermined maximum number of iterations ranges from 10 to 20. In this embodiment, the foreground mask M obtained in step S203 is used(2)And an initial foreground mask M of the input liver(1)Is compared, and if the volume is greater than or equal to the predetermined value, the step S3 is executed again, and the foreground mask M is obtained(2)The same method is used to obtain the foreground mask M(3)Then mask the foreground with a mask M(2)And a foreground mask M(3)Comparing the volumes of (a); if the foreground mask M(2)And an initial foreground mask M of the input liver(1)Is less than a predetermined value, the initial foreground mask M(1)I.e. the foreground of the desired segmentation. And foreground mask M(1)And a foreground mask M(2)Ratio of (A) to (B)More equally, the foreground mask M(2)And a foreground mask M(3)Is less than a predetermined value, the foreground mask M(2)And if not, continuously calculating the next foreground mask until the change of the foreground mask in the two previous and next times is smaller than a preset value. In addition, in the embodiment, the predetermined maximum number of iterations is 12, and if the iteration reaches the 12 th iteration, the foreground mask M(12)And a foreground mask M(13)Is still greater than or equal to the predetermined value, at this point, the iteration is also ended, the foreground mask M(12)I.e. the foreground of the desired segmentation.
As shown in FIG. 3, the graphs (a) and (b) are the liver position and the spleen position obtained by the present method, respectively, and the graphs (c) and (d) are the liver position and the spleen position obtained by the conventional region growing method, respectively. It can be seen from the figure that with the same gray threshold and iteration times, a large number of mistakenly-segmented pixel points appear in the traditional region growing method, and the method can well retain the shapes of corresponding organs by segmenting the liver and the spleen in the CT abdominal image.
Although the present invention has been described with reference to the preferred embodiments, it is not intended to limit the present invention, and those skilled in the art can make variations and modifications of the present invention without departing from the spirit and scope of the present invention by using the methods and technical contents disclosed above.