This repository contains an unofficial python implementation of the Line Thinning by Line Following (LF) described in "Pattern Recogniion Letters" by Orit Baruch (1988).
Line Thinning by Line Following [PDF] How would we, humans, perform line thinning? The most natural way is by following the line with our eyes, and marking the approximate center between the line edges. Sesing the global picture enables us to ignore noise and identify easily line ends. Why not make the computer do the same thing?
- The line-follower is called to follow each encountered line.
- While following, the line follower erases the line in the input image and creates the skeleton in the target image.
-
The line following is based on two pointers and a dynamic window:
LP A pointer to follow the left edge of a line RP A pointer to follow the right edge of a line W A rectangular window whose sides are parallel to the sides of the matrix d The distance of a point to a line is measured as usual by the length (in pixels) of the normal from the point to that line
- When the follow identifies branching of the line, it calls itself recursively to follow each of the branches.
| single-branch (d=1) |
![]() |
| two-branch (d=1) |
![]() |
| multi-branch (d=1) |
![]() |
$ python thin.py --input ./data/no-branch.jpg -out output.jpg
This project is under the MIT License. See the LICENSE file for the full license text.





