[Insight-users] FDF Reader

Luis Ibanez luis.ibanez at kitware.com
Tue, 09 Mar 2004 16:15:46 -0500


Hi Glen,

You may want to try reading the .raw file using
VolView. The open file dialog will give you several
options for entering the dimensions, byte order and
pixel type of your binary file.

You can get the free version of VolView from

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

You could also try ParaView

    http://www.paraview.org


Another option is the ImageViewer application
in InsightApplications. (you will need FLTK).



-----
[Sorry for my bad multiplication ( 256 x 256 x 4 )]   :-/
-----


About your code,


Why are you setting the call for Render() in
an infinite loop [ while(1) ]   ?

The interactor is supposed to take care of this
for you.



Regards,


      Luis



------------


Glenn Pierce wrote:

> On Mon, 2004-03-08 at 15:05, Luis Ibanez wrote: 
> 
>>Hi Glen,
>>
>>First,
>>The obvious question:  Have you succeded
>>visualizing this FDF file with any other tool ?
>>In other words: Do you trust this file ?
> 
> 
> I did, but I am now not so sure. It is fine on the sun machine in work
> but the files were then emailed to me perhaps a corruption during email
> transit ?
> I have not been able to read the data with any other programs due to a
> lack of knowledge about programs that get open raw data or fdf files.
> Although I did try with ImageJ with little luck so maybe it is the file.
> 
> 
> 
>>Are you sure that the pixel is encoded in floats
>>in this file ?  a simple verification is that
>>the file size should have a size of
>>
>>        256 x 256 x 4 = 250880 bytes
> 
> 
> After I manually stripped the header off, the file size was 262161 
> compared to
> 
>   256*256*4 =262144
> 
> So a few bytes extra ?
> 
> 
>>Second:
>>You may want to simplify your MetaHeader
>>to be just
>>
>>
>>    NDims = 2
>>    DimSize = 256 256
>>    ElementType = MET_FLOAT
>>    ElementSpacing = 1.0 1.0
>>    ElementByteOrderMSB = False
>>    ElementDataFile = brain.raw
>>
>>
>>That's the minimum number of entries needed
>>in the header.
> 
> 
> Tried this, but it didn't help
> 
> 
>>Third:
>>Please post the section of code where you are
>>instantiating the MetaImage reader and printing
>>out its content.  The order of operations may
>>be important.
>>
> 
> 
> I have attached my code.
> 
> I am going to try to get other fdf files by methods other than email in
> case the image is corrupt.
> 
> Thanks for the help! 
> 
> 
> 
> ___________________________________________
> 
> Glenn Pierce
> ___________________________________________
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> #include "itkImageFileReader.h"
> #include "itkImageToVTKImageFilter.h"
> #include <vtkRenderWindowInteractor.h>
> 
> #include "itkFDFImageIO.h"
> 
> #include <vtkImageViewer.h>
> 
> #include "itkImage.h"
> 
> int main( int argc, char ** argv )
> {
>   typedef float      PixelType;
>   const   unsigned int        Dimension = 2;
>   typedef itk::Image< PixelType, Dimension >    ImageType;
>   typedef itk::ImageFileReader< ImageType >  ReaderType;
>   typedef itk::ImageToVTKImageFilter< ImageType > ImageToVTKType;
>   //typedef itk::FDFImageIO ImageIOType;
> 
>   ReaderType::Pointer reader = ReaderType::New();
>   //ImageIOType::Pointer fdfIO = ImageIOType::New();
>   //fdfIO->SetFileTypeToBinary();
>   //fdfIO->SetFileTypeToASCII();
>   //fdfIO->SetByteOrderToBigEndian();
>   //reader->SetImageIO( fdfIO );
> 
>   reader->SetFileName( "/home/glenn/development/reader/brain.mhd" );
>   //reader->SetFileName( "/home/glenn/development/reader/test.fdf" );
> 
>   try {
>       reader->Update();
>   }
>   catch( itk::ExceptionObject & exp )
>   {
>       std::cerr << "Exception caught" << std::endl;
>       std::cerr << exp << std::endl;
>   }
> 
>   std::cout << reader << std::endl;
> 
>   vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New(); 
> 
>   ImageToVTKType::Pointer bridge = ImageToVTKType::New();
>   bridge->SetInput( reader->GetOutput() );
> 
>   vtkImageViewer *viewer = vtkImageViewer::New();
>   viewer->SetInput( bridge->GetOutput() );
>   viewer->SetColorWindow(255);
>   viewer->SetColorLevel(128);
>   //viewer->SetupInteractor(iren);
> 
>   while(1)
>       viewer->Render();
> 
>   viewer->Delete();
>   //iren->Delete();
> 
>   return 0;
> }
> 
> 
>