Chain Coding – Defining the Exterior Boundary
Chain coding defines the outer boundary using relative positions from a start point. The sequence of the exterior is stored where the endpoint finishes at the start point.
During the encoding, the direction is stored as an integer. However, in this example we use cardinal directions for simplicity. For example, the value 0 is north and 1 is east.
In the example, we start at position (5,2). From here we define the border using cardinal directions and number of movements. We move east 3 positions until we hit the edge. At this location, we move south 4 positions. This process continues until the end point hits the start point.
Note: Only for the purpose of this exercise, we used north, east, south and west as alphabetical values. When encoded, it is a numerical value.
This is basically a notation for recording list of edge points along a contour. It specifies contour direction at each edge in the list. Directions are quantized into one of the 8 directions. Starting at 1st edge in the list and going clockwise around the contour, the direction to the next edge is specified using one of the 8 chain codes. The direction is the chain code for the 8-neighbour of the edge.