How do I display a 3-D image in MATLAB using a function similar to IMAGESC for 2-D image?
6 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Edited: MathWorks Support Team
on 10 Mar 2016
I have a 3-D matrix, called A, with M-by-N-by-P dimensions. For example, A is a 16-by-16-by-16 matrix and I am storing intensity values to some of its locations. For example, in A(1,16,16) which is row 1, column 16 and page 16, the intensity value is 128. Then, in A(16,16,1) it is 255, but not all the locations will have values. These locations will have a value of zero. I am trying to view this 3D matrix according to its intensity values. I would like to view this matrix as a 3-D image.
Accepted Answer
MathWorks Support Team
on 10 Mar 2016
There is no MATLAB function that can directly display a 3-D matrix according to the intensity value.
To work around this issue, you can use the SCATTER3 function and use the indices of A as the X, Y, Z coordinates. Please see the attached example.
1 Comment
Walter Roberson
on 20 Sep 2015
Edited: Walter Roberson
on 20 Sep 2015
Demetri pointed out that the example code is missing. Here is some:
idx = find(A);
[X, Y, Z] = ind2sub(size(A), idx);
pointsize = 20;
scatter3(X(:), Y(:), Z(:), pointsize, A(idx));
colormap(gray(256));
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!