[GRASS5] cell neighbors

Glynn Clements glynn at gclements.plus.com
Thu Apr 21 13:57:56 EDT 2005


Jachym Cepicky wrote:

> I would like to program some filters for GRASS and I started with the Gaussian
> filter.
> 
> I took r.neigbors as an teplate, but I'am not able to understand, how to get
> the values of neigbors cells into the *values array :-/
> 
> How (or where is it clearly showen) can I get the neigbors cell values?
> 
> I can get the whole raster row saved in 'inrast', using 
> 
>     G_get_raster_row (infd, inrast, row, data_type)
> 
> I can acces on every column of the raster, using
> 
>     value = ((CELL *) inrast)[col];
> 
> I can acces the values -1 and +1 pixel on the row:
>     
>     value[0] = ((CELL *) inrast)[col-1];
>     value[1] = ((CELL *) inrast)[col];
>     value[2] = ((CELL *) inrast)[col+1];
> 
> But how to acces the values "above" and "under" actual row? Do I need to
> allocate the whole row above and under actual row and to read the data from
> them, or is there some better way? So something like
> 
>     G_get_raster_row (infd, inrast[0], row-1, data_type)
>     G_get_raster_row (infd, inrast[1], row, data_type)
>     G_get_raster_row (infd, inrast[2], row+1, data_type)

Implement a scrolling vertical window; for an example, see r.neighbors
or r.grow2.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list