Tone Mapping operator in C++