You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
790 B
38 lines
790 B
13 years ago
|
//
|
||
|
// Tonemapper.hpp
|
||
|
// AwesomeAttractorND
|
||
|
//
|
||
|
// Created by Joshua Moerman on 10/28/11.
|
||
|
// Copyright 2011 Vadovas. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#ifndef AwesomeAttractorND_Tonemapper_hpp
|
||
|
#define AwesomeAttractorND_Tonemapper_hpp
|
||
|
|
||
|
#include <algorithm>
|
||
|
|
||
|
namespace Tonemappers {
|
||
|
|
||
|
class Normalizer2D {
|
||
|
unsigned int max;
|
||
|
|
||
|
template <typename C>
|
||
|
void analyse(C const & canvas){
|
||
|
max = *std::max_element(canvas.cbegin(), canvas.cend());
|
||
|
}
|
||
|
|
||
|
template <typename C, typename I>
|
||
|
void process(C const & canvas, I & image){
|
||
|
for (size_t x = 0; x < canvas.get_size(0); ++x) {
|
||
|
for (size_t y = 0; y < canvas.get_size(1); ++y) {
|
||
|
const double grayscale = (double) canvas[x][y] / (double) max;
|
||
|
image << I::pixel(grayscale, grayscale, grayscale);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|