How to built a 3D binary volume array from set of X,Y,Z coordinates?
Hi Guys,
Could I get some help with building a single binary 3D matrix array from a set of 3D field coordinates data please
I have compiled the X,Y,Z field coordinates of the 1100 nodes into a single array. where it can be written as 3 column vectors each of size (1100 x 1).
>> Node_X = XYZ{1};
>> Node_Y = XYZ{2};
>> Node_Z = XYZ{3};
>> scatter3(Node_X,Node_Y,Node_Z)
I tried using scatter3 to visualize the 3D image and it gives the image. But I would like to represent this 3D image as a 3D binary matrix array I also tried using meshgrid, but there seems to be an error stating the size of the array to be too large.
I thought of converting all the 517 x 517 (XY slices) along the Z coordinate to a binary matrix.(slice by slice) and eventually combining the slices into a 3D binary volume.
Z_unique=unique(Node_Z(:)); Slice_bin= zeros (517,517);
XY=[Node_X, Node_Y];
for n=Z_unique
k=1;
for i=1:1189
if Node_Z(i)==n
n_slice(k,:)=[Node_X(i), Node_Y(i)]; k=k+1; end end Slice_bin(n_slice{1}, n_slice{2})=1; end % Stack these 2-D binary matrices into a single 3D matrix I=cat(length(n),Slice_bin{1},Slice_bin{2}); % Display image %imshow3Dfull function (Maysam Shahedi,2018) Image = squeeze(I);
figure,
imshow3Dfull(Image)
The binary image slices don't seem to show up using the above code. Is there any error in my coding? or any other way, I could build a 3D matrix from set of x,y,z field coordinates?
Any feedback/insights are greatly appreciated!
Thanks
3 Comments
Accepted Answer
1 Comment
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!