Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp @ 1291:ea6c2254536d bugs/2020-02-invisible-slice
Removal of debug logs
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 21 Feb 2020 15:23:40 +0100 |
parents | 343aa1dfaa90 |
children | 6ab03e429f06 |
comparison
equal
deleted
inserted
replaced
1290:7def6ab2929f | 1291:ea6c2254536d |
---|---|
23 | 23 |
24 #include "../../Toolbox/ImageToolbox.h" | 24 #include "../../Toolbox/ImageToolbox.h" |
25 | 25 |
26 | 26 |
27 #include <Core/OrthancException.h> | 27 #include <Core/OrthancException.h> |
28 | |
29 | |
30 int OrthancStone_Internals_dump_LoadTexture_histogram = 0; | |
31 | 28 |
32 namespace OrthancStone | 29 namespace OrthancStone |
33 { | 30 { |
34 namespace Internals | 31 namespace Internals |
35 { | 32 { |
80 assert(source.GetFormat() == Orthanc::PixelFormat_Float32 && | 77 assert(source.GetFormat() == Orthanc::PixelFormat_Float32 && |
81 target.GetFormat() == Orthanc::PixelFormat_RGBA32 && | 78 target.GetFormat() == Orthanc::PixelFormat_RGBA32 && |
82 sizeof(float) == 4); | 79 sizeof(float) == 4); |
83 | 80 |
84 | 81 |
85 std::map<uint8_t, int> debugHistogram; | |
86 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) | |
87 { | |
88 for (int i = 0; i <= 255; ++i) | |
89 { | |
90 uint8_t k = static_cast<uint8_t>(i); | |
91 debugHistogram[k] = 0; | |
92 } | |
93 } | |
94 | |
95 for (unsigned int y = 0; y < height; y++) | 82 for (unsigned int y = 0; y < height; y++) |
96 { | 83 { |
97 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); | 84 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); |
98 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); | 85 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); |
99 | 86 |
109 v = 255; | 96 v = 255; |
110 } | 97 } |
111 | 98 |
112 uint8_t vv = static_cast<uint8_t>(v); | 99 uint8_t vv = static_cast<uint8_t>(v); |
113 | 100 |
114 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) | |
115 debugHistogram[vv] += 1; | |
116 | |
117 | |
118 q[0] = lut[4 * vv + 0]; // R | 101 q[0] = lut[4 * vv + 0]; // R |
119 q[1] = lut[4 * vv + 1]; // G | 102 q[1] = lut[4 * vv + 1]; // G |
120 q[2] = lut[4 * vv + 2]; // B | 103 q[2] = lut[4 * vv + 2]; // B |
121 q[3] = lut[4 * vv + 3]; // A | 104 q[3] = lut[4 * vv + 3]; // A |
122 | 105 |
123 p++; | 106 p++; |
124 q += 4; | 107 q += 4; |
125 } | 108 } |
126 } | 109 } |
127 | 110 |
128 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) | |
129 { | |
130 LOG(INFO) << "+----------------------------------------+"; | |
131 LOG(INFO) << "| This is not an error! |"; | |
132 LOG(INFO) << "+----------------------------------------+"; | |
133 LOG(INFO) << "Work on the \"invisible slice\" bug"; | |
134 LOG(INFO) << "--> in OpenGLLookupTableTextureRenderer::LoadTexture():"; | |
135 LOG(INFO) << "layer.GetMinValue() = " << layer.GetMinValue() << " | layer.GetMaxValue() = " << layer.GetMaxValue(); | |
136 LOG(INFO) << "a = " << a << " | slope = " << slope; | |
137 | |
138 LOG(INFO) << "SOURCE gets scaled and offset, this yields --> TEMP that gets through the lut to yield RESULT"; | |
139 LOG(INFO) << "The SOURCE (layer.GetTexture()) will be dumped below (format is Float32)"; | |
140 LOG(INFO) << ""; | |
141 HistogramData hd; | |
142 double minValue = 0; | |
143 double maxValue = 0; | |
144 ComputeMinMax(source, minValue, maxValue); | |
145 double binSize = (maxValue - minValue) * 0.01; // split in 100 bins | |
146 ComputeHistogram(source, hd, binSize); | |
147 std::string s; | |
148 DumpHistogramResult(s, hd); | |
149 LOG(INFO) << s; | |
150 LOG(INFO) << ""; | |
151 | |
152 | |
153 LOG(INFO) << "TEMP will be dumped below (format is uint8_t)"; | |
154 LOG(INFO) << ""; | |
155 | |
156 { | |
157 uint8_t vv = 0; | |
158 do | |
159 { | |
160 LOG(INFO) << " TEMP. Pixel " << (int)vv << " is present " | |
161 << debugHistogram[vv] << " times"; | |
162 } while (vv++ != 255); | |
163 } | |
164 | |
165 LOG(INFO) << "\nThe LUT will be dumped below"; | |
166 LOG(INFO) << "----------------------------"; | |
167 LOG(INFO) << "bgotag-2020-02-18-20-26"; | |
168 LOG(INFO) << ""; | |
169 | |
170 { | |
171 uint8_t vv = 0; | |
172 // proper way to loop on all unsigned values is a do while loop | |
173 do | |
174 { | |
175 LOG(INFO) << " LUT[" << (int)vv << "] =" | |
176 << " R:" << (int)lut[4 * vv + 0] | |
177 << " G:" << (int)lut[4 * vv + 1] | |
178 << " B:" << (int)lut[4 * vv + 2] | |
179 << " A:" << (int)lut[4 * vv + 3]; | |
180 } while (vv++ != 255); | |
181 } | |
182 LOG(INFO) << "+----------------------------------------+"; | |
183 LOG(INFO) << "| end of debug dump |"; | |
184 LOG(INFO) << "+----------------------------------------+"; | |
185 } | |
186 } | 111 } |
187 | 112 |
188 context_.MakeCurrent(); | 113 context_.MakeCurrent(); |
189 glTexture_.reset(new OpenGL::OpenGLTexture(context_)); | 114 glTexture_.reset(new OpenGL::OpenGLTexture(context_)); |
190 glTexture_->Load(*texture_, layer.IsLinearInterpolation()); | 115 glTexture_->Load(*texture_, layer.IsLinearInterpolation()); |