1 __device__ inline void s(int* a, int* b)
13 #define min3(a, b, c) s(a, b); s(a, c);
14 #define max3(a, b, c) s(b, c); s(a, c);
15 #define minmax3(a, b, c) max3(a, b, c); s(a, b);
16 #define minmax4(a, b, c, d) s(a, b); s(c, d); s(a, c); s(b, d);
17 #define minmax5(a, b, c, d, e) s(a, b); s(c, d); min3(a, c, e); max3(b, d, e);
18 #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);
20 __global__ void kernel_median3( short *output, int i_dim, int j_dim)
23 // coordonnees absolues du point
24 int j = __mul24(blockIdx.x,blockDim.x) + threadIdx.x ;
25 int i = __mul24(blockIdx.y,blockDim.y) + threadIdx.y ;
27 /**************************************************************************
29 **************************************************************************/
30 int a0, a1, a2, a3, a4, a5 ;
32 /********************************************************************************
33 * les six premieres valeurs (suffisant pour median 3x3 par forgetfull selection)
34 ********************************************************************************/
35 a0 = tex2D(tex_img_ins, j-1, i-1) ;
36 a1 = tex2D(tex_img_ins, j, i-1) ;
37 a2 = tex2D(tex_img_ins, j+1, i-1) ;
38 a3 = tex2D(tex_img_ins, j-1, i) ;
39 a4 = tex2D(tex_img_ins, j, i) ;
40 a5 = tex2D(tex_img_ins, j+1, i) ;
43 //min max aux extremites
44 minmax6(&a0, &a1, &a2, &a3, &a4, &a5) ;
46 /********************************************
47 * les deux valeurs suivantes aux extremites
48 ********************************************/
49 a5 = tex2D(tex_img_in, j-1, i+1) ;
51 minmax5(&a1, &a2, &a3, &a4, &a5) ;
53 /********************************************
54 * la derniere valeur a la fin
55 ********************************************/
57 a5 = tex2D(tex_img_ins, j, i+1) ;
59 minmax4(&a2, &a3, &a4, &a5) ;
61 a5 = tex2D(tex_img_ins, j+1, i+1) ;
62 minmax3(&a3, &a4, &a5) ;
66 output[ __mul24(i, j_dim) +j ] = a4 ;