From 839308fe335645b71d617ed075a0434adfd724ca Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Fri, 4 Dec 2015 14:01:13 +0100 Subject: [PATCH] [TASK] Not quite sure, but partial linear histogramm adaption seems to be done. --- imageviewer-qt4.cpp | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index e4139a3..7f56a9c 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -375,17 +375,19 @@ void ImageViewer::partialLinearHistogrammAdaption() { double* reference_histogramm = histogramm_reference->getRelativeCumulativeIntensityHistogramm(); // Split [0,255] into n parts (slider) + // This produces a list of brightness indexes to interpolate in between. int number_parts = partial_adaption_pieces_slider->value(); - int* parts = (int*) malloc(number_parts*sizeof(int)); - for(int i=0; i 255) j = 255; + brightness_map[i] = j; + } + + for(int i=0; i<256; i++) { + logFile << i << " -> " << brightness_map[i] << std::endl; + } + renewLogging(); + + // Apply the brightness map int h, s, l; - int pixels = working_copy->getImage()->width() * working_copy->getImage()->height(); for(int x=0; xgetImage()->width(); x++) { for(int y=0; ygetImage()->height(); y++) { QColor color = QColor::fromRgb(original->getImage()->pixel(x, y)); color.getHsl(&h, &s, &l); - l = qRound(histogramm_map[l] * (255/pixels)); + l = brightness_map[l]; color.setHsl(h, s, l); working_copy->getImage()->setPixel(x, y, color.rgb()); } - }*/ + } + + // Done. + free(brightness_map); free(histogramm_map); free(parts); logFile << "done." << std::endl; @@ -788,7 +809,7 @@ void ImageViewer::generateControlPanels() { partial_adaption_pieces_slider = new QSlider(Qt::Horizontal); partial_adaption_pieces_slider->setMinimum(2); - partial_adaption_pieces_slider->setMaximum(10); + partial_adaption_pieces_slider->setMaximum(20); partial_adaption_pieces_slider->setValue(5); //QObject::connect(partial_adaption_pieces_slider, SIGNAL(valueChanged(int)), this, SLOT(robustAutomaticContrastAdaption(int)));