[GRASS-user] counting cells equal center cell on window

Dear all,

I have a raster map with categorical values.
I have many occurrence of alone-pixels, where all neighbours
are different from a central pixels. So I need to change all pixels
that differ from alll its neighbours for the “mode” value.

I know that “r.neighbours …method=mode” return the mode value.
Now I need to identify only those pixels that differ from neighbours.
I think one way is count all occurrence the value of central pixel
on a windows (like 3x3, 5x5), and attrib it on a bynary map, where
“ones” is for those positons where central pixels have frequency 1,
and “zeros” for those potisions where central pixels have frequency >1.

Any help are welcome.

Best wishes,

miltinho astronauta
brazil

Milton Cezar Ribeiro wrote

I have a raster map with categorical values.
I have many occurrence of alone-pixels, where all neighbours
are different from a central pixels. So I need to change all pixels
that differ from alll its neighbours for the "mode" value.

I know that "r.neighbours ..method=mode" return the mode value.
Now I need to identify only those pixels that differ from neighbours.

you might check out the r.game_of_life module in wiki addons for inspiration.

Hamish

Milton Cezar Ribeiro wrote:

I have a raster map with categorical values.
I have many occurrence of alone-pixels, where all neighbours
are different from a central pixels. So I need to change all pixels
that differ from alll its neighbours for the "mode" value.

I know that "r.neighbours ..method=mode" return the mode value.
Now I need to identify only those pixels that differ from neighbours.
I think one way is count all occurrence the value of central pixel
on a windows (like 3x3, 5x5), and attrib it on a bynary map, where
"ones" is for those positons where central pixels have frequency 1,
and "zeros" for those potisions where central pixels have frequency >1.

Maybe you want method=interspersion:

       interspersion
     The percentage of cells containing values which differ from the
     values assigned to the center cell in the neighborhood, plus 1. In
     the above example, the interspersion is:
     5/8 * 100 + 1 = 63.5
     The result is rounded to the nearest integer (in this case 64).

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