Posted by
Gabriel Landini on
May 14, 2009; 10:00pm
URL: http://imagej.273.s1.nabble.com/Convert-a-set-of-points-into-an-ROI-tp3692520p3692522.html
On Thursday 14 May 2009 20:19:34 Ghislain Bonamy wrote:
> One quick question. I assume that because I return a polygon, points that
> lay on the line are not required? For Instance:
>
> 10000001
> 10000001
> 01111111
> 00000000
>
> Can be represented as:
>
> X;Y
> 0;0
> 0;1
> 1;2
> 7;2 <- Here I spiked 2;2 3;2, etc.
> 7;0 <- Here I skip 7;1
It depends, if you are counting 8 connected the chain code should be (going
clockwise):
X;Y
0;0
0;1
1;2 (now do the RLE, if you want)
6;2 (the next one is diagonally up)
7;1
7;0 (now you can jump down)
7;2 (and another RLE)
1;2
0;1
0;0 (you arrived to the start again)
If you are checking neighbours anti-clockwise:
X;Y
0;0
0;1
1;2 (now do the RLE, if you want)
7;2
7;0
7;1
6;2
1;2
0;1
0;0 (you arrived to the start again)
Think of this object
> 10000001
> 10001001
> 01111111
> 00000000
If you are checking anti clockwise, and stop at 7;0 you would have missed 4;1.
I think you'll have to assume that they are all closed contours and some of
these will have near 0-thickness.
That is why I still suggest that you implement a tested algorithm. You can
take a look at the code in particles8 plugin to get an idea of the order in
which one needs to do the checking.
Cheers
G.