[TASK] Make slider for automatic contrast adaption trigger the algorithm on its own.

This commit is contained in:
Jan Philipp Timme 2015-11-13 15:24:12 +01:00
parent bacc1b3567
commit bc5bec953f
2 changed files with 19 additions and 15 deletions

View File

@ -193,7 +193,9 @@ void ImageViewer::analyzeImage() {
working_copy->updateStatistics();
logFile << "done" << std::endl;
renewLogging();
QString result = QString("Intensity: Average: %1, Variance: %2").arg(working_copy->getIntensityAverage()).arg(working_copy->getIntensityVariance());
QString result = QString("Intensity: Average: %1, Variance: %2").arg(original->getIntensityAverage()).arg(original->getIntensityVariance());
original_stats->setText(result);
result = QString("Intensity: Average: %1, Variance: %2").arg(working_copy->getIntensityAverage()).arg(working_copy->getIntensityVariance());
stats->setText(result);
histogramm_label->setPixmap(QPixmap::fromImage(*(working_copy->getHistogrammImage())));
original_histogramm_label->setPixmap(QPixmap::fromImage(*(original->getHistogrammImage())));
@ -249,14 +251,14 @@ void ImageViewer::adjustContrast(int c) {
renewLogging();
}
/**
/** copy
* Using the percentile given by the slider, do a robust automatic contrast adaption.
*
* @brief ImageViewer::robustAutomaticContrastAdaption
*/
void ImageViewer::robustAutomaticContrastAdaption(void) {
void ImageViewer::robustAutomaticContrastAdaption(int c_param) {
double* histogramm = original->getRelativeIntensityHistogramm();
double limit = contrast_percentile_slider->value() / 100.0;
double limit = c_param / 1000.0;
logFile << "Doing automatic robust contrast adaption (" << limit << "), hold tight ..." << std::endl;
renewLogging();
@ -379,8 +381,11 @@ void ImageViewer::generateControlPanels() {
histogramm_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
histogramm_label->setScaledContents(false);
original_stats = new QLabel();
original_stats->setText("Stats for original image will be shown here.");
stats = new QLabel();
stats->setText("Intensity will be shown here.");
stats->setText("Stats for working copy will be shown here.");
analyze_image = new QPushButton();
analyze_image->setText("Update image statistics, redraw histogramms.");
@ -400,16 +405,16 @@ void ImageViewer::generateControlPanels() {
contrast_percentile_slider = new QSlider(Qt::Horizontal);
contrast_percentile_slider->setMinimum(0);
contrast_percentile_slider->setMaximum(50);
contrast_percentile_slider->setValue(5);
contrast_percentile_slider->setMaximum(100);
contrast_percentile_slider->setValue(10);
automatic_robust_contrast = new QPushButton("Automatic robust contrast adaption");
QObject::connect(automatic_robust_contrast, SIGNAL(clicked()), this, SLOT(robustAutomaticContrastAdaption()));
QObject::connect(contrast_percentile_slider, SIGNAL(valueChanged(int)), this, SLOT(robustAutomaticContrastAdaption(int)));
task_tab2->addWidget(stats);
task_tab2->addWidget(new QLabel("Histogramm of original image"));
task_tab2->addWidget(new QLabel("Original image"));
task_tab2->addWidget(original_stats);
task_tab2->addWidget(original_histogramm_label);
task_tab2->addWidget(new QLabel("Histogramm of working copy"));
task_tab2->addWidget(new QLabel("Working copy"));
task_tab2->addWidget(stats);
task_tab2->addWidget(histogramm_label);
task_tab2->addWidget(analyze_image);
task_tab2->addWidget(new QLabel("Brightness"));
@ -418,7 +423,6 @@ void ImageViewer::generateControlPanels() {
task_tab2->addWidget(contrast_slider);
task_tab2->addWidget(new QLabel("Automatic Contrast Percentile"));
task_tab2->addWidget(contrast_percentile_slider);
task_tab2->addWidget(automatic_robust_contrast);
tabWidget->addTab(task_tab_widget2, "Task #2");

View File

@ -87,6 +87,7 @@ class ImageViewer : public QMainWindow {
QWidget* task_tab_widget2;
QVBoxLayout* task_tab2;
QLabel* original_stats;
QLabel* stats;
QLabel* original_histogramm_label;
QLabel* histogramm_label;
@ -96,7 +97,6 @@ class ImageViewer : public QMainWindow {
QSlider* contrast_slider;
QSlider* contrast_percentile_slider;
QPushButton* automatic_robust_contrast;
// Third task tab
QWidget* task_tab_widget3;
@ -116,7 +116,7 @@ class ImageViewer : public QMainWindow {
void adjustContrast(int c);
void convertToMonochrome();
void resetWorkingCopy();
void robustAutomaticContrastAdaption();
void robustAutomaticContrastAdaption(int c_param);
void open();
void print();