222 unsigned int _width,
unsigned int _height,
Image &_output,
226 unsigned int samples = _width * _height;
227 unsigned int bufferSize = samples *
sizeof(T);
230 memcpy(buffer.data(), _data, bufferSize);
239 for (
unsigned int i = 0; i < samples; ++i)
245 if (v > max && !
std::isinf(
static_cast<float>(v)))
247 if (v < min && !
std::isinf(
static_cast<float>(v)))
256 double range =
static_cast<double>(max - min);
259 unsigned int idx = 0;
260 for (
unsigned int j = 0; j < _height; ++j)
262 for (
unsigned int i = 0; i < _width; ++i)
264 auto v = buffer[idx++];
265 double t =
static_cast<double>(v - min) / range;
268 uint8_t r =
static_cast<uint8_t
>(255*t);
269 unsigned int outIdx = j * _width * 3 + i * 3;
270 outputRgbBuffer[outIdx] = r;
271 outputRgbBuffer[outIdx + 1] = r;
272 outputRgbBuffer[outIdx + 2] = r;
275 _output.
SetFromData(outputRgbBuffer.data(), _width, _height, RGB_INT8);