Matlab中DWT问题
我正在尝试使用 10 点 daubechies 过滤器获取图像的第 4 级 DWT。 (并且自然地反转它!)
host = double(imread('lena512.bmp')); % Load image data
nLevel = 4; % Number of decompositions
cwA = cell(1,nLevel); % Approximation coefficients
cwH = cell(1,nLevel); % Horizontal detail coefficients
cwV = cell(1,nLevel); % Vertical detail coefficients
cwD = cell(1,nLevel); % Diagonal detail coefficients
% Do the DWT
myImage = host;
for iLevel = 1:nLevel,
[cwA{iLevel},cwH{iLevel},cwV{iLevel},cwD{iLevel}] = dwt2(myImage,'db10');
myImage = cwA{iLevel};
end
% Do the inverse DWT
fullRecon = cA{nLevel};
for iLevel = nLevel:-1:1
fullRecon = idwt2(fullRecon,cH{iLevel},cV{iLevel},cD{iLevel},'db10');
end
上面的代码不断给我错误:
???使用 ==> 时出错加 矩阵维度必须一致。
错误==> idwt2 93 x = upsconv2(a,{Lo_R,Lo_R},sx,dwtEXTM,shift)+ ... % 近似值。
错误==> 18岁的假人 全面侦察= idwt2(fullRecon,cH{iLevel},cV{iLevel},cD{iLevel},'db10');
我相信这是由于逆 dwt 做了一些奇怪的事情。我也尝试过更改 dwtmode 但没有帮助。我真的很感谢任何帮助。
PS:lena512.bmp只是lena的灰度图。它的尺寸为 512x512。
我对新想法持开放态度 =)
I am trying to get the 4th level DWT of an image using the 10 point daubechies filter. (and naturally inverting it!)
host = double(imread('lena512.bmp')); % Load image data
nLevel = 4; % Number of decompositions
cwA = cell(1,nLevel); % Approximation coefficients
cwH = cell(1,nLevel); % Horizontal detail coefficients
cwV = cell(1,nLevel); % Vertical detail coefficients
cwD = cell(1,nLevel); % Diagonal detail coefficients
% Do the DWT
myImage = host;
for iLevel = 1:nLevel,
[cwA{iLevel},cwH{iLevel},cwV{iLevel},cwD{iLevel}] = dwt2(myImage,'db10');
myImage = cwA{iLevel};
end
% Do the inverse DWT
fullRecon = cA{nLevel};
for iLevel = nLevel:-1:1
fullRecon = idwt2(fullRecon,cH{iLevel},cV{iLevel},cD{iLevel},'db10');
end
The code above keeps giving me the error :
??? Error using ==> plus
Matrix dimensions must agree.Error in ==> idwt2 at 93
x = upsconv2(a,{Lo_R,Lo_R},sx,dwtEXTM,shift)+ ... % Approximation.Error in ==> dummy at 18
fullRecon =
idwt2(fullRecon,cH{iLevel},cV{iLevel},cD{iLevel},'db10');
This I believe is due to the inverse dwt doing some funky stuff. I also tried changing dwtmode but it didn't help. I would really appriciate any help.
PS: lena512.bmp is just a gray-scale picture of lena. It's dimensions are 512x512.
I am open to fresh ideas =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重写代码
解决了我的问题。希望它能帮助其他人...
Rewriting the code as
fixed my problem. Hope it helps others...