InsightSoftwareConsortium / InsightSoftwareConsortium/ITK
MattesMutualInformation corner case spacing error
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 748
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 64
Description
### Description
corner case error in ITK's MattesMutualInformation metric when both images are all zeros, then the internal data structure (Image) has the reported invalid size
### Steps to Reproduce
> import SimpleITK as sitk
> import numpy as np
>
> I = np.zeros((100,100,100))
> I = sitk.GetImageFromArray(I)
> I.SetSpacing((1.0,1.0,1.0))
> I = sitk.Cast(I, sitk.sitkFloat32)
>
> J = np.zeros((100,100,100))
> J = sitk.GetImageFromArray(J)
> J.SetSpacing((1.0,1.0,1.0))
> J = sitk.Cast(J, sitk.sitkFloat32)
>
> R = sitk.ImageRegistrationMethod()
> R.SetMetricAsMattesMutualInformation()
> MMI = R.MetricEvaluate(I, J)
### Expected behavior
Evaluation of Mutual Information Metric
### Actual behavior
> ERROR: Image(0x32256f0): A spacing of 0 is not allowed: Spacing is [0, 0]
### Reproducibility
100%
### Versions
### Environment
Ubuntu 18.04, python 3.7, SimpleITK 1.1.0, numpy 1.17.2
### Additional Information
Changing metric e.g. SetMetricAsCorrelation() does not throw error -> therefore must be the MattesMutualInformation metric
Initializing image with np.random.rand(100,100,100) does not throw error -> therefore must be the corner case where inputs are zero
Contributor guide
Assessment
This issue has not been assessed yet.