GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-f13a4924e1
imagery.h
Go to the documentation of this file.
1 #ifndef GRASS_IMAGERY_H
2 #define GRASS_IMAGERY_H
3 
4 #include <grass/gis.h>
5 #include <grass/raster.h>
6 
7 /* File/directory name lengths */
8 #define INAME_LEN GNAME_MAX /* coupled to raster map name length */
9 
10 struct Ref_Color {
11  unsigned char *table; /* color table for min-max values */
12  unsigned char *index; /* data translation index */
13  unsigned char *buf; /* data buffer for reading color file */
14  int fd; /* for image i/o */
15  CELL min, max; /* min,max CELL values */
16  int n; /* index into Ref_Files */
17 };
18 
19 struct Ref_Files {
20  char name[INAME_LEN]; /* length is not in sync with other definitions */
22 };
23 
24 struct Ref {
25  int nfiles;
26  struct Ref_Files *file;
27  struct Ref_Color red, grn, blu;
28 };
29 
30 struct Tape_Info {
31  char title[75];
32  char id[2][75];
33  char desc[5][75];
34 };
35 
37  int count;
38  double *e1;
39  double *n1;
40  double *z1;
41  double *e2;
42  double *n2;
43  double *z2;
44  int *status;
45 };
46 
47 struct One_Sig {
48  char desc[256]; /* name of target class */
49  int npoints; /* cell count used to determine class parameters */
50  double *mean; /* one mean for each band */
51  double **var; /* covariance band-band */
52  int status; /* may be used to 'delete' a signature */
53  float r, g, b; /* color */
55  int oclass; /* original class value */
56 };
57 
58 struct Signature {
59  int nbands; /* band (imagery group member) count */
60  char **semantic_labels; /* list of semantic labels */
61  int nsigs; /* signature count */
62  int have_oclass; /* is One_Sig.oclass filled with values? */
63  char title[100]; /* not used? */
64  struct One_Sig *sig; /* array of one signature per class */
65 };
66 
67 struct SubSig {
68  double N;
69  double pi;
70  double *means;
71  double **R;
72  double **Rinv;
73  double cnst;
74  int used;
75 };
76 
77 struct ClassData {
78  int npixels;
79  int count;
80  double **x; /* pixel list: x[npixels][nbands] */
81  double **p; /* prob p[npixels][subclasses] */
82 };
83 
84 struct ClassSig {
85  long classnum; /* c_cat */
86  char *title; /* from Rast_get_c_cat */
87  int used;
88  int type; /* always is SIGNATURE_TYPE_MIXED ? */
89  int nsubclasses; /* SubSig item count */
90  struct SubSig *SubSig;
91  struct ClassData ClassData; /* used for SubSig calculation only */
92 };
93 
94 struct SigSet {
95  int nbands;
96  char **semantic_labels; /* list of semantic labels [nbands]char* */
97  int nclasses; /* ClassSig item count */
98  char *title;
99  struct ClassSig *ClassSig;
100 };
101 
102 /* IClass */
103 
104 /*! Holds statistical values for creating histograms and raster maps for one
105  class.
106 
107  One class is represented by one category (cat).
108  */
109 typedef struct {
110  int cat; /*!< class */
111  const char *name; /*!< signature description (class name) */
112  const char *color; /*!< class color (RRR:GGG:BBB) */
113  int nbands; /*!< number of bands */
114 
115  int ncells; /*!< number of cells in training areas */
116 
117  int *band_min; /*!< minimum value for each band */
118  int *band_max; /*!< maximum value for each band */
119  float *band_sum; /*!< sum of values for each band */
120  float *band_mean; /*!< mean of values for each band */
121  float *band_stddev; /*!< standard deviation for each band */
122 
123  float **
124  band_product; /*!< sum of products of cell category values of 2 bands */
125  int **band_histo; /*!< number of cells for cell category value (0-256) for
126  each band */
127 
128  int *band_range_min; /*!< min range of values to create raster map */
129  int *band_range_max; /*!< max range of values to create raster map */
130  float nstd; /*!< multiplier of standard deviation */
131 
133 
134 /* wx.iscatt backend */
135 
136 #define SC_SCATT_DATA 0
137 #define SC_SCATT_CONDITIONS 1
138 
139 /*! Holds list of all categories.
140  It can contain selected areas for scatter plots (SC_SCATT_CONDITIONS type)
141  or computed scatter plots (SC_SCATT_DATA type).
142  */
143 struct scCats {
144  int type; /*!< SC_SCATT_DATA -> computed scatter plots, SC_SCATT_CONDITIONS
145  -> set conditions for scatter plots to be computed */
146 
147  int n_cats; /*!< number of allocated categories */
148 
149  int n_bands; /*!< number of analyzed bands */
150  int n_scatts; /*!< number of possible scattter plots, which can be created
151  from bands */
152 
153  int n_a_cats; /*!< number of used/active categories */
154  int *cats_ids; /*!< (cat_idx->cat_id) array index is internal idx (position
155  in cats_arr) and id is saved in it's position */
156  int *cats_idxs; /*!< (cat_id->cat_idx) array index is id and internal idx is
157  saved in it's position */
158 
159  struct scScatts **cats_arr; /*!< array of pointers to struct scScatts */
160 };
161 
162 /*! Holds list of all scatter plots, which belongs to category.
163  */
164 struct scScatts {
165  int n_a_scatts; /*!< number of used/active scatter plots */
166 
167  int *scatts_bands; /*!< array of bands, which represents the scatter plots,
168  every scatter plot has assigned two bads
169  (size of the array is n_a_scatts * 2 -> idx*2) */
170  int *scatt_idxs; /*!< (scatt_id->scatt_idx) internal idx of the scatter plot
171  (position in scatts_arr) */
172 
173  struct scdScattData **scatts_arr; /*!< array of pointers to scdScattData */
174 };
175 
176 /*! Holds scatter plot data.
177  */
178 struct scdScattData {
179  int n_vals; /*!< Number of values in scatter plot
180  (length of b_conds_arr or scatt_vals_arr arrays). */
181 
182  unsigned char
183  *b_conds_arr; /*!< array of selected areas
184  (used for SC_SCATT_CONDITIONS type) otherwise NULL */
185  unsigned int
186  *scatt_vals_arr; /*!< array of computed areas
187  (used for SC_SCATT_DATA type) otherwise NULL */
188 };
189 
190 /*! Supported signature file types.
191  * Remember to adjust I_SIGFILE_TYPE_COUNT on a change
192  */
193 typedef enum {
194  I_SIGFILE_TYPE_SIG, /*! Signature files used by i.maxlik */
195  I_SIGFILE_TYPE_SIGSET, /*! Signature files used by i.smap */
196  I_SIGFILE_TYPE_LIBSVM, /*! Signature files used by i.svm */
198 
199 #define SIGNATURE_TYPE_MIXED 1 /* Unused? */
200 #define I_SIGFILE_TYPE_COUNT \
201  3 /*! Total count of supported signature file types */
202 
203 #define GROUPFILE "CURGROUP"
204 #define SUBGROUPFILE "CURSUBGROUP"
205 
206 #include <grass/defs/imagery.h>
207 
208 #endif
int CELL
Definition: gis.h:625
#define INAME_LEN
Definition: imagery.h:8
I_SIGFILE_TYPE
Definition: imagery.h:193
@ I_SIGFILE_TYPE_LIBSVM
Definition: imagery.h:196
@ I_SIGFILE_TYPE_SIGSET
Definition: imagery.h:195
@ I_SIGFILE_TYPE_SIG
Definition: imagery.h:194
int npixels
Definition: imagery.h:78
double ** p
Definition: imagery.h:81
double ** x
Definition: imagery.h:80
int count
Definition: imagery.h:79
int nsubclasses
Definition: imagery.h:89
long classnum
Definition: imagery.h:85
int type
Definition: imagery.h:88
char * title
Definition: imagery.h:86
struct SubSig * SubSig
Definition: imagery.h:90
int used
Definition: imagery.h:87
double * z2
Definition: imagery.h:43
int * status
Definition: imagery.h:44
double * e2
Definition: imagery.h:41
double * e1
Definition: imagery.h:38
double * n2
Definition: imagery.h:42
double * n1
Definition: imagery.h:39
double * z1
Definition: imagery.h:40
const char * color
Definition: imagery.h:112
int * band_range_max
Definition: imagery.h:129
int ** band_histo
Definition: imagery.h:125
float * band_sum
Definition: imagery.h:119
const char * name
Definition: imagery.h:111
float * band_stddev
Definition: imagery.h:121
int * band_range_min
Definition: imagery.h:128
float * band_mean
Definition: imagery.h:120
float ** band_product
Definition: imagery.h:124
int status
Definition: imagery.h:52
char desc[256]
Definition: imagery.h:48
int npoints
Definition: imagery.h:49
double * mean
Definition: imagery.h:50
double ** var
Definition: imagery.h:51
float g
Definition: imagery.h:53
float b
Definition: imagery.h:53
float r
Definition: imagery.h:53
int oclass
Definition: imagery.h:55
int have_color
Definition: imagery.h:54
int fd
Definition: imagery.h:14
unsigned char * index
Definition: imagery.h:12
CELL min
Definition: imagery.h:15
unsigned char * table
Definition: imagery.h:11
unsigned char * buf
Definition: imagery.h:13
int n
Definition: imagery.h:16
CELL max
Definition: imagery.h:15
char name[INAME_LEN]
Definition: imagery.h:20
char mapset[INAME_LEN]
Definition: imagery.h:21
Definition: imagery.h:24
struct Ref_Color red grn blu
Definition: imagery.h:27
int nfiles
Definition: imagery.h:25
struct Ref_Files * file
Definition: imagery.h:26
Definition: imagery.h:94
int nbands
Definition: imagery.h:95
struct ClassSig * ClassSig
Definition: imagery.h:99
char ** semantic_labels
Definition: imagery.h:96
int nclasses
Definition: imagery.h:97
char * title
Definition: imagery.h:98
int have_oclass
Definition: imagery.h:62
int nsigs
Definition: imagery.h:61
struct One_Sig * sig
Definition: imagery.h:64
char ** semantic_labels
Definition: imagery.h:60
char title[100]
Definition: imagery.h:63
int nbands
Definition: imagery.h:59
Definition: imagery.h:67
double pi
Definition: imagery.h:69
double N
Definition: imagery.h:68
int used
Definition: imagery.h:74
double ** R
Definition: imagery.h:71
double cnst
Definition: imagery.h:73
double * means
Definition: imagery.h:70
double ** Rinv
Definition: imagery.h:72
char title[75]
Definition: imagery.h:31
char desc[5][75]
Definition: imagery.h:33
int type
Definition: imagery.h:144
int n_cats
Definition: imagery.h:147
int * cats_ids
Definition: imagery.h:154
struct scScatts ** cats_arr
Definition: imagery.h:159
int n_a_cats
Definition: imagery.h:153
int * cats_idxs
Definition: imagery.h:156
int n_scatts
Definition: imagery.h:150
int n_bands
Definition: imagery.h:149
int * scatt_idxs
Definition: imagery.h:170
int n_a_scatts
Definition: imagery.h:165
struct scdScattData ** scatts_arr
Definition: imagery.h:173
int * scatts_bands
Definition: imagery.h:167
unsigned int * scatt_vals_arr
Definition: imagery.h:186
int n_vals
Definition: imagery.h:179
unsigned char * b_conds_arr
Definition: imagery.h:183