What is the chain code?

In computer graphics and image processing, the chain code is an algorithm used to encode the outline of the object in black and white or monochrome image. The resulting sequence of codes can either describe how to draw the outline of the object in view of the image in which it is located, or it can be a collection of directions due to the location of the outline where the algorithm began, and basically to provide steps that can be monitored to redraw the object. These codes can be normalized according to the formula and then compared to another string code to determine whether two objects are identical. The string code can be used to insulate objects in computer vision program or image segmentation in image processing, although it can be used more often in optical character recognition programs (OCR).

Although there are several established algorithms for the chain code, the basic concept is the same in each. First, the edge of the object is located, usually by moving a pixel using a pixuel via a raster image. Once placed, the position is recordedand the surrounding edges are detected. Depending on whether the detection algorithm moves clockwise or counterclockwise, the current location moves in one or the other along the edge until it returns to its original position.

Every time the current position moves, the number is recorded in the chain code. This number generally indicates a direction that has been moved along the edge of the object. For example, if the algorithm of the code string monitors the straight edge from the right to the left, then every time the edge is traced to the left, the numeric code to the left is added to the end of the code. The resulting code is a string of numbers in which, if the sequence is monitored from any starting point and pixels located in each step, the outline of the object would be redrawn.

Once the UP code chain is completed, it can be used for several different algorithms to compare with other sequences of the code string. First, the number is normalized by turning the initial number until the lowest integer value is determined. In this way, two objects that have the same outline can be compared, no matter where the coding has started on each object.

There are other, more complex versions of the code algorithm. These include vector coding, in which the outline of the object is described by the sequence of coordinates that are linked to the lines, although this method may be a loss when used on finely detailed outlines. The algorithm version also exists, which uses the running length (RLE) to further compress codes for exceptionally large or complex objects to be stored in a more efficient way.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?