read_image.c

来自「shpf 1.9一个并行编译器」· C语言 代码 · 共 41 行

C
41
字号

#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 + =
减小字号Ctrl + -
显示快捷键?