changeset 1163:ba9db2ad317c broker

test log
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 Nov 2019 20:44:55 +0100
parents 709aa65aca17
children 6c159b8362ff
files Framework/Scene2D/FloatTextureSceneLayer.cpp Framework/Scene2D/FloatTextureSceneLayer.h Framework/Scene2D/GrayscaleStyleConfigurator.cpp Framework/Scene2D/GrayscaleStyleConfigurator.h Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.cpp
diffstat 5 files changed, 48 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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
--- 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_);
   }
 }
--- 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_;
--- 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<float>(v));
+            if (v <= 0)
+            {
+              v = 0;
+            }
+            else if (v >= 255)
+            {
+              v = 255;
+            }
+          }
+
           uint8_t vv = static_cast<uint8_t>(v);
 
           q[0] = lut[4 * vv + 2];  // B