-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbinarytest.cpp
51 lines (44 loc) · 1.03 KB
/
binarytest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "binarytest.h"
#include "ui_binarytest.h"
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include "ImageWidget-Qt/ImageWidget.h"
#include "QImageMatConvert/mat_qimage_convert.h"
BinaryTest::BinaryTest(QWidget *parent) :
QWidget(parent),
ui(new Ui::BinaryTest)
{
ui->setupUi(this);
}
BinaryTest::~BinaryTest()
{
delete ui;
}
void BinaryTest::setImg(Mat &img)
{
if (img.empty()) {
return;
}
mInputImg = img.clone();
normalize(mInputImg, mInputImg, 0, UINT8_MAX, NORM_MINMAX);
procImg();
}
void BinaryTest::closeEvent(QCloseEvent *event)
{
emit sendWindowsCloseEvent();
}
void BinaryTest::procImg()
{
if (mInputImg.empty()) {
return;
}
threshold(mInputImg, mOutputImg, binaryThreshold, UINT8_MAX, THRESH_BINARY);
qProcessedImg = ConvertMatToQImage(mOutputImg);
ui->iwProcessedImg->setImage(qProcessedImg);
}
void BinaryTest::on_qsbBinaryThreshold_valueChanged(int arg1)
{
binaryThreshold = double(arg1);
procImg();
}