Code covered by the BSD License  

Highlights from
Run Length coding v4


3.0 | 1 rating Rate this file 20 Downloads (last 30 days) File Size: 1.72 KB File ID: #36708

Run Length coding v4



Implements runLength coding for image processing

| Watch this File

File Information

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.

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
18 May 2012 Bruno Luong

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

17 May 2012 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

17 May 2012 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

17 May 2012 Bruno Luong

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.

16 May 2012 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

Contact us