Matlab中DWT问题

发布于 2024-11-14 20:32:29 字数 1238 浏览 3 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷荒 2024-11-21 20:32:29

重写代码

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

解决了我的问题。希望它能帮助其他人...

Rewriting the code as

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

fixed my problem. Hope it helps others...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文