diff --git a/Modules/Core/Common/include/itkImageBase.h b/Modules/Core/Common/include/itkImageBase.h index 8571659f663..b8391e65c2b 100644 --- a/Modules/Core/Common/include/itkImageBase.h +++ b/Modules/Core/Common/include/itkImageBase.h @@ -44,6 +44,15 @@ namespace itk { +/** The default tolerance when comparing the geometry of two images. + * + * The value was chosen based on precisions of file formats such as DICOM, + * to enable interoperability with images saved to file formats with higher precision. + */ +inline constexpr double DefaultImageCoordinateTolerance = 1e-6; +inline constexpr double DefaultImageDirectionTolerance = 1e-6; + + /** \class ImageBase * \brief Base class for templated image classes. * @@ -791,8 +800,8 @@ class ITK_TEMPLATE_EXPORT ImageBase : public DataObject */ bool IsSameImageGeometryAs(const ImageBase * otherImage, - double coordinateTolerance = 1e-6, - double directionTolerance = 1e-6) const; + double coordinateTolerance = DefaultImageCoordinateTolerance, + double directionTolerance = DefaultImageDirectionTolerance) const; /** INTERNAL This method is used internally by filters to copy meta-data from * the output to the input. Users should not have a need to use this method. diff --git a/Modules/Core/Common/include/itkMacro.h b/Modules/Core/Common/include/itkMacro.h index a01303407c2..40e41077431 100644 --- a/Modules/Core/Common/include/itkMacro.h +++ b/Modules/Core/Common/include/itkMacro.h @@ -485,6 +485,7 @@ OutputWindowDisplayGenericOutputText(const char *); extern ITKCommon_EXPORT void OutputWindowDisplayDebugText(const char *); + } // end namespace itk // The itkDebugStatement is to be used to protect code that is only used in the itkDebugMacro diff --git a/Modules/Core/Common/src/itkImageToImageFilterCommon.cxx b/Modules/Core/Common/src/itkImageToImageFilterCommon.cxx index 6aac727f33a..5246051f173 100644 --- a/Modules/Core/Common/src/itkImageToImageFilterCommon.cxx +++ b/Modules/Core/Common/src/itkImageToImageFilterCommon.cxx @@ -23,8 +23,8 @@ namespace itk namespace { -double globalDefaultCoordinateTolerance = 1.0e-6; -double globalDefaultDirectionTolerance = 1.0e-6; +double globalDefaultCoordinateTolerance = DefaultImageCoordinateTolerance; +double globalDefaultDirectionTolerance = DefaultImageDirectionTolerance; } // namespace void