[GRASS-user] Fwd: How to obtain selected adjacent pixel values?
Nikos Alexandris
nik at nikosalexandris.net
Fri Jun 28 12:31:31 PDT 2013
Yasser Said Lopez de Olmos Reyes wrote:
> 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))
This boils down to calculating
(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)
Please check the manual of r.mapcalc. There is
--%<---
THE NEIGHBORHOOD MODIFIER
Maps and images are data base files stored in raster format, i.e., two-
dimensional matrices of integer values. In r.mapcalc, maps may be followed by
a neighborhood modifier that specifies a relative offset from the current cell
being evaluated. The format is map[r,c], where r is the row offset and c is
the column offset. For example, map[1,2] refers to the cell one row below and
two columns to the right of the current cell, map[-2,-1] refers to the cell
two rows above and one column to the left of the current cell, and map[0,1]
refers to the cell one column to the right of the current cell. This syntax
permits the development of neighborhood-type filters within a single map or
across multiple maps.
--->%--
which I think can be used to obtain what is asked.
So, for each of the off-current pixel, the modifiers would be like
RASTER_IN_PUSHED_ONE_ROW_UP: map[-1,0]
RASTER_IN_PUSHED_ONE_ROW_DOWN: map[1,0]
RASTER_IN_PUSHED_ONE_COLUMN_LEFT: map[0,-1]
RASTER_IN_PUSHED_ONE_COLUMN_RIGHT: map[0,1]
I am not exactly sure about the implementation though.
Nikos
More information about the grass-user
mailing list