imagery.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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];
  47. int npoints;
  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;
  57. int nsigs;
  58. char title[100];
  59. struct One_Sig *sig;
  60. };
  61. struct SubSig
  62. {
  63. double N;
  64. double pi;
  65. double *means;
  66. double **R;
  67. double **Rinv;
  68. double cnst;
  69. int used;
  70. };
  71. struct ClassData
  72. {
  73. int npixels;
  74. int count;
  75. double **x; /* pixel list: x[npixels][nbands] */
  76. double **p; /* prob p[npixels][subclasses] */
  77. };
  78. struct ClassSig
  79. {
  80. long classnum;
  81. char *title;
  82. int used;
  83. int type;
  84. int nsubclasses;
  85. struct SubSig *SubSig;
  86. struct ClassData ClassData;
  87. };
  88. struct SigSet
  89. {
  90. int nbands;
  91. int nclasses;
  92. char *title;
  93. struct ClassSig *ClassSig;
  94. };
  95. /* IClass */
  96. /*! Holds statistical values for creating histograms and raster maps for one class.
  97. One class is represented by one category (cat).
  98. */
  99. typedef struct
  100. {
  101. int cat; /*!< class */
  102. const char *name; /*!< signature description (class name) */
  103. const char *color; /*!< class color (RRR:GGG:BBB)*/
  104. int nbands; /*!< number of bands */
  105. int ncells; /*!< number of cells in training areas */
  106. int *band_min; /*!< minimum value for each band */
  107. int *band_max; /*!< maximum value for each band */
  108. float *band_sum; /*!< sum of values for each band */
  109. float *band_mean; /*!< mean of values for each band */
  110. float *band_stddev; /*!< standard deviation for each band */
  111. float **band_product; /*!< sum of products of cell category values of 2 bands */
  112. int **band_histo; /*!< number of cells for cell category value (0-256) for each band */
  113. int *band_range_min; /*!< min range of values to create raster map */
  114. int *band_range_max; /*!< max range of values to create raster map */
  115. float nstd; /*!< multiplier of standard deviation */
  116. } IClass_statistics;
  117. /* wx.iscatt backend */
  118. #define SC_SCATT_DATA 0
  119. #define SC_SCATT_CONDITIONS 1
  120. /*! Holds list of all categories.
  121. It can contain selected areas for scatter plots (SC_SCATT_CONDITIONS type)
  122. or computed scatter plots (SC_SCATT_DATA type).
  123. */
  124. struct scCats
  125. {
  126. int type; /*!< SC_SCATT_DATA -> computed scatter plots, SC_SCATT_CONDITIONS ->
  127. set conditions for scatter plots to be computed */
  128. int n_cats; /*!< number of allocated categories */
  129. int n_bands; /*!< number of analyzed bands */
  130. int n_scatts; /*!< number of possible scattter plots, which can be created from bands */
  131. int n_a_cats; /*!< number of used/active categories */
  132. int * cats_ids; /*!< (cat_idx->cat_id) array index is internal idx (position in cats_arr)
  133. and id is saved in it's position*/
  134. int * cats_idxs; /*!< (cat_id->cat_idx) array index is id and internal idx is saved
  135. in it's position*/
  136. struct scScatts ** cats_arr; /*!< array of pointers to struct scScatts */
  137. };
  138. /*! Holds list of all scatter plots, which belongs to category.
  139. */
  140. struct scScatts
  141. {
  142. int n_a_scatts; /*!< number of used/active scatter plots*/
  143. int * scatts_bands; /*!< array of bands, which represents the scatter plots,
  144. every scatter plot has assigned two bads
  145. (size of the array is n_a_scatts * 2 -> idx*2)*/
  146. int * scatt_idxs; /*!< (scatt_id->scatt_idx) internal idx of the scatter plot
  147. (position in scatts_arr)*/
  148. struct scdScattData ** scatts_arr; /*!< array of pointers to scdScattData */
  149. };
  150. /*! Holds scatter plot data.
  151. */
  152. struct scdScattData
  153. {
  154. int n_vals; /*!< Number of values in scatter plot
  155. (length of b_conds_arr or scatt_vals_arr arrays). */
  156. unsigned char * b_conds_arr; /*!< array of selected areas
  157. (used for SC_SCATT_CONDITIONS type) otherwise NULL */
  158. unsigned int * scatt_vals_arr; /*!< array of computed areas
  159. (used for SC_SCATT_DATA type) otherwise NULL */
  160. };
  161. #define SIGNATURE_TYPE_MIXED 1
  162. #define GROUPFILE "CURGROUP"
  163. #define SUBGROUPFILE "CURSUBGROUP"
  164. #include <grass/defs/imagery.h>
  165. #endif