1 __global__ void kernel_medianV_sh( short *output, int i_dim, int j_dim, int r)
4 int idc, val, min, max, inf, equal, sup, mxinf, minsup, estim ;
6 //coordinates in the block
9 int idx_h = __mul24(ib+r,blockDim.x) +jb; // base pixel index
10 int offset = __mul24(blockDim.x,r) ;
12 int j = __mul24(blockIdx.x,blockDim.x) + jb ;
13 int i = __mul24(blockIdx.y,blockDim.y) + ib ;
15 // DATA PREFETCHING INTO SHARED MEM
16 extern __shared__ int buff[] ;
17 buff[ idx_h ] = tex2D(tex_img_ins, j, i) ;
21 buff[ idx_h - offset ] = tex2D(tex_img_ins, j, i-r) ;
23 if (ib >= (blockDim.y-r))
25 buff[ idx_h + offset ] = tex2D(tex_img_ins, j, i+r) ;
30 // TORBEN MOGENSEN SORTING
31 min = max = buff[ ib*blockDim.x +jb] ;
33 for (idc= 0 ; idc< 2*r+1 ; idc++ )
35 val = buff[ __mul24(ib+idc, blockDim.x) +jb ] ;
36 if ( val < min ) min = val ;
37 if ( val > max ) max = val ;
43 inf = sup = equal = 0 ;
46 for (idc =0; idc< 2*r+1 ; idc++)
48 val = buff[ __mul24(ib+idc, blockDim.x) +jb ] ;
52 if( val > mxinf) mxinf = val ;
53 } else if (val > estim)
56 if( val < minsup) minsup = val ;
59 if ( (inf <= (r+1))&&(sup <=(r+1)) ) break ;
60 else if (inf>sup) max = mxinf ;
64 if ( inf >= r+1 ) val = mxinf ;
65 else if (inf+equal >= r+1) val = estim ;
68 output[ __mul24(j, i_dim) +i ] = val ;