【发布时间】:2012-06-25 20:01:13
【问题描述】:
我有一个作业,我必须将一些图像转换为灰度并使用霍夫曼编码对其进行压缩。我将它们转换为灰度,然后尝试压缩它们,但出现错误。我使用了我找到的代码here。
这是我正在使用的代码:
A=imread('Gray\36.png');
[symbols,p]=hist(A,unique(A))
p=p/sum(p)
[dict,avglen]=huffmandict(symbols,p)
comp=huffmanenco(A,dict)
这是我得到的错误。它出现在第二行。
Error using eps
Class must be 'single' or 'double'.
Error in hist (line 90)
bins = xx + eps(xx);
我做错了什么?
谢谢。
附:如何找到每张图片的压缩比?
【问题讨论】:
标签: image matlab huffman-code