【发布时间】:2017-04-22 13:04:37
【问题描述】:
我正在尝试在 Matlab xyz 3-D 空间中旋转 2D 图像。我想将图像 I 围绕 x 轴旋转一个角度 θ=i。我通过乘以旋转矩阵(定义为here)来做到这一点:
这是我的代码:
x = linspace(-1,1,size(I,1));
[x0,y0,z0] = meshgrid(x,x,1);
R = [1 0 0; 0 cosd(-i) -sind(-i); 0 sind(-i) cosd(-i)];
xy = [x0(:),y0(:), z0(:)]*R';
X = reshape(xy(:,1),size(x0));
Y = reshape(xy(:,2),size(y0));
Z = reshape(xy(:,3),size(z0));
rotatedI = interp3(x0,y0,z0,I,X,Y,Z, 'nearest');
rotatedI(isnan(rotatedI)) = 0;
我得到的错误是插值线:
Error using griddedInterpolant
Interpolation requires at least two sample points in each
dimension.
那么这里到底是什么问题,我该如何解决呢?
我很困惑,因为此代码在专门用于二维时可以正常工作。任何解释都非常感谢。
【问题讨论】:
标签: matlab image-processing rotation image-rotation