[Insight-users] query on Interpolation and Resampling..

Martin Styner martin_styner@ieee.org
Tue, 12 Nov 2002 13:57:32 +0100


Hi Suresh
I also was able to use the filter in this fashion with correct results:

   typedef ResampleImageFilter<ImageType , ImageType > ResamplerType;
   typedef AffineTransform<CoordRepType, Dimension> TransformType;
   typedef LinearInterpolateImageFunction<ImageType, CoordRepType>
	LinearInterpolFunctionType;

... some code where computation of a scaling factor (spacing) is done ..

     ResamplerType::Pointer resampleFilter = ResamplerType::New();
     TransformType::Pointer transform = TransformType::New();
     LinearInterpolFunctionType::Pointer interpolFunction =
	LinearInterpolFunctionType::New();

     transform->SetIdentity();
     interpolFunction->SetInputImage(image);

     ImageSizeType   size;
     ImageType::RegionType imageRegion = image->GetBufferedRegion();
     const double *inSpacing = image->GetSpacing();
     for (int i = 0; i < Dimension; i++) {
       size[i] = ((double) inSpacing[i] * imageRegion.GetSize(i) /
	spacing[i] );
     }
     resampleFilter->SetInput(image);
     resampleFilter->SetSize(size);
     resampleFilter->SetOutputSpacing(spacing);
     resampleFilter->SetOutputOrigin(image->GetOrigin());
     resampleFilter->SetTransform(transform.GetPointer());
     resampleFilter->SetInterpolator(interpolFunction.GetPointer());

     resampleFilter->Update();

But then, I also had problems when I tried to use 
BSplineInterpolateImageFunction , which just delivered an
empty image ( with SetSplineOrder(3) )....

hope this helps
Martin

suresh wrote:
> hi all,
> 
> about resampling...
> 
> i posted a message erlier on the same issue.
> now i did some chages to the code.
> 
> here is the description of the code and changes.
> 
> 1. i took a MRI of size 256X256X120.
> 2. i subsampled it manually by dropping alternate pixel in all the three 
> directions.The result is a 128X128X60 image which looks good.
> 4. Now i applied ResampleImageFilter witg AffineTransform set to 
> Identity.and default Interpolation .
> 5. The result is a 256X256X120 image. but...
>    the actual brain image is 1/4 th earlier image.(the subsampled one).
>    What i expect is to be same as the original image .But The 
> interpolation is not done that way.The whole image is about 36 slices 
> (84 to 119), all other slices were simply of 0 intensity.
> 
> 6. The change i did to this procedure is setting the outputimage spacing 
> to half the original.
> 7. The image looks larger.. but  stil all that image is with some 30 - 
> 40 slices. all other slices were simply of o intensity.
> 
> 
> I guess the problem is with interpolation. am i right??
> 
> Please can any body help me to get this right.
> 
> Thank you.
> 
> suresh
> 
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users



-- 
Martin Styner, PhD. Ing. ETH
Group Head Medical Image Analysis for Orthopiaedics
M.E. Mueller Institute for Biomechanics
Center for Computed Assisted Surgery
University of Bern
Murtenstrasse 35
P.O.Box 30
CH - 3010 Bern
Switzerland
Tel office: ++41-31-632-0940 , FAX: ++41-31-632-4951
email: Martin.Styner@memot.unibe.ch, martin_styner@ieee.org
WWW: http://cranium.unibe.ch/~mstyner