Fact-checked by Grok 2 weeks ago

Run-length encoding

Run-length encoding (RLE) is a lossless that reduces the size of by replacing consecutive sequences of identical symbols, known as runs, with a single representation consisting of the run's length (count) and the symbol's value. This method is particularly effective for exhibiting long runs of repetition, such as in text files with repeated characters, binary images, or quantized coefficients in image formats. It operates by scanning the input stream to identify these runs and encoding them in a compact form, often using escape sequences to distinguish counts from the actual symbols, ensuring the original can be perfectly reconstructed during decoding. Popularized by in the mid-, RLE has roots in early efforts to compact data for efficient storage and transmission in and . It gained prominence in standards like () transmission, where it efficiently compresses black-and-white images with large uniform areas, and in the image format, where it is applied to runs of zero-valued (DCT) coefficients before further with Huffman or arithmetic methods. Additional applications include space data missions since the late , sequence storage due to repetitive genomic patterns, and column-store databases for attribute value . While RLE's simplicity makes it computationally inexpensive and suitable for real-time processing, its effectiveness diminishes or even increases size for inputs with short or irregular runs, necessitating hybrid approaches with other like dictionary-based or for broader applicability. Despite these limitations, RLE remains a foundational in compression, influencing modern algorithms in graphics hardware, FPGA configurations, and secure data protection schemes.

Fundamentals

Definition and Principles

Run-length encoding (RLE) is a form of lossless compression that replaces sequences of identical elements, known as runs, with a single representation of the value followed by the of its occurrences. This technique ensures that the original can be perfectly reconstructed without any loss of information, making it suitable for applications requiring exact . By encoding runs in this manner, RLE exploits the redundancy inherent in repetitive structures, thereby reducing the overall or transmission size compared to the uncompressed form. The core principle of RLE involves sequentially scanning the input to detect consecutive identical , then grouping each such run into a pair consisting of the value and its . For with long runs of repeated —such as images featuring extended areas of the same color or text strings with frequent repetitions—RLE achieves significant by minimizing the number of entries needed to describe the sequence. Non-repeating elements are handled as runs of 1, ensuring all input is covered without special cases disrupting the encoding flow. Counts are commonly limited to a range of 1 to 255 to fit within a single byte, with longer runs divided into multiple segments to adhere to this constraint. RLE variants differ in their formatting approaches, notably between packed and unpacked schemes. In unpacked RLE, each run is represented by a straightforward pair of the and , often without further optimization, allowing decoding but potentially less efficient storage for short runs. Packed RLE, by contrast, employs more compact representations, such as fixed-size counts integrated with variable-length coding (e.g., Huffman codes for run lengths in standards like T.4), which enhances for typical data distributions where short runs predominate. RLE techniques of this nature were first applied in for processing analog television signals.

Mathematical Foundations

Run-length encoding (RLE) is particularly effective for data exhibiting low , characterized by long sequences of identical , as it replaces these runs with a compact representation of the value and its count, thereby reducing redundancy without loss of information. In terms, the entropy H of a source measures the average per , given by H = -\sum p_i \log_2 p_i, where p_i is the probability of each ; RLE exploits sources where the probability of is high, leading to clustered symbol distributions and lower effective entropy after encoding. For instance, in run-compressed domains, entropy can be computed directly from transition probabilities between runs, such as E(t) = E^+(t) + E^-(t), where E^+(t) and E^-(t) quantify entropies for transitions from 0 to 1 and 1 to 0, respectively, using the proportion of non-zero runs per row. This approach allows RLE to achieve ratios approaching the theoretical entropy bound for low-entropy inputs like images or sparse data. The (CR) for RLE is formally defined as CR = \frac{\text{original size}}{\text{encoded size}}, where the encoded size is the number of runs multiplied by the combined of each and its corresponding , i.e., \text{encoded size} = R \times (V + C), with R as the number of runs, V as the bit of each , and C as the bit of each . This yields a compression of \left( \frac{T - (S \times E)}{T} \right) \times 100\%, where T is the total original bits, S is the number of symbols, and E is the per symbol, providing a quantitative measure of relative to theoretical limits. For a single run of length L consisting of identical values V, the space savings is calculated as L \times V - (C + V) bits; positive savings occur when L > 1 + \frac{C}{V}, such as L > 2 assuming 1-byte values and counts, highlighting RLE's breakeven point for repetitive data. RLE's theoretical suitability stems from data where run lengths follow a geometric probability distribution, modeling the probability of continuation as constant, with P(\text{run length} = k) = (1-p)^{k-1} p for k = 1, 2, \dots, where p is the probability of termination (e.g., symbol change), yielding an expected run length of $1/p. Seminal analysis posits that pictures or sequences can be represented as a Markov process, where run lengths are geometrically distributed, enabling derivation of the expected factor as a of P(\text{run length} \geq k) = (1-p)^{k-1}, which decreases exponentially for small p, favoring long runs and high compression. This model underpins RLE's efficiency for sources like scanned documents, where transition probabilities align with geometric assumptions. In edge cases, RLE can lead to expansion rather than ; for alternating (e.g., ABAB...), every symbol forms a run of length 1, resulting in R = N runs for N original symbols, and encoded size $2N \times \max(V, C) assuming equal sizing, effectively doubling the size in the worst case and underscoring RLE's dependency on run-length statistics. This expansion is bounded by the overhead of encoding runs, contrasting with its benefits for clustered .

