239 unsigned int _width,
unsigned int _height,
Image &_output,
243 unsigned int samples = _width * _height;
244 unsigned int bufferSize = samples *
sizeof(T);
247 memcpy(buffer.data(), _data, bufferSize);
256 for (
unsigned int i = 0; i < samples; ++i)
262 if (v > max && !
std::isinf(
static_cast<float>(v)))
264 if (v < min && !
std::isinf(
static_cast<float>(v)))
273 double range =
static_cast<double>(max - min);
276 unsigned int idx = 0;
277 for (
unsigned int j = 0; j < _height; ++j)
279 for (
unsigned int i = 0; i < _width; ++i)
281 auto v = buffer[idx++];
282 double t =
static_cast<double>(v - min) / range;
285 uint8_t r =
static_cast<uint8_t
>(255*t);
286 unsigned int outIdx = j * _width * 3 + i * 3;
287 outputRgbBuffer[outIdx] = r;
288 outputRgbBuffer[outIdx + 1] = r;
289 outputRgbBuffer[outIdx + 2] = r;
292 _output.
SetFromData(outputRgbBuffer.data(), _width, _height, RGB_INT8);