The basic idea of the algorithm is to select the pixels of a finger that have one or more pixels in their 8-connected neighborhood belonging to the background. A pixel pair, where one pixel belongs to the finger and another is from the background, is marked with the starting label. Subsequently, in a clockwise direction, the algorithm assigns a new label index to the border pixels until the starting label is no longer met