【发布时间】:2018-11-18 01:46:30
【问题描述】:
我有一张使用imrotate 旋转的图像,如下所示:
Im_requete=imread('lena.jpg');
Im_requete_G=rgb2gray(Im_requete);
Im_requete_G_scale_rot = imresize(imrotate(Im_requete_G,-20), 1.2);
我正在尝试获取旋转图像的四个角的坐标(x,y),如下图所示(红色圆圈代表所需的角):
这是我的代码:
stat = regionprops(Im_requete_G_scale_rot,'Extrema'); %extrema detection of the image.
point = stat.Extrema;
hold on
figure,imshow(Im_requete_G_scale_rot)
hold on
for i = 2:2:length(point)
x = point(i,1);
y = point(i,2);
plot(x,y,'o');
text(x,y,num2str(i),'color','r')
end
但生成的坐标位于边缘某处,而不是我想要的位置,如第二张图片所示:
谁能告诉我这段代码有什么问题?
【问题讨论】:
-
围绕中心的旋转和图像的大小调整可以使用单个仿射变换来表示。有什么理由不能只使用与此旋转相对应的仿射变换将图像的角映射到旋转图像中的相应位置?除非这是一项家庭作业,否则我不确定您为什么要使用角点检测来执行此操作。
-
感谢您的回答;我已经尝试过corner()函数,但结果不理想
C = corner(Im_requete_G_scale_rot,'Harris',4); figure, imshow(Im_requete_G_scale_rot); hold on plot(C(:,1), C(:,2), 'r*'); -
Alex 没有建议你使用角点检测,他建议你在给定旋转角度的情况下计算角点的位置。这是一个涉及
cos和sin的简单练习。
标签: image matlab image-processing rotation corner-detection