# HG changeset patch # User Sebastien Jodogne # Date 1574192695 -3600 # Node ID ba9db2ad317ca1e7632173b0792c0018555f827f # Parent 709aa65aca175d64fe1700cbd6b75a93b2592d87 test log diff -r 709aa65aca17 -r ba9db2ad317c Framework/Scene2D/FloatTextureSceneLayer.cpp --- a/Framework/Scene2D/FloatTextureSceneLayer.cpp Tue Nov 19 19:04:15 2019 +0100 +++ b/Framework/Scene2D/FloatTextureSceneLayer.cpp Tue Nov 19 20:44:55 2019 +0100 @@ -92,6 +92,14 @@ IncrementRevision(); } + + void FloatTextureSceneLayer::SetApplyLog(bool apply) + { + applyLog_ = apply; + IncrementRevision(); + } + + void FloatTextureSceneLayer::FitRange() { float minValue, maxValue; diff -r 709aa65aca17 -r ba9db2ad317c Framework/Scene2D/FloatTextureSceneLayer.h --- a/Framework/Scene2D/FloatTextureSceneLayer.h Tue Nov 19 19:04:15 2019 +0100 +++ b/Framework/Scene2D/FloatTextureSceneLayer.h Tue Nov 19 20:44:55 2019 +0100 @@ -32,6 +32,7 @@ float customCenter_; float customWidth_; bool inverted_; + bool applyLog_; public: // The pixel format must be convertible to "Float32" @@ -60,6 +61,13 @@ void FitRange(); + void SetApplyLog(bool apply); + + bool IsApplyLog() const + { + return applyLog_; + } + virtual ISceneLayer* Clone() const; virtual Type GetType() const diff -r 709aa65aca17 -r ba9db2ad317c Framework/Scene2D/GrayscaleStyleConfigurator.cpp --- a/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Tue Nov 19 19:04:15 2019 +0100 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Tue Nov 19 20:44:55 2019 +0100 @@ -59,6 +59,12 @@ revision_++; } + void GrayscaleStyleConfigurator::SetApplyLog(bool apply) + { + applyLog_ = apply; + revision_++; + } + TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromImage( const Orthanc::ImageAccessor& image) const { @@ -99,6 +105,8 @@ l.SetCustomWindowing(customWindowCenter_, customWindowWidth_); } } + l.SetInverted(inverted_); + l.SetApplyLog(applyLog_); } } diff -r 709aa65aca17 -r ba9db2ad317c Framework/Scene2D/GrayscaleStyleConfigurator.h --- a/Framework/Scene2D/GrayscaleStyleConfigurator.h Tue Nov 19 19:04:15 2019 +0100 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.h Tue Nov 19 20:44:55 2019 +0100 @@ -39,6 +39,7 @@ float customWindowWidth_; float customWindowCenter_; bool inverted_; + bool applyLog_; public: GrayscaleStyleConfigurator() : @@ -47,7 +48,8 @@ hasWindowing_(false), customWindowWidth_(0), customWindowCenter_(0), - inverted_(false) + inverted_(false), + applyLog_(false) { } @@ -66,6 +68,13 @@ return linearInterpolation_; } + void SetApplyLog(bool apply); + + bool IsApplyLog() const + { + return applyLog_; + } + virtual uint64_t GetRevision() const { return revision_; diff -r 709aa65aca17 -r ba9db2ad317c Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.cpp --- a/Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.cpp Tue Nov 19 19:04:15 2019 +0100 +++ b/Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.cpp Tue Nov 19 20:44:55 2019 +0100 @@ -84,6 +84,20 @@ v = 255; } + if (1) //l.IsApplyLog()) + { + // https://theailearner.com/2019/01/01/log-transformation/ + v = 255.0f / log(1.0f + 255.0f * 1.5f) * log(1.0f + static_cast(v)); + if (v <= 0) + { + v = 0; + } + else if (v >= 255) + { + v = 255; + } + } + uint8_t vv = static_cast(v); q[0] = lut[4 * vv + 2]; // B