History and Development

Origins

Run-length encoding originated in the mid-20th century as a straightforward technique for compressing repetitive sequences, with its earliest documented applications in the of signals to address limitations. In 1967, engineers A. H. Robinson and C. Cherry developed a system at the forefront of this , applying run-length encoding to compress and half-tone signals for efficient . Their approach targeted repetitive patterns in video , such as test signals, by replacing sequences of identical values with a single value and its count, thereby reducing the required without loss of . This initial implementation arose from the need to handle the high redundancy in early analog video feeds, where long runs of uniform intensities were common, enabling more effective use of communication channels in resource-constrained environments. The method was not patented at the time, facilitating its dissemination through academic publications and reports, which encouraged widespread experimentation and refinement. to modern run-length encoding can be found in 19th-century practices, where operators used abbreviated encodings for repeated symbols or signals to expedite message transmission over long distances, laying conceptual groundwork for later techniques.

Key Milestones and Adoption

In the early , run-length encoding saw significant activity, with filing a in 1983 for its application in , later corresponding to 4,586,027 granted in 1986 for a method and system of data compression and restoration using RLE techniques. This highlighted RLE's utility in reducing in data, marking a key step in its commercial formalization for processing. Adoption accelerated in the through integration into prominent formats. Truevision introduced the () format in 1984, which incorporated RLE compression to support efficient storage of high-color raster images on its . Similarly, employed an RLE-based format for black-and-white online transmission starting around 1985, enabling compact delivery of 256x192 pixel images over early dial-up networks before transitioning to the LZW-based in 1987. These implementations demonstrated RLE's practicality for in and early environments. Standardization efforts further propelled RLE's integration during the decade. The ITU-T Recommendation T.4, established in 1980 for Group 3 facsimile terminals, utilized Modified Huffman coding—a run-length based scheme—to encode horizontal black and white runs efficiently for document transmission. This was extended in 1984 with T.6 for Group 4 facsimile, introducing two-dimensional run-length coding (MMR) to enhance compression ratios for error-free lines. In 1988, the TIFF Revision 5.0 specification adopted PackBits, an adaptive RLE variant originally from Apple's MacPaint, as compression tag 32773 for byte-oriented raster data interchange. By the 1990s, RLE expanded into multimedia systems, notably through the Amiga's ILBM format within the (IFF) standard, which used pack bits RLE for compressing interleaved bitplane images in video and applications. Concurrently, open-source implementations proliferated, with RLE routines appearing in early graphics libraries like those in the GNU Image Manipulation Program () precursors and Unix-based tools, facilitating broader accessibility in .

Applications

In Compression and Storage

Run-length encoding (RLE) serves as a foundational technique in lossless data compression, particularly effective for datasets exhibiting repetitive patterns, such as text files with repeated characters or sequences, where it replaces consecutive identical elements with a single instance and a count to reduce storage requirements. In database systems employing columnar storage, RLE is widely applied to compress columns with long runs of identical values, such as timestamps or categorical data in analytical workloads, enabling significant space savings without data loss. For instance, in formats like Apache Parquet, RLE encodes sequential repetitions efficiently, making it suitable for processing large-scale structured data like CSV files containing identical rows from batch imports or monitoring outputs. RLE also finds utility in compressing log files, where entries often feature repeated timestamps, status codes, or error messages, allowing for compact representation in storage systems optimized for time-series data. Specialized tools, such as the RLE toolkit developed for Unix environments, provide command-line utilities for applying RLE to raster image files, facilitating its integration into workflows for archiving and data processing on resource-constrained systems. In archive formats, RLE acts as a simple fallback mechanism in certain implementations, particularly for data with predictable repetitions, though it is often combined with other methods for broader applicability. In embedded systems and (IoT) applications, RLE enhances storage efficiency for sensor data streams that include prolonged constant readings, such as temperature logs from environmental monitors, by minimizing transmission overhead and on-device usage. This approach is especially valuable in low-power devices, where RLE's simplicity allows for quick encoding and decoding without heavy computational demands. Furthermore, RLE functions as a building block in hybrid compression schemes, preprocessing data to create longer runs before applying advanced algorithms like dictionary encoding, thereby improving overall ratios in systems handling mixed repetitive and sparse content. Its adoption in standards for data interchange underscored its reliability in early storage solutions.

In Imaging and Graphics

