⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dwt.java

📁 这是DWT和IDWT的源码. 离散小波的原始程式。
💻 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 + -