imagery.h 6.3 KB

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