# Check that two images are at the same physical location

**URL:** <https://discourse.itk.org/t/check-that-two-images-are-at-the-same-physical-location/5883>\
**Category:** Engineering\
**Tags:** rtk\
**Created:** [April 20, 2023, 11:46am UTC](https://discourse.itk.org/t/check-that-two-images-are-at-the-same-physical-location/5883 "2023-04-20T11:46:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arobert01](https://discourse.itk.org/user_avatar/discourse.itk.org/arobert01/32/2554_2.png) [@arobert01](https://discourse.itk.org/u/arobert01)\
**Post date:** [April 20, 2023, 11:46am UTC](https://discourse.itk.org/t/check-that-two-images-are-at-the-same-physical-location/5883/1 "2023-04-20T11:46:25Z")

</div>

Hello,

In [itkImageToImageFilter](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkImageToImageFilter.hxx) the method [VerifyInputInformation](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkImageToImageFilter.hxx#L146-L223) check that all the inputs are in the same physical location. When filters do not expect all input images to be at the same physical location, this method is overridden and the check is removed.

In [RTK](https://github.com/RTKConsortium/RTK), sometimes we want to perform this check not on all the inputs but only on specific ones. For now, every time we need to do this test we basically copy/paste the code from [itkImageToImageFilter](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkImageToImageFilter.hxx) and apply it to the specific inputs (see [here](https://github.com/RTKConsortium/RTK/blob/master/include/rtkJosephForwardAttenuatedProjectionImageFilter.hxx#L72-L160) for example).

In order to avoid this copy/paste, @simon.rit suggests in this [thread](https://github.com/RTKConsortium/RTK/pull/543#discussion_r1171054662) to create a method in [ImageBase](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkImageBase.h) `HasSameInformation(Self *img2)` (or another convenient name) in which we would move most of the `ImageToImageFilter::VerifyInputInformation()` code to reuse it when needed on the specific inputs.

What do you think of this solution ? If it suits you, I could implement it and do a pull request on ITK repository. Or maybe do you have a better solution in mind ?

Thanks,

Antoine

---

<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:** [April 20, 2023, 2:04pm UTC](https://discourse.itk.org/t/check-that-two-images-are-at-the-same-physical-location/5883/2 "2023-04-20T14:04:03Z")

</div>

That sounds good to me.
