How to make an X by 3 matrix into a grid of points

2 visualizaciones (últimos 30 días)
Joph
Joph el 22 de Jun. de 2014
Respondida: DGM el 13 de Jul. de 2025
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.

Respuesta aceptada

Image Analyst
Image Analyst el 22 de Jun. de 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 comentarios
Joph
Joph el 22 de Jun. de 2014
Well the thing is the points from readSTL were from 93.137-98.463 for x, 121.354-127.352 for y, and 45.362-49.234 for z. So I just multiplied them by 1000 since scale isn't a problem, but the precision is still relevant and going down to 3 digits obscures the image too much.
And yeah, I guess I could get more memory, I was just trying to see if there was a less memory intensive answer available, but no worries.
Thanks for the help!
John D'Errico
John D'Errico el 22 de Jun. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

DGM
DGM el 13 de Jul. de 2025

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by