0
24kviews
Short note on Chain Codes. Also explain Circular Chain Codes and Shape Number
1 Answer
1
3.6kviews

Chain codes are used to represent the binary by a connected sequence of straight –line segments. This represented is based on 4-connectivity and 8-connectivity of the segments.

The chain code works best with binary images and is a concise way of representing a shape contour. The chain code direction convention is given below:

enter image description here

As an edge is traced from its beginning point to the end point the direction that must be taken to move from one pixel to the next is given by the number represented in either the 4-chain code or the 8-chain code.

As an edge can be completely described in terms of its starting coordinate and its sequence of chain codes descriptors. Of the two chain codes, the 4-chain is easier requiring only four different code values.

For e.g.: Given an image, for 4-chain code for the same.

enter image description here

Figure 20

Let us take a starting point which is arbitrary chosen (p). From this point on, the cursor follows the contour, usually in the clockwise direction. For every pixel the direction is noted.

enter image description here

Figure 21 The 4-chain code is given edge is

0 0 3 0 3 3 2 2 2 1 1 1

  • Hence instead of storing the coordinates of each pixel, we can store the chain code and starting coordinates. Remember 8-connectivity is closer to the human eye than 4-connectivity.
  • The chain code allows an edge to be described using vertical, horizontal as well as diagonal descriptors at 45 0 , 135 0 , 225 0 and 315 0 .
  • The problem with above chain code is, if we change starting point we will get different chain code, even if the object is same.
  • Therefore the chain code is normalized with respect to the starting point.
  • We treat the chain code as a circular sequence of numbers and redefine the starting point so that the resulting sequence of numbers, forms an integer of minimum magnitude.
  • Circular codes can be also normalized for rotation by taking the first difference of chain code.
  • For example: The 4-chain code is given edge is

    0 0 3 0 3 3 2 2 2 1 1 1

    First difference is

    enter image description here

    Circular difference = last – first = 0 – 0 = 0

Therefore circular chain code =

0 0 0 3 0 3 3 2 2 2 1 1 1

  • Shape Number: Shape no of a boundary obtained from a chain code is defined as the smallest magnitude of the circular first difference.
Please log in to add an answer.