User:晚饭4000

Crack Code is a variation of Chain code  to encode greyscale images with lossless compression. As with a Chain code  the algorithm selects a boundary point and follows the object in a clockwise manner. However rather than encoding the boundary pixels of the object in eight directions, Crack Code encodes the crack between the boundary pixels and background in four directions. The resulting codes can be used to encode curves parametrically.

== Algorithm ==

Steps:
 * Assume that a pixel with value 1 belongs to an object whereas a pixel with the value 0 is part of the background.
 * Find a black pixel X belonging to the object with a neighbouring white pixel Y in either the north, west, south or east direction.
 * The initial direction is set by the relative positions of X and Y. Depending on the relative positions of X and Y check one of four patterns. From the crack between X and Y take X to be facing left and add in two pixels F and G to complete the square facing forwards shown below.


 * The algorithm follows the crack along the edge of the object until it returns to the start point whereupon it locates the next object and starts again. 								     *The next direction is determined by the values of X Y F and G according to the Crack Code Derivative Table . To code this use a modulo 4 counter.



An example Crack Code is given here Illustrated Dictionary Of Computer Vision

Further Details

 * Crack Code can be used in Fourier Transforms if they are first computed into fourier transforms given on page 568 of Computer Vision and Information Technology: Advances and Applications


 * They are more complicated to compute but more accurate than Chain Codes