How to make an X by 3 matrix into a grid of points
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So currently I have a 262014x3 matrix that has 262014 coordinates of an image.
To be able to use this for my application it has to be a 3D matrix of binary points. So I want to put a point in a, let's say, 512x512x512 matrix (I know, I'll lose a lot of definition, that's not the concern), how would I go about that?
Just a side note, the initial matrix was made by using stlread (as found here http://www.mathworks.com/matlabcentral/fileexchange/29906-binary-stl-file-reader) And I'm only using the coordinates of the vertices.
0 commentaires
Réponse acceptée
Image Analyst
le 22 Juin 2014
Try this:
m3d = false(512,512,512); % Initialize binary image.
for row = 1 : size(coordinates, 1)
row = coordinates(row, 1);
col = coordinates(row, 2);
slice = coordinates(row, 3);
m3d(row, col, slice) = true;
end
7 commentaires
John D'Errico
le 22 Juin 2014
I'm confused. Subtract the min, then multiply by 511/(max - min), add 1. This will scale it to 1-512. Then round.
If you are truly memory limited, then use a bit smaller matrix.
If you really just want to visualize the points as a scatter cloud, then why not use plot3 in one call? If your goal is really to visualize this as an object, then use an alpha shape, or a convex hull if the set is convex.
Plus de réponses (1)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!