1 __global__ void kernel_median5_2pix( short *output, int i_dim, int j_dim)
3 int j = __mul24(__mul24(blockIdx.x,blockDim.x) + threadIdx.x,2) ;
4 int i = __mul24(blockIdx.y,blockDim.y) + threadIdx.y ;
5 int a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13 ;//left window
6 int b6, b7, b8, b9, b10, b11, b12, b13 ; //right window
8 a0 = tex2D(tex_img_ins, j-1, i-2) ; // first line
9 a1 = tex2D(tex_img_ins, j , i-2) ;
10 a2 = tex2D(tex_img_ins, j+1, i-2) ;
11 a3 = tex2D(tex_img_ins, j+2, i-2) ;
12 a4 = tex2D(tex_img_ins, j-1, i-1) ; //seconde line
13 a5 = tex2D(tex_img_ins, j , i-1) ;
14 a6 = tex2D(tex_img_ins, j+1, i-1) ;
15 a7 = tex2D(tex_img_ins, j+2, i-1) ;
16 a8 = tex2D(tex_img_ins, j-1, i) ; // third line
17 a9 = tex2D(tex_img_ins, j , i) ;
18 a10 = tex2D(tex_img_ins, j+1, i) ;
19 a11 = tex2D(tex_img_ins, j+2, i) ; // first 2 of fourth line
20 a12 = tex2D(tex_img_ins, j-1, i+1) ;
21 a13 = tex2D(tex_img_ins, j , i+1) ;
24 minmax14(&a0,&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
25 a13 = tex2D(tex_img_ins, j+1, i+1);
26 minmax13(&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
27 a13 = tex2D(tex_img_ins, j+2, i+1);
28 minmax12(&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
29 a13 = tex2D(tex_img_ins, j-1, i+2);
30 minmax11(&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
31 a13 = tex2D(tex_img_ins, j , i+2);
32 minmax10(&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
33 a13 = tex2D(tex_img_ins, j+1, i+2);
34 minmax9(&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
35 a13 = tex2D(tex_img_ins, j+2, i+2);
36 minmax8(&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
39 b6=a6; b7=a7; b8=a8; b9=a9; b10=a10; b11=a11; b12=a12; b13=a13;
41 // separate selections for the 5 remaining pixels in both windows
42 a13 = tex2D(tex_img_ins, j-2, i-2);
43 b13 = tex2D(tex_img_ins, j+3, i-2);
44 minmax7(&a7,&a8,&a9,&a10,&a11,&a12,&a13);
45 minmax7(&b7,&b8,&b9,&b10,&b11,&b12,&b13);
46 a13 = tex2D(tex_img_ins, j-2, i-1);
47 b13 = tex2D(tex_img_ins, j+3, i-1);
48 minmax6(&a8,&a9,&a10,&a11,&a12,&a13);
49 minmax6(&b8,&b9,&b10,&b11,&b12,&b13);
50 a13 = tex2D(tex_img_ins, j-2, i );
51 b13 = tex2D(tex_img_ins, j+3, i );
52 minmax5(&a9,&a10,&a11,&a12,&a13);
53 minmax5(&b9,&b10,&b11,&b12,&b13);
54 a13 = tex2D(tex_img_ins, j-2, i+1);
55 b13 = tex2D(tex_img_ins, j+3, i+1);
56 minmax4(&a10,&a11,&a12,&a13);
57 minmax4(&b10,&b11,&b12,&b13);
58 a13 = tex2D(tex_img_ins, j-2, i+2);
59 b13 = tex2D(tex_img_ins, j+3, i+2);
60 minmax3(&a11,&a12,&a13);
61 minmax3(&b11,&b12,&b13);
63 output[ __mul24(i, j_dim) +j ] = a12 ; //middle values
64 output[ __mul24(i, j_dim) +j+1 ] = b12 ;