[Insight-users] ImageFileReader exception

Luis Ibanez luis.ibanez at kitware.com
Sun Mar 16 11:06:49 EDT 2008


Hi Aaron,


1) What *exact* filename are you passing for the output image ?

2) What *exact* error message are you getting from the exception ?


It is a common mistake to pass to the ImageFileWriter a filename
with an extension that is not recognized by ITK.


Please look at the FAQ for a list of fileformats supported in ITK.


     Regards,


        Luis


----------------------
Marius Staring wrote:
> Hi Aaron,
> 
> You should use the ImageFileWriter.
> 
> Marius
> 
> Aaron Skewes wrote:
> 
>> Dear all,
>>
>>  
>>
>> I am receiving an ImageFileReader exception //file not found when I 
>> specify an *output file name*. Of course the file does not exist; it 
>> is the output of my process. I do not understand why I would get this 
>> error. If I specify an output file which exists, it proceeds. I want 
>> to create a new file, not overwrite an existing file.
>>
>>  
>>
>> Thanks!
>>
>> Aaron
>>
>>  
>>
>>  
>>
>> ReaderType::Pointer reader = ReaderType::New();                     
>>
>>             reader->SetFileName( inputFileName  );
>>
>>             //Explicitly update the reader
>>
>>             try
>>
>>                         {
>>
>>                         reader->Update();
>>
>>                         }
>>
>>             catch( itk::ExceptionObject & err )
>>
>>                         {
>>
>>                         std::cout << "ExceptionObject caught !" << 
>> std::endl;
>>
>>                         std::cout << err << std::endl;
>>
>>                         }
>>
>>            
>>
>>             ImageType::Pointer image = reader->GetOutput();
>>
>> //***********************************************************************************
>>
>>  
>>
>>             NeighborhoodIteratorType::RadiusType radius;
>>
>>             radius.Fill(1);
>>
>>             NeighborhoodIteratorType it( radius, reader->GetOutput(), 
>> reader->GetOutput()->GetRequestedRegion() );
>>
>>  
>>
>>             ImageType::Pointer ConvOutput = ImageType::New();
>>
>>             
>> ConvOutput->SetRegions(reader->GetOutput()->GetRequestedRegion());
>>
>>             ConvOutput->Allocate();
>>
>>            
>>
>>             float sum;
>>
>>            
>>
>>             IteratorType out(ConvOutput, 
>> reader->GetOutput()->GetRequestedRegion());
>>
>>            
>>
>>             for (it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, 
>> ++out)
>>
>>     {
>>
>>   
>>
>>    Do something
>>
>>     }      
>>
>>  
>>
>> //**********************************************************************************
>>
>> //Set up the image writer and rescale image
>>
>>             RescaleFilterType::Pointer rescaler = 
>> RescaleFilterType::New();
>>
>>  
>>
>>             rescaler->SetOutputMinimum(   0 );
>>
>>             rescaler->SetOutputMaximum( 255 );
>>
>>             rescaler->SetInput(ConvOutput);
>>
>>  
>>
>>             WriterType::Pointer writer = WriterType::New();
>>
>>             writer->SetFileName( outputFileName );
>>
>>             writer->SetInput(rescaler->GetOutput());
>>
>>             try
>>
>>                         {
>>
>>                         writer->Update();
>>
>>                         }
>>
>>             catch ( itk::ExceptionObject &err)
>>
>>                         {
>>
>>                         std::cout << "ExceptionObject caught !" << 
>> std::endl;
>>
>>                         std::cout << err << std::endl;
>>
>>             }
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>>  
>>
> 
> -- 
> Marius Staring
> Image Sciences Institute
> University Medical Centre Utrecht
> Heidelberglaan 100, 3584 CX Utrecht, The Netherlands
> phone: +31 (0)88 75 53186, fax: +31 (0)30 251 3399
> marius at isi.uu.nl, http://www.isi.uu.nl/People/Marius
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list