public void Forward ( ImageSource fastBitmap ) { this . width = fastBitmap . getWidth ( ) ; this . height = fastBitmap . getHeight ( ) ; if ( ! isTransformed ) { if ( fastBitmap . isGrayscale ( ) ) { if ( Tools . isPowerOf2 ( width ) && Tools . isPowerOf2 ( height ) ) { data = new double [ height ] [ width ] ; for ( int i = 0 ; i < height ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { data [ i ] [ j ] = Tools . Scale ( 0 , 255 , 0 , 1 , fastBitmap . getRGB ( i , j ) ) ; } } DiscreteCosineTransform . Forward ( data ) ; isTransformed = true ; } else { try { throw new IllegalArgumentException ( "Image width and height should be power of 2." ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } else { try { throw new IllegalArgumentException ( "Only grayscale images are supported." ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } }
Applies forward Cosine transformation to an image .