Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp @ 1287:8e82fdc6200e bugs/2020-02-invisible-slice
Heavy (temporary) logging in the path that leads
from multiframe volume to slice (rendered texture)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 14 Feb 2020 15:00:54 +0100 |
parents | 29cdd73d9477 |
children | 343aa1dfaa90 |
comparison
equal
deleted
inserted
replaced
1286:ddb6676bbcbf | 1287:8e82fdc6200e |
---|---|
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #include "OpenGLLookupTableTextureRenderer.h" | 22 #include "OpenGLLookupTableTextureRenderer.h" |
23 | 23 |
24 #include "../../Toolbox/ImageToolbox.h" | |
25 | |
26 | |
24 #include <Core/OrthancException.h> | 27 #include <Core/OrthancException.h> |
25 | 28 |
26 | 29 |
27 int OrthancStone_Internals_dump_LoadTexture_histogram = 0; | 30 int OrthancStone_Internals_dump_LoadTexture_histogram = 0; |
28 | 31 |
87 uint8_t k = static_cast<uint8_t>(i); | 90 uint8_t k = static_cast<uint8_t>(i); |
88 debugHistogram[k] = 0; | 91 debugHistogram[k] = 0; |
89 } | 92 } |
90 } | 93 } |
91 | 94 |
92 | |
93 for (unsigned int y = 0; y < height; y++) | 95 for (unsigned int y = 0; y < height; y++) |
94 { | 96 { |
95 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); | 97 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); |
96 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); | 98 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); |
97 | 99 |
107 v = 255; | 109 v = 255; |
108 } | 110 } |
109 | 111 |
110 uint8_t vv = static_cast<uint8_t>(v); | 112 uint8_t vv = static_cast<uint8_t>(v); |
111 | 113 |
112 if(OrthancStone_Internals_dump_LoadTexture_histogram == 1) | 114 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) |
113 debugHistogram[vv] += 1; | 115 debugHistogram[vv] += 1; |
116 | |
114 | 117 |
115 q[0] = lut[4 * vv + 0]; // R | 118 q[0] = lut[4 * vv + 0]; // R |
116 q[1] = lut[4 * vv + 1]; // G | 119 q[1] = lut[4 * vv + 1]; // G |
117 q[2] = lut[4 * vv + 2]; // B | 120 q[2] = lut[4 * vv + 2]; // B |
118 q[3] = lut[4 * vv + 3]; // A | 121 q[3] = lut[4 * vv + 3]; // A |
122 } | 125 } |
123 } | 126 } |
124 | 127 |
125 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) | 128 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) |
126 { | 129 { |
127 uint8_t vv; | 130 LOG(ERROR) << "+----------------------------------------+"; |
128 LOG(INFO) << "Dumping texture loaded with OpenGLLookupTableTextureRenderer::LoadTexture"; | 131 LOG(ERROR) << "| This is not an error! |"; |
129 for (int i = 0; i <= 255; ++i) | 132 LOG(ERROR) << "+----------------------------------------+"; |
130 { | 133 LOG(ERROR) << "Work on the \"invisible slice\" bug"; |
131 vv = static_cast<uint8_t>(i); | 134 LOG(ERROR) << "--> in OpenGLLookupTableTextureRenderer::LoadTexture():"; |
132 int ivv = vv; | 135 LOG(ERROR) << "layer.GetMinValue() = " << layer.GetMinValue() << " | layer.GetMaxValue() = " << layer.GetMaxValue(); |
133 int count = debugHistogram[vv]; | 136 LOG(ERROR) << "a = " << a << " | slope = " << slope; |
134 int lutr = lut[4 * vv + 0]; | 137 |
135 int lutg = lut[4 * vv + 1]; | 138 LOG(ERROR) << "SOURCE gets scaled and offset, this yields --> TEMP that gets through the lut to yield RESULT"; |
136 int lutb = lut[4 * vv + 2]; | 139 LOG(ERROR) << "The SOURCE (layer.GetTexture()) will be dumped below (format is Float32)"; |
137 int luta = lut[4 * vv + 3]; | 140 LOG(ERROR) << ""; |
138 | 141 HistogramData hd; |
139 LOG(ERROR) << "This is no error! Y= " << ivv << " count= " << count | 142 double minValue = 0; |
140 << " lut R= " << lutr << " lut G= " << lutg << " lut B= " << lutb << " lut A= " << luta; | 143 double maxValue = 0; |
141 } | 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(ERROR) << s; | |
150 LOG(ERROR) << ""; | |
151 | |
152 | |
153 LOG(ERROR) << "TEMP will be dumped below (format is uint8_t)"; | |
154 LOG(ERROR) << ""; | |
155 | |
156 { | |
157 uint8_t vv = 0; | |
158 do | |
159 { | |
160 LOG(ERROR) << " TEMP. Pixel " << (int)vv << " is present " | |
161 << debugHistogram[vv] << " times"; | |
162 } while (vv++ != 255); | |
163 } | |
164 | |
165 LOG(ERROR) << "\nThe LUT will be dumped below"; | |
166 LOG(ERROR) << "----------------------------"; | |
167 LOG(ERROR) << ""; | |
168 | |
169 { | |
170 uint8_t vv = 0; | |
171 // proper way to loop on all unsigned values is a do while loop | |
172 do | |
173 { | |
174 LOG(ERROR) << " LUT[" << (int)vv << "] =" | |
175 << " R:" << (int)lut[4 * vv + 0] | |
176 << " G:" << (int)lut[4 * vv + 1] | |
177 << " B:" << (int)lut[4 * vv + 2] | |
178 << " A:" << (int)lut[4 * vv + 3]; | |
179 } while (vv++ != 255); | |
180 } | |
181 LOG(ERROR) << "+----------------------------------------+"; | |
182 LOG(ERROR) << "| end of debug dump |"; | |
183 LOG(ERROR) << "+----------------------------------------+"; | |
142 } | 184 } |
143 } | 185 } |
144 | 186 |
145 context_.MakeCurrent(); | 187 context_.MakeCurrent(); |
146 glTexture_.reset(new OpenGL::OpenGLTexture(context_)); | 188 glTexture_.reset(new OpenGL::OpenGLTexture(context_)); |