[GRASS5] cell neighbors

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@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.fle.czu.cz/~jachym/gnupg_public_key/

Hi list,

Allmost a year ago we were discussing the doxygen generated output. I've finally finished a script which puts eveything in it's own directory and is fully linked against each other.
As you were the only one, ever to express any interest, I'm hopefully not bothering you too much.

To make it easy for you I've put the main directories $grass_sources/include and $grass_sources/lib on my webspace here:

members.home.nl/jkwast/doxygenhtml

I forgot to run ./configure before running the scripts, so some links are not made but will when you run configure first (things like in config.h). Also in some cases there are double names for structs, unions, functions etc. that doxygen cannot handle proper. I will, to that purpose, finish another script in a couple of days to make lists of those so we can remedy that easily.

If you like it, I can send you the scripts and related files for reviewing and maybe uploading to cvs.

Greetings,

J.C.M. van der Kwast
Bsc. Tropical Agriculture

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@gclements.plus.com>