![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/515372/image.png)
Reconstructing a 3D Surface from a 2D Surface using Mesh surface plot in Matlab
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am not good at this and I need your help to display a 3D RGB or true color surface from a 2D or single image surface using Mesh surface plot function.
Here's what I did:
I = imread('2d_test_image.png');
figure, imshow(I); title('2D RGB surface')
I = rgb2gray(I);
I = im2double(I);
figure, imshow(I);
shading interp
colormap gray
FV = mesh(I); title('3D GRAY surface')
Here is the 2D RGB image (i.e., 2d_test_image.png ).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/515312/image.png)
Here are results.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/515317/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/515322/image.png)
I can only display a 3D 'gray' surface. Can you please show me how to display the 3D RGB surface or how to modify the above source code so that I can generate the 'RGB colomap' or produce a 3D surface with colors similar to the 2D RGB surface colors?
0 个评论
采纳的回答
Iuliu Ardelean
2021-2-10
编辑:Iuliu Ardelean
2021-2-10
Hey!
Use surf instead of mesh
Looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/515372/image.png)
Here it is:
I = imread('2d_test_image.png');
Igray = rgb2gray(I);
Igray = im2double(Igray);
[x, y] = size(Igray);
[X, Y] = meshgrid(1:x,1:y);
FV = surf(X, Y, Igray, I, 'EdgeColor', 'none');
title('3D GRAY surface') % actually this is no longer a gray surface...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!