public static void process ( GrayI orig , GrayI derivX , GrayI derivY ) { final int width = orig . getWidth ( ) ; final int height = orig . getHeight ( ) ; for ( int y = 1 ; y < height - 1 ; y ++ ) { for ( int x = 1 ; x < width - 1 ; x ++ ) { int dy = - ( orig . get ( x - 1 , y - 1 ) + 2 * orig . get ( x , y - 1 ) + orig . get ( x + 1 , y - 1 ) ) ; dy += ( orig . get ( x - 1 , y + 1 ) + 2 * orig . get ( x , y + 1 ) + orig . get ( x + 1 , y + 1 ) ) ; int dx = - ( orig . get ( x - 1 , y - 1 ) + 2 * orig . get ( x - 1 , y ) + orig . get ( x - 1 , y + 1 ) ) ; dx += ( orig . get ( x + 1 , y - 1 ) + 2 * orig . get ( x + 1 , y ) + orig . get ( x + 1 , y + 1 ) ) ; derivX . set ( x , y , dx ) ; derivY . set ( x , y , dy ) ; } } }
Computes the derivative of orig along the x and y axes