diff --git a/lazy_image.cpp b/lazy_image.cpp index 432c163..08adc57 100644 --- a/lazy_image.cpp +++ b/lazy_image.cpp @@ -65,21 +65,16 @@ class LazyImage { for(int i=0; i<256;i++) { sum += (i*histogramm_relative_intensity[i]); } - this->intensity_average = (int) qRound(sum); + this->intensity_average = qRound(sum); }; void calcIntensityVariance(void) { int intensity_average = this->intensity_average; - int sum_difference = 0; - for(int x=0; ximg->width(); x++) { - for(int y=0; yimg->height(); y++) { - 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);; - } + double sum = 0; + for(int i=0; i<256; i++) { + sum += histogramm_relative_intensity[i] * pow((i - intensity_average),2); } - this->intensity_variance = (int) qRound(sum_difference/(this->img->width()*this->img->height())); + this->intensity_variance = qRound(sum); }; void generateNormalHistogrammImage(void) {