[Insight-users] Cannot run the example Image5 after building (cvs source)

Luis Ibanez luis.ibanez at kitware.com
Mon, 15 Mar 2004 21:53:15 -0500


Atwood, Robert C wrote:

> Sorry, I do not see anywhere that it explains:
> 
> (1) that the file format will be determined by the file name (extension)


mmm,
somebody hasn't done his homework:

http://www.itk.org/ItkSoftwareGuide.pdf

Chapter 7 "Reading and Writing Images", page pdf 221:

" The object factory mechanism enables the ImageFileReader
   and ImageFileWriter to determine (at run-time) with which
   file format it is working with. Typically, file formats are
   chosen based on the filename extension, but the architecture
   supports arbitrarily complex processes to determine whether
   a file can be read or written. "



> (2) what the file name extension should be to generate a "MetaImage"
> format, which would be most usable (It is almost exactly the same as my
> own header/raw format I have been using)
>


FAQ: entry 1.7
http://www.itk.org/cgi-bin/InsightFAQ/InsightFAQ?req=show&file=faq01.007.htp



> (3) any other way to specify the file type  
> 

more homework undone...

http://www.itk.org/ItkSoftwareGuide.pdf

Chapter 7, Section 7.1,  "Using Image IO Classes Explicitly"
pdf-page 237,




> for this example. I would like to be able to understand and run this
> example before trying acutally programming using ITK filters. This
> example is only supposed to WRITE a file, it generates its own data in
> the main() routine, to demonstrate how to pass a local buffer into the
> ITK image class , which is undoubtedly what I want to do. I think I can
> probably do everything that I need to do with the toolkit by modifying
> this example code, if only I can get it to work.
> 
> 
> Some further experiments reveal that the example does indeed process the
> file name extension, thanks, Lydia, for the tip, 
> but I cannot find any extension that actually works for the three-d data
> (No extension, .tif, .png, .MetaImage, .raw, .RAW, .mim )
> 
> 


TIFF and PNG are only capable of managing 2D images.
You can write 3D volumes as sets of 2D files (TIFF, PNG)
by using the ImageSeriesWriter:

http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageSeriesWriter.html


Please look at the examples in

                  Insight/Examples/IO



> 
> Thanks for any further tips or relevant document reference locations.
> 565 pages is a big doc.
> 


Note that the 565 pages of the Software guide are a searcheable
PDF document. Doing Ctrl-F with the string "extension" will bring
you to the right page at the second hit.



Please let us know if you have further questions,


    Thanks


      Luis



----------------------------
> Dr. Robert Atwood
> Dept of Materials
> Imperial College London
> London UK
>  
>  
> 
>  
> 
> 
> 
> ./Image5 testit
> Exception caught !
> 
> itk::ExceptionObject (0x8067600)
> Location: "Unknown"
> File: /sources/local/InsightToolKit_cvs/Code/IO/itkImageFileWriter.txx
> Line: 143
> Description: itk::ERROR: ImageFileWriter(0x8062ed0): No ImageIO set, or
> none could be created.
> 
> 
> ./Image5 testit.tif
> Exception caught !
> 
> itk::ExceptionObject (0x8067ed0)
> Location: "Unknown"
> File: /sources/local/InsightToolKit_cvs/Code/IO/itkTIFFImageIO.cxx
> Line: 716
> Description: itk::ERROR: TIFFImageIO(0x8067588): TIFF Writer can only
> write 2-dimensional images
> 
> ./Image5 testit.MetaImage
> Exception caught !
> 
> itk::ExceptionObject (0x8067ef8)
> Location: "Unknown"
> File: /sources/local/InsightToolKit_cvs/Code/IO/itkImageFileWriter.txx
> Line: 143
> Description: itk::ERROR: ImageFileWriter(0x8062ed0): No ImageIO set, or
> none could be created.
> 
>  ./Image5 testit.RAW
> Exception caught !
> 
> itk::ExceptionObject (0x8067600)
> Location: "Unknown"
> File: /sources/local/InsightToolKit_cvs/Code/IO/itkImageFileWriter.txx
> Line: 143
> Description: itk::ERROR: ImageFileWriter(0x8062ed0): No ImageIO set, or
> none could be created.
> 
> 
> ************************************************************************
> *******************
> The relevant code from Image5.cxx
> ************************************************************************
> *******************
> 
> 
>  //  Software Guide : BeginLatex
>   //
>   //  Finally, we can connect the output of this filter to a pipeline.
>   //  For simplicity we just use a writer here, but it could be any
> other filter.
>   //
>   //  Software Guide : EndLatex
> 
>   typedef itk::ImageFileWriter< ImageType > WriterType;
>   WriterType::Pointer writer = WriterType::New();
> 
>   writer->SetFileName( ctrl->outfile ); /*???? does this also set the
> output file type ???*/
> 
>   // Software Guide : BeginCodeSnippet
>   writer->SetInput(  importFilter->GetOutput()  ); 
>   // Software Guide : EndCodeSnippet
> 
> 
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & exp )
>     {
>     std::cerr << "Exception caught !" << std::endl;
>     std::cerr << exp << std::endl;
>     }
> 
> 
> -----Original Message-----
> From: Lydia Ng [mailto:lng at insightful.com] 
> Sent: 12 March 2004 19:06
> To: Atwood, Robert C; insight-users at itk.org
> Subject: RE: [Insight-users] Cannot run the example Image5 after
> building (cvs source)
> 
> 
> I think it is because ImageIO doesn't understand the format of ".bin".
> See http://www.itk.org/HTML/Data.htm for the list of format ITK accepts.
> 
> If your "testit.bin" contain raw data - consider creating a meta-header
> for it.
>  
> - Lydia
>  
> -----Original Message-----
> From: Atwood, Robert C [mailto:r.atwood at imperial.ac.uk] 
> Sent: Friday, March 12, 2004 10:05 AM
> To: insight-users at itk.org
> Subject: [Insight-users] Cannot run the example Image5 after building
> (cvs source)
>  
> I was able to build the tooklit, then build the example Hello World and
> run it, but the next one I tried did not work. 
>  
> I copied Examples/DataRepresentation/Image/Image5.cxx to a new
> directory, and edited teh CMakeLists.txt, successfully building the
> file, then upon running it I receive the following problem:
>  
>  
> ./Image5 testit.bin
> Exception caught !
>  
> itk::ExceptionObject (0x8067600)
> Location: "Unknown"
> File: /sources/local/InsightToolKit_cvs/Code/IO/itkImageFileWriter.txx
> Line: 143
> Description: itk::ERROR: ImageFileWriter(0x8062ed0): No ImageIO set, or
> none could be created.
>  
> Next I tried the Image5 already built in the build/bin directory, with
> the same result.
>  
> Thanks for any advice 
> Robert
>  
>  
> Dr. Robert Atwood
> Dept of Materials
> Imperial College London
> London UK
>  
>  
>  
>  
>  
>  
>  
>  
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>