Mercurial > hg > orthanc-wsi
changeset 395:0045d4f23eba default tip
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Apr 2025 11:05:20 +0200 (5 weeks ago) |
parents | 14303bf258b0 |
children | |
files | Framework/ImageToolbox.cpp Framework/ImageToolbox.h ViewerPlugin/Plugin.cpp |
diffstat | 3 files changed, 19 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/ImageToolbox.cpp Sun Apr 27 20:27:54 2025 +0200 +++ b/Framework/ImageToolbox.cpp Mon Apr 28 11:05:20 2025 +0200 @@ -48,7 +48,15 @@ bool IsNear(double a, double b) { - return std::abs(a - b) < 100.0 * std::numeric_limits<double>::epsilon(); + return IsNear(a, b, 10.0 * std::numeric_limits<float>::epsilon()); + } + + + bool IsNear(double a, + double b, + double threshold) + { + return std::abs(a - b) < threshold; }
--- a/Framework/ImageToolbox.h Sun Apr 27 20:27:54 2025 +0200 +++ b/Framework/ImageToolbox.h Mon Apr 28 11:05:20 2025 +0200 @@ -36,6 +36,10 @@ bool IsNear(double a, double b); + bool IsNear(double a, + double b, + double threshold); + Orthanc::ImageAccessor* Allocate(Orthanc::PixelFormat format, unsigned int width, unsigned int height);
--- a/ViewerPlugin/Plugin.cpp Sun Apr 27 20:27:54 2025 +0200 +++ b/ViewerPlugin/Plugin.cpp Mon Apr 28 11:05:20 2025 +0200 @@ -472,17 +472,17 @@ OrthancWSI::LABColor lab; if (!OrthancWSI::LABColor::DecodeDicomRecommendedAbsentPixelCIELab(lab, "65535\\0\\0") || - !OrthancWSI::ImageToolbox::IsNear(lab.GetL(), 100.0) || - !OrthancWSI::ImageToolbox::IsNear(lab.GetA(), -128.0) || - !OrthancWSI::ImageToolbox::IsNear(lab.GetB(), -128.0)) + !OrthancWSI::ImageToolbox::IsNear(lab.GetL(), 100.0, 0.001) || + !OrthancWSI::ImageToolbox::IsNear(lab.GetA(), -128.0, 0.001) || + !OrthancWSI::ImageToolbox::IsNear(lab.GetB(), -128.0, 0.001)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } if (!OrthancWSI::LABColor::DecodeDicomRecommendedAbsentPixelCIELab(lab, "0\\32896\\65535") || - !OrthancWSI::ImageToolbox::IsNear(lab.GetL(), 0.0) || - !OrthancWSI::ImageToolbox::IsNear(lab.GetA(), 0.0) || - !OrthancWSI::ImageToolbox::IsNear(lab.GetB(), 127.0)) + !OrthancWSI::ImageToolbox::IsNear(lab.GetL(), 0.0, 0.001) || + !OrthancWSI::ImageToolbox::IsNear(lab.GetA(), 0.0, 0.001) || + !OrthancWSI::ImageToolbox::IsNear(lab.GetB(), 127.0, 0.001)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); }