After each split, a test is necessary to determine whether each new region needs further splitting. The criterion for the test is the homogeneity of the region. There are several ways to define homogeneity, some examples are:
where r and c are row and column, N is the number of pixels in the region and
An example incorporation would be that the variance of a region be less than a specified value in order to be considered homogeneous.
The splitting results in a partitioned image as shown below to 3 levels.
Each level of partitioning can be represented in a tree-like structure.
MATLAB function: Quadtree decomposition
S = qtdecomp(I, threshold, [mindim maxdim])
I = imread('images/cameraman.jpg'); S = qtdecomp(I, 0.4); 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; figure(1); subplot(1,2,1); imshow(I); title('Original Image'); subplot(1,2,2); imshow(blocks,); title('Output Image');