diff Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp @ 1179:177e7d431cd1 broker

log scale in textures, remove redundant code for LUTs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Nov 2019 15:24:20 +0100
parents 6e79e8c9021c
children 0ca50d275b9a
line wrap: on
line diff
--- a/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp	Wed Nov 20 14:12:11 2019 +0100
+++ b/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp	Wed Nov 20 15:24:20 2019 +0100
@@ -53,6 +53,8 @@
              target.GetFormat() == Orthanc::PixelFormat_BGRA32 &&
              sizeof(float) == 4);
 
+      static const float LOG_NORMALIZATION = 255.0f / log(1.0f + 255.0f);
+      
       for (unsigned int y = 0; y < height; y++)
       {
         const float* p = reinterpret_cast<const float*>(source.GetConstRow(y));
@@ -70,6 +72,14 @@
             v = 255;
           }
 
+          if (l.IsApplyLog())
+          {
+            // https://theailearner.com/2019/01/01/log-transformation/
+            v = LOG_NORMALIZATION * log(1.0f + static_cast<float>(v));
+          }
+
+          assert(v >= 0.0f && v <= 255.0f);
+
           uint8_t vv = static_cast<uint8_t>(v);
 
           if (l.IsInverted())