?? dwt.java
字號:
/* **************************************************************************** * * Transform a grayscale image into a wavelet integer array * **************************************************************************** */import java.io.*;public class Dwt { public static void main(String[] args) { int level, nrows, ncols; int img[][], source[][], result[][]; int i, j, i1, j1, i2, j2, k; int nr, nc, nr2, nc2; if (args.length != 5) { System.out.println( "Usage: Dwt <level> <nrows> <ncols> <img> <out_file>"); System.exit(0); } // Command line processing: level = Integer.parseInt(args[0]); if (level <= 0) { System.out.println("Number of levels should be greater than 0."); System.exit(0); } nrows = nr = Integer.parseInt(args[1]); ncols = nc = Integer.parseInt(args[2]); img = new int[nrows][ncols]; ArrayIO.readByteArray(args[3], img, nrows, ncols); source = new int[nrows][ncols]; result = new int[nrows][ncols]; for (i=0; i<nrows; i++) for (j=0; j<ncols; j++) source[i][j] = img[i][j]; for (k=1; k<=level; k++, nr/=2, nc/=2) { // Horizontal processing: nc2 = nc/2; for (i=0; i<nr; i++) { for (j=0; j<nc; j+=2) { j1 = j+1; j2 = j/2; result[i][j2] = source[i][j] + source[i][j1]; result[i][nc2+j2] = source[i][j] - source[i][j1]; } } // Copy to source: for (i=0; i<nr; i++) for (j=0; j<nc; j++) source[i][j] = result[i][j]; // Vertical processing: nr2 = nr/2; for (i=0; i<nr; i+=2) { for (j=0; j<nc; j++) { i1 = i+1; i2 = i/2; result[i2][j] = source[i][j] + source[i1][j]; result[nr2+i2][j] = source[i][j] - source[i1][j]; } } // Copy to source: for (i=0; i<nr; i++) for (j=0; j<nc; j++) source[i][j] = result[i][j]; } ArrayIO.writeIntArray(args[4], result, nrows, ncols); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -