3D binary matrix of a voxelised 3d model

7 views (last 30 days)
ELVIS
ELVIS on 19 Sep 2020
Commented: mariem on 12 Apr 2023
I have a voxelised 3d model (as cone30 v1 (1).obj which is attached as zip file) which should be represented in the form of 3D binary (as 0 and 1) matrix.
Can anyone please help me out in doing so. Your help will be highly appreciated.
Thanks in advance.
  5 Comments
ELVIS
ELVIS on 25 Sep 2020
I have modelled the cone in CAD modelling software and then converted model into voxel model uisng online voxilser application (https://drububu.com/miscellaneous/voxelizer/?out=obj).
My objective here is to load the model in matlab by means of 3D binary matrix.
Example: I give input as in form of 3D binary matrix (as rho) and I will be able to get output of a voxel model by the below mentioned function display_3D(rho)
function display_3D(rho)
[nely,nelx,nelz] = size(rho);
hx = 1; hy = 1; hz = 1; % User-defined unit element size
face = [1 2 3 4; 2 6 7 3; 4 3 7 8; 1 5 8 4; 1 2 6 5; 5 6 7 8];
set(gcf,'Name','ISO display','NumberTitle','off');
for k = 1:nelz
z = (k-1)*hz;
for i = 1:nelx
x = (i-1)*hx;
for j = 1:nely
y = nely*hy - (j-1)*hy;
if (rho(j,i,k) > 0.5) % User-defined display density threshold
vert = [x y z; x y-hx z; x+hx y-hx z; x+hx y z; x y z+hx;x y-hx z+hx; x+hx y-hx z+hx;x+hx y z+hx];
vert(:,[2 3]) = vert(:,[3 2]); vert(:,2,:) = -vert(:,2,:);
patch('Faces',face,'Vertices',vert,'FaceColor',[0.2+0.8*(1-rho(j,i,k)),0.2+0.8*(1-rho(j,i,k)),0.2+0.8*(1-rho(j,i,k))]);
patch('Faces',face,'Vertices',vert,'FaceColor','green');
hold on;
end
end
end
end
axis equal; axis tight; axis off; box on; view([30,30]); pause(1e-6);
toc
end
Rik
Rik on 25 Sep 2020
So you don't yet have a function that will load the obj file into Matlab? Is the result a triangular mesh?
And please format your posts with the toolbar buttons: have a read here.
If you ignore my question again I will ignore this thread. If you are not willing to read my questions carefully enough, I'm not willing to spend my free time helping you.

Sign in to comment.

Answers (1)

ELVIS
ELVIS on 26 Sep 2020
Sorry that I cannot make you understand the problem clearly.
Thanks for efforts taken by you in helping me out.
I have ffound solution of the problem with the help of my friend.
Sorry that I have wasted your valuable time.
  1 Comment
mariem
mariem on 12 Apr 2023
hello, can you please share the solution.
thank you in advance

Sign in to comment.

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!