Skip to content

Commit

Permalink
ENH: Introduce constants for the default tolerances
Browse files Browse the repository at this point in the history
Consolidates constants used for default tolerances into the itkImage
header file.
  • Loading branch information
blowekamp authored and hjmjohnson committed Mar 6, 2024
1 parent 876da25 commit 4881cee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions Modules/Core/Common/include/itkImageBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/src/itkImageToImageFilterCommon.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4881cee

Please sign in to comment.