how to calculate voxel image volume ?

26 次查看(过去 30 天)
Hi,
I am nex in matlab coding.
I am using voxel image function to drow voxels on a point cloud.
the code is runing and it gives a good plot. But the problem is that i do not know how to estimate the volume of my voxelized object ?
anyone can help ?
I already use volume function or [C,V] like alphashape or convexhull, but it doesn't work.
Thank's
  2 个评论
Walter Roberson
Walter Roberson 2022-8-31
is it https://www.mathworks.com/help/vision/ref/pcmapndt.html that you are using?
Moussa DIEDHIOU
Moussa DIEDHIOU 2022-8-31
Hi,
the code is :
ptclouds = load('exemple.xyz');
Pts = ptclouds(:,1:3);
vs = [0.5, 0.5, 0.5]; % voxel size
vxl = voxel_image(Pts, vs);
Thank's

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2022-8-31
Try regionprops3 or just sum the binarized image to count the voxels.
  3 个评论
Walter Roberson
Walter Roberson 2022-8-31
Image Analyst is not available through email.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2022-8-31
discretize() each coordinate axis separately, getting an index number for each point. Use accumarray() with the combined indices, and count 1. Afterwards the volume is nnz() of the count times the volume of each voxel.
  3 个评论
Walter Roberson
Walter Roberson 2022-8-31
N = 500;
data = randn(N,3) .* [20 10 15];
ptc = pointCloud(data);
%pcshow does not work in MATLAB Answers
xyz = ptc.Location;
scatter3(xyz(:,1), xyz(:,2), xyz(:,3)); %instead of pcshow for Answers
minxyz = floor(min(xyz,[],1));
maxxyz = ceil(max(xyz,[],1));
dx = .5; dy = .25; dz = .5;
xidx = 1 + floor((xyz(:,1) - minxyz(1))/dx);
yidx = 1 + floor((xyz(:,2) - minxyz(2))/dy);
zidx = 1 + floor((xyz(:,3) - minxyz(3))/dz);
counts = accumarray([xidx, yidx, zidx], 1);
volume = nnz(counts) .* (dx .* dy .* dz)
volume = 31.2500
volshow(counts, 'BackgroundColor', [0.8 0.8 0.8]);
Moussa DIEDHIOU
Moussa DIEDHIOU 2022-9-1
移动:Image Analyst 2022-9-1
It works ! Thank you so so much for your help Roberson.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by