Clear Filters
Clear Filters

how to overlay the image on the surface?

1 view (last 30 days)
Elite cada
Elite cada on 26 Mar 2013
i want to overlay an image on the generated surface (which we generate by algorithms)
the problem is that when we try to overlay the image on generated surface, the result is coming but when i execute it again without the surface code the result is still same. i don't understand where this generated surface is getting saved so image automatically comes in that shape.
% make dummy test data%
N = 400;
X = 1:N;
Y = 1:N;
[X, Y] = meshgrid(X,Y);
Z = (X+Y)/20;
%mesh(Z);
%colormap(red);
%surf(X,Y,Z);
%axis([0 10 0 10 0 40]);
% read jpg and make same size as grid
im = imread('cameraman.tif');
% convert image to indexed colours
[im, map] = rgb2ind(im, 256);
% make figure
figure(1),clf
% make image same size as grid
subimage = im(1:N,1:N);
colormap(map)
% plot surf and use image as texture
s = surf(X,Y,Z);
set(s, 'faceColor', 'texture',...
'edgecolor', 'none',...
'cdata', subimage)

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!