The pruning algorithm is a technique used in digital image processing based on mathematical morphology. It is used as a complement to the skeleton and thinning algorithms to remove unwanted parasitic components. In this case 'parasitic' components refer to branches of a line which are not key to the overall shape of the line and should be removed. These components can often be created by edge detection algorithms or digitisation.
The standard pruning algorithm will remove all branches shorter than a given number of points. The algorithm starts at the end points and recursively removes a given number (n) of points from each branch. After this step it will apply dilation on the new end points with a (2N+1)(2N+1) structuring element of 1’s and will intersect the result with the original image. If a parasitic branch is shorter than four points and we run the algorithm with n = 4 the branch will be removed. The second step ensures that the main trunks of each line are not shortened by the procedure.