matlab 纹理画刷,matlab – 如何使用纹理贴图绘制曲面

我不认为你可以用Matlab的内置命令和功能做你想做的事.但是使用

my other answer中的技术和高分辨率版本的网格可以为您完成.

“高分辨率”是指具有更密集数据点的非均匀网格的插值版本.这用于在更密集的数据点处对纹理进行采样,因此可以使用surf的texturemap特征进行绘制.但是,您不能使用普通的2D插值,因为您需要保留不均匀的网格形状.这就是我提出的:

function g = nonUniformGridInterp2(g, sx, sy)

[a,b] = size(g);

g = interp1(linspace(0,1,a), g, linspace(0,1,sy)); % interp columns

g = interp1(linspace(0,1,b), g', linspace(0,1,sx))'; % interp rows

请注意,您必须调用此方法两次才能独立插入X和Y点.这是原始网格和每个方向上有10个点的插值版本的示例.

以下是如何使用具有interp2和texturemap的高分辨率网格.

function nonUniformTextureMap

% define the non-uniform surface grid

X = [310,270,330; 430,410,400; 480,500,520];

Y = [300,400,500; 300,400,500; 300,400,500];

Z = [300,330,340; 300,310,330; 290,300,300];

% get texture data

load penny % loads data in variable P

% define texture grid based on image size

% note: using 250-550 so that a,b covers the range used by X,Y

[m,n] = size(P);

[a,b] = meshgrid(linspace(250,550,n), linspace(250,550,m));

% get a high-res version of the non-uniform grid

s = 200; % number of samples in each direction

X2 = nonUniformGridInterp2(X, s, s);

Y2 = nonUniformGridInterp2(Y, s, s);

% sample (map) the texture on the non-uniform grid

C = interp2(a, b, P, X2, Y2);

% plot the original and high-res grid

figure

plot(X(:),Y(:),'o',X2(:),Y2(:),'.')

legend('original','high-res')

% plot the surface using sampled points for color

figure

surf(X, Y, Z, C, 'edgecolor', 'none', 'FaceColor','texturemap')

colormap gray

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值