GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
quant.c File Reference
#include <stdlib.h>
#include <grass/gis.h>
Include dependency graph for quant.c:

Go to the source code of this file.

Macros

#define USE_LOOKUP   1
 
#define MAX_LOOKUP_TABLE_SIZE   2048
 
#define NO_DATA   (G_set_c_null_value (&tmp, 1), (CELL) tmp)
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define NO_LEFT_INFINITE_RULE   (! q->infiniteLeftSet)
 
#define NO_RIGHT_INFINITE_RULE   (! q->infiniteRightSet)
 
#define NO_FINITE_RULE   (q->nofRules <= 0)
 
#define NO_EXPLICIT_RULE
 

Functions

void G_quant_clear (struct Quant *q)
 
void G_quant_free (struct Quant *q)
 
int G__quant_organize_fp_lookup (struct Quant *q)
 
int G_quant_init (struct Quant *quant)
 Initializes the q struct. More...
 
int G_quant_is_truncate (const struct Quant *quant)
 
int G_quant_is_round (const struct Quant *quant)
 
int G_quant_truncate (struct Quant *quant)
 sets the quant for q rules to perform simple truncation on floats. More...
 
int G_quant_round (struct Quant *quant)
 
int G_quant_get_limits (const struct Quant *q, DCELL *dMin, DCELL *dMax, CELL *cMin, CELL *cMax)
 Extracts the minimum and maximum floating-point and integer values from all the rules (except the "infinite" rules) in q into dmin, dmax, cmin, and cmax. Returns 1 if there are any explicit rules. If there are no explicit rules, (this includes cases when q is set to truncate or round map), it returns 0 and sets dmin, dmax, cmin, and cmax to NULL. More...
 
int G_quant_nof_rules (const struct Quant *q)
 
void G_quant_get_ith_rule (const struct Quant *q, int i, DCELL *dLow, DCELL *dHigh, CELL *cLow, CELL *cHigh)
 
void G_quant_set_neg_infinite_rule (struct Quant *q, DCELL dLeft, CELL c)
 
int G_quant_get_neg_infinite_rule (const struct Quant *q, DCELL *dLeft, CELL *c)
 
void G_quant_set_pos_infinite_rule (struct Quant *q, DCELL dRight, CELL c)
 
int G_quant_get_pos_infinite_rule (const struct Quant *q, DCELL *dRight, CELL *c)
 
