File Exchange

image thumbnail

Run Length coding v4

version 1.0 (1.72 KB) by

Implements runLength coding for image processing

3 Ratings



View License

This version supports encoding and decoding binary images and also large binary signals.
Change log v4
o Added comments
o Added help
o Added auto mode-detection
o First two are image resolution
o Added version control at 3rd number
o Fourth digit is 1st element (0 or 1)

Probable next release v5
o Optimization for decompression algorithm
o Support for gray scale images

Comments appreciated.

Comments and Ratings (7)

mak khatib

waiting for v5 with grayscale images thanksss alot

Bruno Luong

Bruno Luong (view profile)

I directed to SplitVec to indicate the algorithm can be done without for-loop and faster. It's not designed for the same task.

Saket Dandawate

The program not only addresses time optimization but data reduction too, here r the findings when used for an image
>> tic; [a b]=SplitVec(in(:),[],'first','length'); toc
Elapsed time is 0.028276 seconds.
>> tic; [out]=runLengthCode(in,'e'); toc
Elapsed time is 0.053063 seconds.
>> whos
Name Size Bytes Class Attributes

a 5440x1 43520 double
b 5440x1 43520 double
in 486x486 236196 uint8
out 1x4061 32488 double

Saket Dandawate

o i had updated my program to v3 in the previous submission. unfortunately the files didnt update properly and same code is still shown hence the different upload
o ill try to optimize this till then
o gray scale support might take time exams going on

Bruno Luong

Bruno Luong (view profile)

Why not update your previous submission?

My comments is still hold, using for-loop is slow.

If you want to see how the encoder can be vectorized, see my submission

>> in=ceil(3*rand(500));

>> tic; [a b]=SplitVec(in(:),[],'first','length'); toc
Elapsed time is 0.015698 seconds.

>> tic; [out]=runLengthCode(in,'e'); toc
Elapsed time is 0.146707 seconds.

The time gain can be a factor 5-10.

Similar remark for the decoder.

Saket Dandawate

if you face error of incorrect version even after entering a valid image for encoding then force encode by passing 'e' as a second parameter to the function

MATLAB Release
MATLAB 7.11 (R2010b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today