Finished prototype
This commit is contained in:
+59
-9
@@ -2,36 +2,53 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QFileDialog>
|
||||
#include <QMenuBar>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QDockWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include "clahe.h"
|
||||
|
||||
const QString imageFilter = "Images (*.png *.jpg *.jpeg);;All files (*)";
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
setupUI();
|
||||
_clahe = new CLAHE;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete _clahe;
|
||||
}
|
||||
|
||||
void MainWindow::openFile()
|
||||
{
|
||||
QStringList list = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::PicturesLocation);
|
||||
list.append("");
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Open image"), list.first(), tr("Images (*.png *.jpg *.jpeg);;All files (*)"));
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Open image"), list.first(), imageFilter);
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
CLAHE cl;
|
||||
cl.loadFile(path);
|
||||
cl.apply(5, 64);
|
||||
QPixmap pixmap;
|
||||
pixmap = cl.getImage();
|
||||
_image->setPixmap(pixmap);
|
||||
_clahe->loadFile(path);
|
||||
applyClahe();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::saveFile()
|
||||
{
|
||||
QStringList list = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::PicturesLocation);
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Save image"), list.first(), imageFilter);
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
_clahe->saveFile(path);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::applyClahe()
|
||||
{
|
||||
QPixmap pixmap;
|
||||
_clahe->apply(_clipLimitSlider->value()/100.0f, _kernelSizeSelect->currentText().toInt());
|
||||
pixmap = _clahe->getImage();
|
||||
_imageScrollArea->setImage(pixmap);
|
||||
}
|
||||
|
||||
void MainWindow::setupUI()
|
||||
@@ -43,6 +60,39 @@ void MainWindow::setupUI()
|
||||
fileMenu->addAction(tr("Save file"), this, SLOT(saveFile()), QKeySequence("Ctrl+S"));
|
||||
fileMenu->addAction(tr("Quit"), this, SLOT(close()), QKeySequence("Ctrl+Q"));
|
||||
|
||||
_image = new QLabel(this);
|
||||
setCentralWidget(_image);
|
||||
_clipLimitEdit = new QLineEdit;
|
||||
_clipLimitEdit->setInputMask("000.00");
|
||||
_clipLimitEdit->setText("1.00");
|
||||
_clipLimitEdit->setMaximumWidth(100);
|
||||
|
||||
_clipLimitSlider = new QSlider(Qt::Horizontal);
|
||||
_clipLimitSlider->setRange(0, 10000);
|
||||
_clipLimitSlider->setValue(100);
|
||||
connect(_clipLimitSlider, SIGNAL(valueChanged(int)), this, SLOT(clipSliderValueChanged(int)));
|
||||
|
||||
QPushButton *applyButton = new QPushButton(tr("Apply"));
|
||||
connect(applyButton, SIGNAL(clicked()), this, SLOT(applyClahe()));
|
||||
|
||||
_kernelSizeSelect = new QComboBox;
|
||||
_kernelSizeSelect->addItems({"8", "16", "32", "64", "128", "256"});
|
||||
|
||||
QHBoxLayout *claheLayout = new QHBoxLayout;
|
||||
claheLayout->addWidget(_clipLimitEdit);
|
||||
claheLayout->addWidget(_clipLimitSlider);
|
||||
claheLayout->addWidget(_kernelSizeSelect);
|
||||
claheLayout->addWidget(applyButton);
|
||||
|
||||
QDockWidget *claheDock = new QDockWidget(tr("CLAHE"), this);
|
||||
QWidget *claheWidget = new QWidget(claheDock);
|
||||
claheDock->setWidget(claheWidget);
|
||||
claheWidget->setLayout(claheLayout);
|
||||
addDockWidget(Qt::TopDockWidgetArea, claheDock);
|
||||
|
||||
_imageScrollArea = new ImageScrollArea(this);
|
||||
setCentralWidget(_imageScrollArea);
|
||||
}
|
||||
|
||||
void MainWindow::clipSliderValueChanged(int value)
|
||||
{
|
||||
_clipLimitEdit->setText(QString::number(value/100.0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user