[Insight-users] downsampling a 3D volume

Kishore Mosaliganti kishoreraom at gmail.com
Tue Mar 30 18:43:20 EDT 2010


I think that only changes the spacing of the image artificially and does not
change the image size and its contents.

It is best to use a ResampleImageFilter and you can set the output spacing
and size of the output image:

  ResampleFilterType::Pointer resample = ResampleFilterType::New();
  resample->SetTransform ( transform ); // identity transform
  resample->SetInterpolator ( interp ); // linear interpolator
  resample->SetInput ( reader->GetOutput() );
  resample->SetSize ( size );
  resample->SetOutputOrigin ( origin );
  resample->SetOutputSpacing ( spacing );
  resample->SetDefaultPixelValue ( 0 );
  resample->Update();

Kishore

On Tue, Mar 30, 2010 at 5:40 PM, michiel mentink <
michael.mentink at st-hughs.ox.ac.uk> wrote:

> I think the easiest option for you would be just to open an image, and then
> decrease the pixel size.
> After opening an image, the pixel size is just a property of the matrix
> with
> pixel values.
>
> You can get that property with
>
>
>  image=reader->GetOutput(); // open your image
>
> ImageType::SpacingType sp = image->GetSpacing();
>    std::cout << "Spacing = ";
>    std::cout << sp[0] << ", " << sp[1] << ", " << sp[2] << std::endl;
>
> Then, divide all spacing parameters by 1.07:
>
> sp[0] = sp[0]/1.07;
> sp[1] = sp[1]/1.07; // etc.
>
> and then set the spacing:
>
> image->SetSpacing(sp)
>
> After that, you will have changed the dimension of your image without
> having
> touched any of your pixels. Ideal.
>
> cheers, Michael
>
>
>
> On 3/30/10, Reda, Fitsum A <fitecx at gmail.com> wrote:
> > Hi all,
> >
> > I wanted to downsample CT volumes using floating point scale , say,
> > (scale_x, scale_y,scale_z) = (1.07, 1.07, 1.07);
> > I would really appreciate any help with this. I am kind of getting
> started
> > with itk.
> >
> > Thanks in advance,
> > Reda
> >
> >
> >
> > _____________________________________
> >  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
> >
> >
> _____________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100330/a64b86ec/attachment.htm>


More information about the Insight-users mailing list