imagery.h 5.4 KB

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