matlab 画3个图片吗,如何在2-D和3-D中在MATLAB中绘制图像(.jpg)?

对于2-D图

功能IMAGE是您正在寻找的。以下是一个例子:

img = imread('peppers.png'); %# Load a sample image

scatter(rand(1,20)-0.5,rand(1,20)-0.5); %# Plot some random data

hold on; %# Add to the plot

image([-0.1 0.1],[0.1 -0.1],img); %# Plot the image

3-D图…

IMAGE功能不再合适,因为除非从正上方观察轴(即沿着正z轴),否则不会显示图像。在这种情况下,您必须使用SURF功能在3-D中创建一个曲面,并将图像映射到其上。以下是一个例子:

[xSphere,ySphere,zSphere] = sphere(16); %# Points on a sphere

scatter3(xSphere(:),ySphere(:),zSphere(:),'.'); %# Plot the points

axis equal; %# Make the axes scales match

hold on; %# Add to the plot

xlabel('x');

ylabel('y');

zlabel('z');

img = imread('peppers.png'); %# Load a sample image

xImage = [-0.5 0.5; -0.5 0.5]; %# The x data for the image corners

yImage = [0 0; 0 0]; %# The y data for the image corners

zImage = [0.5 0.5; -0.5 -0.5]; %# The z data for the image corners

surf(xImage,yImage,zImage,... %# Plot the surface

'CData',img,...

'FaceColor','texturemap');

请注意,该表面固定在空间中,因此在旋转轴时,图像不会始终直接面向相机。如果您希望纹理映射表面自动旋转,以便它始终垂直于摄像机的视线,这是一个更加涉及的过程。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值