1
#include <grass/raster.h>
2
#include <grass/imagery.h>
3
#include <grass/glocale.h>
7
int write_img(unsigned char **img, float **goodness, int ncols, int nrows,
8
struct SigSet *S, /* class parameters */
9
struct parms *parms, /* parms: command line parameters */
11
{ /* files: contains file to output */
13
FCELL *fcellbuf = NULL;
15
G_important_message(_("Writing output raster map(s)..."));
17
/* write goodness of fit */
18
if (parms->goodness_map)
19
fcellbuf = Rast_allocate_f_buf();
21
for (row = 0; row < nrows; row++) {
22
G_percent(row, nrows, 2);
23
for (col = 0; col < ncols; col++) {
24
int class = (int)img[row][col];
26
G_debug(3, "class: [%d] row/col: [%d][%d]", class, row, col);
27
files->outbuf[col] = (CELL) S->ClassSig[class].classnum;
29
if (parms->goodness_map)
30
fcellbuf[col] = goodness[row][col];
32
Rast_put_row(files->output_fd, files->outbuf, CELL_TYPE);
33
if (parms->goodness_map)
34
Rast_put_row(files->goodness_fd, fcellbuf, FCELL_TYPE);