<div dir="ltr">Dear Glynn and Manning<div><br></div><div>Your tips solved my problem.</div><div><br></div><div>Many thanks for both.</div><div><br></div><div>Best wishes</div><div><br></div><div>miltinho<br><br><div class="gmail_quote">
2008/9/15 Glynn Clements <span dir="ltr"><<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d"><br>
Milton Cezar Ribeiro wrote:<br>
<br>
> I tryed your suggestion and notice that the F8 solution<br>
> simulate a dilatation of 1pixels on everyside of patches.<br>
> But, if I am not wrong, when I have a patch separated by<br>
> 2 pixels, the F8 solution will join these patches on only one.<br>
><br>
> But I can preserve the patches separated, and only<br>
> consider as one patches those pixels that can be joined<br>
> on the rule 8. I donīt know if I am so clear, but I would<br>
> like to request a little more time of you on this regard.<br>
><br>
> I run the folowwing commands:<br>
><br>
> r.mapcalc "F8 = (A*A[-1,-1]) * (A*A[-1,0]) * (A*A[1,-1]) * (A*A[0,-1]) * (A*A[0,1]) * (A*A[-1,1]) * (A*A[1,1])"<br>
> r.clump input=F8 output=F8_clump<br>
<br>
</div>The r.mapcalc command will perform "thinning". The result will be one<br>
if all nine cells (the centre and all eight surrounding cells) are<br>
one, and zero if any of the nine cells are zero).<br>
<br>
[Actually, you're missing A[1,0].]<br>
<br>
For "fattening", you should use e.g.:<br>
<br>
r.mapcalc "F8 = A[-1,-1] || A[-1,0] || A[-1,1] || A[0,-1] || A || A[0,1] || A[1,-1] || A[1,0] || A[1,1]"<br>
<br>
[For 0/1, multiplication is equivalent to the "&&" operator (logical<br>
conjunction).]<br>
<br>
Another option, which should only fill in the cells necessary to make<br>
r.clump recognise diagonal adjacency, is:<br>
<br>
r.mapcalc "AF = A || A[0,1] && A[1,0] || A[0,-1] && A[1,0] || A[0,1] && A[-1,0] || A[0,-1] && A[-1,0]"<br>
<br>
This will only set the centre cell if two diagonally-adjacent<br>
neighbours are both set.<br>
<br>
It may even suffice to use:<br>
<br>
r.mapcalc "AF = A || A[0,1] && A[1,0] || A[0,-1] && A[1,0]"<br>
<br>
This will only fill the cell on one side of a pair of diagonally<br>
adjacent cells.<br>
<font color="#888888"><br>
--<br>
Glynn Clements <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>><br>
</font></blockquote></div><br></div></div>