[Insight-users] Reading complex image file

Luis Ibanez luis.ibanez at kitware.com
Thu May 19 11:35:04 EDT 2005


Hi Martin,


Thanks for pointing this out.


There is actually a very simple way to extend the factories for managing
std::complex<> pixel types.  This is done in the file:


            Insight/Code/IO/
                     itkImageIOBase.h
                     itkImageIOBase.cxx


In this files we list all the "known" pixel types, meaning that we
specify how they should be managed (number of compoentes, component
type etc.).


Responding to your request, We just commited a change to this files
in order to make possible for you to read and write images whose pixel
type is std::complex<>

http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkImageIOBase.cxx?root=Insight&sortby=date&r2=1.54&r1=1.53
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkImageIOBase.h?root=Insight&sortby=date&r2=1.37&r1=1.36


You can now use *ANY* fileformat that support multiple component
datasets. For example:


        - MetaImage
        - VTK
        - GIPL



For an example on how your code will look like,
please check the file:



       Insight/Examples/Filtering/
                           FFTImageFilter.cxx


It will be something like:


   typedef std::complex<float> ComplexPixelType;

   typedef itk::Image< ComplexPixelType, 2 > ComplexImageType;

   typedef itk::ImageFileWriter< ComplexImageType > ComplexWriterType;

   ComplexWriterType::Pointer complexWriter = ComplexWriterType::New();

   complexWriter->SetFileName("complexImage.mhd");

   complexWriter->SetInput( filter->GetOutput() );
   complexWriter->Update();



Note that you will have to use an updated CVS version of ITK
in order to take advantage of this feature.



Regards,



     Luis



--------------------
Martin Kavec wrote:

> After further reading of the ITK docs, replying myself :).
> 
> It seems that I can use VECTOR pixel type to read complex data points from a 
> file, since complex number is indeed a vector. However, still have a problem. 
> In ITK, FFT needs as an input std::complex< Type >.
> 
> So it seems that I will have to do manual conversion from itk::Vector<double, 
> 2> to std::complex<double>. Am a right or is there any other - easier - way? 
> 
> Regards.
> 
> Martin
> 
> On Wednesday 18 May 2005 15:09, Martin Kavec wrote:
> 
>>Hi,
>>
>>I am writing a class (by inheriting from ImageIOBase) to read  from an
>>unknown file a complex image data, which I want to FFT afterwards (using
>>VnlFFTComplex To* filter). So, I want to have somewhere:
>>
>>typedef std::complex< double> ComplexPixelType;
>>typedef itk::Image< ComplexPixelType, Dimension > ComplexImageType;
>>typedef itk::MyComplexImageReader< ComplexImageType >;
>>
>>to easy perform FFT.
>>
>>I am running into problem in writing MyComplexImageReader. This class uses
>>virtual void Read(void* buffer) to read from file and store the image data
>>in the provided buffer. My question is, how to store the data in the
>>buffer? I tried to figure out this from existing TIFF, JPEG, ..., readers,
>>but got lost. Also, these file formats don't store complex data, I suppose.
>>If I read the data sequentially (as they are stored in a file), complex
>>double pairs, how would MyComplexImageReader::GetOutput() know how to
>>format the data into ComplexPixelType? I guess that in RGB pixel type
>>images, GetOutput() method knows the order from from
>>ImageIOBase::SetPixelType( PixelType ) method, where PixelType can be one
>>of SCALAR, VECTOR, RGB and so on.
>>
>>Am I concerned with something, which is solved upstream of the ImageIOBase
>>inheritance tree and don't need to be bothered with. Or, am I missing
>>anything else?
>>
>>Thanks for help.
>>
>>Martin
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
> 
> 





More information about the Insight-users mailing list