275 unsigned int _width,
unsigned int _height,
Image &_output,
279 unsigned int samples = _width * _height;
280 unsigned int bufferSize = samples *
sizeof(T);
283 memcpy(buffer.data(), _data, bufferSize);
292 for (
unsigned int i = 0; i < samples; ++i)
298 if (v > max && !
std::isinf(
static_cast<float>(v)))
300 if (v < min && !
std::isinf(
static_cast<float>(v)))
309 double range =
static_cast<double>(max - min);
312 unsigned int idx = 0;
313 for (
unsigned int j = 0; j < _height; ++j)
315 for (
unsigned int i = 0; i < _width; ++i)
317 auto v = buffer[idx++];
318 double t =
static_cast<double>(v - min) / range;
321 uint8_t r =
static_cast<uint8_t
>(255*t);
322 unsigned int outIdx = j * _width * 3 + i * 3;
323 outputRgbBuffer[outIdx] = r;
324 outputRgbBuffer[outIdx + 1] = r;
325 outputRgbBuffer[outIdx + 2] = r;
328 _output.
SetFromData(outputRgbBuffer.data(), _width, _height, RGB_INT8);