[GRASS5] cell neighbors

Jachym Cepicky jachym.cepicky at centrum.cz
Tue Apr 19 13:20:44 EDT 2005


Hallo,
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)

??
Thank you for hints

Jachym
-- 
Jachym Cepicky
e-mail: jachym.cepicky at centrum.cz
URL: http://les-ejk.cz
GPG: http://www.fle.czu.cz/~jachym/gnupg_public_key/




More information about the grass-dev mailing list