[Insight-users] Reading complex image file
Martin Kavec
kavec at messi.uku.fi
Fri May 20 05:04:27 EDT 2005
Hi Luis,
many thanks for fantastic support! The changes in IOBase were really minor,
but implications big. Lots of algorithms in MRI are done in complex data
space (k-space), so it will be comfortable to start implementing these and
that's exactly what I'm working on. I'm updating my ITK right now.
Thanks again.
Martin
On Thursday 19 May 2005 17:35, Luis Ibanez wrote:
> 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=Insi
>ght&sortby=date&r2=1.54&r1=1.53
> http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkImageIOBase.h?root=Insigh
>t&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
--
*********************************
Department of Electrical Engineering and Computer Science
University of Liege
Sart-Tilman, Bldg. B28
Liege B-4000
BELGIUM
Phone: +32 4 366-2870
*********************************
More information about the Insight-users
mailing list