令G表示一幅图像, 将G分割成n个子区域G1, G2, ···, Gn的过程就叫分割
四叉树的分解步骤
1、将图像分成大小相同的区域。
2、阈值判断
3、像素点合并
4、过程迭代
clear;
z=1;
b=imread('veg.png');
I=rgb2gray(b);
figure(1);
imshow(I);
title('o image');
[m,n]=size(I);
figure(2);
imhist(I);
title('histogram of original image');
mindim=4;
S = qtdecomp(I,@Split,mindim,@Predicate);
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;