主题:请求四叉树算法的源程序,在此先谢谢了
lff1105
[专家分:0] 发布于 2007-09-15 16:11:00
本人是想利用此算法利用在土壤采样上,本意是想将四叉树与地统计结合,产生方差四叉树法,即VQT,来优化采样方案,但是我没有这种算法的源程序,希望各位朋友能给我一个好的建议,急需解决这个问题,谢谢大家了!
回复列表 (共7个回复)
沙发
windfoxe [专家分:70] 发布于 2007-09-15 21:01:00
具体不懂你要用四叉树干什么?
我用四叉树做过图像纹理区域分割,逐次将图像分割。
在父节点欲分割的四个子节点计算它们之间的纹理特征距离,如果距离小于阈值则不分割四叉树,如果距离大于阈值就分割四叉树。一直将图像分割至最小图像块。
我用vc编的,matlab也很方便的。
就是不知道你怎么用四叉树。
板凳
lff1105 [专家分:0] 发布于 2007-09-16 14:41:00
看到你写得这翻,我感觉轻松多,因为你说的跟我要的VQT整个原理是一样的,当然其中有一些不同的就是我这个是用来优化土壤采样方案的,也是跟不断地使方差变得最小,即小于阈制值,这整个步骤我可以把他发给你,我就是不知道他在matlab 底下是 怎么实现的?
你能给我一个联系的方式吗,让我把文章发给你,你帮我看看好吗?谢谢了.
顺便自我介绍一下,我是浙江大学的博士生,是matlab的初学者,希望以后能跟你多交流.谢谢.
3 楼
lff1105 [专家分:0] 发布于 2007-09-16 14:42:00
看到你写得这翻,我感觉轻松多,因为你说的跟我要的VQT整个原理是一样的,当然其中有一些不同的就是我这个是用来优化土壤采样方案的,也是跟不断地使方差变得最小,即小于阈制值,这整个步骤我可以把他发给你,我就是不知道他在matlab 底下是 怎么实现的?
你能给我一个联系的方式吗,让我把文章发给你,你帮我看看好吗?谢谢了.
顺便自我介绍一下,我是浙江大学的博士生,是matlab的初学者,希望以后能跟你多交流.谢谢.
4 楼
windfoxe [专家分:70] 发布于 2007-09-16 20:55:00
我的签名栏就有我的联系方式。
email和qq都有!
可以探讨一下。四叉树方法很简单,matlab运用很简单。就是具体要联系你的专业,和你的专业结合就可以实现了。
方法可以与你探讨。。。。。。。
也可以为您提供有偿源码服务!
5 楼
mikle [专家分:390] 发布于 2007-09-17 13:14:00
qtdecomp
matlab 里自带四叉树分解的函数
QTDECOMP Perform quadtree decomposition.
QTDECOMP divides a square image into four equal-sized square blocks, and
then tests each block to see if meets some criterion of homogeneity. If a
block meets the criterion, it is not divided any further. If it does not
meet the criterion, it is subdivided again into four blocks, and the test
criterion is applied to those blocks. This process is repeated iteratively
until each block meets the criterion. The result may have blocks of several
different sizes.
S = QTDECOMP(I) performs a quadtree decomposition on the intensity image I,
and returns the quadtree structure in the sparse matrix S. If S(k,m) is
nonzero, then (k,m) is the upper-left corner of a block in the
decomposition, and the size of the block is given by S(k,m). By default,
QTDECOMP splits a block unless all elements in the block are equal.
S = QTDECOMP(I,THRESHOLD) splits a block if the maximum value of the block
elements minus the minimum value of the block elements is greater than
THRESHOLD. THRESHOLD is specified as a value between 0 and 1, even if I is
of class uint8 or uint16. If I is uint8, the threshold value you supply is
multiplied by 255 to determine the actual threshold to use; if I is uint16,
the threshold value you supply is multiplied by 65535.
S = QTDECOMP(I,THRESHOLD,MINDIM) will not produce blocks smaller than
MINDIM, even if the resulting blocks do not meet the threshold condition.
S = QTDECOMP(I,THRESHOLD,[MINDIM MAXDIM]) will not produce blocks smaller
than MINDIM or larger than MAXDIM. Blocks larger than MAXDIM are split even
if they meet the threshold condition. MAXDIM/MINDIM must be a power of 2.
S = QTDECOMP(I,FUN) uses the function FUN to determine whether to split a
block. QTDECOMP calls FUN with all the current blocks of size M-by-M stacked
into M-by-M-by-K array, where K is the number of M-by-M blocks. FUN should
return a logical K-element vector whose values are 1 if the corresponding
block should be split, and 0 otherwise. FUN can be a FUNCTION_HANDLE,
created using @, or an INLINE object.
S = QTDECOMP(I,FUN,P1,P2,...) passes P1,P2,..., as additional arguments to
FUN.
Class Support
-------------
For the syntaxes that do not include a function, the input image can be
of class logical, uint8, uint16, or double. For the syntaxes that include
a function, the input image can be of any class supported by the
function. The output matrix is always of class sparse.
Examples
--------
View the quadtree decomposition of a matrix.
I = [1 1 1 1 2 3 6 6;...
1 1 2 1 4 5 6 8;...
1 1 1 1 7 7 7 7;...
1 1 1 1 6 6 5 5;...
20 22 20 22 1 2 3 4;...
20 22 22 20 5 4 7 8;...
20 22 20 20 9 12 40 12;...
20 22 20 20 13 14 15 16];
S = qtdecomp(I,5);
disp(full(S));
View the block representation of quadtree decomposition.
I = imread('liftingbody.png');
S = qtdecomp(I,.27);
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;
imshow(I),figure,imshow(blocks,[])
6 楼
mikle [专家分:390] 发布于 2007-09-17 13:14:00
其源代码分析,可以自己挖掘 matlab 代码
7 楼
lff1105 [专家分:0] 发布于 2007-09-19 21:50:00
谢谢你,mikle
我自己看看,有问题希望再讨论
我来回复