__global__ void kernel_median5_2pix( short *output, int i_dim, int j_dim) { int j = __mul24(__mul24(blockIdx.x,blockDim.x) + threadIdx.x,2) ; int i = __mul24(blockIdx.y,blockDim.y) + threadIdx.y ; int a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13 ;//left window int b6, b7, b8, b9, b10, b11, b12, b13 ; //right window a0 = tex2D(tex_img_ins, j-1, i-2) ; // first line a1 = tex2D(tex_img_ins, j , i-2) ; a2 = tex2D(tex_img_ins, j+1, i-2) ; a3 = tex2D(tex_img_ins, j+2, i-2) ; a4 = tex2D(tex_img_ins, j-1, i-1) ; //seconde line a5 = tex2D(tex_img_ins, j , i-1) ; a6 = tex2D(tex_img_ins, j+1, i-1) ; a7 = tex2D(tex_img_ins, j+2, i-1) ; a8 = tex2D(tex_img_ins, j-1, i) ; // third line a9 = tex2D(tex_img_ins, j , i) ; a10 = tex2D(tex_img_ins, j+1, i) ; a11 = tex2D(tex_img_ins, j+2, i) ; // first 2 of fourth line a12 = tex2D(tex_img_ins, j-1, i+1) ; a13 = tex2D(tex_img_ins, j , i+1) ; //common selection minmax14(&a0,&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13); a13 = tex2D(tex_img_ins, j+1, i+1); minmax13(&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13); a13 = tex2D(tex_img_ins, j+2, i+1); minmax12(&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13); a13 = tex2D(tex_img_ins, j-1, i+2); minmax11(&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13); a13 = tex2D(tex_img_ins, j , i+2); minmax10(&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13); a13 = tex2D(tex_img_ins, j+1, i+2); minmax9(&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13); a13 = tex2D(tex_img_ins, j+2, i+2); minmax8(&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13); // separation b6=a6; b7=a7; b8=a8; b9=a9; b10=a10; b11=a11; b12=a12; b13=a13; // separate selections for the 5 remaining pixels in both windows a13 = tex2D(tex_img_ins, j-2, i-2); b13 = tex2D(tex_img_ins, j+3, i-2); minmax7(&a7,&a8,&a9,&a10,&a11,&a12,&a13); minmax7(&b7,&b8,&b9,&b10,&b11,&b12,&b13); a13 = tex2D(tex_img_ins, j-2, i-1); b13 = tex2D(tex_img_ins, j+3, i-1); minmax6(&a8,&a9,&a10,&a11,&a12,&a13); minmax6(&b8,&b9,&b10,&b11,&b12,&b13); a13 = tex2D(tex_img_ins, j-2, i ); b13 = tex2D(tex_img_ins, j+3, i ); minmax5(&a9,&a10,&a11,&a12,&a13); minmax5(&b9,&b10,&b11,&b12,&b13); a13 = tex2D(tex_img_ins, j-2, i+1); b13 = tex2D(tex_img_ins, j+3, i+1); minmax4(&a10,&a11,&a12,&a13); minmax4(&b10,&b11,&b12,&b13); a13 = tex2D(tex_img_ins, j-2, i+2); b13 = tex2D(tex_img_ins, j+3, i+2); minmax3(&a11,&a12,&a13); minmax3(&b11,&b12,&b13); output[ __mul24(i, j_dim) +j ] = a12 ; //middle values output[ __mul24(i, j_dim) +j+1 ] = b12 ; }