How to save the output of 'surf' into a 3-D matrix?
Show older comments
Hi,
I input a 2-D image to ' surf' to generate a 3-D surface image. I would like to save the output of ' surf' in the form of a 3-D matrix as follows.
Assume a 2-D (2x2)image;
image=[2 0; 6 2]
image =
2 0
6 2
Now, I would like to represent this image as a 3D surface matrix; image3d of size (2x2xC). The third dimension (i.e. C) here stands for the number of sub-images generated from the input image based on the individual pixel values.
For example, if I assume that I will consider 7 sub-images (i.e. sampled slices); given that the maximum pixel value is 6 (+1 for zero pixel-value)in the input image. I will have C=7, and my image3D would be of size 2x2x7, and it will presumably look as follows:
image3D(:,:,1) =
NaN 0
NaN NaN
image3D(:,:,2) =
NaN NaN
NaN NaN
image3D(:,:,3) =
2 NaN
NaN 2
image3D(:,:,4) =
NaN NaN
NaN NaN
image3D(:,:,5) =
NaN NaN
NaN NaN
image3D(:,:,6) =
NaN NaN
NaN NaN
image3D(:,:,7) =
NaN NaN
6 NaN
Assuming that my understanding of the way ' surf' works is correct, how to implement this in Matlab? Is there a feasible way to extract the result generated by ' surf' and store it in a 3-D matrix as shown above?
The reason for doing this is that I need to input the 3-D image generated by ' surf' to a program designed to handle a 3-D volume matrix.
I read the documentation of ' surf' where it mentions that some sampling procedure is followed to generate the 3-D surface image, but I did not find any information on how to store the result in a matrix format. http://www.mathworks.com/help/techdoc/ref/surf.html
Thanks in advance for your help,
Khalid
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!