Run-length encoding (RLE) plays a significant role in compression for with repetitive patterns, such as icons, cartoons, and images, where long sequences of identical colors are common. Developed in the , the format, introduced by ZSoft in 1985, employs a byte-oriented RLE scheme to compress image data efficiently, making it ideal for low-resolution displays and early like 16-color EGA or 256-color VGA modes used in games and illustrations. This approach reduces file sizes by encoding consecutive pixels of the same value as a single byte pair (count and value), particularly effective for sparse or uniform content prevalent in that era. In facsimile transmission and scanned documents, RLE variants enhance efficiency for images. The Modified Huffman (MH) coding, standardized in Recommendation T.4 for Group 3 machines, is a one-dimensional RLE method that encodes runs of white and black pixels using variable-length Huffman codes from predefined tables, assigning shorter codes to frequent run lengths like 0-63 pixels. This enables reliable transmission over telephone lines at speeds up to 14.4 kbit/s, with MH ensuring compatibility across Group 3 devices for document archiving and sharing. Contemporary formats retain RLE principles indirectly through preprocessing that exploits pixel runs. In the Portable Network Graphics (PNG) format, per-scanline filtering (e.g., , Up, , or Paeth methods) transforms raw pixel data into differences from predicted values, often producing long runs of zeros or similar bytes that the subsequent compressor (LZ77 + Huffman) handles akin to RLE, improving ratios for images with horizontal or vertical continuity. Similarly, the Tagged Image File Format (TIFF) 6.0 specification includes PackBits, an adaptive RLE algorithm that encodes both runs and literals, standardized for versatile raster storage in professional imaging workflows. RLE's strengths shine in low-color-depth graphics, such as sprites and elements, where limited palettes (e.g., 8-256 colors) yield extensive uniform regions. By collapsing these into compact counts, RLE minimizes storage and needs without , outperforming general-purpose compressors on synthetic or vector-derived visuals like logos and icons, though it falters on high-detail photographs.

Algorithm

Encoding Process

The encoding process in run-length encoding (RLE) involves traversing the input data sequentially to identify and compress sequences of identical symbols, known as runs, by replacing each run with a pair consisting of the run length (count) and the symbol value. This technique is particularly effective for data with long repetitive sequences, such as images or textual patterns. processes the input from left to right, maintaining a current count of consecutive identical symbols, and outputs the compressed representation only when a run ends or the input is exhausted. The procedure begins by initializing variables for the current symbol value and its count, typically set to the first element of the input with a count of 1. For each subsequent element in the input, the algorithm compares it to the current symbol: if it matches, the count is incremented; if it differs, the current (count, value) pair is outputted to the encoded stream, and the variables are reset to the new symbol with a count of 1. At the end of the input, the final (count, value) pair is outputted. This sequential traversal ensures that runs are detected by direct adjacency comparisons without requiring look-ahead buffering. Pseudocode for the core encoding loop can be outlined as follows:
[function](/page/Function) encode(input):
    if input is empty:
        return empty output
    output = []
    current_value = input[0]
    current_count = 1
    for i from 1 to length(input) - 1:
        if input[i] == current_value:
            current_count += 1
        else:
            append (current_count, current_value) to output
            current_value = input[i]
            current_count = 1
    append (current_count, current_value) to output
    return output
This pseudocode assumes a simple list-based output of pairs and handles the traversal without specifying storage formats. Edge cases are managed explicitly to ensure completeness. For single-element runs, a count of 1 is outputted directly, preventing omission of unique symbols. When the input ends mid-run, the final pair is appended without further comparison. If the symbol value could conflict with the count delimiter (e.g., in formats where counts use specific markers), escaping mechanisms are applied, such as prefixing the value with a special escape byte if it matches the delimiter. Format variations in output representation adapt to data types and constraints. In byte-packed formats, each count is stored in a fixed number of bytes (e.g., one byte for counts up to 255), followed by the byte, suitable for general-purpose . For , bit-packed formats use fewer bits per pair, such as 3 bits for counts (up to 7) and 1 bit for the (0 or 1), optimizing in monochrome images. These choices depend on the maximum expected run length and alphabet size, with the algorithm core remaining unchanged.

Decoding Process

The decoding process in run-length encoding (RLE) reverses the by reconstructing the original from the encoded stream, which consists of pairs indicating a count followed by a value to be repeated that many times. This procedure reads the encoded data sequentially, interpreting each pair and expanding it into the repeated values until the entire stream is processed, thereby restoring the uncompressed data without loss. The fundamental steps involve initializing an empty output buffer, then iteratively reading a count (typically an representing the run ) and the corresponding (such as a , byte, or ) from the input . For each pair, the is appended to the output buffer exactly 'count' times. This continues until the end of the input is reached, at which point the output buffer holds the fully decoded data. In the basic unpacked format, counts and values are stored as fixed- or variable- fields without additional flags, allowing straightforward pair extraction. To illustrate the algorithm abstractly, the following outlines the core loop for basic RLE decoding:
initialize empty result sequence
while not end of input stream:
    read count from input
    read value from input
    append value repeated 'count' times to result
