Understanding the algorithm behind findContours from OpenCV based on the paper "Topological structural analysis of digitized binary images by border following."