在使用matlab内置几何变换函数 fitgeotrans imwarp transformPointsForward 进行透视校正时遇到了一些问题
想要在透视校正后依然标出左下角方块的四个角点,但是不知道要怎么提取角点
I = imread([pn fn]); %读入彩色图像
figure('NumberTitle','off','Name','原始图像');
imshow(I);title('原始图像'); %显示原始图像
%% prepare
img = rgb2gray(I);
width = size(img,2);
height = size(img,1);
figure;imshow(img)
% moving_points = [0,0;
% 100,50;
% 0,50;
% 50,100];
moving_points = ginput(4);
hold on ; plot(moving_points(:,1),moving_points(:,2),'ro');
fixed_points = [0,0;
100,0;
0,200;
100,200];
%% method 1,use matlab function
tfom = fitgeotrans(moving_points,fixed_points,'projective');
X = moving_points(:,1);
Y = moving_points(:,2);
[x,y] = transformPointsForward(tfom,X(:),Y(:));
figure;plot(x,y,'ro');title('验证坐标点对齐')
grid on
tic; %计时
dst_img = imwarp(img,tfom);
t_sys = toc;
imshow(dst_img);title(['图像仿射变换后(系统函数),耗时(s):',num2str(t_sys)])