void G_quant_add_rule (struct Quant *q, DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
 
void G_quant_reverse_rule_order (struct Quant *q)
 
CELL G_quant_get_cell_value (struct Quant *q, DCELL dcellVal)
 Returns a CELL category for the floating-point value based on the quantization rules in q. The first rule found that applies is used. The rules are searched in the reverse order they are added to q. If no rule is found, the value is first tested against the negative infinite rule, and finally against the positive infinite rule. if none of these rules apply, the NULL-value is returned. NOTE. See G_quant_organize_fp_lookup() for details on how the values are looked up from fp_lookup table when it is active. (Right now fp_lookup is automatically organized during the first call to G_quant_get_cell_value() More...
 
void G_quant_perform_d (struct Quant *q, const DCELL *dcell, CELL *cell, int n)
 
void G_quant_perform_f (struct Quant *q, const FCELL *fcell, CELL *cell, int n)
 
struct Quant_table * G__quant_get_rule_for_d_raster_val (const struct Quant *q, DCELL val)
 

Macro Definition Documentation

#define MAX (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 298 of file quant.c.

#define MAX_LOOKUP_TABLE_SIZE   2048

Definition at line 292 of file quant.c.

Referenced by G__quant_organize_fp_lookup().

#define MIN (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 297 of file quant.c.

#define NO_DATA   (G_set_c_null_value (&tmp, 1), (CELL) tmp)

Definition at line 293 of file quant.c.

Referenced by G__quant_organize_fp_lookup(), and G_quant_get_cell_value().

#define NO_EXPLICIT_RULE
Value:
#define NO_RIGHT_INFINITE_RULE
Definition: quant.c:301
#define NO_LEFT_INFINITE_RULE
Definition: quant.c:300
#define NO_FINITE_RULE
Definition: quant.c:302

Definition at line 303 of file quant.c.

Referenced by G_quant_get_cell_value(), and G_quant_get_limits().

#define NO_FINITE_RULE   (q->nofRules <= 0)

Definition at line 302 of file quant.c.

Referenced by G__quant_organize_fp_lookup(), and G_quant_get_cell_value().

#define NO_LEFT_INFINITE_RULE   (! q->infiniteLeftSet)

Definition at line 300 of file quant.c.

Referenced by G__quant_organize_fp_lookup(), and G_quant_get_cell_value().

#define NO_RIGHT_INFINITE_RULE   (! q->infiniteRightSet)

Definition at line 301 of file quant.c.

Referenced by G__quant_organize_fp_lookup(), and G_quant_get_cell_value().

#define USE_LOOKUP   1

Definition at line 291 of file quant.c.

Referenced by G_quant_get_cell_value().

Function Documentation

struct Quant_table* G__quant_get_rule_for_d_raster_val ( const struct Quant *  q,
DCELL  val 
)

Definition at line 929 of file quant.c.

References NULL.

Referenced by G__quant_organize_fp_lookup(), and G_quant_get_cell_value().

int G__quant_organize_fp_lookup ( struct Quant *  q)
void G_quant_add_rule ( struct Quant *  q,
DCELL  dLow,
DCELL  dHigh,
CELL  cLow,
CELL  cHigh 
)

Definition at line 655 of file quant.c.

References G_free().

Referenced by G_quantize_fp_map_range(), G_set_d_raster_cat(), and G_set_quant_rules().

void G_quant_clear ( struct Quant *  q)

Definition at line 308 of file quant.c.

Referenced by G_quant_free(), and G_quant_init().

void G_quant_free ( struct Quant *  q)

Definition at line 316 of file quant.c.

References G_free(), and G_quant_clear().

Referenced by G__quant_import(), and G_free_raster_cats().

CELL G_quant_get_cell_value ( struct Quant *  q,
DCELL  dcellVal 
)

Returns a CELL category for the floating-point value based on the quantization rules in q. The first rule found that applies is used. The rules are searched in the reverse order they are added to q. If no rule is found, the value is first tested against the negative infinite rule, and finally against the positive infinite rule. if none of these rules apply, the NULL-value is returned. NOTE. See G_quant_organize_fp_lookup() for details on how the values are looked up from fp_lookup table when it is active. (Right now fp_lookup is automatically organized during the first call to G_quant_get_cell_value()

Parameters
q
value
Returns
CELL

Definition at line 775 of file quant.c.

References G__quant_get_rule_for_d_raster_val(), G__quant_organize_fp_lookup(), G_is_d_null_value(), int, NO_DATA, NO_EXPLICIT_RULE, NO_FINITE_RULE, NO_LEFT_INFINITE_RULE, NO_RIGHT_INFINITE_RULE, and USE_LOOKUP.

Referenced by G_get_raster_cat(), G_mark_raster_cats(), G_quant_perform_d(), and G_quant_perform_f().

void G_quant_get_ith_rule ( const struct Quant *  q,
int  i,
DCELL *  dLow,
DCELL *  dHigh,
CELL *  cLow,
CELL *  cHigh 
)

Definition at line 562 of file quant.c.

Referenced by E_edit_fp_cats(), and G_get_ith_d_raster_cat().

int G_quant_get_limits ( const struct Quant *  q,
DCELL *  dMin,
DCELL *  dMax,
CELL *  cMin,
CELL *  cMax 
)

Extracts the minimum and maximum floating-point and integer values from all the rules (except the "infinite" rules) in q into dmin, dmax, cmin, and cmax. Returns 1 if there are any explicit rules. If there are no explicit rules, (this includes cases when q is set to truncate or round map), it returns 0 and sets dmin, dmax, cmin, and cmax to NULL.

Parameters
q
dmin
dmax
cmin
cmax
Returns
int

Definition at line 534 of file quant.c.

References G_set_c_null_value(), G_set_d_null_value(), and NO_EXPLICIT_RULE.

Referenced by E_edit_cats(), G_read_range(), and G_write_quant().

int G_quant_get_neg_infinite_rule ( const struct Quant *  q,
DCELL *  dLeft,
CELL *  c 
)

Definition at line 611 of file quant.c.

Referenced by G_set_quant_rules().

int G_quant_get_pos_infinite_rule ( const struct Quant *  q,
DCELL *  dRight,
CELL *  c 
)

Definition at line 641 of file quant.c.

Referenced by G_set_quant_rules().

int G_quant_init ( struct Quant *  quant)

Initializes the q struct.

Parameters
q
Returns
int

Definition at line 422 of file quant.c.

References G_quant_clear().

Referenced by G_init_raster_cats(), G_quantize_fp_map_range(), G_read_quant(), G_round_fp_map(), G_set_quant_rules(), and G_truncate_fp_map().

int G_quant_is_round ( const struct Quant *  quant)

Definition at line 442 of file quant.c.

Referenced by G_read_range().

int G_quant_is_truncate ( const struct Quant *  quant)

Definition at line 435 of file quant.c.

Referenced by G_read_range().

int G_quant_nof_rules ( const struct Quant *  q)

Definition at line 555 of file quant.c.

Referenced by G3d_writeCats(), G__write_cats(), and G_get_next_marked_d_raster_cat().

void G_quant_perform_d ( struct Quant *  q,
const DCELL *  dcell,
CELL *  cell,
int  n 
)

Definition at line 884 of file quant.c.

References G_is_d_null_value(), G_quant_get_cell_value(), G_set_c_null_value(), and n.

void G_quant_perform_f ( struct Quant *  q,
const FCELL *  fcell,
CELL *  cell,
int  n 
)

Definition at line 898 of file quant.c.

References G_is_f_null_value(), G_quant_get_cell_value(), G_set_c_null_value(), and n.

void G_quant_reverse_rule_order ( struct Quant *  q)

Definition at line 694 of file quant.c.

int G_quant_round ( struct Quant *  quant)

Definition at line 479 of file quant.c.

Referenced by G_round_fp_map().

void G_quant_set_neg_infinite_rule ( struct Quant *  q,
DCELL  dLeft,
CELL  c 
)

Definition at line 595 of file quant.c.

Referenced by G_set_quant_rules().

void G_quant_set_pos_infinite_rule ( struct Quant *  q,
DCELL  dRight,
CELL  c 
)

Definition at line 625 of file quant.c.

Referenced by G_set_quant_rules().

int G_quant_truncate ( struct Quant *  quant)

sets the quant for q rules to perform simple truncation on floats.

Parameters
q
Returns
int

sets the quant for q rules to perform simple rounding on floats.

Parameters
q
Returns
int

Definition at line 471 of file quant.c.

Referenced by G_set_quant_rules(), and G_truncate_fp_map().