vibrancy correctly implemented
This commit is contained in:
parent
6e2c2a6b2d
commit
3b1135274b
1 changed files with 12 additions and 12 deletions
|
@ -107,14 +107,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
const double vibrancy = v;
|
const double vibrancy = v;
|
||||||
double averagePower = 0;
|
|
||||||
for(unsigned int i = 0; i < num_colors; i++) {
|
|
||||||
averagePower += power[i];
|
|
||||||
}
|
|
||||||
averagePower /= (double)num_colors;
|
|
||||||
for(unsigned int i = 0; i < num_colors; i++) {
|
|
||||||
power[i] = vibrancy*power[i] + (1.0 - vibrancy)*averagePower;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: find a way to set these things:
|
// TODO: find a way to set these things:
|
||||||
// pngFile->setcompressionlevel(9);
|
// pngFile->setcompressionlevel(9);
|
||||||
|
@ -137,16 +129,24 @@ public:
|
||||||
double r = 0.0;
|
double r = 0.0;
|
||||||
double g = 0.0;
|
double g = 0.0;
|
||||||
double b = 0.0;
|
double b = 0.0;
|
||||||
|
double average_norm_value = 0.0;
|
||||||
|
for(unsigned int c = 0; c < num_colors; ++c){
|
||||||
|
average_norm_value += (double)int_array[x + y*width + c*width*height]/max_int[c];
|
||||||
|
}
|
||||||
|
average_norm_value /= (double) num_colors;
|
||||||
for(unsigned int c = 0; c < num_colors; c++) {
|
for(unsigned int c = 0; c < num_colors; c++) {
|
||||||
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c];
|
double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c];
|
||||||
|
norm_value = vibrancy*norm_value + (1.0 - vibrancy) * average_norm_value;
|
||||||
|
norm_value = std::max(0.0, norm_value);
|
||||||
r += (std::pow(norm_value, power[c]*power_matrix[c+0]))*output_matrix[c+0];
|
r += (std::pow(norm_value, power[c]*power_matrix[c+0]))*output_matrix[c+0];
|
||||||
g += (std::pow(norm_value, power[c]*power_matrix[c+2]))*output_matrix[c+2];
|
g += (std::pow(norm_value, power[c]*power_matrix[c+2]))*output_matrix[c+2];
|
||||||
b += (std::pow(norm_value, power[c]*power_matrix[c+4]))*output_matrix[c+4];
|
b += (std::pow(norm_value, power[c]*power_matrix[c+4]))*output_matrix[c+4];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: also clamp is below 0 ?
|
// TODO: also clamp is below 0 ?
|
||||||
r = std::min(1.0, r);
|
r = std::max(0.0, std::min(1.0, r));
|
||||||
b = std::min(1.0, b);
|
b = std::max(0.0, std::min(1.0, b));
|
||||||
g = std::min(1.0, g);
|
g = std::max(0.0, std::min(1.0, g));
|
||||||
image[y][x] = png::rgb_pixel(r*255, g*255, b*255);
|
image[y][x] = png::rgb_pixel(r*255, g*255, b*255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue