# Scaling 3D images in pytorch

**URL:** <https://discuss.pytorch.org/t/scaling-3d-images-in-pytorch/3373>\
**Category:** Uncategorized\
**Created:** [May 23, 2017, 6:59pm UTC](https://discuss.pytorch.org/t/scaling-3d-images-in-pytorch/3373 "2017-05-23T18:59:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abweiss](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@abweiss](https://discuss.pytorch.org/u/abweiss)\
**Post date:** [May 23, 2017, 6:59pm UTC](https://discuss.pytorch.org/t/scaling-3d-images-in-pytorch/3373/1 "2017-05-23T18:59:36Z")

</div>

As a preprocessing step, I need to scale 3D images. Does pytorch have a 3D bilinear interpolation tool or any other useful upsample/downsample tools for this purpose?

---

<div class="post-metadata">

**Author:** ![alexis-jacq](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alexis-jacq/32/180_2.png) [@alexis-jacq](https://discuss.pytorch.org/u/alexis-jacq)\
**Post date:** [May 24, 2017, 8:19pm UTC](https://discuss.pytorch.org/t/scaling-3d-images-in-pytorch/3373/2 "2017-05-24T20:19:32Z")

</div>

Torchvision.transforms.Scale is based on Pil’s tools for interpolation (Pil.image.resize) that works in 2D only. To your purpose, you should rather have a look to scipy ndimages : [https://docs.scipy.org/doc/scipy/reference/ndimage.html](https://docs.scipy.org/doc/scipy/reference/ndimage.html)

---

<div class="post-metadata">

**Author:** ![ajbrock](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ajbrock/32/139_2.png) [@ajbrock](https://discuss.pytorch.org/u/ajbrock)\
**Post date:** [May 25, 2017, 11:19am UTC](https://discuss.pytorch.org/t/scaling-3d-images-in-pytorch/3373/3 "2017-05-25T11:19:29Z")

</div>

I wrote a pytorch GPU-accelerated 3d resampler a while back that uses catmull-rom spline interpolation

> <https://gist.github.com/ajbrock/86fd41cf468839fe804ce28df145d170>
