# Inputs physical space do not match when using itk.LabelMapOverlayImageFilter

**URL:** <https://discourse.itk.org/t/inputs-physical-space-do-not-match-when-using-itk-labelmapoverlayimagefilter/272>\
**Category:** Beginner Questions\
**Created:** [October 9, 2017, 2:19am UTC](https://discourse.itk.org/t/inputs-physical-space-do-not-match-when-using-itk-labelmapoverlayimagefilter/272 "2017-10-09T02:19:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjaminhon](https://discourse.itk.org/user_avatar/discourse.itk.org/benjaminhon/32/83_2.png) [@benjaminhon](https://discourse.itk.org/u/benjaminhon)\
**Post date:** [October 9, 2017, 2:19am UTC](https://discourse.itk.org/t/inputs-physical-space-do-not-match-when-using-itk-labelmapoverlayimagefilter/272/1 "2017-10-09T02:19:24Z")

</div>

Hi,  
I have a DICOM Series which I loaded as well as a series of PNG files which are the segmentations. I am trying to overlay, the segmentations on top of the DICOM series, however I get this error when I do:

```auto
itk.GetArrayFromImage(labelMapOverlayImageFilter.GetOutput())

```

```auto
itk::ERROR: LabelMapOverlayImageFilter(0x7ff266c0e790): Inputs do not occupy the same physical space! 
InputImage Origin: [-1.1700000e+02, -1.1972100e+02, -4.5426899e+01], InputImage_1 Origin: [-1.1700000e+02, -1.1972200e+02, -4.5426701e+01]
	Tolerance: 4.6875000e-07
InputImage Spacing: [4.6875000e-01, 4.6874800e-01, 6.0001812e+00], InputImage_1 Spacing: [4.6875000e-01, 4.6874800e-01, 6.0002131e+00]
	Tolerance: 4.6875000e-07

```

As you can see the difference is very minute:

origin:  
in1: [-1.1700000e+02, -1.1972100e+02, -4.5426899e+01]  
in2: [-1.1700000e+02, -1.1972200e+02, -4.5426701e+01]

spacing:  
in1: [4.6875000e-01, 4.6874800e-01, 6.0001812e+00]  
in2: [4.6875000e-01, 4.6874800e-01, 6.0002131e+00]

Is there any recommended best practice to deal with this?

Thanks

---

<div class="post-metadata">

**Author:** ![benjaminhon](https://discourse.itk.org/user_avatar/discourse.itk.org/benjaminhon/32/83_2.png) [@benjaminhon](https://discourse.itk.org/u/benjaminhon)\
**Post date:** [October 9, 2017, 3:26am UTC](https://discourse.itk.org/t/inputs-physical-space-do-not-match-when-using-itk-labelmapoverlayimagefilter/272/2 "2017-10-09T03:26:37Z")

</div>

Hi nvm I think I solved my own problem 😃  
For anyone having the same problems you need to resample the labels to the reference image here is my solution

```auto
resampleImageFilter = itk.ResampleImageFilter[IUC3, IUC3].New()
resampleImageFilter.SetInput(niiFileReader.GetOutput())
resampleImageFilter.SetTransform(itk.IdentityTransform[itk.D, 3].New())
resampleImageFilter.SetInterpolator(itk.NearestNeighborInterpolateImageFunction[IUC3, itk.D].New())
resampleImageFilter.UseReferenceImageOn()
resampleImageFilter.SetReferenceImage(imageSeriesReader.GetOutput())

```

---

<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:** [October 10, 2017, 1:12pm UTC](https://discourse.itk.org/t/inputs-physical-space-do-not-match-when-using-itk-labelmapoverlayimagefilter/272/3 "2017-10-10T13:12:51Z")

</div>

You could invoke `filter->SetCoordinateTolerance()` or change `GlobalDefaultCoordinateTolerance`. You should take a look at ImageToImageFilter [documentation](https://itk.org/Doxygen/html/classitk_1_1ImageToImageFilter.html) (scroll down to description, there is a long list of derived classes at the beginning of that page).
