entropy encoding for images

is there any source codes available for entropy encoding for images, please help

2 Comments

What difficulty are you having with the code version of it that you wrote?
I am using 2010a version
code is
[dict,avglen] = huffmandict(symbols,p)
comp = huffmanenco(img,dict);
but taking long time to run and crashes out

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 24 Dec 2012

8 Comments

FIR
FIR on 25 Dec 2012
Edited: Walter Roberson on 25 Dec 2012
i used code for arthimetic encoding but returns error
original=imread('Lena.bmp'); % Read an image Lena 512*512 to original variable
seq=original(:); % convert the matrix original into a vector by morton scan order which is a fucntion i made up by myself
seq=double(seq);
ta=tabulate(seq); % create a three column with the internal function ... first column is the symbol... second is the times it occured ... third is the propability
count=ta(:,2); %copy the count column into count variable from ta variable
code=arithenco(seq,count);
nnz(seq)
ans =
65536
>> nnz(count)
ans =
230
please tell how to correct it
error
Error using ==> arithenco at 36
The symbol counts parameter must be a vector of positive finite integers.
Error in ==> sample6 at 63
code=arithenco(seq,count);
You correct it by stepping through your code in the debugger. I can't do it because I don't have those functions. I know you know how to use the debugger by now. Evidently seq or count is not "a vector of positive finite integers" and you can find out why by examining the variable in the debugger.
i have not used Debugger till now,can u tell how to debub please
It's hard to believe you have used MATLAB for this long and have never stepped through your code or looked at variables. That is usually taught in the first hour of MATLAB training. Nevertheless, you can learn how to debug your code here: http://blogs.mathworks.com/videos/2010/09/02/using-debugger-to-walk-through-code/ You will absolutely need to learn how to debug your code because "debugging via the Answers forum" is a very inefficient and lengthy way to debug your code.
Sorry that debugging know very well,i thought it was some thing new
is there any codes available for shanon fano encoding
what does
length(count)
show? And also
sum(count <= 0)
?
length(count)
ans =
238
>> sum(count <= 0)
ans =
8

Sign in to comment.

Walter Roberson
Walter Roberson on 25 Dec 2012
Edited: Walter Roberson on 25 Dec 2012
If x is a numeric array, TABLE is a numeric matrix. If the elements of x are nonnegative integers, TABLE includes 0 counts for integers between 1 and max(x) that do not appear in x.
But you already read the documentation so you already knew that, so somehow you must have gotten some negative counts. What does
count(counts <= 0)
show, and what does class(count) show?

10 Comments

count(count <= 0)
ans =
0
0
0
0
0
0
0
0
class(count)
ans =
double
Then your data being tabulated is non-negative integers and some of the integers between the lowest value and the maximum value do not happen to have any pixels with that value, so as documented, tabulate() generated entries with 0 counts for those values. Consider removing the entries that have the 0 counts.
can we replace it with 0.1,or it can be removed
The error message you quoted was,
The symbol counts parameter must be a vector of positive finite integers.
0 is not a positive integer, so counts of 0 are not permitted. You must remove all entries with count of 0.
ok walter thanks a lot ,can u tell why my matlab crashed when using
[dict,avglen] = huffmandict(s,q)
its taking longtime to run
like huffman is there and code for shanon fanon
I do not have that toolbox, so I do not know why it is taking so long. Have you tried using the profiler? Did you manage to find the reason why it was giving you infinite recursion ?
No walter i could not findout,so walter is there any codes for shanon fanon
after deleting zeros i get error
Error using ==> arithenco at 36
The symbol sequence parameter can take values only between 1 and the length of the
symbol counts parameter.
Error in ==> sample6 at 79
code=arithenco(seq,count);
Sorry, Google doesn't seem to be accessible to me tonight. Perhaps you could try it from your end?

Sign in to comment.

Categories

Asked:

FIR
on 24 Dec 2012

Community Treasure Hunt

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

Start Hunting!