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);
|
||||
return QPixmap::fromImage(ret);
|
||||
}
|
||||
|
||||
bool CLAHE::imageLoaded() const
|
||||
{
|
||||
return _lumImage.ptr();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
void apply(float clipLimit, int kernelSize);
|
||||
QPixmap getImage() const;
|
||||
QPixmap getLumImage() const;
|
||||
bool imageLoaded() const;
|
||||
};
|
||||
|
||||
#endif // CLAHE_H
|
||||
|
||||
+18
-4
@@ -45,10 +45,19 @@ void MainWindow::saveFile()
|
||||
|
||||
void MainWindow::applyClahe()
|
||||
{
|
||||
QPixmap pixmap;
|
||||
_clahe->apply(_clipLimitSlider->value()/100.0f, _kernelSizeSelect->currentText().toInt());
|
||||
pixmap = _clahe->getImage();
|
||||
_imageScrollArea->setImage(pixmap);
|
||||
if(_clahe->imageLoaded())
|
||||
{
|
||||
QPixmap pixmap;
|
||||
_clahe->apply(_clipLimitSlider->value()/100.0f, _kernelSizeSelect->currentText().toInt());
|
||||
pixmap = _clahe->getImage();
|
||||
_imageScrollArea->setImage(pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::applyLive()
|
||||
{
|
||||
if(_liveApply->isChecked())
|
||||
applyClahe();
|
||||
}
|
||||
|
||||
void MainWindow::setupUI()
|
||||
@@ -58,6 +67,9 @@ void MainWindow::setupUI()
|
||||
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
|
||||
fileMenu->addAction(tr("Open file"), this, SLOT(openFile()), QKeySequence("Ctrl+O"));
|
||||
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"));
|
||||
|
||||
_clipLimitEdit = new QLineEdit;
|
||||
@@ -75,6 +87,7 @@ void MainWindow::setupUI()
|
||||
|
||||
_kernelSizeSelect = new QComboBox;
|
||||
_kernelSizeSelect->addItems({"8", "16", "32", "64", "128", "256"});
|
||||
connect(_kernelSizeSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(applyLive()));
|
||||
|
||||
QHBoxLayout *claheLayout = new QHBoxLayout;
|
||||
claheLayout->addWidget(_clipLimitEdit);
|
||||
@@ -95,4 +108,5 @@ void MainWindow::setupUI()
|
||||
void MainWindow::clipSliderValueChanged(int value)
|
||||
{
|
||||
_clipLimitEdit->setText(QString::number(value/100.0));
|
||||
applyLive();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class MainWindow : public QMainWindow
|
||||
QLineEdit *_clipLimitEdit;
|
||||
CLAHE *_clahe;
|
||||
ImageScrollArea *_imageScrollArea;
|
||||
QAction *_liveApply;
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
@@ -22,6 +23,7 @@ public slots:
|
||||
void openFile();
|
||||
void saveFile();
|
||||
void applyClahe();
|
||||
void applyLive();
|
||||
private:
|
||||
void setupUI();
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user