Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV - Can someone explain me in detail the findContours algorithm?

I am working with OpenCV and I am using the findContours function to detect the contours in an image. Because I wanted to learn more about the algorithm that this function uses, I downloaded the relevant research paper which is used by the software engineers of OpenCV for this. It is the following one: http://download.xuebalib.com/xuebalib.com.17233.pdf

I think that I understand in page 35 the marking policy which is the following:

(a) If the current following border is between the 0-component which contains the pixel (p, q + 1) and the 1-component which contains the pixel (p, q), change the value of the pixel (p, q) to -NBD.

(b) Otherwise, set the value of the pixel (p, q) to NBD unless (p, q) is on an already followed border.

But then I cannot understand in the example at page 37:

C:\fakepath\Paper.png

why at (a)-(b) the left ones (1) become twos (2) while the right ones (1) become minus twos (-2). In the same way, I cannot understand why at (b)-(c) the central ones (1) do not become minus threes (-3) but threes (3).

Can someone explain me this?