# Proper way to resample a 3D image

**URL:** https://discourse.itk.org/t/proper-way-to-resample-a-3d-image/5227
**Category:** Beginner Questions
**Created:** [July 30, 2022, 1:49am UTC](https://discourse.itk.org/t/proper-way-to-resample-a-3d-image/5227 "2022-07-30T01:49:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chlee](https://discourse.itk.org/user_avatar/discourse.itk.org/chlee/32/3788_2.png) [@chlee](https://discourse.itk.org/u/chlee)
#### Post date: [July 30, 2022, 1:49am UTC](https://discourse.itk.org/t/proper-way-to-resample-a-3d-image/5227/1 "2022-07-30T01:49:16Z")

</div>

Hi,

I have acquired my 3D image z-stack, from z=0 to z=70, total of 71 slices on the z-axis. I have another image that I had a spacing of 2, and acquired from z=0 to z=70, so 36 slices on the z-axis.

I am following the resample 3D image example to upsample the second image to the first image, [Resample an Image — v5.3.0](https://examples.itk.org/src/filtering/imagegrid/resampleanimage/documentation) but following the calculation, I end up of having a slightly less spacing of 2. I am a bit confused how to handle this correctly such that I can truly “align” the two images.

Thank you very much for your help!

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [July 30, 2022, 2:22pm UTC](https://discourse.itk.org/t/proper-way-to-resample-a-3d-image/5227/2 "2022-07-30T14:22:50Z")

</div>

You might be dividing `n/2` instead of `(n-1)/2`, or something similar. If it is a one-off operation, you might want to use `Resample Image (BRAINS)` module in [Slicer](https://slicer.org/). Use the hi-res image as reference and not setting a transform should imply identity (which is what you want).

---

<div class="post-metadata">

### Author: ![chlee](https://discourse.itk.org/user_avatar/discourse.itk.org/chlee/32/3788_2.png) [@chlee](https://discourse.itk.org/u/chlee)
#### Post date: [August 3, 2022, 11:15pm UTC](https://discourse.itk.org/t/proper-way-to-resample-a-3d-image/5227/3 "2022-08-03T23:15:32Z")

</div>

Thank you! Embarassing, indeed, I was using `n/2` instead of `(n-1)/2`, and by fixing this everything was in line!
