diff --git a/Modules/Core/Metadata/include/otbImageMetadata.h b/Modules/Core/Metadata/include/otbImageMetadata.h
index 77a405ac21078baacf930853dd04fb27fee77457..ac8b9f2c574015598aef13d4e1d7a0e4350b7636 100644
--- a/Modules/Core/Metadata/include/otbImageMetadata.h
+++ b/Modules/Core/Metadata/include/otbImageMetadata.h
@@ -25,6 +25,7 @@
 #include "otbMetaDataKey.h"
 #include "OTBMetadataExport.h"
 #include "otbMacro.h"
+#include "itkMath.h"
 
 #include <boost/any.hpp>
 #include <vector>
diff --git a/Modules/Core/Metadata/src/otbImageMetadata.cxx b/Modules/Core/Metadata/src/otbImageMetadata.cxx
index 631f482a723924bcf939c344c717cf0caeead487..1997503e2544f4e44a415b1b12787ff324a80345 100644
--- a/Modules/Core/Metadata/src/otbImageMetadata.cxx
+++ b/Modules/Core/Metadata/src/otbImageMetadata.cxx
@@ -479,7 +479,7 @@ void ImageMetadata::compact()
     {
       auto otherKey = bandIt->NumericKeys.find(kv.first);
       if ((otherKey == bandIt->NumericKeys.end())
-       || !(std::fabs(otherKey->second != kv.second) <= std::numeric_limits<double>::epsilon()))
+       || !itk::Math::AlmostEquals(otherKey->second, kv.second))
       {
         compactVal = false;
         break;
@@ -531,7 +531,7 @@ void ImageMetadata::compact()
     {
       auto otherKey = bandIt->TimeKeys.find(kv.first);
       if ((otherKey == bandIt->TimeKeys.end())
-       || !(std::fabs(otherKey->second.frac_sec != kv.second.frac_sec) <= std::numeric_limits<double>::epsilon()))
+       || !itk::Math::AlmostEquals(otherKey->second.frac_sec, kv.second.frac_sec))
       {
         compactVal = false;
         break;