Function File: S = qtdecomp (I)
Function File: S = qtdecomp (I, threshold)
Function File: S = qtdecomp (I, threshold, mindim)
Function File: S = qtdecomp (I, threshold, [mindim maxdim])
Function File: S = qtdecomp (I, fun)
Function File: S = qtdecomp (I, fun, P1, P2, …)

Performs quadtree decomposition.

qtdecomp decomposes a square image I into four equal-sized blocks. Then it performs some kind of test on each block to decide if it should decompose them further. This process is repeated iteratively until there’s no block left to be decomposed.

Note that blocks are not decomposed if their dimensions are not even.

The output is a sparse matrix whose non-zero elements determine the position of the block (the element is at top-left position in the block) and size of each block (the value of the element determines length of a side of the square-shaped block).

S = qtdecomp(I) decomposes an intensity image I as described above. By default it doesn’t split a block if all elements are equal.

S = qtdecomp(I, threshold) decomposes an image as described, but only splits a block if the maximum value in the block minus the minimum value is greater than threshold, which is a value between 0 and 1. If I is of class uint8, threshold is multiplied by 255 before use. Also, ifI is of class uint16, threshold is multiplied by 65535.

S = qtdecomp(I, threshold, mindim) decomposes an image using the threshold as just described, but doesn’t produce blocks smaller than mindim.

S = qtdecomp(I, threshold, [mindim maxdim]) decomposes an image as described, but produces blocks that can’t be bigger than maxdim. It decomposes to maxdim even if it isn’t needed if only threshold was considered.

S = qtdecomp(I, fun) decomposes an image I and uses function fun to decide if a block should be splitted or not. fun is called with a m-by-m-by-k array of m-by-m blocks to be considered, and should return a vector of size k, whose elements represent each block in the stacked array. fun sets the corresponding value to 1 if the block should be split, and 0 otherwise.

S = qtdecomp(I, fun, …) behaves as qtdecomp(I, fun) but passes extra parameters to fun.

See also: qtgetblk, qtsetblk.

Demonstration 1

The following code

 full(qtdecomp(eye(8)))
 %It finds 2 big blocks of 0 and it decomposes further where 0 and 1 are mixed.

Produces the following output

ans =

   1   1   2   0   4   0   0   0
   1   1   0   0   0   0   0   0
   2   0   1   1   0   0   0   0
   0   0   1   1   0   0   0   0
   4   0   0   0   1   1   2   0
   0   0   0   0   1   1   0   0
   0   0   0   0   2   0   1   1
   0   0   0   0   0   0   1   1

Package: image