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

Lydia Ng lng@insightful.com
Tue, 12 Nov 2002 13:55:23 -0800


Hi Martin,

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

I've just tested the BSplineInterpolateImageFunction
(I changed MultiResMIRegistration application to use
BSplineInterpolateImageFunction for resampling) and=20
the output looks ok to me.

If you are able to reproduce your problem with ITK only code,
packaged with a small test image - then we can have a look
at what's going on in the debugger.

One of the issue with BSpline interpolation is that the kernel goes=20
negative in places - so even if you have all positive values in the=20
image, some of the interpolated results might be negative.
ResampleImageFilter just does a static_cast from double to
the output image type - so it might happen that you get=20
a very large number if your output type is unsigned.
Do you think your problem relates to this or are truly getting an
all zero output?

-Lydia

> -----Original Message-----
> From: Martin Styner [mailto:martin_styner@ieee.org]
> Sent: Tuesday, November 12, 2002 4:58 AM
> To: suresh; insight-users
> Subject: Re: [Insight-users] query on Interpolation and Resampling..
>=20
>=20
> Hi Suresh
> I also was able to use the filter in this fashion with=20
> correct results:
>=20
>    typedef ResampleImageFilter<ImageType , ImageType > ResamplerType;
>    typedef AffineTransform<CoordRepType, Dimension> TransformType;
>    typedef LinearInterpolateImageFunction<ImageType, CoordRepType>
> 	LinearInterpolFunctionType;
>=20
> ... some code where computation of a scaling factor (spacing)=20
> is done ..
>=20
>      ResamplerType::Pointer resampleFilter =3D ResamplerType::New();
>      TransformType::Pointer transform =3D TransformType::New();
>      LinearInterpolFunctionType::Pointer interpolFunction =3D
> 	LinearInterpolFunctionType::New();
>=20
>      transform->SetIdentity();
>      interpolFunction->SetInputImage(image);
>=20
>      ImageSizeType   size;
>      ImageType::RegionType imageRegion =3D image->GetBufferedRegion();
>      const double *inSpacing =3D image->GetSpacing();
>      for (int i =3D 0; i < Dimension; i++) {
>        size[i] =3D ((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());
>=20
>      resampleFilter->Update();
>=20
> But then, I also had problems when I tried to use=20
> BSplineInterpolateImageFunction , which just delivered an
> empty image ( with SetSplineOrder(3) )....
>=20
> hope this helps
> Martin
>=20
> suresh wrote:
> > hi all,
> >=20
> > about resampling...
> >=20
> > i posted a message erlier on the same issue.
> > now i did some chages to the code.
> >=20
> > here is the description of the code and changes.
> >=20
> > 1. i took a MRI of size 256X256X120.
> > 2. i subsampled it manually by dropping alternate pixel in=20
> all the three=20
> > directions.The result is a 128X128X60 image which looks good.
> > 4. Now i applied ResampleImageFilter witg AffineTransform set to=20
> > Identity.and default Interpolation .
> > 5. The result is a 256X256X120 image. but...
> >    the actual brain image is 1/4 th earlier image.(the=20
> subsampled one).
> >    What i expect is to be same as the original image .But The=20
> > interpolation is not done that way.The whole image is about=20
> 36 slices=20
> > (84 to 119), all other slices were simply of 0 intensity.
> >=20
> > 6. The change i did to this procedure is setting the=20
> outputimage spacing=20
> > to half the original.
> > 7. The image looks larger.. but  stil all that image is=20
> with some 30 -=20
> > 40 slices. all other slices were simply of o intensity.
> >=20
> >=20
> > I guess the problem is with interpolation. am i right??
> >=20
> > Please can any body help me to get this right.
> >=20
> > Thank you.
> >=20
> > suresh
> >=20
> >=20
> >=20
> >=20
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-users
>=20
>=20
>=20
> --=20
> 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
>=20
>=20
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>=20
>=20