[Insight-users] Bug when writing images --> itkAnalyseImageIO

Benoit Regrain benoit.regrain at creatis.insa-lyon.fr
Mon Apr 10 05:50:02 EDT 2006


Hi,

I have wrote a test reading a 2D image, and writing it in an other file (in 
attachment)
If the output file have a .img extention, the program fails at line 1139 of 
the itkAnalyseImageIO file.

When debugging, I see your are considering that the image is 3D... instead 
of considering the image dimensionnality !!!
I have :
  dirx.size() = 2
  diry.size() = 2
  dirz.size() = 0
and dir that is a 3x3 matrix
thus when copiing dirz into dir... it fails.

I'm working on windows, with the last release of ITK (named 2.6.0 but 
considered to 2.5.0 when seeing the CMakeLists.txt file, downloaded the 
03/07/06)

Cheers
Benoit 
-------------- next part --------------
#include <iostream>

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

int main(int argc, char *argv[])
{
   if(argc<3)
   {
      std::cout<<"Use : "<<std::endl
               <<"   "<<argv[0]<<" input output"<<std::endl
               <<"   Option :"<<std::endl
               <<"     input  : filename to read"<<std::endl
               <<"     output : filename to write"<<std::endl;
      return(1);
   }

   std::cout<<"Input : "<<argv[1]<<std::endl;
   std::cout<<"Output : "<<argv[2]<<std::endl;
   std::cout<<std::endl;

   // Definition des types
   typedef itk::Image<unsigned short,2> ImageType;
   typedef itk::ImageFileReader<ImageType> ReaderType;
   typedef itk::ImageFileWriter<ImageType> WriterType;

   // Reader
   ReaderType::Pointer reader=ReaderType::New();
   reader->SetFileName(argv[1]);
   reader->Update();

   // Image (print)
   reader->GetOutput()->Print(std::cout);

   // Writer
   WriterType::Pointer writer=WriterType::New();
   writer->SetInput(reader->GetOutput());
   writer->SetFileName(argv[2]);
   writer->Update();

   return(0);
}


More information about the Insight-users mailing list