File Exchange

image thumbnail

RLE de/encoding

version (545 Bytes) by Stefan Eireiner
A simple m-file which (de)compresses your data using RLE.


Updated 24 May 2004

No License

A simple (de)compression program using Run Length Encoding.

Compression is done that easy:
compressedData = rle(originalData);

originalData = rle(compressedData);

Cite As

Stefan Eireiner (2020). RLE de/encoding (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (26)

aslan memo

this not code for rle image compress


Great code. Thank you for sharing.

Sharo Chen


can anyone specifiy how to input original data @@

I am not able to view or download the file. I am getting "invalid menu handle". Kindly advise. This is 1st time I am attempting file exchange.

x is the argument of the function


pleeeeeeaze reply to me


it appear the variable x is not define, please help me

Zahra M

Great and Thanks



Ram prasad

zhang yong

Thurein Oo

lot thanks

siva kumar


xiaofan feng

brilliant, though need specified by oneself.

Shiva Krishna

Deserves more than 5 rating!!!

Kallol Roy

But when I'm decompressing the compressed image I'm getting back an one dimensional row vector. How can this prb be solved?

I used binary image for tedting.

Zhuo Hao

It's short but efficient.

Saeed Mozaffari

simple and efficient

Jeffrey Marten Gillmor

Simple, yet very quick and effective, thanks

Gabriel Peyré

Very nice compact code. One then just need to use an entropy coder to compress the runs length.

Janet Khuu

A note that this function does not find the number of zeros in a run (if used for JPEG coding); otherwise, this is great.

lele zhou

good, thanks

Bush George


MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux