[Insight-users] Sub sampling

Luis Ibanez luis.ibanez@kitware.com
Sat, 26 Apr 2003 16:24:41 -0400


Hi  Sateesh,


Please read with attention the section on resampling
in the software guide.

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

This is section 5.7.1, pdf-page 140-156.

-----

The first important thing to understand with resampling
is that everything is done in physical coordinates, not
in pixels.

If you want to reduce the number of pixels of the image
you will have to *multiply* the spacing instead of dividing
it.

For covering the same extent of space with half the samples,
the distance between the samples must be doubled.


There are multiple examples on this topic on the
SoftwareGuide.



Regards,


   Luis


------------
cspl wrote:
> Hi Luis,
>  
>     I have worked on subsampling the 2d-image. But i didn't get the 
> subsampled output but a part of the image with given dimensions. I am 
> using "ResampleImageFilter" to resample the image. If i give the size of 
> the image to the half of the original image, it is giving the left top 
> half part of the image but it is not actually shrinking the image. I 
> even tried with by decreasing the spacing to its half.
>  
>     I have gone through the examples on resampleimagefilter in 
> ..\Examples\Filtering\ path.
>  
>    My code is...
>  
>  finalTransform->SetIdentity();
>  resample->SetTransform( finalTransform );
>  resample->SetInput(FixedImage);
>  unsigned long ss[2] = {pInput.width / 2, pInput.height / 2};
>  ImageType::SizeType Size = 
> FixedImage->GetLargestPossibleRegion().GetSize();
>  Size[0] = ss[0];
>  Size[1] = ss[1];
>  resample->SetSize( Size );
>  resample->SetOutputOrigin(  FixedImage->GetOrigin() );
>  double * spacing = new double [ Dimension ];
>  spacing = (double *)FixedImage->GetSpacing();
>  spacing[0] /= 2;
>  spacing[1] /= 2;
>  resample->SetOutputSpacing( spacing );
>  resample->SetInterpolator( interpolator );
>  resample->SetDefaultPixelValue( 0 );
>  resample->Update();
>  
>      I am using NearestNeighbout interpolator and Centered affine transform.
>  
>     What else i have to add to my code to subsample the image.
>  
>     Please help me in this regard.
>  
>     Thanks in advance.
>  
> -Regards,
>    Sateesh.
>