[Insight-users] Resampling without Interpolation

Luis Ibanez luis.ibanez at kitware.com
Wed Apr 7 09:52:37 EDT 2010


Hi Himanshu,

We don't quite have a filter that does this type of mapping.

However, you could easily implement this by creating the
output image from scratch as described in the ITK Software
Guide

           http://www.itk.org/ItkSoftwareGuide.pdf

in the "Data Representation" chapter,

and then using an Image Region iterator plus to walk along
the pixels of the original image.

The code will look like

(where image1 is the input image,
and image2 is the output image).

 unsigned int upsizeFactor = 2;
 RegionType region;
 IndexType start;
 start.Fill( 0 );
 region.SetIndex( start );

 SizeType size;
 size = image1->GetLargestPossibleRegion();
 size[0] *= upsizeFactor;
 size[1] *= upsizeFactor;
 size[2] *= upsizeFactor;
 region.SetSize( size );

 SpacingType spacing = image1->GetSpacing();
 spacing[0] /= upsizeFactor;
 spacing[1] /= upsizeFactor;
 spacing[2] /= upsizeFactor;
 image2->SetSpacing( spacing );

 image2->SetOrigin( image1->GetOrigin() );
 image2->SetDirection( image1->GetDirection() );
 image2->SetRegions( region );
 image2->Allocate();
 image2->FillBuffer( 0 );

 PointType point;
 IndexType index2;

 while (   ! itr.IsAtEnd()   )
 {
 PixelType pixelValue = itr.Get();
 IndexType index1 = itr.GetIndex();
 image1->TransformIndexToPhysicalPoint( index1, point );
 image2->TransformPhysicalPointToIndex( point, index2 );
 image2->SetPixel( index2, pixelValue );
 ++itr;
 }


Regards,


       Luis


-------------------------------------------------------------------------
On Sun, Apr 4, 2010 at 2:40 PM, Himanshu Neema <usc.himanshu at gmail.com> wrote:
> Hi,
> I want to resample (upsize) an image without interpolator inserting
> interpolated values. For example :
> image = 1 2 3
>              4 5 6
>              7 8 9
> I want resampled image to be : ( upsize by 2)
> interpolatedImage = 1 0 2 0 3 0
>                               0 0 0 0 0 0
>                               4 0 5 0 6 0
>                               0 0 0 0 0 0
>                               7 0 8 0 9 0
>                               0 0 0 0 0 0
> Basically I dont want resampler to use any interpolator , I just want zero
> padding in case of upsampling.
> Thanks for your help
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list