|
function [map]=plotbmp(fig)<BR>% 读取图象数据到矩阵<BR>[A, map] = imread(fig);<BR>% 得到图象信息<BR>info = imfinfo(fig);<BR>w = info.Width;<BR>h = info.Height;<BR>% 创建与图象大小相对应的网格<BR>[x,y] = meshgrid(1:w,1:h);<BR>z = x - y + y - x;<BR>i = 1;<BR>j = 1;<BR>% 用图象灰度值填充高度值<BR>while (i - 1) * w + j <= w * h<BR>z(i,j) = A(i,j);<BR>j = j + 1;<BR>if j > w<BR>j = 1;<BR>i = i + 1;<BR>end <BR>end;<BR>% 绘制三维图象<BR>meshc(x,y,z);<BR>% 绘制表面<BR>surf(x,y,z,'FaceColor','interp','EdgeColor','none','FaceLighting','phong')<BR><BR> |
|