GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
|
Imagery library - functions for wx.iclass. More...
#include <math.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
#include <grass/colors.h>
#include "iclass_local_proto.h"
Go to the source code of this file.
Functions | |
void | I_iclass_init_statistics (IClass_statistics *statistics, int category, const char *name, const char *color, float nstd) |
Initialize statistics. More... | |
void | alloc_statistics (IClass_statistics *statistics, int nbands) |
Allocate space for statistics. More... | |
void | I_iclass_free_statistics (IClass_statistics *statistics) |
Free space allocated for statistics attributes. More... | |
int | make_all_statistics (IClass_statistics *statistics, IClass_perimeter_list *perimeters, CELL **band_buffer, int *band_fd) |
Calculate statistics for all training areas. More... | |
int | make_statistics (IClass_statistics *statistics, IClass_perimeter *perimeter, CELL **band_buffer, int *band_fd) |
Calculate statistics for one training area. More... | |
void | create_raster (IClass_statistics *statistics, CELL **band_buffer, int *band_fd, const char *raster_name) |
Create raster map based on statistics. More... | |
void | band_range (IClass_statistics *statistics, int band) |
Helper function for computing min and max range in one band. More... | |
float | mean (IClass_statistics *statistics, int band) |
Helper function for computing mean. More... | |
float | stddev (IClass_statistics *statistics, int band) |
Helper function for standard deviation. More... | |
float | var (IClass_statistics *statistics, int band1, int band2) |
Helper function for computing variance. More... | |
float | var_signature (IClass_statistics *statistics, int band1, int band2) |
Helper function for computing variance for signature file. More... | |
void | I_iclass_statistics_get_nbands (IClass_statistics *statistics, int *nbands) |
Get number of bands. More... | |
void | I_iclass_statistics_get_cat (IClass_statistics *statistics, int *cat) |
Get category (class). More... | |
void | I_iclass_statistics_get_name (IClass_statistics *statistics, const char **name) |
Get category (class) name. More... | |
void | I_iclass_statistics_get_color (IClass_statistics *statistics, const char **color) |
Get category (class) color. More... | |
void | I_iclass_statistics_get_ncells (IClass_statistics *statistics, int *ncells) |
Get number of cells in training areas. More... | |
void | I_iclass_statistics_get_nstd (IClass_statistics *statistics, float *nstd) |
Get the multiplier of standard deviation. More... | |
void | I_iclass_statistics_set_nstd (IClass_statistics *statistics, float nstd) |
Set the multiplier of standard deviation. More... | |
int | I_iclass_statistics_get_min (IClass_statistics *statistics, int band, int *min) |
Get minimum value in band. More... | |
int | I_iclass_statistics_get_max (IClass_statistics *statistics, int band, int *max) |
Get maximum value in band. More... | |
int | I_iclass_statistics_get_sum (IClass_statistics *statistics, int band, float *sum) |
Get sum of values in band. More... | |
int | I_iclass_statistics_get_mean (IClass_statistics *statistics, int band, float *mean) |
Get mean of cell category values in band. More... | |
int | I_iclass_statistics_get_stddev (IClass_statistics *statistics, int band, float *stddev) |
Get standard deviation of cell category values in band. More... | |
int | I_iclass_statistics_get_histo (IClass_statistics *statistics, int band, int cat, int *value) |
Get histogram value in band. More... | |
int | I_iclass_statistics_get_product (IClass_statistics *statistics, int band1, int band2, float *value) |
Get product value. More... | |
int | I_iclass_statistics_get_range_min (IClass_statistics *statistics, int band, int *min) |
Get minimum cell value based on mean and standard deviation for band. More... | |
int | I_iclass_statistics_get_range_max (IClass_statistics *statistics, int band, int *max) |
Get maximum cell value based on mean and standard deviation for band. More... | |
Imagery library - functions for wx.iclass.
Computation based on training areas for supervised classification. Based on i.class module (GRASS 6).
Computation and writing signatures to file.
Copyright (C) 1999-2007, 2011 by the GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Computation based on training areas for supervised classification. Based on i.class module (GRASS 6).
Computing statistical values (mean, min, max, ...) from given area perimeters for each band.
Copyright (C) 1999-2007, 2011 by the GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Definition in file iclass_statistics.c.
void alloc_statistics | ( | IClass_statistics * | statistics, |
int | nbands | ||
) |
Allocate space for statistics.
statistics | pointer to statistics structure |
nbands | number of band files |
Definition at line 76 of file iclass_statistics.c.
References IClass_statistics::band_histo, IClass_statistics::band_max, IClass_statistics::band_mean, IClass_statistics::band_min, IClass_statistics::band_product, IClass_statistics::band_range_max, IClass_statistics::band_range_min, IClass_statistics::band_stddev, IClass_statistics::band_sum, G_calloc, G_debug(), and IClass_statistics::nbands.
Referenced by I_iclass_analysis().
void band_range | ( | IClass_statistics * | statistics, |
int | band | ||
) |
Helper function for computing min and max range in one band.
Computing min and max range value (distance from mean dependent on number od std ddevs).
statistics | pointer to statistics structure |
band | band index |
Definition at line 350 of file iclass_statistics.c.
References IClass_statistics::band_mean, IClass_statistics::band_range_max, IClass_statistics::band_range_min, IClass_statistics::band_stddev, and IClass_statistics::nstd.
Referenced by I_iclass_create_raster(), and make_all_statistics().
void create_raster | ( | IClass_statistics * | statistics, |
CELL ** | band_buffer, | ||
int * | band_fd, | ||
const char * | raster_name | ||
) |
Create raster map based on statistics.
statistics | pointer to statistics structure |
band_buffer | buffer to read band rows into |
band_fd | band files descriptors |
raster_name | name of new raster map |
Definition at line 282 of file iclass_statistics.c.
Referenced by I_iclass_analysis(), and I_iclass_create_raster().
void I_iclass_free_statistics | ( | IClass_statistics * | statistics | ) |
Free space allocated for statistics attributes.
Frees all allocated arrays in statistics structure.
statistics | pointer to statistics structure |
Definition at line 108 of file iclass_statistics.c.
References IClass_statistics::band_histo, IClass_statistics::band_max, IClass_statistics::band_mean, IClass_statistics::band_min, IClass_statistics::band_product, IClass_statistics::band_range_max, IClass_statistics::band_range_min, IClass_statistics::band_stddev, IClass_statistics::band_sum, IClass_statistics::color, G_debug(), G_free(), IClass_statistics::name, and IClass_statistics::nbands.
void I_iclass_init_statistics | ( | IClass_statistics * | statistics, |
int | category, | ||
const char * | name, | ||
const char * | color, | ||
float | nstd | ||
) |
Initialize statistics.
[out] | statistics | pointer to statistics structure |
category | category (class) | |
name | class name | |
color | class color | |
nstd | standard deviation |
Definition at line 45 of file iclass_statistics.c.
References IClass_statistics::band_histo, IClass_statistics::band_max, IClass_statistics::band_mean, IClass_statistics::band_min, IClass_statistics::band_product, IClass_statistics::band_range_max, IClass_statistics::band_range_min, IClass_statistics::band_stddev, IClass_statistics::band_sum, IClass_statistics::cat, IClass_statistics::color, G_debug(), G_store(), IClass_statistics::name, IClass_statistics::nbands, IClass_statistics::ncells, IClass_statistics::nstd, and NULL.
void I_iclass_statistics_get_cat | ( | IClass_statistics * | statistics, |
int * | cat | ||
) |
Get category (class).
statistics | pointer to statistics structure | |
[out] | cat | category |
Definition at line 475 of file iclass_statistics.c.
References IClass_statistics::cat.
void I_iclass_statistics_get_color | ( | IClass_statistics * | statistics, |
const char ** | color | ||
) |
Get category (class) color.
statistics | pointer to statistics structure | |
[out] | color | category color |
Definition at line 506 of file iclass_statistics.c.
References IClass_statistics::color.
int I_iclass_statistics_get_histo | ( | IClass_statistics * | statistics, |
int | band, | ||
int | cat, | ||
int * | value | ||
) |
Get histogram value in band.
Each band has one value for each raster cell category. Value is number of cells in category.
statistics | pointer to statistics structure | |
band | band index | |
cat | raster cell category | |
[out] | value | number of cells in category |
Definition at line 676 of file iclass_statistics.c.
References _, IClass_statistics::band_histo, G_warning(), and IClass_statistics::nbands.
int I_iclass_statistics_get_max | ( | IClass_statistics * | statistics, |
int | band, | ||
int * | max | ||
) |
Get maximum value in band.
statistics | pointer to statistics structure | |
band | band index | |
[out] | max | maximum value |
Definition at line 580 of file iclass_statistics.c.
References _, IClass_statistics::band_max, G_warning(), and IClass_statistics::nbands.
int I_iclass_statistics_get_mean | ( | IClass_statistics * | statistics, |
int | band, | ||
float * | mean | ||
) |
Get mean of cell category values in band.
statistics | pointer to statistics structure | |
band | band index | |
[out] | mean | mean |
Definition at line 626 of file iclass_statistics.c.
References _, IClass_statistics::band_mean, G_warning(), and IClass_statistics::nbands.
int I_iclass_statistics_get_min | ( | IClass_statistics * | statistics, |
int | band, | ||
int * | min | ||
) |
Get minimum value in band.
statistics | pointer to statistics structure | |
band | band index | |
[out] | min | minimum value |
Definition at line 557 of file iclass_statistics.c.
References _, IClass_statistics::band_min, G_warning(), and IClass_statistics::nbands.
void I_iclass_statistics_get_name | ( | IClass_statistics * | statistics, |
const char ** | name | ||
) |
Get category (class) name.
statistics | pointer to statistics structure | |
[out] | name | category name |
Definition at line 490 of file iclass_statistics.c.
References IClass_statistics::name.
void I_iclass_statistics_get_nbands | ( | IClass_statistics * | statistics, |
int * | nbands | ||
) |
Get number of bands.
statistics | pointer to statistics structure | |
[out] | nbands | number of bands |
Definition at line 463 of file iclass_statistics.c.
References IClass_statistics::nbands.
void I_iclass_statistics_get_ncells | ( | IClass_statistics * | statistics, |
int * | ncells | ||
) |
Get number of cells in training areas.
statistics | pointer to statistics structure | |
[out] | ncells | number of cells |
Definition at line 519 of file iclass_statistics.c.
References IClass_statistics::ncells.
void I_iclass_statistics_get_nstd | ( | IClass_statistics * | statistics, |
float * | nstd | ||
) |
Get the multiplier of standard deviation.
statistics | pointer to statistics structure | |
[out] | nstd | multiplier of standard deviation |
Definition at line 531 of file iclass_statistics.c.
References IClass_statistics::nstd.
int I_iclass_statistics_get_product | ( | IClass_statistics * | statistics, |
int | band1, | ||
int | band2, | ||
float * | value | ||
) |
Get product value.
Product value of two bands is sum of products of cell category values of two bands. Only cells from training areas are taken into account.
statistics | statistics object | |
band1 | index of first band | |
band2 | index of second band | |
[out] | value | product value |
Definition at line 708 of file iclass_statistics.c.
References _, IClass_statistics::band_product, G_warning(), and IClass_statistics::nbands.
int I_iclass_statistics_get_range_max | ( | IClass_statistics * | statistics, |
int | band, | ||
int * | max | ||
) |
Get maximum cell value based on mean and standard deviation for band.
statistics | pointer to statistics structure | |
band | band index | |
[out] | max | maximum value |
Definition at line 754 of file iclass_statistics.c.
References _, IClass_statistics::band_range_max, G_warning(), and IClass_statistics::nbands.
int I_iclass_statistics_get_range_min | ( | IClass_statistics * | statistics, |
int | band, | ||
int * | min | ||
) |
Get minimum cell value based on mean and standard deviation for band.
statistics | pointer to statistics structure | |
band | band index | |
[out] | min | minimum value |
Definition at line 731 of file iclass_statistics.c.
References _, IClass_statistics::band_range_min, G_warning(), and IClass_statistics::nbands.
int I_iclass_statistics_get_stddev | ( | IClass_statistics * | statistics, |
int | band, | ||
float * | stddev | ||
) |
Get standard deviation of cell category values in band.
statistics | pointer to statistics structure | |
band | band index | |
[out] | stddev | standard deviation |
Definition at line 649 of file iclass_statistics.c.
References _, IClass_statistics::band_stddev, G_warning(), and IClass_statistics::nbands.
int I_iclass_statistics_get_sum | ( | IClass_statistics * | statistics, |
int | band, | ||
float * | sum | ||
) |
Get sum of values in band.
statistics | pointer to statistics structure | |
band | band index | |
[out] | sum | sum |
Definition at line 603 of file iclass_statistics.c.
References _, IClass_statistics::band_sum, G_warning(), and IClass_statistics::nbands.
void I_iclass_statistics_set_nstd | ( | IClass_statistics * | statistics, |
float | nstd | ||
) |
Set the multiplier of standard deviation.
statistics | pointer to statistics structure |
nstd | multiplier of standard deviation |
Definition at line 542 of file iclass_statistics.c.
References IClass_statistics::nstd.
int make_all_statistics | ( | IClass_statistics * | statistics, |
IClass_perimeter_list * | perimeters, | ||
CELL ** | band_buffer, | ||
int * | band_fd | ||
) |
Calculate statistics for all training areas.
statistics | pointer to statistics structure |
perimeters | list of all area perimeters |
band_buffer | buffer to read band rows into |
band_fd | band files descriptors |
Definition at line 144 of file iclass_statistics.c.
References b, IClass_statistics::band_histo, IClass_statistics::band_max, IClass_statistics::band_mean, IClass_statistics::band_min, IClass_statistics::band_product, band_range(), IClass_statistics::band_stddev, IClass_statistics::band_sum, G_debug(), make_statistics(), mean(), IClass_statistics::nbands, and stddev().
Referenced by I_iclass_analysis().
int make_statistics | ( | IClass_statistics * | statistics, |
IClass_perimeter * | perimeter, | ||
CELL ** | band_buffer, | ||
int * | band_fd | ||
) |
Calculate statistics for one training area.
[out] | statistics | pointer to statistics structure |
perimeter | area perimeter | |
band_buffer | buffer to read band rows into | |
band_fd | band files descriptors |
Definition at line 195 of file iclass_statistics.c.
References b.
Referenced by make_all_statistics().
float mean | ( | IClass_statistics * | statistics, |
int | band | ||
) |
Helper function for computing mean.
Computing mean value of cell category values in one band within training area.
statistics | pointer to statistics structure |
band | band index |
Definition at line 372 of file iclass_statistics.c.
References IClass_statistics::band_sum, and IClass_statistics::ncells.
Referenced by Cdhc_anderson_darling(), Cdhc_anderson_darling_exp(), Cdhc_chi_square(), Cdhc_chi_square_exp(), Cdhc_cramer_von_mises(), Cdhc_cramer_von_mises_exp(), Cdhc_dmax(), Cdhc_dmax_exp(), Cdhc_omnibus_moments(), Cdhc_shapiro_wilk_exp(), Cdhc_watson_u2(), Cdhc_watson_u2_exp(), make_all_statistics(), N_compute_gradient_field_2d(), N_compute_gradient_field_3d(), P_Mean_Calc(), and var().
float stddev | ( | IClass_statistics * | statistics, |
int | band | ||
) |
Helper function for standard deviation.
Computing standard deviation of cell category values in one band within training area.
statistics | pointer to statistics structure |
band | band index |
Definition at line 388 of file iclass_statistics.c.
References var().
Referenced by make_all_statistics().
float var | ( | IClass_statistics * | statistics, |
int | band1, | ||
int | band2 | ||
) |
Helper function for computing variance.
Computing variance of cell category values in one band within training area.
statistics | pointer to statistics structure |
band1 | band index |
band2 | band index |
Definition at line 407 of file iclass_statistics.c.
References IClass_statistics::band_product, mean(), and IClass_statistics::ncells.
Referenced by c_kurt(), c_stddev(), stddev(), w_kurt(), and w_stddev().
float var_signature | ( | IClass_statistics * | statistics, |
int | band1, | ||
int | band2 | ||
) |
Helper function for computing variance for signature file.
Computing variance of cell category values in one band within training area. Variance is computed in special way.
statistics | pointer to statistics structure |
band1 | band index |
band2 | band index |
Definition at line 440 of file iclass_statistics.c.
References IClass_statistics::band_product, IClass_statistics::band_sum, and IClass_statistics::ncells.
Referenced by I_iclass_add_signature().