[TASK] Add support for negative weights.

This commit is contained in:
Jan Philipp Timme 2015-11-27 15:06:21 +01:00
parent f875f1b8b6
commit 1b71c572b9
1 changed files with 5 additions and 2 deletions

View File

@ -487,8 +487,8 @@ void ImageViewer::applyBasicFilter() {
for(int i=0; i<filter_size; i++) {
for(int j=0; j<filter_size; j++) {
int current_data = data[i*filter_size + j];
filter_sum += current_data;
//logFile << "@" << i << "," << j << " -> " << current_data << std::endl;
filter_sum += abs(current_data); // support for negativ weights using abs()
logFile << "@" << i << "," << j << " -> " << current_data << std::endl;
}
}
@ -515,6 +515,9 @@ void ImageViewer::applyBasicFilter() {
//std::cout << "old lightness: " << l << ", filter_sum: " << filter_sum << ", intensity_sum:" << intensity_sum;
// divide by sum of weights
l = qRound((intensity_sum*1.0) / filter_sum);
//optional clamping for exotic stuff like negative values
if(l > 255) l = 255;
if(l < 0) l = 0;
//std::cout << " --> new l: " << l << std::endl;
color.setHsl(h, s, l);
// and set it.