My old project for strange attractors, new approach
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 

48 lines
1.0 KiB

//
// 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>
#include <cmath>
namespace Tonemappers {
struct Normalizer2D {
Normalizer2D()
: max(0)
{}
template <typename C>
void analyse(C const & canvas){
//max = *std::max_element(canvas.cbegin(), canvas.cend());
for (size_t x = 0; x < canvas.get_size(0); ++x) {
for (size_t y = 0; y < canvas.get_size(1); ++y) {
max = std::max(max, (unsigned int)canvas[x][y]);
}
}
}
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 << typename I::pixel(std::pow(grayscale, 0.2), std::pow(grayscale, 0.6), grayscale*1.5);
}
}
}
private:
unsigned int max;
};
}
#endif