GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
iscatt_core.c File Reference

Imagery library - wx.iscatt (wx Interactive Scatter Plot Tool) backend. More...

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/raster.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
#include "iclass_local_proto.h"
Include dependency graph for iscatt_core.c:

Go to the source code of this file.

Functions

int I_create_cat_rast (struct Cell_head *cat_rast_region, const char *cat_rast)
 Create category raster conditions file. The file is used for holding selected areas from mapwindow. The reason why the standard GRASS raster is not used is that for every modification (new area is selected) we would need to create whole new raster. Instead of this scatter plot only modifies affected region in the internal pgm file. More...
 
int I_insert_patch_to_cat_rast (const char *patch_rast, struct Cell_head *cat_rast_region, const char *cat_rast)
 Insert raster map patch into pgm file. More...
 
int I_compute_scatts (struct Cell_head *region, struct scCats *scatt_conds, const char **cats_rasts_conds, const char **bands, int n_bands, struct scCats *scatts, const char **cats_rasts)
 Compute scatter plots data. More...
 
int I_merge_arrays (unsigned char *merged_arr, unsigned char *overlay_arr, unsigned rows, unsigned cols, double alpha)
 Merge arrays according to opacity. Every pixel in array must be represented by 4 values (RGBA). More...
 
int I_apply_colormap (unsigned char *vals, unsigned char *vals_mask, unsigned nvals, unsigned char *colmap, unsigned char *col_vals)
 Apply colromap to the raster. More...
 
int I_rasterize (double *polygon, int pol_n_pts, unsigned char val, struct Cell_head *rast_region, unsigned char *rast)
 Wrapper for using of iclass perimeter rasterization by scatter plot. Warning: calls Rast_set_window. More...
 

Detailed Description

Imagery library - wx.iscatt (wx Interactive Scatter Plot Tool) backend.

Copyright (C) 2013 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.

Author
Stepan Turek stepa.nosp@m.n.tu.nosp@m.rek@s.nosp@m.ezna.nosp@m.m.cz (GSoC 2013, Mentor: Martin Landa)

Definition in file iscatt_core.c.

Function Documentation

◆ I_apply_colormap()

int I_apply_colormap ( unsigned char *  vals,
unsigned char *  vals_mask,
unsigned  nvals,
unsigned char *  colmap,
unsigned char *  col_vals 
)

Apply colromap to the raster.

Implementd for speeding up of scatter plots rendering.

Parameters
valsarray of values for applying the colormap
vals_maskmaks of vals array
nvalsnumber of items of vals_mask and vals array
colmapcolour map to be applied
[out]col_valsoutput raster with applied color map (length is 4 * nvals (RGBA))
Returns
0

Definition at line 905 of file iscatt_core.c.

◆ I_compute_scatts()

int I_compute_scatts ( struct Cell_head region,
struct scCats scatt_conds,
const char **  cats_rasts_conds,
const char **  bands,
int  n_bands,
struct scCats scatts,
const char **  cats_rasts 
)

Compute scatter plots data.

If category has not defined category raster condition file and no scatter plot exists with condition, default/full scatter plot is computed. Warning: calls Rast_set_window

Parameters
regionanalysis region, beaware that all input data must be prepared for this region (bands (their ranges), cats_rasts_conds rasters...)
regionfunction calls Rast_set_window for this region
scatt_condspointer to scScatts struct of type SC_SCATT_CONDITIONS, where are stored selected areas (conditions) in scatter plots
cats_rasts_condspaths to category raster conditions files representing selected areas from mapwindow (conditions) in rasters for every category
cats_rasts_condsindex in array represents corresponding category id
cats_rasts_condsfor manipulation with category raster conditions file see also I_id_scatt_to_bands and I_insert_patch_to_cat_rast
bandsnames of analyzed bands, order of bands is defined by their id
n_bandsnumber of bands
[out]scattspointer to scScatts struct of type SC_SCATT_DATA, where are computed scatter plots stored
[out]cats_rastsarray of raster maps names for every category where will be stored all selected pixels
Returns
0 on success
-1 on failure

Definition at line 695 of file iscatt_core.c.

◆ I_create_cat_rast()

int I_create_cat_rast ( struct Cell_head cat_rast_region,
const char *  cat_rast 
)

Create category raster conditions file. The file is used for holding selected areas from mapwindow. The reason why the standard GRASS raster is not used is that for every modification (new area is selected) we would need to create whole new raster. Instead of this scatter plot only modifies affected region in the internal pgm file.

Parameters
cat_rast_regionregion to be file generated for
[out]cat_rastpath where the pgm raster file will be generated

Definition at line 58 of file iscatt_core.c.

References G_warning().

◆ I_insert_patch_to_cat_rast()

int I_insert_patch_to_cat_rast ( const char *  patch_rast,
struct Cell_head cat_rast_region,
const char *  cat_rast 
)

Insert raster map patch into pgm file.

See also
I_create_cat_rast

Warning: calls Rast_set_window

Parameters
patch_rastname of raster map
cat_rast_regionregion of category raster file
cat_rastpath to category raster file
Returns
0 on success
-1 on failure

Definition at line 236 of file iscatt_core.c.

◆ I_merge_arrays()

int I_merge_arrays ( unsigned char *  merged_arr,
unsigned char *  overlay_arr,
unsigned  rows,
unsigned  cols,
double  alpha 
)

Merge arrays according to opacity. Every pixel in array must be represented by 4 values (RGBA).

Implementd for speeding up of scatter plots rendering.

Parameters
merged_arrarray which will be overlayd with overlay_arr
overlay_arrarray to be merged_arr overlaid with
rowsnumber of rows for the both arrays
colsnumber of columns for the both arrays
alphatransparency (0-1) of the overlay array for merging
Returns
0

Definition at line 862 of file iscatt_core.c.

◆ I_rasterize()

int I_rasterize ( double *  polygon,
int  pol_n_pts,
unsigned char  val,
struct Cell_head rast_region,
unsigned char *  rast 
)

Wrapper for using of iclass perimeter rasterization by scatter plot. Warning: calls Rast_set_window.

Parameters
polygonarray of polygon coordinates [x, y, x, y...]
pol_n_ptsnumber of points in the polygon array
valvalue to be assigned to cells, which belong to plygon
rast_regionregion of raster
[out]rastraster to be pologyn rasterized in
Returns
0 on success
1 on failure

Definition at line 948 of file iscatt_core.c.