Image to Use:

This shows a degenerate case for the naive 4 connectivity border tracking algorithm that merely stops when it encounters the first pixel a second time. The other example for when 4 connectivity or 8 connectivity can fail is if one starts at a different first pixel value.

To preserve holes within regions one could keep track of when the color changes in magnitude and determine whether or not one is inside of the border or outside of the border. Thus maintaining the hole.

Image to use for region labeling

This code labels the regions based on 4 connectivity. There are 11 entries in the equivalence table to map each region to another.


<< Back to other examples