GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
iclass_bands.c
Go to the documentation of this file.
1/*!
2 \file lib/imagery/iclass_bands.c
3
4 \brief Imagery library - functions for wx.iclass
5
6 Computation based on training areas for supervised classification.
7 Based on i.class module (GRASS 6).
8
9 Reading bands cell category values.
10
11 Copyright (C) 1999-2007, 2011 by the GRASS Development Team
12
13 This program is free software under the GNU General Public License
14 (>=v2). Read the file COPYING that comes with GRASS for details.
15
16 \author David Satnik, Central Washington University (original author)
17 \author Markus Neteler <neteler itc.it> (i.class module)
18 \author Bernhard Reiter <bernhard intevation.de> (i.class module)
19 \author Brad Douglas <rez touchofmadness.com>(i.class module)
20 \author Glynn Clements <glynn gclements.plus.com> (i.class module)
21 \author Hamish Bowman <hamish_b yahoo.com> (i.class module)
22 \author Jan-Oliver Wagner <jan intevation.de> (i.class module)
23 \author Anna Kratochvilova <kratochanna gmail.com> (rewriting for wx.iclass)
24 \author Vaclav Petras <wenzeslaus gmail.com> (rewriting for wx.iclass)
25 */
26
27#include <grass/imagery.h>
28#include <grass/raster.h>
29
30#include "iclass_local_proto.h"
31
32/*!
33 \brief Open and allocate space for the group band files.
34
35 \param refer pointer to band files structure
36 \param[out] band_buffer buffer to read one row of each band
37 \param[out] band_fd band files descriptors
38 */
40{
41 int n, nbands;
42
43 char *name, *mapset;
44
45 G_debug(3, "open_band_files()");
46
47 /* allocate row buffers and open raster maps */
48 nbands = refer->nfiles;
49 *band_buffer = (CELL **)G_malloc(nbands * sizeof(CELL *));
50 *band_fd = (int *)G_malloc(nbands * sizeof(int));
51
52 for (n = 0; n < nbands; n++) {
53 (*band_buffer)[n] = Rast_allocate_c_buf();
54 name = refer->file[n].name;
55 mapset = refer->file[n].mapset;
56 (*band_fd)[n] = Rast_open_old(name, mapset);
57 }
58}
59
60/*!
61 \brief Close and free space for the group band files.
62
63 \param refer pointer to band files structure
64 \param band_buffer buffer to read one row of each band
65 \param band_fd band files descriptors
66 */
68{
69 int n, nbands;
70
71 G_debug(3, "close_band_files()");
72
73 nbands = refer->nfiles;
74 for (n = 0; n < nbands; n++) {
77 }
78
81}
82
83/*!
84 \brief Read one row of each band.
85
86 \param band_buffer buffer to read one row of each band
87 \param band_fd band files descriptors
88 \param nbands number of band files
89 \param row data row
90 */
91void read_band_row(CELL **band_buffer, int *band_fd, int nbands, int row)
92{
93 int i;
94
95 G_debug(5, "read_band_row(): row = %d", row);
96
97 for (i = 0; i < nbands; i++)
99}
AMI_err name(char **stream_name)
Definition ami_stream.h:426
void G_free(void *)
Free allocated memory.
Definition gis/alloc.c:147
#define G_malloc(n)
Definition defs/gis.h:139
int G_debug(int, const char *,...) __attribute__((format(printf
CELL * Rast_allocate_c_buf(void)
Allocate memory for a CELL type raster map.
Definition alloc_cell.c:80
void Rast_get_c_row_nomask(int, CELL *, int)
Read raster row without masking (CELL type)
void Rast_close(int)
Close a raster map.
int Rast_open_old(const char *, const char *)
Open an existing integer raster map (cell)
int CELL
Definition gis.h:634
void read_band_row(CELL **band_buffer, int *band_fd, int nbands, int row)
Read one row of each band.
void close_band_files(struct Ref *refer, CELL **band_buffer, int *band_fd)
Close and free space for the group band files.
void open_band_files(struct Ref *refer, CELL ***band_buffer, int **band_fd)
Open and allocate space for the group band files.
const char * name
Definition named_colr.c:6
Definition imagery.h:24