[Insight-users] Problem with ResampleImageFilter

Luis Ibanez luis.ibanez at kitware.com
Thu, 29 Jan 2004 09:14:37 -0500


Hi Rama,

What is the origin of the input image ?

In your code I see the origin of the
output image what I didn't find any
reference to the origin of the input
image.  Can you please post its value
to the list ?


The physical extent of the input image
seems to be:

     Ex = 550 mm
     EY = 550 mm
     Ez = 148 mm

and the physical extent of the output
image seems to be:

     Ex = 500 mm
     EY = 500 mm
     Ez = 148 mm

If the two origins where coincident the
output image should have a subregion of
the input image.  Basically it should be
taking out a border of 50mm in the upper
coordinates on X and a border of 50mm
in the upper coordinates on Y.

The description of shifting "down and right"
unfortunately doesn't tell us much since it
depends on what kind of viewer you are using
for visualizing your image. It may be using
any of the four flipng possibilities in 2D.

The best way to understan the effects of
resampling is to draw in a piece of paper
the coordinate system of the input image,
draw a rectangle indicating the physical
region covered by the input image, then
locating where in this coordinate system
will be mapped the origin of the output
image as well as its other three corners.
By completing the rectangle of the region
corresponding to the output image is should
be very easy to visualize what piece of the
input image will appear on the output image.


Please check the origin of the input
image and let us know.


Regards,


    Luis



-----------
CSPL wrote:
> Hello Luis,
>  
>  I have been using the ResampleImageFilter of ITK to resample an image 
> (source/input) with the following properties
>   Width = 128 VoxelWidth = 4.296875
>   Height = 128 VoxelHeight = 4.296875
>   Depth = 35 VoxelDepth = 4.25
>  
>  into an image (destination/output) with the following properties
>   Width = 512 VoxelWidth = 0.976562
>   Height = 512 VoxelHeight = 0.976562
>   Depth = 35 VoxelDepth = 4.25
>  
>  I have set the other values for the filter as follows:
>  
>  typedef itk::ResampleImageFilter<InputImageType,OutputImageType >    
> ResampleFilterType;
>  ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>  
>  typedef itk::AffineTransform<double,3> TransformType;
>  TransformType::Pointer transform = TransformType::New();
>  
>  transform->SetIdentity();
>  resampler->SetTransform( transform );
>  resampler->SetInput( Mask ); // Mask is InputImageType
>  
>  // Output image spacing : (0.976562, 0.976562, 4.25)
>  double Spacing[ 3 ] = { voxelWidth, voxelHeight, voxelDepth };
>  
>  // Output image size : (512, 512, 35)
>  int fSize[ 3 ] = { width, height, depth };
>  
>  double Origin[ 3 ] = { 0, 0, 0 };
>  
>  InputImageType::SizeType Size;
>  Size[0] = fSize[0];
>  Size[1] = fSize[1];
>  Size[2] = fSize[2];
>  
>  typedef itk::NearestNeighborInterpolateImageFunction<
>                        InputImageType, double>  InterpolatorType;
>  InterpolatorType::Pointer interpolator = InterpolatorType::New();
>  
>  resampler->SetSize( Size );
>  resampler->SetOutputOrigin( Origin );
>  resampler->SetDefaultPixelValue( 0 );
>  resampler->SetOutputSpacing( Spacing );
>  resampler->SetInterpolator(interpolator);
>  
>  After executing the above code, the mask appears to have shifted down 
> and right.
>  What could the reason be? Is it the pixel spacing?
>  
>  I tried giving the values 1 and 0.8 for the spacing values in the above 
> code.
>  When I did that the mask completely disappeared from the image. That is 
> why I thought pixel spacing is the reason for the shift in the output.
>  
>  The same code has given an output of our satisfaction for the following
>  Input Image:
>   Width = 128 VoxelWidth = 3.90625
>   Height = 128 VoxelHeight = 3.90625
>   Depth = 35 VoxelDepth = 4.25 
>  
>  Output Image:
>   Width = 512 VoxelWidth = 0.976562
>   Height = 512 VoxelHeight = 0.976562
>   Depth = 35 VoxelDepth = 4.25 
>  
>  In both the above cases the data type of input and output images is 
> "short".
>  Please help me out with this situation sir.
>  
> bye,
>  Rama Krishna.