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

2 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2014-6-22
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 个评论
Joph
Joph 2014-6-22
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 2014-6-22
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.

请先登录,再进行评论。

更多回答(1 个)

DGM
DGM 2025-7-13

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by