Search code examples
matlabquadtree

Quadtree decomposition


I tried the quadtree decomposition using the following code, but every time I am getting an error.

>> I=imread('hyd.tif');

>> S=qtdecomp(I)

Or

>> I=imread('hyd.tif');

>> S=qtdecomp(I,.27)

Error:

??? Error using ==> qtdecomp>ParseInputs at 145

A must be two-dimensional

Error in ==> qtdecomp at 88

[A, func, params, minDim, maxDim] = ParseInputs(varargin{:});

Solution

  • The culprit is due to your image being in colour or RGB. Try converting the image to grayscale before using the algorithm.

    I = imread('hyd.tif');
    Igray = rgb2gray(I);
    S = qtdecomp(Igray);
    

    Also make sure that your image dimensions are of a power of 2 or else the quadtree decomposition algorithm will not work.