[Insight-users] downsampling a 3D volume

michiel mentink michael.mentink at st-hughs.ox.ac.uk
Tue Mar 30 17:40:30 EDT 2010


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
>
>


More information about the Insight-users mailing list