18 #ifndef PIC_UTIL_DYNAMIC_RANGE_HPP 19 #define PIC_UTIL_DYNAMIC_RANGE_HPP 21 #include "../base.hpp" 22 #include "../util/math.hpp" 40 float aperture_value = 1.0f,
41 float iso_value = 1.0f,
42 float K_value = 12.5f)
44 K_value =
CLAMPi(K_value, 10.6f, 13.4f);
46 return (iso_value * shutter_speed) / (K_value * aperture_value * aperture_value);
58 float thr = 1.0f + delta;
60 for(
int i = 0; i < size; i++) {
79 int size,
LDR_type type,
float gamma = 2.2f)
86 dataOut =
new float[size];
90 for(
int i = 0; i < 256; i++) {
100 LUT[i] = i_f / 255.0f;
105 LUT[i] = powf(i_f / 255.0f, gamma);
115 #pragma omp parallel for 116 for(
int i = 0; i < size; i++) {
117 dataOut[i] = LUT[dataIn[i]];
133 int size,
LDR_type type,
float gamma = 2.2f)
139 if(dataOut == NULL) {
140 dataOut =
new unsigned char[size];
143 gamma = gamma > 0.0f ? gamma : 2.2f;
145 float invGamma = 1.0f / gamma;
150 #pragma omp parallel for 151 for(
int i = 0; i < size; i++) {
158 #pragma omp parallel for 159 for(
int i = 0; i < size; i++) {
160 dataOut[i] =
CLAMPi(
int(
lround(dataIn[i] * 255.0f)), 0, 255);
166 #pragma omp parallel for 167 for(
int i = 0; i < size; i++) {
168 float tmp = powf(dataIn[i], invGamma);
184 #endif //PIC_UTIL_DYNAMIC_RANGE_HPP PIC_INLINE long lround(double x)
lround rounds double numbers properly.
Definition: math.hpp:229
LDR_type
The LDR_type enum.
Definition: dynamic_range.hpp:29
PIC_INLINE bool checkNormalized(const float *data, int size, float delta=1e-6f)
checkNormalized checks if data is in [0,1].
Definition: dynamic_range.hpp:56
#define PIC_INLINE
Definition: base.hpp:33
Definition: dynamic_range.hpp:29
Definition: dynamic_range.hpp:29
Definition: dynamic_range.hpp:29
#define CLAMPi(x, a, b)
Definition: math.hpp:81
Definition: dynamic_range.hpp:29
Definition: bilateral_separation.hpp:25
PIC_INLINE float * convertLDR2HDR(unsigned char *dataIn, float *dataOut, int size, LDR_type type, float gamma=2.2f)
convertLDR2HDR converts a buffer of unsigned char into float.
Definition: dynamic_range.hpp:78
PIC_INLINE unsigned char * convertHDR2LDR(const float *dataIn, unsigned char *dataOut, int size, LDR_type type, float gamma=2.2f)
convertHDR2LDR converts a buffer of float into unsigned char.
Definition: dynamic_range.hpp:132
PIC_INLINE float estimateAverageLuminance(float shutter_speed, float aperture_value=1.0f, float iso_value=1.0f, float K_value=12.5f)
estimateAverageLuminance estimates the average luminance of the shot.
Definition: dynamic_range.hpp:39