return result
This loop assumes the input format from encoding, where counts and values are distinctly separable, and processes all pairs until exhaustion. Error handling is essential to ensure robustness, particularly in preventing buffer overflows from invalid counts exceeding available space or original data length. Decoders typically validate each count to confirm it is positive and within bounds before expansion, discarding or flagging malformed inputs if counts are zero, negative, or excessively large. Additionally, detection of the end-of-stream or end-of-scan-line markers is critical to halt processing gracefully, avoiding cross-coding where runs span unintended boundaries in formats like files. For instance, in packed RLE variants, input validation may include checking for even-length arrays or proper flag bytes to reject invalid streams early. Format-specific decoding adapts the basic process to handle optimizations in the encoded structure. For example, in the format's RLE compression (BI_RLE8), the data consists of escape sequences: a byte pair where the first byte is the count—if 1 to 255, repeat the second byte (value) that many times; if 0, it is an escape followed by a second byte indicating the action (e.g., 0 for end of line, 1 for end of bitmap, 2 for delta with x/y offsets, or 3 to 255 for literal mode with that many color index bytes copied directly, padded to even length). In TIFF's PackBits compression, a code byte determines the operation: if 0 to 127, copy the next (code + 1) bytes literally; if 129 to 255, repeat the next byte (257 - code) times; 128 is a no-operation. This allows efficient handling of both repetitive and non-repetitive data. Conversely, unpacked RLE employs variable-length encoding for counts (e.g., multi-byte integers), requiring the decoder to parse lengths dynamically—such as accumulating digits until a non-numeric value—before repeating the value. These variants maintain the core expansion logic but incorporate flag interpretation or length parsing to navigate the stream accurately.

Performance and Analysis

Efficiency Measures

Run-length encoding (RLE) exhibits linear for both the encoding and decoding processes. The encoding traverses the input sequence in a single pass, incrementing a counter for each consecutive identical element until a change occurs, resulting in time complexity, where n is the size of the input data. Similarly, decoding involves a single pass over the encoded representation, expanding each run by repeating the value the specified number of times, also achieving time complexity. The of RLE is O(1) in terms of auxiliary space, as the algorithm requires only a constant number of variables (e.g., for the current value, count, and temporary storage) regardless of input size, enabling streaming implementations without additional data structures. However, the output space can reach O(n) in the worst case, particularly when the input has no runs and the encoded form expands the data. Compression ratios for RLE vary significantly based on data characteristics, typically achieving 2-5x (i.e., reducing size to 20-50% of original) for run-heavy datasets like those with long sequences of identical values. For instance, an all-identical file of length n compresses to a single value plus a , yielding substantial savings depending on the size used to encode the . In contrast, random or alternating data leads to expansion, with a as low as 0.5 (doubling the size), as seen in sequences like "abababab" where each single-element run requires separate encoding. The Big-O analysis of run detection and repetition loops underscores RLE's efficiency: run detection occurs in amortized O(1) time per element via simple equality checks in a loop, while repetition counting is a constant-time increment until a mismatch, collectively yielding the overall O(n) traversal without nested operations.

Advantages and Limitations

Run-length encoding (RLE) is prized for its simplicity, making it one of the easiest compression algorithms to implement with minimal code and computational overhead. This straightforward approach, which involves scanning data sequentially and replacing runs of identical values with a count-value pair, requires no complex data structures or preprocessing, enabling rapid deployment in resource-constrained environments. A key strength lies in its linear time complexity for both encoding and decoding, typically O(n) where n is the input size, which supports real-time processing and hardware acceleration. For instance, GPU implementations can achieve up to 2x speedups over CPU versions for volumetric data, facilitating interactive applications like rendering pipelines. As a lossless method, RLE ensures perfect data reconstruction without any information loss, and its lack of look-ahead requirements allows streaming encoding without buffering entire datasets. These attributes make it ideal for hardware encoders in embedded systems or real-time scenarios, such as fax machines or simple image processing. Despite these benefits, RLE exhibits significant limitations, particularly its ineffectiveness on lacking long runs of identical values. In random or short-run sequences, the addition of count bytes for each can expand the —potentially doubling it in the worst case. This makes it vulnerable to adversarial inputs designed to minimize runs, rendering it counterproductive for highly varied or complex patterns like natural language text or photographic images. Moreover, RLE fails to capture inter-run correlations or broader statistical patterns, limiting its compression ratios to scenarios with homogeneous regions, such as images or sparse matrices. Comparatively, RLE outperforms Huffman coding in speed and ease but yields inferior compression for data with uneven symbol probabilities, where Huffman better exploits frequency distributions; thus, RLE is often paired with Huffman as a preprocessing step for 5-10% gains. Against LZ77, RLE's focus on identical consecutive symbols makes it simpler and faster but far less general, as LZ77 detects arbitrary repeats across distances, suiting diverse data like executables while RLE falters there. DEFLATE, integrating LZ77 and Huffman, surpasses RLE on mixed datasets for higher ratios, though RLE serves effectively as an initial stage in some pipelines for run-heavy content. In contemporary views, RLE is largely obsolete for universal compression due to these constraints but retains utility in specialized domains, such as genomic sequencing, where homopolymers enable strong ratios after base-splitting (e.g., reducing 92 bytes to 80 for a 16-base sequence).

