[Insight-users] Re: Extracting Coronal, Saggital, Axial

Luis Ibanez luis . ibanez at kitware . com
Wed, 06 Aug 2003 12:02:11 -0400


Hi Marcellus,

Please add a try/catch block around the write->Update() line.
Just like the one on the reader.

If the error is produced by an exception, the printed message
will help us to figure out what is wrong.

What size parameters are you passing ?

Please let us know about message you get,


Thanks

    Luis


---------------------------

marcellus walace wrote:

> Hi Luis,
> I'm using the Application ExtractImageRegion to extract region of 
> medical files  and I've
> tried to use it with a dicom image as input and I've a runtime error, 
> and abnormal end of the execution
> of my programme. I don't understand why.
> Can You Help me?
> I've detected that the problem is when I update the image writer at 
> the end. It's the
> instruction   writer->Update();  which is the cause of the problem. I 
> don't understand why although
> I've read the itk guide image section
>
>
>
>
>
> int main(int argc, char **argv)
>  {
> /*
>  if( argc < 9 )
>    {
>    std::cerr << "Usage: ExtractImageRegion inputImageFile 
> outputImageFile ";
>    std::cerr << "xStart yStart zStart  xSize ySize zSize " << std::endl;
>    return 1;
>    }
> */
>     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,"fichier1.%d",1);
>  writer->SetFileName( fName );
>
>  // Set the image to write
>  writer->SetInput( extractor->GetOutput() );
>
>
>  // Write the image
>  writer->Update();
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE* 
> http://join . msn . com/?page=features/junkmail
>
>