MATLAB: Mine Image is not displayed instead image.fig file which i have attached is displayed

Communications Toolboxcompressing image using huffmanimage processinglzwretinex for enhancing

%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;
end
end
disp(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

I can't run your code because I don't have the Communications System Toolbox, but apparently what you're displaying is a 1-D vector, not a 2-D image. What is the size of your arrays?
size(newvec) % Don't use a semicolon. Look in the command window.
size(hcode)