我必须实现压缩方案。我使用以下命令量化了图像的3个通道:
yce = blockproc(y, [8 8], @(block_struct) round(round(block_struct.data) ./ q_y));
cbce = blockproc(cb, [8 8], @(block_struct) round(round(block_struct.data) ./ q_c));
crce = blockproc(cr, [8 8], @(block_struct) round(round(block_struct.data) ./ q_c));
现在我想使用霍夫曼编码对上面的每个元素进行编码,然后执行逆操作。这是我的代码:
Z = unique (yce);
countElY=histc(yce,Z);
p = countElY/numel(yce);
[dict,avglen] = huffmandict(Z,p);
K=unique(cbce);
countelcb=histc(cbce,K);
p1=countelcb/numel(cbce);
[dict1,avglen1]=huffmandict(K,p1);
L=unique(crce);
countelcr=histc(crce,L);
p2=countelcr/numel(crce);
[dict2,avglen2]=huffmandict(L,p2);
comp= huffmanenco(yce,dict);
comp1=huffmanenco(cbce,dict1);
comp2=huffmanenco(crce,dict2);
huffman_code = (cat(3,comp,comp1,comp2));
Im1 = huffmandeco(comp,dict);
im2=huffmandeco(comp1,dict1);
im3=huffmandeco(comp2,dict2);
我收到以下错误:
The probability input must be a vector.
请帮助我这一步吗?提前感谢