220 unsigned int _width,
unsigned int _height,
Image &_output,
224 unsigned int samples = _width * _height;
225 unsigned int bufferSize = samples *
sizeof(T);
228 memcpy(buffer.data(), _data, bufferSize);
237 for (
unsigned int i = 0; i < samples; ++i)
243 if (v > max && !
std::isinf(
static_cast<float>(v)))
245 if (v < min && !
std::isinf(
static_cast<float>(v)))
254 double range =
static_cast<double>(max - min);
257 unsigned int idx = 0;
258 for (
unsigned int j = 0; j < _height; ++j)
260 for (
unsigned int i = 0; i < _width; ++i)
262 auto v = buffer[idx++];
263 double t =
static_cast<double>(v - min) / range;
266 uint8_t r =
static_cast<uint8_t
>(255*t);
267 unsigned int outIdx = j * _width * 3 + i * 3;
268 outputRgbBuffer[outIdx] = r;
269 outputRgbBuffer[outIdx + 1] = r;
270 outputRgbBuffer[outIdx + 2] = r;
273 _output.
SetFromData(outputRgbBuffer.data(), _width, _height, RGB_INT8);