フィルターのクリア

huffman encoding for image

2 ビュー (過去 30 日間)
Nidhi Kumari
Nidhi Kumari 2018 年 10 月 9 日
コメント済み: Walter Roberson 2018 年 10 月 26 日
for the code-
A=imread('xyz.jpg');
A1=rgb2gray(A);
A = A1(:);
[symbols,p]=hist(A,double(unique(A)))
p=p/sum(p)
symbols=symbols/sum(symbols)
[dict,avglen]=huffmandict(symbols,p)
comp=huffmanenco(A,dict)
i am getting error-
Error using huffmandict (line 164)
Source symbols repeat
Error in new (line 7)
[dict,avglen]=huffmandict(symbols,p)
suggest necessary changes
  3 件のコメント
Nidhi Kumari
Nidhi Kumari 2018 年 10 月 10 日
But how to make them same?
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 10 月 10 日
@Nidhi
I have updated the answer, please check here

サインインしてコメントする。

採用された回答

OCDER
OCDER 2018 年 10 月 10 日
I haven't used huffmandict before, but based on the document and the error message you have, I suspect your inputs are wrong.
Double check your inputs to huffmandict. Make sure symbols are unique values, and p are the probability of each value. That means:
[symbols, p] = hist(A,double(unique(A))) should be
[p, symbols] = hist(A,double(unique(A))) because the 1st output of hist is the frequency (probability)
and the second output is the unique bin (unique symbol)
  30 件のコメント
Walter Roberson
Walter Roberson 2018 年 10 月 26 日
You are using a version of MATLAB no later than R2017b: I can tell because is_a_valid_code was removed from huffmandeco as of R2018a.
Looking at the amount of memory you have, I suspect you are running R2015b or earlier with a 32 bit MATLAB.
When I test with peppers.png on R2017b on my system, the decoding took about 53 seconds.
Walter Roberson
Walter Roberson 2018 年 10 月 26 日
I have a memory of having reported an inefficiency to MATLAB having to do with is_a_valid_code, that it was being called far too often. However, I do not seem to find that in my case list, so perhaps I reported it years ago on a different license.
Anyhow: upgrading to R2018a or later would probably speed up quite a bit.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by