Examples and Illustrations

Simple Data Example

A simple illustration of run-length encoding uses the string "AAABBCDDDD", which consists of consecutive repeated characters suitable for compression. The encoding process scans the input sequentially to detect runs of identical characters. Starting from the left, the first run identifies three consecutive 'A's, recorded as the pair "3A". The next run finds two 'B's, encoded as "2B". This continues with one 'C' as "1C" and four 'D's as "4D", yielding the compressed form "3A2B1C4D". Decoding reverses this by parsing the encoded string into count-value pairs and expanding each: "3A" repeats 'A' three times, "2B" repeats 'B' twice, "1C" outputs 'C' once, and "4D" repeats 'D' four times. The result is the original string "AAABBCDDDD", confirming the lossless nature of the method.

Practical Application Example

In practical applications of run-length encoding (RLE), such as compressing scanlines in images, the PackBits variant is widely used to exploit redundancy in pixel data, particularly in formats like where long runs of uniform color are common. Consider a monochrome image row with 10 consecutive black pixels (each represented as byte 0x00), followed by 20 white pixels (0xFF), and then 5 black pixels (0x00), resulting in a total of 35 pixels and thus 35 uncompressed bytes. Using the PackBits algorithm, this row is encoded by replacing each run of identical bytes with a signed header byte indicating the repetition count, followed by a single data byte for the run value. The encoding proceeds as follows:
  • The run of 10 black pixels (0x00) is encoded with header byte -9 (0xF7 in hexadecimal, since -(-9) + 1 = 10 repetitions), followed by 0x00.
  • The run of 20 white pixels (0xFF) uses header -19 (0xED), followed by 0xFF (-(-19) + 1 = 20).
  • The run of 5 black pixels (0x00) uses header -4 (0xFC), followed by 0x00 (-(-4) + 1 = 5).
The complete encoded stream is therefore the 6-byte sequence: F7 00 ED FF FC 00, reducing the data size by a factor of approximately 5.83 while remaining . To decode this stream back to the original row, the process interprets each header byte sequentially:
  • Header 0xF7 (-9) repeats the following byte (0x00) 10 times, yielding 10 black pixels.
  • Header 0xED (-19) repeats 0xFF 20 times, yielding 20 white pixels.
  • Header 0xFC (-4) repeats 0x00 5 times, yielding 5 black pixels.
This reconstructs the exact 35-byte original without loss. Such PackBits encoding applies directly to scanlines in files, enabling efficient storage of images with repetitive patterns, and similar RLE principles are used in facsimile transmission under T.4 to encode runs of black and white pixels along each line for compact signaling over phone lines. In files, an analogous RLE scheme compresses pixel runs, with the file header byte (offset 2) set to 9 or 10 to indicate RLE usage for color-mapped or true-color images, respectively.

Variants

Standard Variants

Standard variants of run-length encoding adapt the basic algorithm to handle literals, variable run lengths, and specific data granularities while maintaining simplicity and . These modifications address limitations in the core encoding process, such as distinguishing runs from non-repeating sequences or optimizing for , without introducing complex adaptive mechanisms. Packed RLE introduces a flag mechanism to efficiently encode both runs and sequences of unique literals within the same stream. In the PackBits scheme, standardized in the 6.0 specification and adopted in formats like , each code byte serves as a flag: values from 0 to 127 indicate the following n+1 bytes are literals to copy unchanged; values from -127 to -1 indicate the following byte is repeated -n+1 times; and -128 acts as a no-operation to align data. This byte-oriented approach processes data row-by-row in images, padding to byte boundaries, and supports uncompressed sizes up to 128 bytes per run or literal group. Unpacked RLE, in contrast, omits flags by encoding all sequences as run counts followed by values, treating single literals as runs of length 1, which simplifies at the cost of potential overhead for sparse runs. Counts are represented as variable-length integers, often using fewer bytes for short runs (e.g., 1 byte for counts up to 255, extended for longer), making it suitable for data streams dominated by long identical sequences where literal copies are rare. This variant streamlines decoding by assuming a consistent (count, value) pair format, as seen in basic implementations for text or numeric data. Bit-oriented RLE extends the technique to by encoding run lengths at the bit level, packing multiple indicators into bytes for density. In the Modified Huffman () mode of CCITT Group 3 ( T.4), used for bilevel images, white and black run lengths are represented by variable-length Huffman codes: short runs (0-63 bits) use terminating codes, while longer runs combine makeup codes (for multiples of ) with terminating codes, starting each line with a white run code. This packs codes into bit streams, with end-of-line signals and byte alignment, optimizing for sparse black pixels on white backgrounds in documents. RLE integrates with Lempel-Ziv-Welch (LZW) compression by serving as a preprocessing step to consolidate long runs into single symbols, shrinking the input and enhancing overall ratios in dictionary-based encoding. Studies on show that applying RLE before LZW reduces redundancy in repetitive patterns, yielding better results than standalone LZW for with uniform regions. This hybrid is particularly effective in formats handling mixed run-heavy and patterned data.

