OpenCV图像旋转

时间:2019-02-15 22:09:13

标签: c++ opencv image-processing image-rotation

我有一个图像full_image_map,它已使用以下代码旋转了某个angle

Mat rotated_full_map_image;
Point2f src_center(full_map_image.cols/2.0F, full_map_image.rows/2.0F);    
Mat rot_mat = getRotationMatrix2D(src_center, angle, 1.0);
warpAffine(full_map_image, rotated_full_map_image, rot_mat, full_map_image.size());

我还使用以下方法在旋转图像中找到了一个点的坐标:

Point rotated_centre;
Point2f p(some_x,some_y);  
rotated_centre.x = rot_mat.at<double>(0,0)*p.x + rot_mat.at<double>(0,1)*p.y + rot_mat.at<double>(0,2);
rotated_centre.y = rot_mat.at<double>(1,0)*p.x + rot_mat.at<double>(1,1)*p.y + rot_mat.at<double>(1,2);

但是,我的原始图像full_image_map比宽高得多。因此,当我将其旋转90度并指定旋转图像的大小为full_map_image.size()时,大部分旋转后的图像都会被切除,因为它尝试仅使其适合所述大小。这类似于this answer

我的问题:如何以任意给定角度正确执行此旋转并仍然使用相同的方法在旋转的图像中查找点的坐标?我在c ++中使用opencv。

0 个答案:

没有答案