How to use voxels of different sizes to measure the volume of a 3D object using Matlab?

조회 수: 15 (최근 30일)
Hi Dear Community members,
i want to measure the volume of a cone using voxels. i am new in this field of voxels. Using the first link, a sphre of radius 8 has been voxelized. After voxelization, how can we count the total number of voxels. how to fix the size of voxels?
Using this method of author, how can we voxelize the cone to measure its volume. The attached file has xyz - coordiantes for the cone.
Thanks in advance for all cooperation and guidance.
% This scrypt illustrates the use of VoxelPlotter function to visualize
% voxel data stored in a 3d matrix
clear all
close all
clc
%Generating sinthetic input
gridesize=16;
R=8;
VoxelMat=zeros(gridesize,gridesize,gridesize);
for i=1:gridesize
for j=1:gridesize
for k=1:gridesize
if (i-gridesize/2)^2+(j-gridesize/2)^2+(k-gridesize/2)^2<R^2
VoxelMat(i,j,k)=1;
end
end
end
end
[vol_handle]=VoxelPlotter(VoxelMat,1);
view(3);
daspect([1,1,1]);
set(gca,'xlim',[0 gridesize], 'ylim',[0 gridesize], 'zlim',[0 gridesize]);

채택된 답변

Bruno Luong
Bruno Luong 2020년 9월 3일
편집: Bruno Luong 2020년 9월 4일
Vol estimate = 1.2692e+06
xyz = load('Cone_20000_points.txt');
[minxyz,maxxyz] = bounds(xyz,1);
N = 30*ones(1,3); % resolution, select with care
ijk = min(max(ceil((xyz-minxyz)./(maxxyz-minxyz).*N),1),N);
C = accumarray(ijk,1);
b = C > 0;
p = mean(C(b))
if p < 2 % Sanity check
warning('Your bin is too small, inaccurate result');
end
Vol = sum(b,'all') * prod((maxxyz-minxyz)./N)
  댓글 수: 11
M.S. Khan
M.S. Khan 2020년 9월 5일
Greetings Bruno, sorry for late reply. i was out of station.
Yes true, i got wrong results. Could you pleasue give me some tips how to count the number of voxels and how to measure the size of voxel.
M.S. Khan
M.S. Khan 2020년 9월 7일
i could not still figure out, how to measure the total number of voxels used. Please anyone can help me?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 3-D Volumetric Image Processing에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by