Advanced and Specialized Forms

Lossy run-length encoding (RLE) extends the basic technique by intentionally discarding precision during compression to achieve greater size reduction, often through quantization of values within runs. For example, in audio processing, samples are rounded to the nearest level before encoding runs, allowing of continuous signals while prioritizing storage efficiency over exact . This approach is particularly useful in transform-based , where quantized coefficients exhibiting long runs of zeros or near-identical values are encoded succinctly after the lossy quantization step. Adaptive RLE improves upon static methods by dynamically tailoring the encoding scheme to the input data's statistical properties, such as or run length distribution, to optimize ratios. A prominent implementation is found in the JPEG-LS standard, where run lengths are encoded using context-adaptive Golomb-Rice codes that adjust based on prior symbols, enabling efficient handling of both short and long runs in lossless . This adaptation, central to the LOCO-I , allows the encoder to switch seamlessly between run-mode for flat regions and regular-mode for variable areas, achieving near-optimal performance across diverse image types. Sequential RLE processes data in a strict linear order, making it ideal for inherently ordered datasets like time-series, where constant-value segments are common and can be predicted to enhance encoding. In predictive variants, the next run value is estimated using prior data, and only the prediction error is subjected to RLE, compressing runs of small or zero errors effectively. This method couples prediction, quantization, and run-length encoding adaptively to minimize redundancy in sequential signals. In modern applications, RLE has been specialized for domain-specific data, such as and tensor storage. For , RLE compresses homopolymer runs in FASTQ files—sequences of identical —by storing the base symbol paired with its length, which is crucial for handling repetitive regions in viral or bacterial genomes like , where such runs dominate and boost compression ratios. In , RLE aids sparse tensor compression in frameworks like by encoding consecutive zero-valued elements in model weights or activations, reducing memory and communication costs; for instance, the DeepReduce framework uses RLE on non-zero indices during federated to cut bandwidth usage by up to 90% for sparse gradients without accuracy loss.

References

  1. [1]
    Compression - Run Length Encoding :: Intro CS Textbook
    In run length encoding, we're looking for runs or repeated sequences in our data. And then we're going to going to replace them with a shorter version of that ...Missing: explanation | Show results with:explanation
  2. [2]
    [PDF] Fundamentals of Data Compression - Stanford Electrical Engineering
    Sep 9, 1997 · Run length encoding: Simple but still useful. Often used for data with many repeated symbols, e.g., FAX and quantized transform coefficients ( ...
  3. [3]
    [PDF] SPACE DATA COMPRESSION STANDARDS
    Space data compression has been used on deep space missions since the late 1960s. Significant flight history on both lossless and lossy methods exists.
  4. [4]
    [PDF] Run-Length and Markov Compression Revisited in DNA Sequences
    Compression algorithms can broadly be classified into 3 categories, compression using run-length encoding techniques, dictionary based compression and Markov ...
  5. [5]
    [PDF] Incrementally Maintaining Run-length Encoded Attributes in Column ...
    ABSTRACT. Run-length encoding is a popular compression scheme which is used extensively to compress the attribute values in column stores.Missing: explanation | Show results with:explanation
  6. [6]
    [PDF] Run-length Encoding on Graphics Hardware - UAF CS
    It produces compressed files consisting of pairs of values, the first holding the run of a data value, the second holding that value.Missing: explanation | Show results with:explanation
  7. [7]
    [PDF] Runlength Compression Techniques for FPGA Configurations
    A variation of Run-Length encoding perfectly meets the requirements for the address compression. A series of addresses with a common offset can be compressed ...Missing: explanation | Show results with:explanation
  8. [8]
    An efficient and secure compression technique for data protection ...
    The proposed method involves scrambling input data with a generated key, transforming it through BWT, and compressing it through Move-To-Front and Run-Length ...
  9. [9]
    [PDF] Introduction to Data Compression - CMU School of Computer Science
    Jan 31, 2013 · The T4 standard uses run-length encoding to code each sequence of black and white pixels. Since there are only two message values black and.
  10. [10]
    Run Length Encoding - an overview | ScienceDirect Topics
    Run-Length Encoding (RLE) is a lossless data compression technique that replaces consecutive occurrences of a given symbol with a single copy of the symbol and ...Missing: handling | Show results with:handling
  11. [11]
  12. [12]
    Run length encoding based wavelet features for COVID-19 ...
    Run length encoding based wavelet features for COVID-19 detection in X-rays ... The RLE methods were first used in 1967 in the analog signal transmission for ...
  13. [13]
    [PDF] Entropy Computation of Document Images in Run-Length ... - arXiv
    In this paper, we report the results of implementing document analysis in run- length compressed domain. The authors [1] compute entropy both in horizontal and ...
  14. [14]
  15. [15]
    None
    ### Space Savings Calculation for Runs of Length L
  16. [16]
    None
    ### Extracted Sections and Formulas
  17. [17]
  18. [18]
    Truevision Targa File Format
    Truevision defined the TGA file format in 1984 for use with its first videographics products. ... Targas can be uncompressed or compressed with RLE (run length ...Missing: adoption 1980s
  19. [19]
    Rediscovering Compuserve RLE Graphics - Brutman.Com
    Aug 30, 2022 · Before Compuserve invented GIF in 1987 it used a graphics format called RLE, which was suited to early eight bit home computers.
  20. [20]
    ITU-T Group 4 FAX Compression (T.6) - The Library of Congress
    Mar 23, 2023 · Format Description for ITU_G4 -- Bitstream encoding format for still images that generally result from the scanning of paper documents.Missing: run- | Show results with:run-
  21. [21]
    TIFF Revision 5.0
    Aug 8, 1988 · 32773 = PackBits compression, a simple byte oriented run length scheme for 1-bit images. See Appendix C. Data compression only applies to raster ...
  22. [22]
    ILBM IFF Interleaved Bitmap - AmigaOS Documentation Wiki
    Jun 8, 2012 · ILBM is a format for 2D raster graphics, an InterLeaved bitplane BitMap image with color map, and an IFF data section for portable storage.Missing: 1990s | Show results with:1990s
  23. [23]
    [PDF] Data Compression - cs.Princeton
    RLE. 8. Run-Length Encoding. Run-length encoding (RLE). n. Exploit long runs of repeated characters. n. Replace run by count followed by repeated character, but ...<|control11|><|separator|>
  24. [24]
    Using run length encoding | Vertica 23.4.x
    Encoding options include run length encoding (RLE), which replaces sequences (runs) of identical values in a column with a set of pairs.
  25. [25]
    All About Parquet Part 02 — Parquet's Columnar Storage Model
    Oct 24, 2024 · By grouping similar values together, columnar formats enable algorithms like dictionary encoding or run-length encoding to achieve high ...
  26. [26]
    A Guide to Run-Length Encoding - Hydrolix
    Dec 23, 2024 · Run-length encoding (RLE) is a simple but powerful data compression technique that's useful for a wide range of use cases from image compression to log data.
  27. [27]
    Utah Raster Toolkit Home Page
    Called the RLE(5) format, it uses run length encoding to reduce storage space for most images. The programs (tools) currently included in the toolkit are listed ...
  28. [28]
    [PDF] Data Compression - Higher Education | Pearson
    Thus run-length encoding, for example, can be used for compression of any type of data in a file system, for example, text, still images for facsimile, or as ...Missing: building | Show results with:building
  29. [29]
    [PDF] Run-Length Encoding (RLE) Data Compression Algorithm ...
    RLE compresses data by replacing n consecutive occurrences with a pair symbol nd. It achieves around 40% data saving for temperature and sea-level pressure.
  30. [30]
    Investigation of Energy Cost of Data Compression Algorithms ... - NIH
    Oct 10, 2022 · Run Length Encoding (RLE) is a frequently used compression method. This algorithm's basic premise is laid forth in [40]. In the case that a data ...
  31. [31]
    Tiger Data Documentation | About compression methods - Docs
    Run-length encoding is also used as a building block for many more advanced algorithms, such as Simple-8b RLE, which is an algorithm that combines run-length ...
  32. [32]
    PCX Format - ModdingWiki
    Sep 18, 2024 · The PCX format is an image format used by many games, usually to store full screen (320x200) 16-colour EGA, and later 256-colour VGA (mode 13h), graphics.
  33. [33]
    Group 3 Facsimile Communication - Garret Wilson
    These two lines are compressed using three compression methods: Modified Huffman (MH), modified read (MR), and modified modified read (MMR). These methods are ...
  34. [34]
  35. [35]
    [PDF] Revision 6.0 - ITU
    2 = CCITT Group 3 1-Dimensional Modified Huffman run length encoding. See ... Loop until you get the number of unpacked bytes you are expecting: Read the next ...
  36. [36]
    Understanding Run-Length Encoding: Data Compression Simplified"
    Feb 19, 2025 · Run-length encoding (RLE) is a type of lossless data compression, meaning no information is lost during the process.
  37. [37]
    The unreasonable effectiveness of run-length encoding
    Feb 4, 2024 · The unreasonable effectiveness of run-length encoding I'm writing a game that uses an extremely limited color palette. Most of my art assets ...Run-Length Encoding · Get Liam Appelbe's Stories... · More Tricks
  38. [38]
    [PDF] Compression and Huffman coding - MIT OpenCourseWare
    19.1.5 Run-length encoding. Imagine you are given the string of bits. 000000 ... Example run of the Huffman algorithm. The six rows represent the state ...
  39. [39]
    Compression, Image Data
    Compression ratio. Run-Length Encoding (RLE). Replace each string of identical bits (or digits, or letters) by a count of the symbols. Example: data (24 bits) ...Missing: explanation | Show results with:explanation
  40. [40]
    Run-Length Encoding and Decoding in Java | Baeldung
    Feb 1, 2024 · Learn how run-length encoding works and then, explore two approaches to implementing run-length encoding and decoding.
  41. [41]
    Run Length Encoding (RLE) Discussion and Implementation
    Dec 30, 2017 · RLE replaces a string of repeated symbols with a single symbol and a count (run length) indicating the number of times the symbol is repeated.
  42. [42]
    [PDF] Run-Length Encoding (RLE)
    Run-length encoding is a data compression algorithm that is supported by most bitmap file formats, such as TIFF, BMP, and PCX. RLE is suited for compressing ...
  43. [43]
    Bitmap Compression - Win32 apps - Microsoft Learn
    Aug 27, 2021 · When the Compression member is BI_RLE4, the bitmap is compressed by using a run-length encoding format for a 4-bit bitmap, which also uses ...Missing: decoding | Show results with:decoding
  44. [44]
    8.2.2 Run Length Encoding Image Compression - DICOM
    Run Length Encoding (RLE) is a byte-oriented, lossless compression scheme in DICOM, also known as 'PackBits' in TIFF 6.0. RLE compressed data is always color- ...Missing: 1988 | Show results with:1988
  45. [45]
    Incrementally maintaining run-length encoded ... - ACM Digital Library
    ... run-length encoding and consequently, the per- formance of reads. ... Time Complexity: Consider a count index on a sequence of n ... quence with n runs from O(n) to ...
  46. [46]
    Run Length Encoding and Decoding - GeeksforGeeks
    Jul 23, 2025 · Given an input string, write a function that returns the Run Length Encoded string for the input string.<|control11|><|separator|>
  47. [47]
    Run Length Encoding (RLE) - Naukri Code 360
    May 31, 2024 · Run-length encoding (RLE) is a compression technique that ... LZ77: LZ77, developed by Abraham Lempel and Jacob Ziv in 1977, is a ...
  48. [48]
    [PDF] Comparative Analysis of Performance Run Length (RLE) Data ...
    Dec 8, 2021 · This research compares RLE data compression using VHDL and a microcontroller, aiming to find the best implementation for speed. RLE compresses ...
  49. [49]
    [PDF] improving run length encoding by preprocessing - arXiv
    Mar 30, 2021 · With our technique we can achieve a lossless average compression which is better than the standard RLE compression by a factor of 8 on average.
  50. [50]
    [PDF] Data Compression - Analog Devices
    Run-length encoding is a simple method of compressing these types of files. Figure 27-1 illustrates run-length encoding for a data sequence having frequent runs ...Missing: 1967 | Show results with:1967
  51. [51]
    [PDF] Comparison between Image Compression Algorithms - IJERA
    Dec 22, 2017 · The Run Length. Encoding algorithm, which aims to reduce pixel redundancy, is straightforward and easy to implement. Its advantages lie with ...
  52. [52]
    [PDF] Run-Length and Markov Compression Revisited in DNA Sequences
    To summarize, run-length encoding involves replacing the number of continuous occurrences of a certain entity by a single instance of that entity followed by a ...
  53. [53]
    TGA format specification - Paul Bourke
    Creating TGA Image files. Written by Paul Bourke September 1996. Introduction. TGA or TARGA format is a format for describing bitmap images, it is capable ...
  54. [54]
    [PDF] Image compression performance comparison of RLE and LZV ...
    Apr 19, 2023 · To give an example of the working principle of the Run Length Encoding compression algorithm, let's assume that the data we want to compress is.
  55. [55]
    Improving Run Length Encoding by Preprocessing - Semantic Scholar
    Improvement of Lossless Text Compression Methods using a Hybrid Method by the Integration of RLE, LZW and Huffman Coding Algorithms · Computer Science.
  56. [56]
    [PDF] Compression of Audio Using Transform Coding
    Mar 7, 2019 · In our proposed system the run length encoding way is applied initial to prune the long runs of quantized coefficients, then an enhanced ...
  57. [57]
    [PDF] The LOCO-I lossless image compression algorithm
    Adaptive Run Length Coding: The encoding of run lengths in JPEG-LS is also based on Golomb codes, orig- inally proposed in [32] for such applications.
  58. [58]
    [2102.03112] DeepReduce: A Sparse-tensor Communication ... - arXiv
    Feb 5, 2021 · This paper introduces DeepReduce, a versatile framework for the compressed communication of sparse tensors, tailored for distributed deep learning.