Text on Sphere-MATLAB CODE
We can see how to wrap a text around a sphere. First obtain the x,y and z co-ordinates of the sphere.These co-ordinates can be used as an input for surface object.
Surface object generates sphere using the co-ordinates. Example:[x,y,z]=sphere(25); surface(x,y,z);
Now read a text image and convert it into binary. Label the components in the image. You can also check how to label components without BWLABELfunction in MATLAB. Now use the labeled image as a CDATA value in surface object.
Example: surface(x,y,z, ‘CDATA’,matrix);
MATLAB CODE:
%Input a text image
A=imread('quotes.png');
A=~im2bw(A);
B=bwlabel(A,8);
F=double(B);
mytext=flipud(F);
% Create the surface.
[x,y,z] = sphere(100);
figure,surface(x,y,z,'CData',mytext,'FaceColor','texturemap','FaceLighting','phong','EdgeLighting','phong','EdgeColor','none');
%set the colormap. Some built-in colormaps are pink, copper, jet, hot...
colormap pink;
%Create light object
light('position',[1 2 0 ],'Style','infinite','color',[0.8 0.7 0.8]);
light('position',[-2 -3 0 ],'color',[0.8 0.7 0.8]);
%Specify the viewpoint
axis square off
view(12,0);
Another Example: To create a GLOBE from a WORLD MAP
0 comments:
Post a Comment