I’ve been always wondering how to create some interesting profile photos, so as to show off to the guys on facebook or twitter. Of course the photo should be different with others, which should not be simply photoshoped. Here comes a simple idea: why not spread a photo on a surface?
With matlab, it’s definitely not hard to make one. I referred to the matlab document , at Coloring mesh and Surface Plots. The “surf” function is a classic tool to plot surface. Inputting a meshgrid matrix with certain spatial shape, it will plot the surface out. Then we can play with the color property of the surface, so that the color accord with the our photo property.
The procedure goes like this:
- Import a graph to matlab, transform the RGB image to an index image.
- Create a surface you want, like sphere, cylinder, you name one.
- Use “surf” function to plot the surface.
- Change the”Texture mapping” properties of the surface, with the image.
Here are the codes:
G= imread(‘filepath & file name’); % load an image
[X,map] = rgb2ind(G,256); % Convert RGB image to indexed image
% Create a surface
[theta,~]=meshgrid([-pi:0.1:pi,pi],[-pi:0.1:pi,pi]);
%[x,y]=meshgrid(10*cos(theta),10*sin(theta));
x=10*cos(theta);
y=10*sin(theta);
[~,z]=meshgrid(1:length(x));
surf(x,y,z) %plot the surface
h = findobj(‘Type’,'surface’); % get the object of the surface
set(h,’CData’,flipud(X),’FaceColor’,'texturemap’,'EdgeColor’,'none’) % Change the surface property
colormap(map) % change colormap
rotate3d on
Advertisement

