【发布时间】:2018-03-17 18:57:09
【问题描述】:
我正在尝试在没有嵌入 Matlab 功能的情况下执行图像旋转。 但我仍然收到此错误: 使用错误。' 未定义 ND 阵列上的转置。请改用 PERMUTE。
interp2 中的错误(第 130 行) V = V.';
但我不知道为什么会出现这样的错误,同样我不知道如何自定义函数 interp2 或 PERMUTE 以使其正常运行(我在 Matlab 中使用过 help)。
您能帮忙定制一下代码吗?
提前致谢!
clc; clear all; close all;
input_image = imread('mri.png');
Z = double(input_image);
Size = size(Z);
[X,Y] = meshgrid(1:Size(2), 1:Size(1));
%Center of an image
c = Size(end:-1:1)/2;
%Angle of rotation
angle = 45;
t = angle*pi/180;
%Making the rotation
ct = cos(t);
st = sin(t);
Xi = c(1) + ct*(X - c(1)) - st*(Y - c(2));
Yi = c(2) + st*(X - c(1)) + ct*(Y - c(2));
%Interpolation
Zi = interp2(X, Y, Z, Xi, Yi);
figure()
subplot(121); imshow(I); title('Original image');
subplot(122); imshow(uint8(Zi)); title('Rotated image without embedded
function');
【问题讨论】:
标签: image matlab matlab-figure