Post-filtering for int SCREEN_HEIGHT for int SCREEN_WIDTH bool ver SCR

 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
//Post-filtering
for(int i = 0; i < SCREEN_HEIGHT; i++){
for(int j = 0; j < SCREEN_WIDTH; j++){
bool ver = (i > 0) & (i < SCREEN_HEIGHT - 1);
bool hor = (j > 0) & (i < SCREEN_WIDTH - 1);
bool diag = ver & hor;
int divider = 1;
if(ver){
pixel a = Raster[i * SCREEN_WIDTH + j];
pixel b = Raster[(i + 1) * SCREEN_WIDTH + j];
pixel c = Raster[(i - 1) * SCREEN_WIDTH + j];
Raster[i * SCREEN_WIDTH + j] = sumPixels(a, b, c);
divider += 2;
}
if(hor){
pixel a = Raster[i * SCREEN_WIDTH + j];
pixel b = Raster[i * SCREEN_WIDTH + (j + 1)];
pixel c = Raster[i * SCREEN_WIDTH + (j - 1)];
Raster[i * SCREEN_WIDTH + j] = sumPixels(a, b, c);
divider += 2;
}
if(diag){
pixel a = Raster[i * SCREEN_WIDTH + j];
pixel b = Raster[(i + 1) * SCREEN_WIDTH + (j + 1)];
pixel c = Raster[(i - 1) * SCREEN_WIDTH + (j - 1)];
Raster[i * SCREEN_WIDTH + j] = sumPixels(a, b, c);
a = Raster[i * SCREEN_WIDTH + j];
b = Raster[(i - 1) * SCREEN_WIDTH + (j + 1)];
c = Raster[(i + 1) * SCREEN_WIDTH + (j - 1)];
Raster[i * SCREEN_WIDTH + j] = sumPixels(a, b, c);
divider += 4;
}
pixel a = Raster[i * SCREEN_WIDTH + j];
Raster[i * SCREEN_WIDTH + j] = divPixel(a, divider);
}
}