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

Atwood, Robert C r.atwood at imperial.ac.uk
Mon, 15 Mar 2004 11:50:53 -0000


Sorry, I do not see anywhere that it explains:

(1) that the file format will be determined by the file name (extension)
(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)

(3) any other way to specify the file type =20

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,=20
but I cannot find any extension that actually works for the three-d data
(No extension, .tif, .png, .MetaImage, .raw, .RAW, .mim )



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

Dr. Robert Atwood
Dept of Materials
Imperial College London
London UK
=20
=20

=20



./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 =3D WriterType::New();

  writer->SetFileName( ctrl->outfile ); /*???? does this also set the
output file type ???*/

  // Software Guide : BeginCodeSnippet
  writer->SetInput(  importFilter->GetOutput()  );=20
  // 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]=20
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.
=20
- Lydia
=20
-----Original Message-----
From: Atwood, Robert C [mailto:r.atwood at imperial.ac.uk]=20
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)
=20
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.=20
=20
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:
=20
=20
./Image5 testit.bin
Exception caught !
=20
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.
=20
Next I tried the Image5 already built in the build/bin directory, with
the same result.
=20
Thanks for any advice=20
Robert
=20
=20
Dr. Robert Atwood
Dept of Materials
Imperial College London
London UK
=20
=20
=20
=20
=20
=20
=20
=20