image compression using run length ecoding

This program takes any image, converts it to binray, and performs RLE on the binary image



%
%Progam to calculate RUN LENGTH ENCODING
%the prog takes any image, converts it to binray, and performs RLE on the binary image
function[rle]=rlemain(f)
I=imread(f);
imshow(I);title('original image');
level=graythresh(I);
bw=im2bw(I,level);
figure;imshow(bw);title('binary image');
a=bw'; a=a(:); a=a';
a=double(a);
rle(1)=a(1); m=2; rle(m)=1;
for i=1:length(a)-1
if a(i)==a(i+1)
rle(m)=rle(m)+1;
else
m=m+1; rle(m)=1; %dynamic allocation and initialization of next element of rle
end
end
display(rle);
%to run the prog type rlemain('imagefilename.ext') at the command window
%the program will return RUN LENGTH ENCODED (row)martix
thumbnail
About The Author

Ut dignissim aliquet nibh tristique hendrerit. Donec ullamcorper nulla quis metus vulputate id placerat augue eleifend. Aenean venenatis consectetur orci, sit amet ultricies magna sagittis vel. Nulla non diam nisi, ut ultrices massa. Pellentesque sed nisl metus. Praesent a mi vel ante molestie venenatis.

9 comments

  1. hey,
    i want the source code for compression of text data using shannon-fano coding in matlab...
    plz HELP ME....!!!

    ReplyDelete
  2. Do you have any idea how to do Segmentation of an image by region growing? Thanks!

    ReplyDelete
  3. hi, can you help me? i'm looking for source code for image compression using huffman algorithm. thanks

    ReplyDelete
  4. I wanted a matlab code for image compression using huffman, rle,and lzw and comparing them on the basis of compression ratio.....CAn u please help me out. I will be very greatful to you......My project is completely dependent on it. Thank you

    ReplyDelete
    Replies
    1. i don know.....btn when is ur project..?/ll try to help u ....asap...

      Delete
  5. what will be output of the above code????pls reply as soon as possible.....

    ReplyDelete
  6. pls mail the o/p to dis id : arshfar@gmail.com

    ReplyDelete
  7. can i know is that possible for the RLE do in the color image?

    ReplyDelete
  8.  Excellent tips. Really useful stuff .Never had an idea about this, will look for more of such informative posts from your side.. Good job...Keep it up
    Software Photo Slideshow

    ReplyDelete