-
Notifications
You must be signed in to change notification settings - Fork 0
/
circleapproximator.h
84 lines (72 loc) · 1.98 KB
/
circleapproximator.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef CIRCLEAPPROXIMATOR_H
#define CIRCLEAPPROXIMATOR_H
#include <QImage>
#include <QPainter>
#include <QColor>
#include <QCoreApplication>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <QTime>
#include <random>
#include <QWidget>
#include <QGridLayout>
#include <QSpinBox>
#include <QLabel>
#include "base.h"
#include <omp.h>
#include <atomic>
#include <mutex>
namespace Circle{
using std::vector;
class Settings;
class Approximator;
//================================================================
//================================================================
class Approximator : public BaseApproximator{
Q_OBJECT
protected:
struct Circle{
int centerX=0,centerY=0;
int radius=0;
QColor color;
double score=0; // amount of change between modified image and original image
};
vector<int> precomputedDistance;
QImage currentApproximation;
QImage origImage;
int minRadius;
int maxRadius;
int randRange(int low,int high); // warning - is inclusive of the high number
double getScore(QImage &firstImage, QImage &secondImage, int centerX, int centerY, int radius, QColor color);
int getColorDelta(QColor c1, QColor c2);
void drawCircle(QImage &image,struct Circle *);
void randomSelectCurrentCircle(struct Circle *);
bool tryPermutationForBetterCircle(struct Circle *);
public:
Approximator(BaseSettings*);
public slots:
virtual void processImage(QImage orig);
};
//================================================================
//================================================================
class Settings : public BaseSettings{
Q_OBJECT
public:
explicit Settings();
int numCircles();
int minRadius();
int maxRadius();
public slots:
void keepRadiusEntriesInSync();
QString getApproximatorName();
protected:
QGridLayout *mainLayout;
QLabel *description;
QSpinBox *numCirclesEntry,*minRadiusEntry,*maxRadiusEntry;
virtual void makeWidgets();
virtual void layoutWidgets();
virtual void makeConnections();
};
} //namespace
#endif // CIRCLEAPPROXIMATOR_H