1 内容介绍
为了解决因散乱点云数据量较大而给点云的存储、传输和应用带来的不便,基于线性八叉树编码方法,结合排序与差分编码、改进的游程编码、算术编码等方法,提出了一种散乱点云的压缩方法.此方法不改变点云数据的精度,只改变测量点的顺序.由于散乱点云具有无序性,因此可以将本方法视为无损压缩.该方法在压缩率上明显优于已有的点云压缩方法和商业软件.对提出的方法在不同的点云密度和数据精度下的压缩率进行了比较研究,发现在点较密集,且精度较低的情况下压缩效果更好.创新之处在于用合理的点云索引方法组织和编码点云,根据编码表现出的特点有选择地综合和改进了多种编码压缩方法,获得了较好的压缩效果.
2 仿真代码
function [Codes,Octree] = GenOctree(points)
tic
mcode = Morton(points);
Lmax = ceil((size(mcode,2)/3));
pointNum = size(mcode,1);
pointID = 1:pointNum;
nodeid = 0;
proot.nodeid = nodeid;
proot.childPoint={pointID};
proot.occupancyCode=[];
proot.parent=0;
Octree(1:Lmax+1) =struct('node',[],'level',0);
Octree(1).node=proot;
% Octree(1).nodeNum = 1;
for L=1:Lmax
Octree(L+1).level = L;
NodeTemp(1:min([pointNum,8^(L-1)])) = struct('nodeid',nan,'childPoint',{[]},'parent',0,'occupancyCode',[]);
nodeNum = 0;
for node = Octree(L).node
for ptid = node.childPoint
PId = ptid{:};
if isempty(PId)
continue
end
PId = pointID(PId);
nodeid=nodeid+1;
Node.nodeid = nodeid;
Node.childPoint=cell(1,8);
Node.parent=node.nodeid;
n = L-1;
mn = mcode(PId,1+n*3:3+n*3);
idn = bin2dec(mn)+1;
for i = 1:8
Node.childPoint(i)= {PId(idn==i)};
end
% Node.occupancyCode = flip(~cellfun("isempty",Node.childPoint));
% fast code
Node.occupancyCode = ismember(8:-1:1,idn);
nodeNum = nodeNum+1;
NodeTemp(nodeNum)=Node;
end
end
Octree(L+1).node= NodeTemp(1:nodeNum);
end
Octree(1)=[];
toc
% fprintf('bpp before entropy coding:%f bit\n',nodeid*8/pointNum);
% Nodes = arrayfun(@(S)S.node,Octree,'UniformOutput',false);
% Codes=cellfun(@(S)arrayfun(@(S)S.occupancyCode,S,'UniformOutput',false),Nodes,'UniformOutput',false);
% Codes = bin2dec(num2str(cell2mat([Codes{:}]')));
Nodes = [Octree.node]';
Codes = bin2dec(num2str(cell2mat({Nodes.occupancyCode}')));
end
function mcode= Morton(A)
n = ceil(log2(max(A(:))+1));
x = dec2bin(A(:,1),n);
y = dec2bin(A(:,2),n);
z = dec2bin(A(:,3),n);
m = cat(3,x,y,z);
m = permute(m,[1,3,2]);
mcode = reshape(m,size(x,1),[]);
% mcode = bin2dec(mcode);
end
3 运行结果
4 参考文献
[1]危育冰. 基于八叉树编码的散乱点云数据压缩[J]. 武汉大学学报:工学版, 2020, 53(8):6.