private int getNeighbours ( int [ ] src1d , int i , int ox , int oy , int d_w , int d_h ) { int x , y , result ; x = ( i % d_w ) + ox ; // d_w and d_h are assumed to be set to the y = ( i / d_w ) + oy ; // width and height of scr1d if ( ( x < 0 ) || ( x >= d_w ) || ( y < 0 ) || ( y >= d_h ) ) { result = 0 ; } else { result = src1d [ y * d_w + x ] & 0x000000ff ; } return result ; }
getNeighbours will get the pixel value of i s neighbour that s ox and oy away from i if the point is outside the image then 0 is returned . This version gets from source image .