MATLAB Answers

using voxelized model, how to measured volume of an object?

2 views (last 30 days)
M.S. Khan
M.S. Khan on 30 Aug 2020
Edited: M.S. Khan on 30 Aug 2020
Hi Community members,
using the below code, i have voxelized the layer of an object. Please guide me how to measure its volume using bins. Thanks in advance for your coopeeration. Regards!!!
clc; clear ;
data = load('Slice_0_to_9.txt') ;
data = round(data) ;
x = data(:,1) ; y = data(:,2) ; z = data(:,3) ;
% x-values
dx = 0.1;
minx = min(x);
maxx = max(x);
first_x = floor(minx / dx) * dx;
last_x = ceil(maxx / dx) * dx;
x_edges_go_here = first_x : dx : last_x
% for y-values
dy = 0.1
miny = min(y);
maxy = max(y);
first_y = floor(miny / dy) * dy;
last_y = ceil(maxy / dy) * dy;
y_edges_go_here = first_y : dy : last_y
% z-values
dz = 0.1
minz = min(z);
maxz = max(z);
first_z = floor(minz / dz) * dz;
last_z = ceil(maxz / dz) * dz;
z_edges_go_here = first_z : dz : last_z
xbin = discretize(x, x_edges_go_here);
ybin = discretize(y, y_edges_go_here);
zbin = discretize(z, z_edges_go_here);
voxelized = accumarray([xbin(:), ybin(:), zbin(:)], 1);

  0 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!