Pruning (morphology)
   HOME

TheInfoList



OR:

The pruning algorithm is a technique used in
digital image processing Digital image processing is the use of a digital computer to process digital images through an algorithm. As a subcategory or field of digital signal processing, digital image processing has many advantages over analog image processing. It allo ...
based on
mathematical morphology Mathematical morphology (MM) is a theory and technique for the analysis and processing of geometrical structures, based on set theory, lattice theory, topology, and random functions. MM is most commonly applied to digital images, but it can be em ...
. It is used as a complement to the
skeleton A skeleton is the structural frame that supports the body of an animal. There are several types of skeletons, including the exoskeleton, which is the stable outer shell of an organism, the endoskeleton, which forms the support structure inside ...
and thinning algorithms to remove unwanted parasitic components (spurs). 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 Edge detection includes a variety of mathematical methods that aim at identifying edges, curves in a digital image at which the image brightness changes sharply or, more formally, has discontinuities. The same problem of finding discontinuitie ...
algorithms or
digitization DigitizationTech Target. (2011, April). Definition: digitization. ''WhatIs.com''. Retrieved December 15, 2021, from https://whatis.techtarget.com/definition/digitization is the process of converting information into a Digital data, digital (i ...
. Common uses for pruning include automatic recognition of hand-printed characters. Often inconsistency in letter writing creates unwanted spurs that need to be eliminated for better characterization.


Mathematical Definition

The standard pruning algorithm will remove all branches shorter than a given number of points. 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.


Structuring Elements

B_1 = \begin x & 0 & 0 \\ 1 & 1 & 0 \\ x & 0 & 0 \end B_2 = \begin x & 1 & x \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end B_3 = \begin 0 & 0 & x \\ 0 & 1 & 1 \\ 0 & 0 & x \end B_4 = \begin 0 & 0 & 0 \\ 0 & 1 & 0 \\ x & 1 & x \end B_5 = \begin 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end B_6 = \begin 0 & 0 & 1 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end B_7 = \begin 0 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end B_8 = \begin 0 & 0 & 0 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end The x in the arrays indicates a “don’t care” condition i.e. the image could have either a 1 or a 0 in the spot.


Step 1:

Thinning Thinning is a term used in agricultural sciences to mean the removal of some plants, or parts of plants, to make room for the growth of others. Selective removal of parts of a plant such as branches, buds, or roots is typically known as pruning. ...

Apply this step a given (n) times to eliminate any branch with (n) or less pixels. X_1 = A \otimes \


Step 2: Find End Points

Wherever the structuring elements are satisfied, the center of the 3x3 matrix is considered an endpoint. X_2 = \bigcup_^8 (X_1\circledast B^k)


Step 3:

Dilate Dilation (or dilatation) may refer to: Physiology or medicine * Cervical dilation, the widening of the cervix in childbirth, miscarriage etc. * Coronary dilation, or coronary reflex * Dilation and curettage, the opening of the cervix and surgic ...
End Points

Perform dilation using a 3x3 matrix (H) consisting of all 1's and only insert 1's where the original image (A) also had a 1. Perform this for each endpoint in all direction (n) times. X_3 = (X_2 \oplus H) \cap A


Step 4:

Union Union commonly refers to: * Trade union, an organization of workers * Union (set theory), in mathematics, a fundamental operation on sets Union may also refer to: Arts and entertainment Music * Union (band), an American rock group ** ''Un ...
of X1 & X3

Take the result from step 1 and union it with step 3 to achieve the final results. X_4 = X_1 \cup X_3


MATLAB MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation ...
Code

%% --------------- % Pruning % --------------- clear; clc; % Image read in img = imread('Pruning.tif'); b_img_skel = bwmorph (img, 'skel', 40); b_img_spur = bwmorph(b_img_skel, 'spur', Inf); figure('Name', 'Pruning'); subplot(1,2,1); imshow(b_img_skel); title(sprintf('Image Skeleton')); subplot(1,2,2); imshow(b_img_spur); title(sprintf('Skeleton Image Pruned'));


MATLAB MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation ...
Example

In the MATLAB example below, it takes the original image (below left) and skeletonize it 40 times then prunes the image to remove the spurs as per the MATLAB code above. As shown (below right) this removed the majority of all spurs resulting in a cleaner image.


See also

*
Morphological image processing Mathematical morphology (MM) is a theory and technique for the analysis and processing of geometrical structures, based on set theory, lattice theory, topology, and random functions. MM is most commonly applied to digital images, but it can be empl ...


External links


Morphological Pruning function
in
Mathematica Wolfram Mathematica is a software system with built-in libraries for several areas of technical computing that allow machine learning, statistics, symbolic computation, data manipulation, network analysis, time series analysis, NLP, optimizat ...

Morphological Operations
in
MATLAB MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation ...


References

{{DEFAULTSORT:Pruning (Morphology) Digital geometry Mathematical morphology