# How is origin calculated during resampling?

**URL:** <https://discourse.itk.org/t/how-is-origin-calculated-during-resampling/6515>\
**Category:** Beginner Questions\
**Created:** [March 14, 2024, 6:45am UTC](https://discourse.itk.org/t/how-is-origin-calculated-during-resampling/6515 "2024-03-14T06:45:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiang\_Zhenyu](https://discourse.itk.org/user_avatar/discourse.itk.org/xiang_zhenyu/32/3950_2.png) [@Xiang\_Zhenyu](https://discourse.itk.org/u/Xiang_Zhenyu)\
**Post date:** [March 14, 2024, 6:45am UTC](https://discourse.itk.org/t/how-is-origin-calculated-during-resampling/6515/1 "2024-03-14T06:45:23Z")

</div>

I want to resample the image to the specified data, but how to calculate the origin so that the image can be displayed normally.  
Example：  
origin:(-90.36074829101562, -172.32485961914062, 121.83561706542969)  
Spacing:(1.0, 1.0, 1.328125)  
Direction:(0.0, 0.0, 1.0, 1.0, -0.0, 0.0, 0.0, -1.0, 0.0)  
Size:(256, 256, 128)  
resample to  
Spacing:(1.0, 1.0, 1.0)  
Direction:(1.0, 0.0, 0.0, 0.0, -0.0, -1.0, 0.0, -1.0, 0.0)  
Size:(256, 256, 256)  
How to calculate new\_origin from original data and target data？  
resampler.SetOutputOrigin(new\_origin)
