%Reading image
I=imread('cameraman.tif');figure,imshow(I),disp(I)%size of the image
[m,n]=size(I);Totalcount=m*n;%variables using to find the probability
cnt=1;sigma=0;%computing the cumulative probability.
for i=0:255 k=I==i; count(cnt)=sum(k(:)) %pro array is having the probabilities
pro(cnt)=count(cnt)/Totalcount; sigma=sigma+pro(cnt); cumpro(cnt)=sigma; cnt=cnt+1;end;%Symbols for an image
symbols = [0:255];%Huffman code Dictionary
dict = huffmandict(symbols,pro);%function which converts array to vector
vec_size = 1;for p = 1:m for q = 1:n newvec(vec_size) = I(p,q); vec_size = vec_size+1; endenddisp(newvec);disp(dict);imshow(newvec);%Huffman Encodig
hcode = huffmanenco(newvec,dict);figure,imshow(hcode)
This is what being displayed instead i want image!!
Best Answer