小波系数的四叉树分解

时间:2014-05-05 09:47:05

标签: matlab quadtree wavelet

在小波分解中检索图像系数(近似和详细)后,我想要四面体结构用于近似和详细系数。但每次我都得到同样的错误。请帮忙。 我试图使它的力量为3而不是2,但它可以提供帮助。可能是我在某个地方出错了。

code for image decomposition


X=imread('abc.tif');
close all
clf
image(X)
colormap('default')
axis ('image'); set(gca,'XTick',[],'YTick',[]); title('Original')
pause

dwtmode('sym')
wname = 'bior4.4'

t = wtree(X,2,'bior4.4');
plot(t)
pause
close(2)

[wc,s] = wavedec2(X,5,wname);

a1 = appcoef2(wc,s,wname,1);         
h1 = detcoef2('h',wc,s,1);           
v1 = detcoef2('v',wc,s,1);           
d1 = detcoef2('d',wc,s,1);           

a2 = appcoef2(wc,s,wname,2);
h2 = detcoef2('h',wc,s,2);
v2 = detcoef2('v',wc,s,2);
d2 = detcoef2('d',wc,s,2);

a3 = appcoef2(wc,s,wname,3);         
h3 = detcoef2('h',wc,s,3);           
v3 = detcoef2('v',wc,s,3);           
d3 = detcoef2('d',wc,s,3);           

a4 = appcoef2(wc,s,wname,4);         
h4 = detcoef2('h',wc,s,4);           
v4 = detcoef2('v',wc,s,4);           
d4 = detcoef2('d',wc,s,4);           

a5 = appcoef2(wc,s,wname,5);         
h5 = detcoef2('h',wc,s,5);           
v5 = detcoef2('v',wc,s,5);           
d5 = detcoef2('d',wc,s,5); 

对于我正在使用的四叉树:

S = qtdecomp(I,.27); %I is image in greyscale.
blocks = repmat(uint8(0),size(S));

for dim = [512 256 128 64 32 16 8 4 2 1];    
  numblocks = length(find(S==dim));    
  if (numblocks > 0)        
    values = repmat(uint8(1),[dim dim numblocks]);
    values(2:dim,2:dim,:) = 0;
    blocks = qtsetblk(blocks,S,dim,values);
  end
end

blocks(end,1:end) = 1;
blocks(1:end,end) = 1;

imshow(I), figure, imshow(blocks,[])

它显示的错误是:

??? Error using ==> qtdecomp>ParseInputs at 229
MAXDIM / MINDIM is not a power of 2

Error in ==> qtdecomp at 88
[A, func, params, minDim, maxDim] = ParseInputs(varargin{:});

or

??? Error using ==> qtdecomp>ParseInputs at 145
A must be two-dimensional

Error in ==> qtdecomp at 88
[A, func, params, minDim, maxDim] = ParseInputs(varargin{:});

1 个答案:

答案 0 :(得分:0)

错误很清楚。您的图片必须具有属于2的幂的尺寸。因此,您需要调整图像大小以便遵循此操作。 qtdecomp计算四叉树分解算法,该函数的前提条件是 NEEDS 使图像的每个维度为2的幂作为输入。

你在另一个问题上问了类似的问题我提供了答案。令人好奇的是,你问的另一个问题是在这个问题之前的6天前,你接受了我对另一个问题的回答。您遇到的问题或多或少都是一样的。

Quadtree decomposition