Problem of a chain code:
a chain code sequence depends on a starting point.
Solution: treat a chain code as a circular sequence and redefine the starting point so that the resulting sequence of numbers forms an integer of minimum magnitude.
The first difference of a chain code: counting the number of direction change (in counterclockwise) between 2 adjacent elements of the code.