[Insight-users] Problem on shrinking factors - Help needed

Luis Ibanez luis.ibanez@kitware.com
Tue, 22 Apr 2003 12:20:58 -0400


Hi Sateesh,

You don't need to instantiate the MetaImageIO
object for reading the image.

The ImageIO factory mechanism will do that for
you.

The only thing you have to do is:





    typedef itk::ImageFileReader< ImageType > ReaderType;
    ReaderType::Point reader = ReaderType::New();
    reader->SetFileName("image.mha");
    filter->SetInput( reader->GetOutput() );





Please look at the examples in the  SoftwareGuide,
that will save you a lot of time.

The process for reading and writing images is shown in
almost all the Filtering examples, all the registration
examples and all the segmentation examples.

--

It also seems that your MetaImage header is not
consistent. Please look at the other headers
available in:

       Insight/Examples/Data


-----


When you consider the shrinking factors, it is useful
to think in terms for number of pixels.  The images will
have always the same physical extent, no matter what
shrinking factor you select. The Multi-resolution pyramid
is subsampling the images, but not changing their physical
size.  If you reduce the number of pixels by half, the
image pyramid will double the pixel spacing, so the image
will always cover the same region of space.



Regards,


    Luis



---------------------
cspl wrote:
> Hi Lius,
>    Thanks for ur reply.
>    I change my code with the MetaImageIO object. But it is giving 
> following itk::exception.
>  
> NDims required and not defined.
> MetaObject: Read: MET_Read Failed
> MetaImage: M_Read: Error parsing file
> MetaImage: Read: Cannot parse file
> ExceptionObject caught !
>  
> itk::ExceptionObject (0012F754)
> Location: "Unknown"
> File: E:\ITK\Insight\Code\IO\itkImageIOBase.cxx
> Line: 126
> Description: itk::ERROR: MetaImageIO(002F75D8): Unknown pixel type: 0





///// THIS CODE IS NOT NEEDED //// BEGIN ////(luis)///////
>  
>   Following is my code:-
>   fMetaImage->SetFileTypeToBinary( );
>   fMetaImage->SetNumberOfComponents( 1 );
>   fMetaImage->SetNumberOfDimensions( 2 );
>   fMetaImage->SetDimensions( 0, 512 );
>   fMetaImage->SetDimensions( 1, 512 );
>   fMetaImage->SetOrigin( 0, 0 );
>   fMetaImage->SetOrigin( 1, 0 );
>  
>   //fMetaImage->SetOrigin(2, 0);
>   fMetaImage->SetSpacing( 0, 0.97 );
>   fMetaImage->SetSpacing( 1, 0.97 );
>  
>   //fMetaImage->SetSpacing(0, 0.97);
>   fMetaImage->ReadImageInformation(); 
>  
///// THIS CODE IS NOT NEEDED ////  END /////(luis)//





>   fixedImageReader->SetFileName( argv[1] );
>   movingImageReader->SetFileName( argv[2] );
> 





///// THIS CODE IS NOT NEEDED //// BEGIN /////(luis)//////
>   int Image1x = 512,Image1y = 512;
>   FixedRawReader->SetDimensions( 0, Image1x );
>   FixedRawReader->SetDimensions( 1, Image1y );
>  
>   fixedImageReader->SetImageIO( fMetaImage );
>  
///// THIS CODE IS NOT NEEDED ////  END //////(luis)/







> 
>     What else is missing in the above code??? Please send me a sample 
> code. I did not find any example related to MetaImageIO class.
>  


There is no example specific for MetaImageIO. In the same way
that there is no example specific for Analyze, nor VTK, nor GIPL.

The imageIO factory mechanism was designed so that you don't need
to specify such details. The extension of the file name should be
enough for the ImageIO factories to figure out the apropriate
file format.







>     Regarding shrinking factors....As i said my data sets are 512x512x35 
> and 128x128x35 with pixel spacing 0.97x0.97x5.0 and 3.906x3.906x4.25. 
> Now for calculating shrinking factors should i consider pixel spacing?? 
> when i consider pixel spacing, the starting shrinking factor will be 1 1 
> 1 for both. But when i consider only pixel dimensions then shrinking 
> factor will be 4 4 1 and 1 1 1. Which is correct??
>  
>     Thanks in advance.
>  
> -Regards,
>    Sateesh.
>  
>