/** * Rotates the image 90 degrees in the counter-clockwise direction. */ public static void rotateCCW( GrayI16 input , GrayI16 output ) { if( input.width != output.height || input.height != output.width ) throw new IllegalArgumentException("Incompatible shapes"); int w = input.width-1; for( int y = 0; y < input.height; y++ ) { int indexIn = input.startIndex + y*input.stride; for (int x = 0; x < input.width; x++) { output.unsafe_set(y,w-x,input.data[indexIn++]); } } }
/** * Rotates the image 90 degrees in the clockwise direction. */ public static void rotateCW( GrayI16 input , GrayI16 output ) { if( input.width != output.height || input.height != output.width ) throw new IllegalArgumentException("Incompatible shapes"); int h = input.height-1; for( int y = 0; y < input.height; y++ ) { int indexIn = input.startIndex + y*input.stride; for (int x = 0; x < input.width; x++) { output.unsafe_set(h-y,x,input.data[indexIn++]); } } }