-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpequal.cpp
49 lines (46 loc) · 1.37 KB
/
pequal.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
#include "pequal.h"
#define PEQUAL_PROB 1
int PEqual::predict(int x, int y, PDistrib *pd, double priority, int rad)
{
Image *img = yuvimage->getPlane(plane);
if (!img || x<0 || x>=img->getWidth() || y<0 || y>=img->getHeight())
return -1;
int val=-1;
float prob;
if (dir == PREDICTOR_DIR_L) {
if (x > 0) {
val = img->get(x-1, y);
prob = PEQUAL_PROB;
// pd.addSpikeEllipse(img->get(x-1, y), getPredParam().SpikeRadius, PEQUAL_PROB);
}
} else if (dir == PREDICTOR_DIR_LU) {
if (x > 0 && y > 0) {
val = img->get(x-1, y-1);
prob = PEQUAL_PROB/1.5;
// pd.addSpikeEllipse(img->get(x-1, y-1), getPredParam().SpikeRadius, PEQUAL_PROB/1.5);
}
} else if (dir == PREDICTOR_DIR_U) {
if (y > 0) {
val = img->get(x, y-1);
prob = PEQUAL_PROB;
// pd.addSpikeEllipse(img->get(x, y-1), getPredParam().SpikeRadius, PEQUAL_PROB);
}
} else if (dir == PREDICTOR_DIR_RU) {
if (x < img->getWidth()-1 && y > 0) {
val = img->get(x+1, y-1);
prob = PEQUAL_PROB/1.5;
// pd.addSpikeEllipse(img->get(x+1, y-1), getPredParam().SpikeRadius, PEQUAL_PROB/1.5);
}
} else
return -1;
val = img->getPointDir(x, y, dir);
if (val < 0)
return -1;
int radius = rad;
if (radius > val)
radius = val;
if (radius > img->getMaxValue() - val)
radius = img->getMaxValue() - val;
pd->addSpikeEllipse(val, radius, prob*priority);
return val;
}