[Insight-users] Re: Extracting Coronal, Saggital, Axial: Bad extension for filename
Luis Ibanez
luis . ibanez at kitware . com
Wed, 06 Aug 2003 13:07:16 -0400
Hi Marcellus,
Thanks for adding the try/catch block.
What happens is that ITK selects the fileformat to write
based on the extension of the filename. The filename that
you are using does not match any of the predefined extensions.
Henceforth, ITK writers cannot select an appropriate ImageIO
object for writing your file.
Details on the IO architecture are available in the SoftwareGuide
http://www . itk . org/ItkSoftwareGuide . pdf
on Chapter 6, pdf-page 184.
Some of the common extensions are:
.mhd for MetaImage
.vtk for VTK
.dcm DICOM (only reading)
.png PNG
.hdr Analyze
Regards,
Luis
------------------------
marcellus walace wrote:
>
> Ok
> I've put a try catch around the writer->Update(); and the message
> error is :
>
> In File InsigthToolkit1.2.0\code\ImageFileWriter.txx
> LINE 119:
> itk::error: ImageFileWriter<010438D0>: No Image set , or non could be
> created.
>
> About the size of my parameters: I've change the application; I pass a
> file name directly inside the code
> a 2D dicom file which is named Im.1 and which is correctly loaded. And
> I can get the
> extract region caracteristics by using the method
> reader->GetOutput()->GetRequestedRegion()
> of the output of the reader.
>
> char* fName;
> fName = new char[64];
> strcpy(fName,"Im.1");
>
>
> // Declare the image
> typedef itk::Image<unsigned short, 3> ImageType;
>
>
> // Declare a Reader
> typedef itk::ImageFileReader< ImageType > VolumeReaderType;
> VolumeReaderType::Pointer reader = VolumeReaderType::New();
>
> // Set the filename
>
> reader->SetFileName(fName);
> try
> {
> reader->Update();
> }
> catch( itk::ExceptionObject & exception )
> {
> std::cout << "Problems reading file format" << std::endl;
> std::cout << exception << std::endl;
> exit(1);
> }
> std::cout << "...Loading File Done" << std::endl;
>
>
>
> // Declare the Extract filter
> typedef itk::ExtractImageFilter< ImageType, ImageType >
> ExtractFilterType;
> ExtractFilterType::Pointer extractor = ExtractFilterType::New();
>
> extractor->SetInput( reader->GetOutput() );
>
> ImageType::SizeType
> size=reader->GetOutput()->GetRequestedRegion().GetSize();
>
> /* ImageType::IndexType index;
>
> index[0] = atoi( argv[3] );
> index[1] = atoi( argv[4] );
> index[2] = atoi( argv[5] );
>
> size[0] = atoi( argv[6] );
> size[1] = atoi( argv[7] );
> size[2] = atoi( 0);*/
>
> ImageType::SizeType size1;
> size1[0] = size[0] ;
> size1[1] = size[1] ;
> size1[2] = size[2] ;
>
>
>
> ImageType::RegionType region;
> region.SetIndex( reader->GetOutput()->GetRequestedRegion().GetIndex() );
> region.SetSize( size1 );
>
>
> extractor->SetExtractionRegion( region );
>
> // Declare a Writer
> typedef itk::ImageFileWriter< ImageType > VolumeWriterType;
> VolumeWriterType::Pointer writer = VolumeWriterType::New();
>
> // Add the MetaImage format to the writer
> writer->SetImageIO( itk::MetaImageIO::New() );
>
> // Set the filename
> sprintf(fName,"fichier.%d",1);
> writer->SetFileName( fName );
>
> // Set the image to write
> writer->SetInput( extractor->GetOutput() );
>
> try{
> // Write the image
> writer->Update();
> } catch( itk::ExceptionObject & exception ){
> std::cout<<"exception...."<<exception <<std::endl;
> }
>
>
> return 0;
> }
>
> _________________________________________________________________
> MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
> http://join . msn . com/?page=features/virus
>
>