Live mode
This commit is contained in:
@@ -56,3 +56,8 @@ QPixmap CLAHE::getLumImage() const
|
|||||||
QImage ret(tmp.data, tmp.cols, tmp.rows, tmp.step1(), QImage::Format_Grayscale8);
|
QImage ret(tmp.data, tmp.cols, tmp.rows, tmp.step1(), QImage::Format_Grayscale8);
|
||||||
return QPixmap::fromImage(ret);
|
return QPixmap::fromImage(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CLAHE::imageLoaded() const
|
||||||
|
{
|
||||||
|
return _lumImage.ptr();
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
void apply(float clipLimit, int kernelSize);
|
void apply(float clipLimit, int kernelSize);
|
||||||
QPixmap getImage() const;
|
QPixmap getImage() const;
|
||||||
QPixmap getLumImage() const;
|
QPixmap getLumImage() const;
|
||||||
|
bool imageLoaded() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLAHE_H
|
#endif // CLAHE_H
|
||||||
|
|||||||
@@ -44,12 +44,21 @@ void MainWindow::saveFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::applyClahe()
|
void MainWindow::applyClahe()
|
||||||
|
{
|
||||||
|
if(_clahe->imageLoaded())
|
||||||
{
|
{
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
_clahe->apply(_clipLimitSlider->value()/100.0f, _kernelSizeSelect->currentText().toInt());
|
_clahe->apply(_clipLimitSlider->value()/100.0f, _kernelSizeSelect->currentText().toInt());
|
||||||
pixmap = _clahe->getImage();
|
pixmap = _clahe->getImage();
|
||||||
_imageScrollArea->setImage(pixmap);
|
_imageScrollArea->setImage(pixmap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::applyLive()
|
||||||
|
{
|
||||||
|
if(_liveApply->isChecked())
|
||||||
|
applyClahe();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::setupUI()
|
void MainWindow::setupUI()
|
||||||
{
|
{
|
||||||
@@ -58,6 +67,9 @@ void MainWindow::setupUI()
|
|||||||
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
|
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
|
||||||
fileMenu->addAction(tr("Open file"), this, SLOT(openFile()), QKeySequence("Ctrl+O"));
|
fileMenu->addAction(tr("Open file"), this, SLOT(openFile()), QKeySequence("Ctrl+O"));
|
||||||
fileMenu->addAction(tr("Save file"), this, SLOT(saveFile()), QKeySequence("Ctrl+S"));
|
fileMenu->addAction(tr("Save file"), this, SLOT(saveFile()), QKeySequence("Ctrl+S"));
|
||||||
|
_liveApply = fileMenu->addAction(tr("Live mode"));
|
||||||
|
_liveApply->setCheckable(true);
|
||||||
|
_liveApply->setChecked(true);
|
||||||
fileMenu->addAction(tr("Quit"), this, SLOT(close()), QKeySequence("Ctrl+Q"));
|
fileMenu->addAction(tr("Quit"), this, SLOT(close()), QKeySequence("Ctrl+Q"));
|
||||||
|
|
||||||
_clipLimitEdit = new QLineEdit;
|
_clipLimitEdit = new QLineEdit;
|
||||||
@@ -75,6 +87,7 @@ void MainWindow::setupUI()
|
|||||||
|
|
||||||
_kernelSizeSelect = new QComboBox;
|
_kernelSizeSelect = new QComboBox;
|
||||||
_kernelSizeSelect->addItems({"8", "16", "32", "64", "128", "256"});
|
_kernelSizeSelect->addItems({"8", "16", "32", "64", "128", "256"});
|
||||||
|
connect(_kernelSizeSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(applyLive()));
|
||||||
|
|
||||||
QHBoxLayout *claheLayout = new QHBoxLayout;
|
QHBoxLayout *claheLayout = new QHBoxLayout;
|
||||||
claheLayout->addWidget(_clipLimitEdit);
|
claheLayout->addWidget(_clipLimitEdit);
|
||||||
@@ -95,4 +108,5 @@ void MainWindow::setupUI()
|
|||||||
void MainWindow::clipSliderValueChanged(int value)
|
void MainWindow::clipSliderValueChanged(int value)
|
||||||
{
|
{
|
||||||
_clipLimitEdit->setText(QString::number(value/100.0));
|
_clipLimitEdit->setText(QString::number(value/100.0));
|
||||||
|
applyLive();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class MainWindow : public QMainWindow
|
|||||||
QLineEdit *_clipLimitEdit;
|
QLineEdit *_clipLimitEdit;
|
||||||
CLAHE *_clahe;
|
CLAHE *_clahe;
|
||||||
ImageScrollArea *_imageScrollArea;
|
ImageScrollArea *_imageScrollArea;
|
||||||
|
QAction *_liveApply;
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
@@ -22,6 +23,7 @@ public slots:
|
|||||||
void openFile();
|
void openFile();
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void applyClahe();
|
void applyClahe();
|
||||||
|
void applyLive();
|
||||||
private:
|
private:
|
||||||
void setupUI();
|
void setupUI();
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user