# How can I find coordinates of a point after resampling?

**URL:** <https://discourse.itk.org/t/how-can-i-find-coordinates-of-a-point-after-resampling/6046>\
**Category:** Beginner Questions\
**Tags:** simpleitk, python\
**Created:** [July 7, 2023, 11:25am UTC](https://discourse.itk.org/t/how-can-i-find-coordinates-of-a-point-after-resampling/6046 "2023-07-07T11:25:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eloy\_Schultz](https://discourse.itk.org/user_avatar/discourse.itk.org/eloy_schultz/32/3538_2.png) [@Eloy\_Schultz](https://discourse.itk.org/u/Eloy_Schultz)\
**Post date:** [July 7, 2023, 11:25am UTC](https://discourse.itk.org/t/how-can-i-find-coordinates-of-a-point-after-resampling/6046/1 "2023-07-07T11:25:57Z")

</div>

Suppose I apply a resampling operation to my image as below:

```auto
    resampler = sitk.ResampleImageFilter()
    resampler.SetSize(target_size)
    resampler.SetOutputSpacing(target_spacing)
    resampler.SetOutputOrigin(original_origin) 
    resampler.SetOutputDirection(image.GetDirection())
    resampled_image = resampler.Execute(image)

```

Now suppose that in the original image, there is a voxel at point (x,y,z). I now want to calculate/find the coordinates of this point in the new image space.

I tried using

```auto
transform = resampler.GetTransform()
new_coordinates = transform.TransformPoint((x,y,z))

```

but that does not seem to work since GetTransform() returns an identity transformation. Any help would be greatly appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [July 7, 2023, 1:04pm UTC](https://discourse.itk.org/t/how-can-i-find-coordinates-of-a-point-after-resampling/6046/2 "2023-07-07T13:04:14Z")

</div>

Hello @Eloy_Schultz,

In the code you provided, the transformation is the identity so the index of a point changes in the `resampled_image`, but its physical coordinates do not. The various options of moving between physical coordinates and indexes are illustrated below:

```auto
original_index = [x, y, z] 
original_physical_coords = image.TransformIndexToPhysicalPoint(original_index) 
# If you have a continuous value for the index, sub pixel use TransformContinuousIndexToPhysicalPoint

# Obtain the corresponding index in the resampled image, either continuous or discrete 
new_index_continous = resampled_image.TransformPhysicalPointToContinuousIndex(original_physical_coords)
new_index = resampled_image.TransformPhysicalPointToIndex(original_physical_coords)

```

---

<div class="post-metadata">

**Author:** ![Eloy\_Schultz](https://discourse.itk.org/user_avatar/discourse.itk.org/eloy_schultz/32/3538_2.png) [@Eloy\_Schultz](https://discourse.itk.org/u/Eloy_Schultz)\
**Post date:** [July 10, 2023, 11:52am UTC](https://discourse.itk.org/t/how-can-i-find-coordinates-of-a-point-after-resampling/6046/3 "2023-07-10T11:52:42Z")

</div>

Great thanks! That is exactly what I was looking for. Also thanks for pointing out the difference between physicial space (coordinates) and image space (indices), this cleared it up for me. Thanks again
