GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-0824e8842e
|
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 349 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 281 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 107 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, 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 471 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 502 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 670 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 574 of file iclass_statistics.c.
References _, IClass_statistics::band_max, G_warning(), max, 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 620 of file iclass_statistics.c.
References _, IClass_statistics::band_mean, G_warning(), mean(), 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 551 of file iclass_statistics.c.
References _, IClass_statistics::band_min, G_warning(), min, 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 486 of file iclass_statistics.c.
References IClass_statistics::name, and 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 460 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 514 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 525 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 702 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 748 of file iclass_statistics.c.
References _, IClass_statistics::band_range_max, G_warning(), max, 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 725 of file iclass_statistics.c.
References _, IClass_statistics::band_range_min, G_warning(), min, 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 643 of file iclass_statistics.c.
References _, IClass_statistics::band_stddev, G_warning(), IClass_statistics::nbands, and stddev().
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 597 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 536 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 142 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 193 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 369 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(), I_iclass_statistics_get_mean(), 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 385 of file iclass_statistics.c.
References var().
Referenced by I_iclass_statistics_get_stddev(), and 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 404 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 437 of file iclass_statistics.c.
References IClass_statistics::band_product, IClass_statistics::band_sum, and IClass_statistics::ncells.
Referenced by I_iclass_add_signature().