1 __device__ inline void s(int* a, int* b)
4 if (*a > *b) { tmp = *b; *b = *a; *a = tmp;}
7 #define min3(a, b, c) s(a, b); s(a, c);
8 #define max3(a, b, c) s(b, c); s(a, c);
9 #define minmax3(a, b, c) max3(a, b, c); s(a, b);
10 #define minmax4(a, b, c, d) s(a, b); s(c, d); s(a, c); s(b, d);
11 #define minmax5(a, b, c, d, e) s(a, b); s(c, d); min3(a, c, e); max3(b, d, e);
12 #define minmax6(a, b, c, d, e, f) s(a,d); s(b, e); s(c, f); min3(a, b, c); max3(d, e, f);
14 __global__ void kernel_medianForget1pix3( short *output, int i_dim, int j_dim)
16 int j = __mul24(blockIdx.x,blockDim.x) + threadIdx.x ;
17 int i = __mul24(blockIdx.y,blockDim.y) + threadIdx.y ;
18 int a0, a1, a2, a3, a4, a5 ;
20 a0 = tex2D(tex_img_ins, j-1, i-1) ; // first 6 values
21 a1 = tex2D(tex_img_ins, j, i-1) ;
22 a2 = tex2D(tex_img_ins, j+1, i-1) ;
23 a3 = tex2D(tex_img_ins, j-1, i) ;
24 a4 = tex2D(tex_img_ins, j, i) ;
25 a5 = tex2D(tex_img_ins, j+1, i) ;
27 minmax6(&a0, &a1, &a2, &a3, &a4, &a5);//min->a0 max->a5
28 a5 = tex2D(tex_img_in, j-1, i+1) ; //next value in a5
29 minmax5(&a1, &a2, &a3, &a4, &a5) ; //min->a1 max->a5
30 a5 = tex2D(tex_img_ins, j, i+1) ; //next value in a5
31 minmax4(&a2, &a3, &a4, &a5) ; //min->a1 max->a5
32 a5 = tex2D(tex_img_ins, j+1, i+1) ; //next value in a5
33 minmax3(&a3, &a4, &a5) ; //min->a1 max->a5
35 output[ __mul24(i, j_dim) +j ] = a4 ; //middle value