一、从不同的观察点观察物体 view(az,e1),az为方位角,e1为仰角,默认az=-37.5,e1=30
subplot(2,2,1);
mesh(peaks);
view(-37.5,30);
title('标准视角');
subplot(2,2,2);
mesh(peaks);
view(0,90);
title('从上往下');
subplot(2,2,3);
mesh(peaks);
view(90,0);
title('侧面观看');
subplot(2,2,4);
mesh(peaks);
view(-7,10);
title('视角4');
二、色彩处理
figure函数
colormap函数
getframe
gcf
imshow
%色彩处理
t=0:pi/20:2*pi;
z=peaks(20);
%使用色图着色colormap
figure(1);
colormap("summer");
surf(z);
title('summer');
fg1=getframe(gcf);
figure(2);
colormap("cool");
surf(z);
title('cool');
fg2=getframe(gcf);
figure(3);
colormap("pink");
surf(z);
title('pink');
fg3=getframe(gcf);
figure(4);
colormap("hot");
surf(z);
title('hot');
fg4=getframe(gcf);
figure(5);
colormap("spring");
surf(z);
title('spring');
fg5=getframe(gcf);
figure(6);
colormap("copper");
surf(z);
title('copper');
fg6=getframe(gcf);
close all;
figure(5);
subplot(231);
imshow(fg1.cdata);
subplot(232);
imshow(fg2.cdata);
subplot(233);
imshow(fg3.cdata);
subplot(234);
imshow(fg4.cdata);
subplot(235);
imshow(fg5.cdata);
subplot(236);
imshow(fg6.cdata);
三、利用色图以及shading进行三维曲面着色演示
%example
t=0:pi/20:2*pi;
z=peaks(20);
%使用色图着色
colormap("cool");
subplot(2,2,1);surf(z);
%shading改变着色
subplot(2,2,2);surf(z);shading flat;%平滑着色,相对光滑
subplot(2,2,3);surf(z);shading interp;%插值着色,最光滑
四、图形裁剪处理
%图形裁剪
%裁剪正弦>0.5部分的赋值,用常数NaN
x=0:pi/10:4*pi;
y=sin(x);
plot(x,y,'--k');
% hold on;
% i=find(y>0.5);
% x(i)=NaN;
% plot(x,y,'r');
%图形裁剪
%裁剪正弦>0.5部分的赋值,用常数NaN
x=0:pi/10:4*pi;
y=sin(x);
plot(x,y,'--k');
hold on;
i=find(y>0.5);
x(i)=NaN;
plot(x,y,'r');
五、对图形的基本操作
imread
%对图像的基本操作
img1=imread('111.jpg');
image(img1);
[imagDate,map]=imread("111.jpg");将图像以数据读出来