【发布时间】:2013-10-27 21:05:58
【问题描述】:
我正在尝试在不使用 imrotate 的情况下执行自己的旋转图像算法。
clear all
img1 = imread('image1.jpg');imshow(img1);
[m,n,p]=size(img1);
thet = pi/6;
m1=round(m*1.5);
n1=round(n*1.5);
rotatedImg = zeros(m1,n1);
for i=1:m
for j=1:n
t = uint16((i)*cos(thet)-(j)*sin(thet)+m+100);
s = uint16((i)*sin(thet)+(j)*cos(thet));
if i>0 && j>0 && i<=m && j<=n
try rotatedImg(t,s,1)=img1(i,j,1);
catch
a=1;
end
end
end
end
figure;
imshow(rotatedImg);
但是由于某些原因,在某个角度,图像的某些部分被剪裁了,所以不是整个图像都在窗口上。我似乎无法弄清楚如何正确地做到这一点。似乎我每次都需要以不同的角度使窗口变大,这样图像就不会被剪裁。
我的图像也充满了黑点,我认为我需要进行某种插值。我该怎么办?
*我使用的图像是 (http://i.stack.imgur.com/kDdx5.jpg) 并以这些角度旋转 - pi/6, pi/2, ((pi/6)*4) *
【问题讨论】:
标签: matlab image-processing computer-vision