grayscale segmentation from binary mask


(Marco Festugato) #1

Hi guys, I’ve roughly segmented the liver using confidence connected. I have obtained a binary mask but what I need is to create an image containing ONLY the segmented liver using that mask. What I have to do is like ‘multiplying’ my mask with the image in order to get only the segmented part (the white ones)…how do i do this? I’ve tried doing: image * mask but it doesnt work…
Any help would be much appreciated! Thanks in advance


(Matt McCormick) #2

Hi @Marco_Festugato,

There are a few options:


(Marco Festugato) #3

Hi matt and thank u for your answer. That is exactly what I was looking for, thank u very much!! And thank u again for the ‘‘itkSoftwareGuide’’, it is saving me so much!
Best regards


(Marco Festugato) #4

Hi @matt.mccormick and sorry to bother u! I’ve got this problem… why, in the segmented image, is it gray in the background instead of black?

I think it’s a problem in the parameter i set using confidence connected (for the liver segmentation) and the MaskImageFilter

confidenceConnected->SetMultiplier( 2.2 );
confidenceConnected->SetNumberOfIterations( 5 );
confidenceConnected->SetReplaceValue( 255 );
confidenceConnected->SetSeed( index );
confidenceConnected->SetInitialNeighborhoodRadius( 2 );

voting->SetRadius( indexRadius );
voting->SetBackgroundValue( 0 );
voting->SetForegroundValue( 255 );
voting->SetMajorityThreshold( 2 );
voting->SetMaximumNumberOfIterations( 15 );

Note: before segmentation, I changed the pixel type of the original image from ‘signed short’ to ‘float’ and I rescaled it between 0 and 1… is this actually affecting the MaskImageFilter? One last thing… the intensity of the pixel in the ‘segmented image’ look different from the ‘Input image’, why? Should I care? Should I not perform rescaling?

Thanks in advance for your precious help!


(Matt McCormick) #5

Hi @Marco_Festugato,

Good questions.

We usually just rescale outputs to make it easier for visualization tools. Many visualization tools just support unsigned char pixel types, which means a range of values from 0 to 255, and they do not support dynamically adjusting the window / level, i.e. how values are mapped to colors.

The color black is dependent on the color mapping settings of the visualization tool.

Many tools we work with for image analysis support multiple pixel types and dynamically adjusting the window / level.

Try:

to name a few.


(Dženan Zukić) #6

“Black” in CT is -1000, not zero. Zero is water, which appears gray. You should set -1000 as OutsideValue in MaskImageFilter.


(Marco Festugato) #7

Ty again @matt.mccormick for your kind answer. I dont think it’s a visualization problem because I’ve opened one of my images with MATLAB and i verified that i dont have the value of 0 in the background but 1024 :frowning:

Maybe i should have been more precisely from the beginning…i have 199 dicom images (CT), from which i segmented the liver (but first i converted the pixel type from ‘signed short’ to ‘float’ and rescaled it between 0 and 1). Now it is mandatory for my project to save the 3d volume of only the segmented liver in 199 dicom images… i symply use a CastFilter from ‘float’ to ‘signed short’ and use the example i found in "DicomSeriesReadSeriesWrite.cxx’’ to first read the series in a volume and then write the volume of the segmented liver in a serie of images… should i rescale first the images in the original range before re-casting? Does this anything to do with the fact that i dont have ‘0’ in the background as i want??

Thank u very much for your help!


(Marco Festugato) #8

hi @dzenanz and thank u for your answer. My range is between 0 and 1, so i set the background value to 0… i tried change it but what i got was a binary image :thinking:


(Eric Kischell) #9

Marco et al,
I am also looking at segmenting the liver from CT images.
I am interested in automatic techniques.
My best leads are:

  1. SimpleITK – for loading and preprocessing
  2. https://github.com/IBBM/Cascaded-FCN – this seems really hopeful
  3. https://imagej.net/Trainable_Weka_Segmentation – need Weka models or create them myself
    I would be willing to share my best approach with you.

I had the following questions on your approach:

  1. Are you performing any preprocessing of your CT images to remove noise?
  2. Is your approach manual, semi-automatic, or fully automatic?
  3. How did you set your seed points?
  4. Can you share your ITK prototype source code?

thx in advance
e.-


(Marco Festugato) #10

Hi @keesh!

  1. Im thinking about performing some noise removal (mean filter) but i havent used it yet;
  2. semi-automatic, I used a simple region growing technique. It’s not perfect but it works fine for our project;
  3. using 3D Slicer (from Kitware as well, and free!). U can also use MATLAB;
  4. Not yet!

(Eric Kischell) #11

Marco,
Thanks for your quick response.
If I achieve decent results on any single stage then I will share them.
thx e.-