我认为您要求获取原始纹理的样本[u,v]
。您可以使用interp2 http://www.mathworks.com/help/matlab/ref/interp2.html.
假设纹理样本位于z
并且您想要新样品z2
。插入原始纹理[u,v]
, use:
z2 = interp2(x,y,z,u,v);
另一方面,如果您想将“变形”纹理映射回规则间隔的网格[x2,y2]
, use griddata http://www.mathworks.com/help/matlab/ref/griddata.html:
[x2,y2] = meshgrid(1:N2,1:M2);
z2 = griddata(u,v,z,x2,y2);
Update:
下面是一些示例代码,展示了如何使用真实数据执行此操作。使用标准化坐标可以让事情变得更容易。
% get texture data
load penny
z = P;
% define original grid based on image size
[m,n] = size(z);
[a,b] = meshgrid(linspace(0,1,n), linspace(0,1,m));
% define new, differently sized grid
m2 = 256;
n2 = 256;
[x,y] = meshgrid(linspace(0,1,n2), linspace(0,1,m2));
% define deformed grid
u = sqrt(x);
v = y.^2;
% sample the texture on the deformed grid
z2 = interp2(a,b,z,u,v);
% plot original and deformed texture
figure
subplot(2,1,1)
surface(a,b,z,'EdgeColor','none')
axis ij image off
colormap gray
title('original')
subplot(2,1,2)
surface(x,y,z2,'EdgeColor','none')
axis ij image off
colormap gray
title('deformed')
这是结果: