Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
1178:3c7cdbf32e2a | 1179:177e7d431cd1 |
---|---|
51 | 51 |
52 assert(source.GetFormat() == Orthanc::PixelFormat_Float32 && | 52 assert(source.GetFormat() == Orthanc::PixelFormat_Float32 && |
53 target.GetFormat() == Orthanc::PixelFormat_BGRA32 && | 53 target.GetFormat() == Orthanc::PixelFormat_BGRA32 && |
54 sizeof(float) == 4); | 54 sizeof(float) == 4); |
55 | 55 |
56 static const float LOG_NORMALIZATION = 255.0f / log(1.0f + 255.0f); | |
57 | |
56 for (unsigned int y = 0; y < height; y++) | 58 for (unsigned int y = 0; y < height; y++) |
57 { | 59 { |
58 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); | 60 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); |
59 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); | 61 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); |
60 | 62 |
67 } | 69 } |
68 else if (v >= 255) | 70 else if (v >= 255) |
69 { | 71 { |
70 v = 255; | 72 v = 255; |
71 } | 73 } |
74 | |
75 if (l.IsApplyLog()) | |
76 { | |
77 // https://theailearner.com/2019/01/01/log-transformation/ | |
78 v = LOG_NORMALIZATION * log(1.0f + static_cast<float>(v)); | |
79 } | |
80 | |
81 assert(v >= 0.0f && v <= 255.0f); | |
72 | 82 |
73 uint8_t vv = static_cast<uint8_t>(v); | 83 uint8_t vv = static_cast<uint8_t>(v); |
74 | 84 |
75 if (l.IsInverted()) | 85 if (l.IsInverted()) |
76 { | 86 { |