18 #ifndef PIC_TONE_MAPPING_SCHLICK_TMO_HPP 19 #define PIC_TONE_MAPPING_SCHLICK_TMO_HPP 21 #include "../base.hpp" 23 #include "../util/array.hpp" 24 #include "../util/indexed_array.hpp" 26 #include "../image.hpp" 27 #include "../filtering/filter.hpp" 28 #include "../filtering/filter_luminance.hpp" 29 #include "../tone_mapping/tone_mapping_operator.hpp" 63 images[0]->getMaxVal(NULL, &LMax);
65 int channels = imgIn[0]->channels;
67 bool bNonUniform = (
mode.compare(
"nonuniform") == 0);
70 if((
mode.compare(
"automatic") == 0) || bNonUniform) {
71 int nValues = 1 <<
nBit;
72 p_prime =
L0 * LMax / (float(nValues) * LMin);
77 float cSqrtLminLmax = sqrtf(LMin * LMax);
79 #pragma omp parallel for 80 for(
int i = 0; i <
images[0]->size(); i++) {
82 float Lw =
images[0]->data[i];
85 float p_prime_w = p_prime;
88 p_prime_w *= (1.0f -
k +
k * Lw / cSqrtLminLmax);
91 float Ld = (p_prime_w * Lw) / ((p_prime_w - 1.0f) * Lw + LMax);
93 int index = i * channels;
94 for(
int j = 0; j < channels; j++) {
96 imgOut->
data[
k] = (imgIn[0]->data[
k] * Ld) / Lw;
133 void update(std::string
mode =
"automatic",
float p = 200.0f,
int nBit = 8,
float L0 = 1.0f,
float k = 0.5f)
136 this->k =
CLAMPi(
k, 0.0f, 1.0f);
138 this->p =
p < 1.0f ? 200.0f :
p;
139 this->L0 =
L0 < 0.0f ? 1.0f :
L0;
150 SchlickTMO stmo(
"automatic", 1.0f / 0.005f, 8, 1.0f, 0.5f);
~SchlickTMO()
Definition: schlick_tmo.hpp:120
float L0
Definition: schlick_tmo.hpp:41
Image * Process(ImageVec imgIn, Image *imgOut=NULL)
Process.
Definition: tone_mapping_operator.hpp:120
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
ImageVec images
Definition: tone_mapping_operator.hpp:35
FilterLuminance flt_lum
Definition: schlick_tmo.hpp:42
The ToneMappingOperator class.
Definition: tone_mapping_operator.hpp:31
static Image * execute(Image *imgIn, Image *imgOut)
execute
Definition: schlick_tmo.hpp:148
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
The FilterLuminance class.
Definition: filter_luminance.hpp:33
float k
Definition: schlick_tmo.hpp:41
static void findSimple(T *data, int nData, bool(*func)(float), IntCoord &ret, int stride=1)
findSimple collects coordinates of data which satisfies a bool function func.
Definition: indexed_array.hpp:80
void updateImage(Image *imgIn)
updateImage
Definition: tone_mapping_operator.hpp:78
void release()
release
Definition: tone_mapping_operator.hpp:68
Image * ProcessAux(ImageVec imgIn, Image *imgOut)
ProcessAux.
Definition: schlick_tmo.hpp:50
std::vector< int > IntCoord
IntCoord.
Definition: indexed_array.hpp:30
The Image class stores an image as buffer of float.
Definition: image.hpp:60
The IndexedArray class.
Definition: indexed_array.hpp:36
static T percentile(T *data, IntCoord &coord, float percent)
percentile
Definition: indexed_array.hpp:181
void update(std::string mode="automatic", float p=200.0f, int nBit=8, float L0=1.0f, float k=0.5f)
update
Definition: schlick_tmo.hpp:133
int nBit
Definition: schlick_tmo.hpp:40
#define CLAMPi(x, a, b)
Definition: math.hpp:81
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Definition: bilateral_separation.hpp:25
The SchlickTMO class.
Definition: schlick_tmo.hpp:36
SchlickTMO(std::string mode, float p, int nBit, float L0, float k)
SchlickTMO.
Definition: schlick_tmo.hpp:114
std::string mode
Definition: schlick_tmo.hpp:39
float p
Definition: schlick_tmo.hpp:41