The check for misalignment in the method mitk::ImageStatisticsCalculator::InternalCalculateStatisticsMasked doesn't work when the geometries of the image and the mask are rotated in the world coordinate system. Currently it checks if the difference between the origin of the mask and the origin of the image is a multiple of the image spacing (for each direction). This doesn't work if the geometries are rotated.
Solution:
- Check if the direction of the mask and the image are the same
- Transform the origin of the mask into continuous index coordinates of the image
- Check if the continuous index coordinates are integer values or rather if they are very close to an integer value ( < mitk::eps )