<div dir="ltr">Sorry, I just need to tell you I'm gonna work on this next week, but I really don't want to discourage you waiting with no news.<div><br></div><div>Thank you all.</div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">2013/6/30 Markus Metz <span dir="ltr"><<a href="mailto:markus.metz.giswork@gmail.com" target="_blank">markus.metz.giswork@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5">On Sun, Jun 30, 2013 at 3:31 PM, Nikos Alexandris<br>
<<a href="mailto:nik@nikosalexandris.net">nik@nikosalexandris.net</a>> wrote:<br>
> (cc-ing @MarkusMetz)<br>
><br>
> Yasser Said Lopez de Olmos Reyes wrote:<br>
><br>
>> > How could I obtain the differences between central pixel values and<br>
>> > cardinal directions pixel values related with a central pixel?<br>
>> > Or in a different manner, how to do this in grass gis?<br>
><br>
>> > RASTER_OUT= round(abs((RASTER_IN - RASTER_IN_PUSHED_ONE_ROW_UP) +<br>
>> > (RASTER_IN - RASTER_IN_PUSHED_ONE_ROW_DOWN) + (RASTER_IN -<br>
>> > RASTER_IN_PUSHED_ONE_COLUMN_LEFT) + (RASTER_IN -<br>
>> > RASTER_IN_PUSHED_ONE_COLUMN_RIGHT))<br>
><br>
> Nikos Alexandris wrote:<br>
>> This boils down to calculating<br>
>> (RASTER_IN - RASTER_IN_PUSHED_ONE_ROW_UP) +<br>
>> (RASTER_IN - RASTER_IN_PUSHED_ONE_ROW_DOWN) +<br>
>> (RASTER_IN - RASTER_IN_PUSHED_ONE_COLUMN_LEFT) +<br>
>> (RASTER_IN - RASTER_IN_PUSHED_ONE_COLUMN_RIGHT)<br>
>><br>
>> Please check the manual of r.mapcalc.  There is<br>
>><br>
>> --%<---<br>
>> THE NEIGHBORHOOD MODIFIER<br>
> ..<br>
>> --->%--<br>
><br>
>> which I think can be used to obtain what is asked.<br>
>> So, for each of the off-current pixel, the modifiers would be like<br>
><br>
>> RASTER_IN_PUSHED_ONE_ROW_UP:  map[-1,0]<br>
>> RASTER_IN_PUSHED_ONE_ROW_DOWN:  map[1,0]<br>
>> RASTER_IN_PUSHED_ONE_COLUMN_LEFT:  map[0,-1]<br>
>> RASTER_IN_PUSHED_ONE_COLUMN_RIGHT:  map[0,1]<br>
>><br>
>> I am not exactly sure about the implementation though.<br>
<br>
</div></div>r.mapcalc "RASTER_OUT=round(abs((RASTER_IN - RASTER_IN[0,-1]) + \<br>
                                                       (RASTER_IN -<br>
RASTER_IN[0,1]) + \<br>
                                                       (RASTER_IN -<br>
RASTER_IN[-1,0]) + \<br>
                                                       (RASTER_IN -<br>
RASTER_IN[1,0])))"<br>
<br>
Note that this is the same like round(abs(4 * RASTER_IN -<br>
(RASTER_IN[0,-1] + RASTER_IN[0,1] + RASTER_IN[-1,0] +<br>
RASTER_IN[1,0])))<br>
<br>
If you are interested in the sum of the absolute differences, you will<br>
need to use abs() for each difference.<br>
<div class="im"><br>
><br>
> @Yasser, if you implement this and think it is something that can be justified<br>
> as generically useful, why not ask @MarkusMetz if it is easy to include in<br>
> "r.neighbors" as yet another method?<br>
<br>
</div># prepare a weights file with the contents<br>
0 1 0<br>
1 0 1<br>
0 1 0<br>
<br>
r.neighbors in=raster_in out=raster_cardinalsum weight=weights method=sum<br>
<br>
r.mapcalc "RASTER_OUT = round(abs(4 * RASTER_IN - raster_cardinalsum))"<br>
<br>
HTH,<br>
<br>
Markus M<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Saludos,<div><br></div><div>Yasser</div>
</div>