public static void scanzigzag(int m) {
    int count = 0;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        System.out.print(block[i][j] + " ");
      }
      System.out.println();
    }
    System.out.println(
        "---------------------------------------------------------------------------------------");
    for (int i = 0; i < 2 * n - 1; i++) {
      int start = i < n ? 0 : (i - n + 1);
      int end = i < n ? i : (n - 1);


      if (i % 2 == 0) {
        for (int j = start; j <= end; j++) {
          if (count == m) {
            block[i - j][j] = 0;
          } else {
            count++;
          }
          System.out.print(block[i - j][j] + " ");
        }
      }
      if (i % 2 == 1) {
        for (int j = start; j <= end; j++) {
          if (count == m) {
            block[j][i - j] = 0;
          } else {
            count++;
          }
          System.out.print(block[j][i - j] + " ");
        }
      }
    }
  }

参数m是将到达一定数量的块后,将后面的块设为0,这个方法是我用于DCT变换后解码前选择恢复的块数。

n是数组行数。

版权声明:本文为yanzhao-x原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/yanzhao-x/p/12678079.html