# [OSGeo-Discuss] How to obtain selected adjacent pixel values?

Alex Mandel tech_dev at wildintellect.com
Wed Jun 26 20:29:42 PDT 2013

```On 06/26/2013 05:25 PM, Yasser Said Lopez de Olmos Reyes wrote:
> Hello all, this is my first time using a subscriber list and I have some
>
> I have an AML script (old arcinfo srcipt) that uses focal operations that
> I've sorted out well using r.neighbors but I have a problem in certain part
> of the script to follow in grass GIS. In some part of the script the author
> declares a variable as a grid called "cbd" and codes as follows:
>
> *%cb%d = int(abs((%cb% - %cb%(1,0)) + (%cb% - %cb%(0,1)) + (%cb% -
> %cb%(0,-1)) + (%cb% - %cb%(-1,0))))*
>
>  From where he obtains a grid filled with integer positive values from 0 to
> 4. All these values come from a binary grid (0 or 1 values) declared as
> "cb" where I believe* (%cb% - %cb%(1,0)) *means something like "central
> pixel value minus pixel value at west from central pixel value" and *(%cb%
> - %cb%(0,1)) *means something like "central pixel value minus pixel value
> at north from central pixel value", and so on...
>
> How could I obtain the differences between central pixel values and
> cardinal directions pixel values related with a central pixel?
>
> Or in a different manner, how to do this in grass gis?
>
> RASTER_OUT= round(abs((RASTER_IN - RASTER_IN_PUSHED_ONE_ROW_UP) +
> (RASTER_IN - RASTER_IN_PUSHED_ONE_ROW_DOWN) + (RASTER_IN -
> RASTER_IN_PUSHED_ONE_COLUMN_LEFT) + (RASTER_IN -
> RASTER_IN_PUSHED_ONE_COLUMN_RIGHT))
>
>
>
>

Yasser,

This question is more likely to get an answer on the GRASS users mailing
list http://lists.osgeo.org/mailman/listinfo/grass-user
I suggest you subscribe and re-post there.

You currently posted to the general discussion list for the OSGeo
foundation which GRASS is but one part of.

Thanks,
Alex

```