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