[TASK] Allow loading a reference image, add indicators for its stats.
This commit is contained in:
parent
e9a397e57a
commit
0fa09a775b
|
@ -47,6 +47,7 @@
|
|||
ImageViewer::ImageViewer() {
|
||||
original = NULL;
|
||||
working_copy = NULL;
|
||||
histogramm_reference = NULL;
|
||||
startLogging();
|
||||
generateMainGui();
|
||||
renewLogging();
|
||||
|
@ -423,6 +424,14 @@ void ImageViewer::generateControlPanels() {
|
|||
task_tab2 = new QVBoxLayout();
|
||||
task_tab_widget2->setLayout(task_tab2);
|
||||
|
||||
reference_histogramm_label = new QLabel();
|
||||
reference_histogramm_label->setBackgroundRole(QPalette::Base);
|
||||
reference_histogramm_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
reference_histogramm_label->setScaledContents(false);
|
||||
|
||||
reference_stats = new QLabel();
|
||||
reference_stats->setText("Stats for reference image will be shown here.");
|
||||
|
||||
original_histogramm_label = new QLabel();
|
||||
original_histogramm_label->setBackgroundRole(QPalette::Base);
|
||||
original_histogramm_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
@ -461,6 +470,9 @@ void ImageViewer::generateControlPanels() {
|
|||
contrast_percentile_slider->setValue(10);
|
||||
QObject::connect(contrast_percentile_slider, SIGNAL(valueChanged(int)), this, SLOT(robustAutomaticContrastAdaption(int)));
|
||||
|
||||
task_tab2->addWidget(new QLabel("Reference image"));
|
||||
task_tab2->addWidget(reference_stats);
|
||||
task_tab2->addWidget(reference_histogramm_label);
|
||||
task_tab2->addWidget(new QLabel("Original image"));
|
||||
task_tab2->addWidget(original_stats);
|
||||
task_tab2->addWidget(original_histogramm_label);
|
||||
|
@ -482,6 +494,11 @@ void ImageViewer::generateControlPanels() {
|
|||
task_tab3 = new QVBoxLayout();
|
||||
task_tab_widget3->setLayout(task_tab3);
|
||||
|
||||
reference_histogramm_cumulative_label = new QLabel();
|
||||
reference_histogramm_cumulative_label->setBackgroundRole(QPalette::Base);
|
||||
reference_histogramm_cumulative_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
reference_histogramm_cumulative_label->setScaledContents(false);
|
||||
|
||||
original_histogramm_cumulative_label = new QLabel();
|
||||
original_histogramm_cumulative_label->setBackgroundRole(QPalette::Base);
|
||||
original_histogramm_cumulative_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
@ -495,6 +512,8 @@ void ImageViewer::generateControlPanels() {
|
|||
linear_histogramm_adaption = new QPushButton("Do linear histogramm adaption (basic)");
|
||||
QObject::connect(linear_histogramm_adaption, SIGNAL(clicked()), this, SLOT(linearHistogrammAdaption()));
|
||||
|
||||
task_tab3->addWidget(new QLabel("Reference image"));
|
||||
task_tab3->addWidget(reference_histogramm_cumulative_label);
|
||||
task_tab3->addWidget(new QLabel("Original image"));
|
||||
task_tab3->addWidget(original_histogramm_cumulative_label);
|
||||
task_tab3->addWidget(new QLabel("Working copy"));
|
||||
|
@ -627,6 +646,36 @@ void ImageViewer::open() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply load another image to provide reference for some operations.
|
||||
* @brief ImageViewer::openReference
|
||||
*/
|
||||
void ImageViewer::openReference() {
|
||||
if(histogramm_reference != NULL) {
|
||||
delete histogramm_reference;
|
||||
histogramm_reference = NULL;
|
||||
}
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Histogramm Reference File"), QDir::currentPath());
|
||||
if(!fileName.isEmpty()) {
|
||||
histogramm_reference = new LazyImage(new QImage(fileName));
|
||||
if(histogramm_reference->getImage()->isNull()) {
|
||||
QMessageBox::information(this, tr("Image Viewer"), tr("Cannot load %1.").arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
if(histogramm_reference->getImage() != NULL) {
|
||||
histogramm_reference->updateStatistics();
|
||||
QString result = QString("Intensity: Average: %1, Variance: %2").arg(histogramm_reference->getIntensityAverage()).arg(histogramm_reference->getIntensityVariance());
|
||||
reference_stats->setText(result);
|
||||
reference_histogramm_label->setPixmap(QPixmap::fromImage(*(histogramm_reference->getHistogrammNormalImage())));
|
||||
reference_histogramm_cumulative_label->setPixmap(QPixmap::fromImage(*(histogramm_reference->getHistogrammCumulativeImage())));
|
||||
}
|
||||
|
||||
logFile << "Referenzbild geladen: " << fileName.toStdString().c_str() << std::endl;
|
||||
renewLogging();
|
||||
}
|
||||
}
|
||||
|
||||
void ImageViewer::resizeEvent(QResizeEvent* event) {
|
||||
QMainWindow::resizeEvent(event);
|
||||
centralwidget->setMinimumWidth(width());
|
||||
|
@ -680,6 +729,10 @@ void ImageViewer::createActions() {
|
|||
openAct->setShortcut(tr("Ctrl+O"));
|
||||
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
||||
|
||||
openHistAct = new QAction(tr("Open &Reference..."), this);
|
||||
openHistAct->setShortcut(tr("Ctrl+O"));
|
||||
connect(openHistAct, SIGNAL(triggered()), this, SLOT(openReference()));
|
||||
|
||||
printAct = new QAction(tr("&Print..."), this);
|
||||
printAct->setShortcut(tr("Ctrl+P"));
|
||||
printAct->setEnabled(false);
|
||||
|
@ -720,6 +773,7 @@ void ImageViewer::createActions() {
|
|||
void ImageViewer::createMenus() {
|
||||
fileMenu = new QMenu(tr("&File"), this);
|
||||
fileMenu->addAction(openAct);
|
||||
fileMenu->addAction(openHistAct);
|
||||
fileMenu->addAction(printAct);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAct);
|
||||
|
|
|
@ -88,8 +88,10 @@ class ImageViewer : public QMainWindow {
|
|||
QWidget* task_tab_widget2;
|
||||
QVBoxLayout* task_tab2;
|
||||
|
||||
QLabel* reference_stats;
|
||||
QLabel* original_stats;
|
||||
QLabel* stats;
|
||||
QLabel* reference_histogramm_label;
|
||||
QLabel* original_histogramm_label;
|
||||
QLabel* histogramm_label;
|
||||
QPushButton* analyze_image;
|
||||
|
@ -103,6 +105,7 @@ class ImageViewer : public QMainWindow {
|
|||
QWidget* task_tab_widget3;
|
||||
QVBoxLayout* task_tab3;
|
||||
|
||||
QLabel* reference_histogramm_cumulative_label;
|
||||
QLabel* original_histogramm_cumulative_label;
|
||||
QLabel* histogramm_cumulative_label;
|
||||
|
||||
|
@ -111,6 +114,7 @@ class ImageViewer : public QMainWindow {
|
|||
// "My" space for storing data/results
|
||||
LazyImage* original;
|
||||
LazyImage* working_copy;
|
||||
LazyImage* histogramm_reference;
|
||||
|
||||
private slots:
|
||||
// Custom slots
|
||||
|
@ -127,6 +131,7 @@ class ImageViewer : public QMainWindow {
|
|||
void linearHistogrammAdaption();
|
||||
|
||||
void open();
|
||||
void openReference();
|
||||
void print();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
@ -175,6 +180,7 @@ class ImageViewer : public QMainWindow {
|
|||
#endif
|
||||
|
||||
QAction *openAct;
|
||||
QAction *openHistAct;
|
||||
QAction *printAct;
|
||||
QAction *exitAct;
|
||||
QAction *zoomInAct;
|
||||
|
|
Loading…
Reference in New Issue