[Insight-users] Re: Scale Image : ERRATA

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


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


Oops,...

Wrong program was attached to the previous email.
Here is attached the correct one.

Sorry about that,


    Luis

---------------------
Luis Ibanez wrote:

> 
> 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.
>>
>>
> ------------------------------------------------------------
> 
> 

//////////    CORRECT RESAMPLING PROGRAM THIS TIME    //////





--------------080806050801050207000105
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 < 4 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << "  fixedImageFile movingImage  resampledMovingImage" << std::endl; 
    return 1;
    }

  const     unsigned int   Dimension = 3;

  typedef   unsigned char  FixedPixelType;
  typedef   unsigned char  MovingPixelType;

  typedef itk::Image< FixedPixelType,  Dimension >   FixedImageType;
  typedef itk::Image< MovingPixelType, Dimension >   MovingImageType;


  typedef itk::ImageFileReader< FixedImageType   >  FixedReaderType;
  typedef itk::ImageFileReader< MovingImageType  >  MovingReaderType;
  typedef itk::ImageFileWriter< MovingImageType  >  MovingWriterType;

  FixedReaderType::Pointer  fixedReader  = FixedReaderType::New();
  MovingReaderType::Pointer movingReader = MovingReaderType::New();

  MovingWriterType::Pointer movingWriter = MovingWriterType::New();

  fixedReader->SetFileName(  argv[1] );
  movingReader->SetFileName( argv[2] );
  movingWriter->SetFileName( argv[3] );

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

  FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput();


  typedef itk::ResampleImageFilter<
                              MovingImageType, 
                              MovingImageType 
                                      >  FilterType;

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


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

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



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

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


  resampler->SetInterpolator( interpolator );


  resampler->SetDefaultPixelValue( 100 );


  resampler->SetOutputSpacing( fixedImage->GetSpacing() );
  resampler->SetOutputOrigin(  fixedImage->GetOrigin() );


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

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


  resampler->SetInput( movingReader->GetOutput() );

  movingWriter->SetInput( resampler->GetOutput() );

  transform->SetIdentity();

  resampler->SetTransform( transform );

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


--------------080806050801050207000105--