A chain code is a lossless compression algorithm for monochrome images. The basic principle of chain codes is to separately encode each connected component, or "blob", in the image.

For each such region, a point on the boundary is selected and its coordinates are transmitted. The encoder then moves along the boundary of the region and, at each step, transmits a symbol representing the direction of this movement.

This continues until the encoder returns to the starting position, at which point the blob has been completely described, and encoding continues with the next blob in the image.

This encoding method is particularly effective for images consisting of a reasonably small number of large connected components.


Some popular chain codes include:

In particular, FCCE, VCC, 3OT and DFCCE can be transformed from one to another [12]

Abstract Cell Coordinate Oriented Crack Code
Abstract Cell Coordinate Oriented Crack Code

A related blob encoding method is crack code.[13] Algorithms exist to convert between chain code, crack code, and run-length encoding.

A new trend of chain codes involve the utilization of biological behaviors. This started by the work of Mouring et al. [6] who developed an algorithm that takes advantage of the pheromone of ants to track image information. An ant releases a pheromone when they find a piece of food. Other ants use the pheromone to track the food. In their algorithm, an image is transferred into a virtual environment that consists of food and paths according to the distribution of the pixels in the original image. Then, ants are distributed and their job is to move around while releasing pheromone when they encounter food items. This helps other ants identify information, and therefore, encode information.

In use

Recently, the combination of move-to-front transform and adaptive run-length encoding accomplished efficient compression of the popular chain codes.[14] Chain codes also can be used to obtain high levels of compression for image documents, outperforming standards such as DjVu and JBIG2. [11] [10] [9] [8] [7] [6] [15]

See also


  1. ^ H. Freeman. On the encoding of arbitrary geometric configurations, IRE Transactions on Electronic Computers EC- 10(1961) 260-268.
  2. ^ Y.K. Liu, B.Zalik, An efficient chain code with Huffman coding, Pattern Recognition 38 (4) (2005) 553-557.
  3. ^ E. Bribiesca, A new chain code, Pattern Recognition 32 (1999) 235–251.
  4. ^ H. Sánchez-Cruz, R. M. Rodríguez-Dagnino. Compressing bi-level images by means of a 3-bit chain code. Optical Engineering. SPIE. 44 (9) 097004 (2005) 1-8.
  5. ^ B. Žalik, D. Mongus, Y.-K. Liu, N. Lukač, Unsigned Manhattan Chain Code, Journal of Visual Communication and Image Representation 38 (2016) 186-194.
  6. ^ a b c Mouring, M., Dhou, K. & Hadzikadic, M. (2018). A Novel Algorithm for Bi-Level Image Coding and Lossless Compression based on Virtual Ant Colonies, in ‘3rd International Conference on Complexity, Future Information Systems and Risk’, Setubal - Portugal, pp. 72-78.
  7. ^ a b Dhou, K. (2020). ‘A new chain coding mechanism for compression stimulated by a virtual environment of a predator-prey ecosystem’, Future Generation Computer Systems 102, 650-669
  8. ^ a b Dhou, K. (2018). A novel agent-based modeling approach for image coding and lossless compression based on the wolf-sheep predation model, in ‘Computational Science - ICCS 2018’, Springer International Publishing, Cham, pp. 117-128.
  9. ^ a b Dhou, K. & Cruzen, C. (2021). ‘A highly efficient chain code for compression using an agent-based modeling simulation of territories in biological beavers’, Future Generation Computer Systems, 118, 1-13.
  10. ^ a b Dhou, K., & Cruzen, C. (2019). An innovative chain coding technique for compression based on the concept of biological reproduction: an agent-based modeling approach. IEEE Internet of Things Journal, 6(6), 9308-9315
  11. ^ a b Dhou, K. (2019). ‘An innovative design of a hybrid chain coding algorithm for bi-level image compression using an agent-based modeling approach’, Applied Soft Computing 79, 94-110.
  12. ^ H, Sánchez-Cruz; H. H. López-Valdéz (2014). "Equivalence of chain codes". Electronic Imaging. 23 (1): 013031. Bibcode:2014JEI....23a3031S. doi:10.1117/1.JEI.23.1.013031.
  13. ^ A. Rosenfeld, A. C. Kak. Digital Picture Processing, 2nd edition (1982). Page 220. Academic Press, Inc. Orlando, FL, USA.
  14. ^ Žalik, Borut; Lukač Niko (2013). "Chain code lossless compression using move-to-front transform and adaptive run-length encoding". Signal Processing: Image Communication. 29: 96–106. doi:10.1016/j.image.2013.09.002.
  15. ^ M, Rodríguez-Díaz; H. Sánchez-Cruz (2014). "Refined fixed double pass binary object classification for document image compression". Digital Signal Processing. 30: 114–130. doi:10.1016/j.dsp.2014.03.007.