Changes to Run-length encoding

TechWritereditor · 5 Dec 2026, 07:28 · “New page”

+ added − removed (first version)

Title

Removed:  
Added: Run-length encoding

Short description

Removed:  
Added: Simple lossless compression of repeated data

Type

Removed:  
Added: technology

Summary

Removed:  
Added: Run-length encoding is a simple lossless compression method that replaces a run of identical symbols with the symbol and a count. It works well on images with large areas of one colour, such as faxed documents, but poorly on photographs.

Fact box

Removed:  
Added: Type: Lossless data compression
Added: Principle: Store each run of repeated symbols as a count
Added: Suited to: Line drawings, scanned black-and-white documents, simple graphics
Added: Used in: Group 3 fax, Windows bitmaps (BI_RLE4, BI_RLE8), TIFF PackBits, JPEG

Article

Added: **Run-length encoding** (RLE) is a simple form of lossless data compression that replaces a long run of the same symbol with the symbol and the number of times it repeats.[^1] For example, the sequence "a B B B B B a a a" can be written as "a 1 B 5 a 3".[^1] Because nothing is thrown away, the original data can be recovered exactly.[^1]
 
Added: ## How it works
Added:  
Added: RLE exploits one kind of redundancy: long runs of repeated values.[^2] When the data has only two possible values, as in a string of bits, the symbol need not be stored at all; the encoder simply records the lengths of alternating runs of 0s and 1s.[^2] Practical schemes use counts of a fixed size, often 8 bits, and must deal with runs longer than the largest count, for example by inserting a run of length zero.[^2] The method gives good results for drawings and black-and-white scanned pages, but little or no saving for data without repeated symbols, such as photographs, where shading changes from pixel to pixel.[^1]
Added:  
Added: ## Applications
Added:  
Added: [[Fax]] machines were a natural fit: long stretches of white or black pixels on a page are sent as counts rather than pixel by pixel.[^1] The Group 3 fax standard combines run lengths with [[Huffman coding]], assigning a code word to each run of all-white or all-black pixels.[^4] Run-length coding is also listed among the techniques used in [[JPEG]].[^2]
Added:  
Added: In [[Microsoft Windows]], bitmaps can be stored with RLE using the BI_RLE8 and BI_RLE4 formats, for 8 and 4 bits per pixel. In "encoded mode" a pair of bytes gives a pixel count and a colour index, while an "absolute mode" stores runs of differing pixels directly.[^3] The TIFF 6.0 image format, published by Aldus in 1992, adopted Apple's PackBits scheme from the [[Macintosh]] as its simple byte-oriented run-length option, noting that in the worst case it adds at most one byte for every 128 input bytes.[^4]
Added:  
Added: ## See also
Added: - [[Huffman coding]]
Added: - [[JPEG]]
Added: - [[GIF]]
Added: - [[Fax]]

Sources

Removed:  
Added: Information and Entropy, Chapter 3: Compression | https://www.ocw.mit.edu/courses/6-050j-information-and-entropy-spring-2008/9f67d1d414e446c9b55925ab92c17c15_MIT6_050JS08_chapter3.pdf | MIT OpenCourseWare | 2008
Added: Data Compression (COS 226 lecture) | https://www.cs.princeton.edu/courses/archive/fall19/cos226/lectures/55DataCompression.pdf | Princeton University | 2019
Added: Bitmap Compression | https://learn.microsoft.com/en-us/windows/win32/gdi/bitmap-compression | Microsoft
Added: TIFF Revision 6.0 | https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf | Aldus Corporation (hosted by ITU) | 1992-06-03

Categories

Removed:  
Added: Data compression
Added: Algorithms

Other names

Removed:  
Added: RLE
Added: Run-length coding