matlab closes when using Huffman encoding

I have a vector of size 65536x1
i am performing compression of image i used code
symbols = unique(YourVector(:));
counts = hist(YourVector(:), symbols);
p = double(counts) ./ sum(counts);
[dict,avglen] = huffmandict(symbols,p)
comp = huffmanenco(sig,dict)
but i get error
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> huffmandict>insertMaxVar
i changed value from 500 to 4000,but my matlab closes

답변 (1개)

Walter Roberson
Walter Roberson 2012년 12월 24일

1 개 추천

You have a routine which is calling itself, such as would happen if you accidentally named your .m file the same as the name of a routine that is used by huffmandict . What name did you give to the .m file for the code you show above?

댓글 수: 7

Pat
Pat 2012년 12월 24일
modifiednew.m
Pat
Pat 2012년 12월 24일
even i type it in command window i get same error
Walter Roberson
Walter Roberson 2012년 12월 24일
Use the debugger and single-step through huffmandict() to figure out what is being called recursively.
Pat
Pat 2012년 12월 24일
편집: Walter Roberson 2012년 12월 24일
walter my code is
img=imread('cameraman.tif');
YourVector=img;
YourVector=double(YourVector(:));
symbols = unique(YourVector);
counts = hist(YourVector(:), symbols);
p = double(counts) ./ sum(counts);
[dict,avglen] = huffmandict(symbols,p)
comp = huffmanenco(YourVector,dict)
in comp i get only binary values,bur is the image really compressed
Walter Roberson
Walter Roberson 2012년 12월 24일
Is the number of elements in "comp" smaller than (the number of elements in YourVector multiplied by 8)? If so then you might have compression. To be more certain you should also include the size needed to represent the dict as part of the encoding cost.
size(comp)
ans =
461689 1
size(img)
ans =
256 256
how to display comp image since sizeis dfferent..
Walter Roberson
Walter Roberson 2012년 12월 24일
comp is not an image. comp is compressed data. You would have to decompress it to display anything.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

질문:

Pat
2012년 12월 24일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by