views:

298

answers:

2

How can I use the qtdecomp(Image,threshold) function in MATLAB to find a quadtree decomposition of an RGB image?

I tried this:

Ig = rgb2gray(I);       % I is the rgb image
S = qtdecomp(I,.27);

but I get this error:

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

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

Also I get this error:

??? Error using ==> qtdecomp>ParseInputs
Size of A is not a multiple of the maximum block dimension

Can someone tell me how can I do it?

+1  A: 

One obvious error... In the code above you are still passing the original RGB image I to the QTDECOMP function. You have to pass Ig instead:

S = qtdecomp(Ig,.27);
gnovice
fixed the error... need to resize the image as a power of 2.
Tasbeer
A: 

There are two problem with the code in your original post:
1) The first error is because you need to supply Ig, the greyscale version of your image to the qtdecomp function, rather than the colour version I:

S = qtdecomp(Ig, .27);

2) The second error is because for the function qtdecomp, the image's size needs to be square and a power of 2. I suggest you resize the image in an image editor. For example, if your image is 1500x1300, you probably want to resize or crop it to 1024x1024, or perhaps 2048x2048.
You can find the size of the greyscale version of your image with this MATLAB command:

size(Ig)

To crop it to the 1024x1024 in the top-left corner, you can run this MATLAB command:

Ig = Ig(1:1024, 1:1024);
AlexC