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

2 ビュー (過去 30 日間)
Joph
Joph 2014 年 6 月 22 日
回答済み: DGM 2025 年 7 月 13 日
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 Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by