[Insight-users] query on Interpolation and Resampling..
Martin Styner
martin_styner@ieee.org
Wed, 13 Nov 2002 15:22:21 +0100
Hi Lydia
Indeed I used an unsigned type and that is the issue here.
Thanks
Martin
Lydia Ng wrote:
> Hi Martin,
>
>
>>But then, I also had problems when I tried to use
>>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
> 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
> negative in places - so even if you have all positive values in the
> 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
> 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..
>>
>>
>>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
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users@public.kitware.com
>>http://public.kitware.com/mailman/listinfo/insight-users
>>
>>
>
> _______________________________________________
> 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 Orthopaedics
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