I am using OpenCV\'s cv::findContours function to extract contours in a binary image, in particular, I\'m extracting a hierarchy of contours (using the CV_RETR_CCOMP
I believe step 1 and 4 of the Appendix I ( in the [Suzuki85] paper you referenced, "Topological Structural Analysis of Digitized Binary Images by Border Following" ) cover your question per the below:
(1) Select one of the following:
(a) If f i, j = 1 and f i, j - 1 = 0, then decide that the pixel ( i, j ) is the border following starting point of an outer border, increment NBD, and ( i 1, j 1 ) + ( i, j - 1 ).
(b) ...
(2) Depending on the types of the newly found border and ...
(3) From the starting point ( i, j ), follow the detected border ...
(4) If f i, j != 1, then LNBD = | f i, j | and resume the raster scan from the pixel ( i, j + 1 ). The algorithm terminates when the scan reaches the lower right corner of the picture.