241 unsigned int _width,
unsigned int _height,
Image &_output,
245 unsigned int samples = _width * _height;
246 unsigned int bufferSize = samples *
sizeof(T);
249 memcpy(buffer.data(), _data, bufferSize);
258 for (
unsigned int i = 0; i < samples; ++i)
264 if (v > max && !
std::isinf(
static_cast<float>(v)))
266 if (v < min && !
std::isinf(
static_cast<float>(v)))
275 double range =
static_cast<double>(max - min);
278 unsigned int idx = 0;
279 for (
unsigned int j = 0; j < _height; ++j)
281 for (
unsigned int i = 0; i < _width; ++i)
283 auto v = buffer[idx++];
284 double t =
static_cast<double>(v - min) / range;
287 uint8_t r =
static_cast<uint8_t
>(255*t);
288 unsigned int outIdx = j * _width * 3 + i * 3;
289 outputRgbBuffer[outIdx] = r;
290 outputRgbBuffer[outIdx + 1] = r;
291 outputRgbBuffer[outIdx + 2] = r;
294 _output.
SetFromData(outputRgbBuffer.data(), _width, _height, RGB_INT8);