MATLAB 棋盘格图片校准
程序员文章站
2022-03-10 16:02:32
...
moveImg=imread('cheesBoard_Object.tiff');
moveImg=rgb2gray(moveImg);
[imagePoints,boardSize] = detectCheckerboardPoints(moveImg);%检测棋盘格角点
figure(1)
imshow(moveImg);
hold on;
plot(imagePoints(:,1),imagePoints(:,2),'ro');
% for i=1:length(imagePoints(:,1))
% str = [num2str(i)];
% text(imagePoints(i,1),imagePoints(i,2),str,'color','black');%显示信息
% plot(imagePoints(i,1),imagePoints(i,2),'ro');
% end
movingPoints=imagePoints;
hold off
%
fixedImg=imread('cheesBoard_1280_800_40.bmp');
% fixedImg=rgb2gray(fixedImg);
[imagePoints_fixedImg,boardSize_fixedImg] = detectCheckerboardPoints(fixedImg);
figure(2)
imshow(fixedImg);
hold on;
plot(imagePoints_fixedImg(:,1),imagePoints_fixedImg(:,2),'ro');
% for i=1:length(imagePoints_fixedImg(:,1))
% str = [num2str(i)];
% text(imagePoints_fixedImg(i,1),imagePoints_fixedImg(i,2),str,'color','black');%显示信息
% plot(imagePoints_fixedImg(i,1),imagePoints_fixedImg(i,2),'ro');
% end
hold off
tempPoints1=reshape(imagePoints_fixedImg(:,1),boardSize_fixedImg(1)-1,boardSize_fixedImg(2)-1);
tempPoints2=reshape(imagePoints_fixedImg(:,2),boardSize_fixedImg(1)-1,boardSize_fixedImg(2)-1);
fixedPoints1=tempPoints1(1:boardSize(1)-1,1:boardSize(2)-1);
fixedPoints2=tempPoints2(1:boardSize(1)-1,1:boardSize(2)-1);
fixedPoints=[fixedPoints1(:),fixedPoints2(:)];
mytform = cp2tform(movingPoints,fixedPoints, 'projective');%求出投影变化的矩阵
registered = imtransform(moveImg, mytform, 'bicubic');%进行变化
figure(3)
imshow(imadjust(registered));
上一篇: matlab画sigmoid函数
下一篇: 用C语言画简单的棋盘