Chain code in dip

2,891 views 12 slides May 14, 2020
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

Explanation of Chain Code in Digital Image Processing


Slide Content

Chain Code in DIP Rishav Bhurtel 19MTRDS008

Chain code is a lossless compression technique used for representing an object in images. The co-ordinates of any continuous boundary of an object can be represented as a string of numbers where each number represents a particular direction in which the next point on the connected line is present. 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. What is Chain Code?

The chain code direction convention is given below:

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.

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.

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.

First Difference is: 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.

Chain-code example. a) coding the 8 directions; b) initial point and edge following  For 8-Chain code the process is same as 4 but we will have extra directions for diagonal pixels.

Thank you!