I = rgb2gray(imread('peppers.png')) ;
% If structured grid
[ny,nx] = size(I) ;
[X,Y] = meshgrid(1:nx,1:ny) ;
figure
ax = gca;
surf(X,Y,I)
shading interp
colormap(gray)
view(2)
set(gca,'Ydir','reverse')
%% If unstructured grid
dt = delaunayTriangulation(X(:),Y(:)) ;
p = dt.ConnectivityList ;
t = dt.Points ;
figure
ax = gca;
patch('faces',p,'vertices',t(:,1:2),'facevertexcdata',I(:),'facecolor','interp','edgecolor','none') ;
shading interp
colormap(gray)
view(2)
set(gca,'Ydir','reverse')