Clear Filters
Clear Filters

3D Binary Mask from Points

7 views (last 30 days)
Jeremy
Jeremy on 28 Sep 2016
Commented: Walter Roberson on 29 Sep 2016
I'm trying to create a binary mask (1 inside the object and 0 outside the object) from some Collada files. This file https://www.mathworks.com/matlabcentral/fileexchange/45687-colladaparser helped me convert the actual .dae files into "tri - contains a 3xNumTri list of vertices that form triangles" and "vertex - contains a list vertices used (Nvertices x 3)."
Now I need to create a binary mask (that is maybe 100 x 250 x 100), or something of that magnitude) where the value of the logical matrix is 1 inside and 0 outside the 3d object created by these points and faces (with the ultimate goal of creating a signed distance function whose zero level set represents the 3d object). Does anyone have any ideas how to create the binary mask or even just the signed distance function itself?
Note that I wouldn't mind using a different 3d object file format (like .obj or .3ds), but I still need to end up with a signed distance function. And the packages I've tried for .obj and .3ds do not work.

Answers (1)

Walter Roberson
Walter Roberson on 28 Sep 2016
  2 Comments
Jeremy
Jeremy on 28 Sep 2016
Edited: Jeremy on 28 Sep 2016
I saw a few of these, and I suppose I should ask a silly question now: is there a way to comprehensively test all points to a certain tolerance to see if they are in the polyhedron? (Like all possible combinations of (x,y,z) for x=a:0.01:b, y=c:0.01:d, z=e:0.01:f).
That is, I can't remember how to get that set of points I just described to be in the format [p1; p2; p3;...;pn] where p1 = (a,c,e) and pi = (xi,yi,zi)) and n = the total number of points
Walter Roberson
Walter Roberson on 29 Sep 2016
The general case is:
sets = {x, y, z}; %adjust this for situation
nset = length(sets);
[T1{1:nset] = ndgrid(sets{:});
output = zeros(numel(T1{1}), nset, class(T1{1}));
for K = 1 : nset
output(:,K) = reshape(T1{K}, [], 1);
end
clear T1
For the 3D case you can use
[T1, T2, T3] = ndgrid(x, y, z);
output = [T1(:), T2(:), T3(:)];
clear T1 T2 T3

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!