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

📄 read_image.c

📁 shpf 1.9一个并行编译器
💻 C
字号:

#include "stdio.h"

#include "ad++.h"
#include "admacros.h"

void read_image(char* filename, Array2<int> image,
                int* nx, int *ny, int *maxin) {

// _____________________________________________________________________
//|                                                                     |
//| Subroutine, to read in a .pgm format image from file, into an       |
//| integer array.                                                      |
//|                                                                     |
//| H W Yau.  14th of February, 1994.                                   |
//| Northeast Parallel Architectures Center.                            |
//| Syracuse University.                                                |
//|_____________________________________________________________________|
//|                                                                     |
//| Edit record:                                                        |
//| 14/Feb/1995: Copied from Guy and Ken's wavelet code.  Hon-ie-fied.  |
//|_____________________________________________________________________|

// .. Local variables ..

  Range i = image.rng(0), j = image.rng(1) ;
  char magic [2] ;

// Read simple image from a file.

  FILE* ifile = gfopen(filename, "r") ;

  gfscanf(ifile, "%2s%d%d%d", magic, nx, ny, maxin) ;
  gprintf("Reading image %s of size %6d by %6d pixels Max intensity =%6d\n",
          filename, *nx, *ny, *maxin) ;
  afscanf(ifile, "%d", image.sect(i.sub(*nx, 0), j.sub(*ny, 0))) ;

  gfclose(ifile) ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -