GRASS 8 Programmer's Manual 8.6.0dev(2026)-0f6a7341fc
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 SPDX-FileCopyrightText: 1999-2007, 2011 GRASS Development Team
12 SPDX-License-Identifier: GPL-2.0-or-later
13
14 \author David Satnik, Central Washington University (original author)
15 \author Markus Neteler <neteler itc.it> (i.class module)
16 \author Bernhard Reiter <bernhard intevation.de> (i.class module)
17 \author Brad Douglas <rez touchofmadness.com>(i.class module)
18 \author Glynn Clements <glynn gclements.plus.com> (i.class module)
19 \author Hamish Bowman <hamish_b yahoo.com> (i.class module)
20 \author Jan-Oliver Wagner <jan intevation.de> (i.class module)
21 \author Anna Kratochvilova <kratochanna gmail.com> (rewriting for wx.iclass)
22 \author Vaclav Petras <wenzeslaus gmail.com> (rewriting for wx.iclass)
23 */
24
25#include <grass/imagery.h>
26#include <grass/raster.h>
27
28#include "iclass_local_proto.h"
29
30/*!
31 \brief Open and allocate space for the group band files.
32
33 \param refer pointer to band files structure
34 \param[out] band_buffer buffer to read one row of each band
35 \param[out] band_fd band files descriptors
36 */
38{
39 int n, nbands;
40
41 char *name, *mapset;
42
43 G_debug(3, "open_band_files()");
44
45 /* allocate row buffers and open raster maps */
46 nbands = refer->nfiles;
47 *band_buffer = (CELL **)G_malloc(nbands * sizeof(CELL *));
48 *band_fd = (int *)G_malloc(nbands * sizeof(int));
49
50 for (n = 0; n < nbands; n++) {
51 (*band_buffer)[n] = Rast_allocate_c_buf();
52 name = refer->file[n].name;
53 mapset = refer->file[n].mapset;
54 (*band_fd)[n] = Rast_open_old(name, mapset);
55 }
56}
57
58/*!
59 \brief Close and free space for the group band files.
60
61 \param refer pointer to band files structure
62 \param band_buffer buffer to read one row of each band
63 \param band_fd band files descriptors
64 */
66{
67 int n, nbands;
68
69 G_debug(3, "close_band_files()");
70
71 nbands = refer->nfiles;
72 for (n = 0; n < nbands; n++) {
75 }
76
79}
80
81/*!
82 \brief Read one row of each band.
83
84 \param band_buffer buffer to read one row of each band
85 \param band_fd band files descriptors
86 \param nbands number of band files
87 \param row data row
88 */
89void read_band_row(CELL **band_buffer, int *band_fd, int nbands, int row)
90{
91 int i;
92
93 G_debug(5, "read_band_row(): row = %d", row);
94
95 for (i = 0; i < nbands; i++)
97}
AMI_err name(char **stream_name)
Definition ami_stream.h:426
void G_free(void *)
Free allocated memory.
Definition gis/alloc.c:145
#define G_malloc(n)
Definition defs/gis.h:136
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:78
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:631
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