[英]Issues with MATLAB: JPEG2000 compression scheme using wavelet toolbox
我和一個隊友正在為項目開發類似JPEG2000的壓縮方案。 它利用matlab和小波工具箱。
有兩個問題。 我對JPEG2000缺乏了解,使我相信我缺少此壓縮過程的步驟。 第二個問題是實際錯誤,涉及到: [dict,avglen] = huffmandict(cQ,p); % Create dictionary.
[dict,avglen] = huffmandict(cQ,p); % Create dictionary.
錯誤:??? 在174個源符號處重復使用==> huffmandict時出錯
我不確定這是否與矩陣中的重復值有關,因為尚未完成游程長度編碼。
==>項目中的錯誤,錯誤值為41 [dict,avglen] = huffmandict(cQ,p); %創建字典。
任何提示或信息將是有益的。
另外,我不確定是否需要預處理步驟
代碼如下:
%wavelet based compression sub-band coding
clear all;
close all;
x=imread('1.png');%input image
n=input('enter the desired decompositon level '); %decompositon level
Q=input('enter the desired quantization step size '); %quantization level
%begin wavelet decomposition
c = [];
sx = size(x);
s = zeros(n+2,length(sx));
if isempty(x) , return; end
s(end,:) = size(x);
for i=1:n
[x,h,v,d] = dwt2(x,'haar'); % decomposition
c = [h(:)' v(:)' d(:)' c]; % store details
s(n+2-i,:) = size(x); % store size
end
% Last approximation.
c = [x(:)' c];
s(1,:) = size(x);
%Begin Quantization
cQ=round(c/Q);
%Begin Entropy Encoding
scQ=length(cQ);
l=1;
for i=1:(scQ-1);
l=l/2;
p(i)=l;
end
p(scQ)=p(scQ-1);
[dict,avglen] = huffmandict(cQ,p); % Create dictionary.
actualsig = randsrc(100,1,[cQ; p]); % Create data using p.
comp = huffmanenco(actualsig,dict); % Encode the data.
我知道這只是部分答案,但看來該錯誤是由於您的輸入包含重復項引起的。
這可以通過使用unique
命令來防止。
在此網站上,他們建議類似:
[symbols,p]=hist(A,double(unique(A)))
但是由於我不確定您的輸入如何工作,您可能需要使用
unique([cQ; p],'rows')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.