0

在小波分解中检索图像系数(近似和详细)后,我想要近似和详细系数的四叉树结构。但每次我得到同样的错误。请帮忙。我试图使它成为 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{:});
4

1 回答 1

0

错误很明显。您的图像必须具有属于 2 次方的尺寸。因此,您需要调整图像大小以使其遵循这一点。 qtdecomp计算四叉树分解算法,此函数的前提条件是它需要具有每个维度为 2 的幂的图像作为输入。

你在另一个我提供了答案的问题中问了类似的问题。奇怪的是,你问的另一个问题是在这个问题之前 6 天,而你接受了我对另一个问题的回答。您遇到的问题或多或少是一回事。

四叉树分解

于 2014-05-11T00:58:25.440 回答