forked from rodrigomas/DCTLs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mean.dctl
57 lines (50 loc) · 1.42 KB
/
Mean.dctl
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
__DEVICE__ float mean(float p_Table[], int m) {
float sum = 0.0f;
int i;
for(i = 0; i < m; ++i)
sum += p_Table[i];
return (sum / m);
}
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, __TEXTURE__ p_TexR, __TEXTURE__ p_TexG, __TEXTURE__ p_TexB)
{
float TableR[9] =
{
_tex2D(p_TexR, p_X - 1, p_Y + 1),
_tex2D(p_TexR, p_X, p_Y + 1),
_tex2D(p_TexR, p_X + 1, p_Y + 1),
_tex2D(p_TexR, p_X - 1, p_Y),
_tex2D(p_TexR, p_X, p_Y),
_tex2D(p_TexR, p_X + 1, p_Y),
_tex2D(p_TexR, p_X - 1, p_Y - 1),
_tex2D(p_TexR, p_X, p_Y - 1),
_tex2D(p_TexR, p_X + 1, p_Y - 1)
};
float TableG[9] =
{
_tex2D(p_TexG, p_X - 1, p_Y + 1),
_tex2D(p_TexG, p_X, p_Y + 1),
_tex2D(p_TexG, p_X + 1, p_Y + 1),
_tex2D(p_TexG, p_X - 1, p_Y),
_tex2D(p_TexG, p_X, p_Y),
_tex2D(p_TexG, p_X + 1, p_Y),
_tex2D(p_TexG, p_X - 1, p_Y - 1),
_tex2D(p_TexG, p_X, p_Y - 1),
_tex2D(p_TexG, p_X + 1, p_Y - 1)
};
float TableB[9] =
{
_tex2D(p_TexB, p_X - 1, p_Y + 1),
_tex2D(p_TexB, p_X, p_Y + 1),
_tex2D(p_TexB, p_X + 1, p_Y + 1),
_tex2D(p_TexB, p_X - 1, p_Y),
_tex2D(p_TexB, p_X, p_Y),
_tex2D(p_TexB, p_X + 1, p_Y),
_tex2D(p_TexB, p_X - 1, p_Y - 1),
_tex2D(p_TexB, p_X, p_Y - 1),
_tex2D(p_TexB, p_X + 1, p_Y - 1)
};
const float r = mean(TableR, 9);
const float g = mean(TableG, 9);
const float b = mean(TableB, 9);
return make_float3(r, g, b);
}