小波变换的Matlab问题



我正在尝试使用10点涂抹滤波器获得图像的第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

上面的代码不断给我错误:

使用===>plus时出错矩阵尺寸必须一致。

===>idwt2中93处的错误x=upscov2(a,{Lo_R,Lo_R},sx,dwtEXTM,shift)+…%近似。

18岁时===>假人出现错误fullRecon=idwt2(fullRecon,cH{iLevel},cV{iLevel},c D{iLevel},'db10’);

我相信这是由于反向dwt做了一些时髦的事情。我也尝试过更改dwtmode,但没有帮助。如果有任何帮助,我真的很乐意。

附言:lena512.bmp只是lena的一张灰度照片。它的尺寸是512x512。

我愿意接受新的想法=)

将代码重写为

clear all;
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
% Size matrix
s = [size(host,1) size(host,2)];
% Do the DWT
myImage = host ;
for iLevel = 1:nLevel
  [cwA{iLevel},cwH{iLevel},cwV{iLevel},cwD{iLevel}] = dwt2(myImage, 'db10');
  s = [s; size(cwH{iLevel},1) size(cwH{iLevel},2)];
  myImage = cwA{iLevel};
end
% Do the inverse DWT
fullRecon = cwA{nLevel};
for iLevel = nLevel:-1:1
  fullRecon = idwt2(fullRecon,cwH{iLevel},cwV{iLevel},cwD{iLevel},'db10',s(iLevel,:));
end

解决了我的问题。希望它能帮助别人。。。

相关内容

  • 没有找到相关文章

最新更新