# resampling

**URL:** https://discourse.itk.org/t/resampling/2954
**Category:** Algorithms
**Tags:** python
**Created:** [April 16, 2020, 2:01pm UTC](https://discourse.itk.org/t/resampling/2954 "2020-04-16T14:01:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Dodox](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@Dodox](https://discourse.itk.org/u/Dodox)
#### Post date: [April 16, 2020, 2:01pm UTC](https://discourse.itk.org/t/resampling/2954/1 "2020-04-16T14:01:59Z")

</div>

hello every one ,  
sorry for my english, i have a question about this part of code (you can find here the [complete code](http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/21_Transforms_and_Resampling.html#Creating-and-Manipulating-Transforms) )

**def resample(image, transform):**  
**reference\_image = image**  
**interpolator = sitk.sitkCosineWindowedSinc**  
**default\_value = 100.0**  
**return sitk.Resample(image, reference\_image, transform,interpolator, default\_value)**

_**translation.SetOffset((3.1, 4.6))**_  
_**transform\_point(translation, point)**_  
_**resampled = resample(grid, translation)**_  
_**myshow(resampled, ‘Resampled Translation’)**_  
so here we are resampling a image,the output image is called resampled and the input image is called grid  
normally the intensity of the output image OutputImage(x, y) is equal to the intensity of the input image in the point InputImage(x+3.1,y+4.6 ) because the offset here for the translation =(3.1,4.6) but when I want to check that using GetPixel () I don’t find the same result  
could you explain to me why?

THANK YOU

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [April 16, 2020, 2:42pm UTC](https://discourse.itk.org/t/resampling/2954/2 "2020-04-16T14:42:50Z")

</div>

In the example notebook the **grid** image has a pixel spacing of [.2, .2], so simply offsetting your points by [3.1,4.6] won’t get you the same locations in the images.

---

<div class="post-metadata">

### Author: ![Dodox](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@Dodox](https://discourse.itk.org/u/Dodox)
#### Post date: [April 16, 2020, 2:52pm UTC](https://discourse.itk.org/t/resampling/2954/3 "2020-04-16T14:52:19Z")

</div>

what exactly should i write in order to verify the result? is there a mathematical formula for that  
Thank you 😊

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [April 16, 2020, 3:12pm UTC](https://discourse.itk.org/t/resampling/2954/4 "2020-04-16T15:12:20Z")

</div>

Well, in this case you could divide the offset by the spacing, i.e, [3.1/.2, 4.6/.2].

---

<div class="post-metadata">

### Author: ![Dodox](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@Dodox](https://discourse.itk.org/u/Dodox)
#### Post date: [April 16, 2020, 3:18pm UTC](https://discourse.itk.org/t/resampling/2954/5 "2020-04-16T15:18:38Z")

</div>

Thank you very much.  
Have a good day

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [April 16, 2020, 3:38pm UTC](https://discourse.itk.org/t/resampling/2954/6 "2020-04-16T15:38:45Z")

</div>

You are very welcome. 😀
