-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexampledialog.cpp
56 lines (48 loc) · 1.35 KB
/
exampledialog.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
51
52
53
54
55
56
#include "exampledialog.h"
#include "ui_exampledialog.h"
exampleDialog::exampleDialog(QWidget *parent, QMLP *mlp) :
QMainWindow(parent),
ui(new Ui::exampleDialog),
_mlp(mlp)
{
ui->setupUi(this);
connect(ui->input, SIGNAL(valueChanged(int)), this, SLOT(refreshView(int)));
}
exampleDialog::~exampleDialog()
{
delete ui;
}
void exampleDialog::refreshView(int index)
{
qint64 dMax = 0,
rMax = 0;
qreal dValue = -10,
rValue = -10;
EigenVector input = _mlp->getInput().col(index),
desiredOutput = _mlp->getOutput().col(index),
realOutput = _mlp->run(index);
QImage image(28, 28, QImage::Format_Grayscale8);
for (qint64 i = 0; i < 28*28 ; ++i)
{
qint8 value = 255-input(i);
quint32 dot = qRgb(value, value, value);
image.setPixel(i%28, floor(i/28), dot);
}
for (qint64 i = 0; i < 10; ++i)
{
if (desiredOutput(i) > dValue)
{
dMax = i;
dValue = desiredOutput(i);
}
if (realOutput(i) > rValue)
{
rMax = i;
rValue = realOutput(i);
}
}
QPixmap pic = QPixmap::fromImage(image);
ui->img->setPixmap(pic);
ui->img->setScaledContents(1);
ui->lcdNumber->display(qreal(rMax));
}