Solution:AW: [Insight-users] Question about itk::ThresholdSegmentationLevelSetImageFilter

Luis Ibanez luis.ibanez at kitware.com
Thu, 29 Jan 2004 09:46:34 -0500


Hi Chunyan,


Thanks for letting us know.


Just for the record, you could avoid converting
the images to PNG and use a more powerful image
file format, such as Analyze, MetaImage, GIPL
or VTK.

In any of those format you will be able to store
the native float data.  We understand that PNG
is convenient sometimes for providing fast and
cheap visualization,... but as you just found
this is not always a good idea when you are
dealing with medical images.

There are multiple viewers available for float
images. You can also easily built your own by
connecting ITK and VTK filters.

You will find a reasonable viewer under

    InsightApplications/ImageViewer


You could also use the free version of VolView
which support multiple pixel types. It can be
downloaded from:

   http://www.kitware.com/products/volview.html


With those viewer you can skip the rescaling
process and keep the original float data.



Regards,


    Luis


--------------
jiang wrote:

> Many thanks to Luis and Joshua,
> I find out why the second case doesn't work. Since I wrote the image data to
> .png file some days ago, I forgot that I rescale the image data to unsigned
> char type as below:
> 
>   typedef unsigned char                   VisualizationPixelType;
>   typedef itk::Image< VisualizationPixelType, 2 >
> VisualizationImageType;
>   typedef itk::RescaleIntensityImageFilter<
>                           ImageType,
>                           VisualizationImageType >   RescaleIntensityFilter;
> 
> 	RescaleIntensityFilter::Pointer     RescaleIntensity;
> 
> 	RescaleIntensity  = RescaleIntensityFilter::New();
> 	RescaleIntensity->SetOutputMaximum( itk::NumericTraits<
> VisualizationPixelType >::max() );
> 	RescaleIntensity->SetOutputMinimum( itk::NumericTraits<
> VisualizationPixelType >::min() );
> 	RescaleIntensity->SetInput( ImageData );
> 
> Then write this RescaleIntensity->GetOutput() to .png file.
> So I try to rescale image data as this procedure, then cast to float type,
> then input it as filter->SetFeatureImage(). This time, the second case works
> same as first case.
> 
> I'm sorry that I disturb you so much because my fault. Any way your answers
> give me some help from other point of view.
> 
> Thank you again and have a nice day!
> 
> 
> Chunyan
> 
> -----Ursprungliche Nachricht-----
> Von: Joshua Cates [mailto:cates at sci.utah.edu]
> Gesendet: Mittwoch, 28. Januar 2004 18:10
> An: jiang
> Cc: ITK
> Betreff: Re: [Insight-users] Question about
> itk::ThresholdSegmentationLevelSetImageFilter
> 
> 
> Hello Chunyan,
> 
> There is probably something in the casting of your image types that is
> causing the differences, but I cannot tell from your description how your
> pipeline is constructed.  Note that the
> ThresholdSegmenationLevelSetImageFilter will automatically cast the
> FeatureImage input to a floating point type.  All of the level-set filters
> requires floating point precision for correct results.  Explicitly casting
> the image to float before setting it as the input should not change the
> result but is not required.
> 
> Josh.
> 
> ______________________________
>  Josh Cates
>  Scientific Computing and Imaging Institute
>  University of Utah
>  Email: cates at sci.utah.edu
>  Phone: (801) 587-7697
>  URL:   http://www.sci.utah.edu/~cates
> 
> 
> On Wed, 28 Jan 2004, jiang wrote:
> 
> 
>>Dear ITK-users,
>>I tried to do image segmentation by
>>itk::ThresholdSegmentationLevelSetImageFilter. It can work now. Firstly, I
>>set m_thresholdSegmentation->SetFeatureImage() by read a .png file. Then I
>>try to set m_thresholdSegmentation->SetFeatureImage() by one
>>InputImageType::Pointer. But the result is not same as before. The other
>>settings are totally same. The following is the detail:
>>In the first case:
>>   typedef signed short                    PixelType;
>>   typedef itk::Image<PixelType, 2>        ImageType;
>>
>>   itk::PNGImageIO::Pointer io;
>>   io = itk::PNGImageIO::New();
>>   itk::ImageFileWriter<ImageType>::Pointer writer;
>>
>>   typedef   float                                   InputPixelType;
>>   typedef   itk::Image< InputPixelType, 2 >         InputImageType;
>>   typedef   itk::ImageFileReader<InputImageType >   ReaderType;
>>   ReaderType::Pointer reader;
>>
>>   ImageType::Pointer --> writer("ImageFile.png") --> reader
>>   m_thresholdSegmentation->SetFeatureImage(reader->GetOutput())
>>
>>In the second case:
>>   typedef itk::CastImageFilter<ImageType,InputImageType> CasterType;
>>   CasterType1::Pointer Caster;
>>
>>   ImageType::Pointer --> Caster
>>   m_thresholdSegmentation->SetFeatureImage(Caster->GetOutput())
>>
>>
>>The result of second case is not what I want. How can I get the same
> 
> result
> 
>>as first case, but not use "writer" and "reader", directly by Pointer?
>>
>>
>>Thanks a lot!
>>
>>
>>Chunyan
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>>
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>