File Exchange

image thumbnail

Run Length coding v4

version 1.0 (1.72 KB) by

Implements runLength coding for image processing

5 Downloads

Updated

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 (6)

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.

The program not only addresses time optimization but data reduction too, here r the findings when used for an image
in=imread('wirebond.jpg');
>> 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

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

http://www.mathworks.com/matlabcentral/fileexchange/24255-consecutive-vector-spliter

>> 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.

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