[Insight-users] Problem with ResampleImageFilter
CSPL
hyd2_affable at sancharnet.in
Fri, 30 Jan 2004 14:38:46 +0530
Hello Luis,
The origins of both input and the output images are the same, it is (0,0,0)
but I have a doubt regarding the 50mm margin that will be cut off. Let me
put forward my question graphically,
|
| x x - is the mask in the input
image.
| X X - is the mask in the output
image.
------(0,0)-------
|
|
|
If we resample a 550mm/550mm image into a 500mm/500mm image doesn't the
mask appear at the same area of the output image as it is in the input
image?
Let us assume that in the above graph 'x' is at location 55,55 (10% of 550
= 55).
I think that when we resample the input image to 500mm it must be
approximately at the location 50,50 (10% of 500 = 50). Isn't it so?
Doesn't it mean that the shift should only be by 5mm?
Doesn't it also mean that the mask should appear to be shifted "down and
left" as in the above graph rather than "down and right" as I have got.
All the above questions appear to be fine when we display the images (input
and output) on a window of fixed height and width without zooming the images
to fit the window.
The error in output I got was when I am displaying the images after zooming
them to fit the window in which they are displayed. Both images are
displayed in separate windows of the same size.
Since the dimensions of the input and output images are proportional (output
img width and height are four times the input image width and height), the
scale factors for zooming would also have been proportional.
Considering all the above points, what should I do to get the correct
output.
Do you think it is only the problem of displaying the image rather than in
passing parameters to the ResampleImageFilter?
Please clarify me on these issues sir.
Thank you,
Rama Krishna.
----- Original Message -----
From: "Luis Ibanez" <luis.ibanez at kitware.com>
To: "CSPL" <hyd2_affable at sancharnet.in>
Cc: <insight-users at itk.org>
Sent: Thursday, January 29, 2004 7:44 PM
Subject: Re: [Insight-users] Problem with ResampleImageFilter
>
> 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.
>
>
>