Octree implementation in matlab -

6 次查看(过去 30 天)
AMR
AMR 2013-1-25
Hello, I require some help in implementing octree algorithm for partitioning a 3D data set (x,y,z). Basically the algorithm goes like this. The entire dataset is split into 8 subspace and a threshold condition is used to check whether to proceed for further splitting. If threshold satisfies then split stops and the particular node is considered as the leaf node. Otherwise the split proceeds. The nodes which doesnt pass the threshold criteria is split again into 8 subspaces each for each node.This continues till the leaf node is reached in each of the dataset.
I have used the cell command to create cell with 8 matrices initially and have split the data - Level 1. I used the cellfun command to execute the condition for each matrix in the cell. So for the nodes that doesnot satisfy the threshold, I call my split function again. This goes on till all the nodes satisfy the threhold condition. The Question is how can I put it in a loop. I am finding it tricky because everytime, the number of input changes (8 , 8^2, 8^3...etc)and the split proceeds only for the nodes which doesnt satisfy the threshold condition.Otherwise it terminates and stores it as a leaf node.
My code is as follows
A = load('test4.txt');
[m,n]=size(A);
k=randperm(m);
B=A(k,:);
f1 =(floor(m/8));%first level
f1node =cell(8,1);
%************************************************************************** % To split the entire dataset into 8 subspaces %**************************************************************************
st=1; for i=1:7 f1node{i}=B(st:i*f1,:); st=1+i*f1; i=i+1;
end
f1node{8}=B(st:m,:); % to check the whether each matrix in the cell satisfy a particular % condition [level1,max_di]=cellfun(@threshold, f1node,'uniformoutput',false); max_di=cell2mat(max_di);
*while max_di<12
[f1node]=cellfun(@split,level1,'uniformoutput',false);
% To again check for the condition before further splitting
[level1,max_di]=cellfun(@threshold, f1node,'uniformoutput',false);
end
*
I am struck with executing the loop in matlab.Any suggestion on how to proceed with certainly help. Thanks in advance

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by