[TASK] Fix contrast calculation.

This commit is contained in:
Jan Philipp Timme 2015-12-11 14:47:16 +01:00
parent 6ead23f875
commit 6ddb798177
1 changed files with 5 additions and 10 deletions

View File

@ -65,21 +65,16 @@ class LazyImage {
for(int i=0; i<256;i++) { for(int i=0; i<256;i++) {
sum += (i*histogramm_relative_intensity[i]); sum += (i*histogramm_relative_intensity[i]);
} }
this->intensity_average = (int) qRound(sum); this->intensity_average = qRound(sum);
}; };
void calcIntensityVariance(void) { void calcIntensityVariance(void) {
int intensity_average = this->intensity_average; int intensity_average = this->intensity_average;
int sum_difference = 0; double sum = 0;
for(int x=0; x<this->img->width(); x++) { for(int i=0; i<256; i++) {
for(int y=0; y<this->img->height(); y++) { sum += histogramm_relative_intensity[i] * pow((i - intensity_average),2);
QColor color = QColor::fromRgb(this->img->pixel(x, y));
int r,g,b;
color.getRgb(&r,&g,&b);
sum_difference += std::abs(this->calcIntensity(r, g, b) - intensity_average);;
} }
} this->intensity_variance = qRound(sum);
this->intensity_variance = (int) qRound(sum_difference/(this->img->width()*this->img->height()));
}; };
void generateNormalHistogrammImage(void) { void generateNormalHistogrammImage(void) {