next up previous
Next: A Skeletonization Algorithm Up: morphology Previous: Morphology

A Thinning Algorithm

Purpose: Convert binary shapes obtained from edge/boundary detection or thresholding to 1-pixel wide lines. For example, the thresholded version of hand written or printed alphanumerics can be thinned for better represetation and further processing.

Method: iteratively delete pixels inside the shape to shrink it without shortening it or breaking it apart.

Some Definitions: To decide whether an edge pixel $P_1$ should be deleted, consider its 8 neighbors in the 3 by 3 neighborhood, $P_2$, $P_3$, $P_4$, $P_5$, $P_6$, $P_7$, $P_8$ and $P_9$, and define:

The Algorithm: This is a 2-pass process:

A problem: When part of the shape is only 2-pixel wide, all pixels are boundary points and will be marked and then deleted. We want to delete only one side at a time.

The Solution: A two-step process:

thinning.gif

Modified Algorithm: Repeat until no more change can be made:

Let $A_i$ represent the event ``$P_i=0$''. Then $[P_2\cdot P_4\cdot P_6=0]\;\wedge\;[P_4\cdot P_6\cdot P_8=0]$ above can be represented by:

\begin{displaymath}(A_2\vee(A_4\vee A_6))\wedge((A_4\vee A_6)\vee A_8)
=A_4\vee A_6\vee(A_2\wedge A_8)\end{displaymath}

i.e.,

\begin{displaymath}(P_4=0) \vee (P_6=0) \vee (P_2=P_8=0) \end{displaymath}

This is either an E edge ($P_4=0$), an S edge ($P_6=0$), an NW edge ($P_2=P_8=0$), an NE edge ($P_4=P_2=0$), or an SW edge ($P_6=P_8=0$). However, the additional condition $P_7\ne 0$ excludes an SW edge.

Similarly, we see hat edges on N, W, SW, or SE side will be deleted in the second pass.


next up previous
Next: A Skeletonization Algorithm Up: morphology Previous: Morphology
Ruye Wang 2011-11-09