[Insight-users] Re: Scale Image

Luis Ibanez luis.ibanez at kitware.com
Tue, 03 Feb 2004 01:26:01 -0500


This is a multi-part message in MIME format.
--------------000403050501040703030902
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


Hi Srivalli,


The Physical Extent of your SPECT image is

   X:  128 pixels  *  1.75 mm/pixel  =  224.0 mm
   Y:  128 pixels  *  1.75 mm/pixel  =  224.0 mm
   Z:   43 pixels  *  3.60 mm/pixel  =  154.8 mm


The Physical Extent of your MR image is

   X:  256 pixels  *  0.9375 mm/pixel  =  240.0 mm
   Y:  256 pixels  *  0.9375 mm/pixel  =  240.0 mm
   Z:  120 pixels  *  3.0000 mm/pixel  =  360.0 mm



        You *DO NOT* need the Scale transform.


Just use the "IdentityTransform" and feed the ResampleImageFilter
with the parameters of the MR image (origin, spacing, region size)

The attached program will do what you need. It takes the
fixed and moving images as command line arguments (fixe = MR,
moving = SPECT). Then it resamples the moving image into the
coordinate system of the fixed image. It will do this just as
you requested: "without registration".


IMPORTANT:
Check the values of "origin" for both images. If the origins
are different, the anatomical structure in the SPECT image
will be shifted with respect to the same anatomical structure
in the MR image.


Image registration *must* be done in physical coordinates,
not in pixels.


Please let us know if you have any further questions,



Thanks,


    Luis



---------------------------------------------------------
valli gummadi wrote:

>  Dear Mr.Luis,
> 
>          I have a requirement to scale SPECT image to MR image size with out Registration.
> My SPECT Image is of size 128X128X43. Spacing is 1.75\1.75\3.60425
> My Mr Image is of size 256X256X120.Spacing is 0.937500\0.937500\3.000000.
> 
> I want to make spect image of size 256X256X120. 
> In ITK documentation i found ScaleTransform class. Example for this class is using sphere. Can i use this class for spect image scaling.
> Please give any suggetions to get the output.
> 
> Regards,
> Srivalli.
> 
> 
------------------------------------------------------------

--------------000403050501040703030902
Content-Type: text/plain;
 name="Identity.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Identity.cxx"


#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkResampleImageFilter.h"
#include "itkIdentityTransform.h"
#include "itkNearestNeighborInterpolateImageFunction.h"


int main( int argc, char * argv[] )
{
  if( argc < 5 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << "  inputImageFile  outputImageFile" << std::endl; 
    return 1;
    }

  const     unsigned int   Dimension = 3;
  typedef   unsigned char  InputPixelType;
  typedef   unsigned char  OutputPixelType;

  typedef itk::Image< InputPixelType,  Dimension >   InputImageType;
  typedef itk::Image< OutputPixelType, Dimension >   OutputImageType;


  typedef itk::ImageFileReader< InputImageType  >  ReaderType;
  typedef itk::ImageFileWriter< OutputImageType >  WriterType;

  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();

  reader->SetFileName( argv[1] );
  writer->SetFileName( argv[2] );

  try 
    {
    reader->Update();
    }
  catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception catched !" << std::endl;
    std::cerr << excep << std::endl;
    }

  InputImageType::ConstPointer inputImage = reader->GetOutput();


  typedef itk::ResampleImageFilter<
                  InputImageType, OutputImageType >  FilterType;

  FilterType::Pointer filter = FilterType::New();


  typedef itk::IdentityTransform< double, Dimension >  TransformType;

  TransformType::Pointer transform = TransformType::New();



  typedef itk::NearestNeighborInterpolateImageFunction< 
                       InputImageType, double >  InterpolatorType;

  InterpolatorType::Pointer interpolator = InterpolatorType::New();


  filter->SetInterpolator( interpolator );


  filter->SetDefaultPixelValue( 100 );


  filter->SetOutputSpacing( inputImage->GetSpacing() );
  filter->SetOutputOrigin(  inputImage->GetOrigin() );


  InputImageType::RegionType  region = inputImage->GetLargestPossibleRegion();
  
  InputImageType::SizeType     size  = region.GetSize();
  InputImageType::IndexType    start = region.GetIndex();

  filter->SetSize( size );
  filter->SetOutputStartIndex( start );


  filter->SetInput( reader->GetOutput() );
  writer->SetInput( filter->GetOutput() );

  transform->SetIdentity();

  filter->SetTransform( transform );

  
  try 
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception catched !" << std::endl;
    std::cerr << excep << std::endl;
    }
 
  return 0;
}


--------------000403050501040703030902--