1 __global__ void kernel_medianR( short *output,
2 int i_dim, int j_dim, int r)
4 // absolute coordinates of the center pixel
5 int j = __mul24(blockIdx.x,blockDim.x) + threadIdx.x ;
6 int i = __mul24(blockIdx.y,blockDim.y) + threadIdx.y ;
9 short histogram[256] ; // 8 bit image
10 // zeroing histogram data
11 for (ic =0; ic<256; ic++) histogram[ ic ]=0 ;
13 for(ic=i-r; ic<=i+r; ic++ )
14 for(jc=j-r; jc<=j+r; jc++)
15 histogram[ tex2D(tex_img_ins, jc, ic) ]++ ;
18 for(ic=0; ic<256; ic++)
20 cpt += histogram[ ic ] ;
21 // selection of 50% percentile
22 if ( cpt > ((2*r+1)*(2*r+1))>>1 ) break ;
24 output[ __mul24(i, j_dim) +j ] = ic ;