我有一个子图像的中心、倾角(方向)和边的测量值,我想从另一个图像中裁剪,例如:
到:
我设法以正确的倾斜度使用:
Mat img;
Point center;
float angle;
Mat rotation = getRotationMatrix2D(center, angle, 1.0);
warpAffine(img, img, rotation, img.size());
但我不知道如何用给定的边切割该区域...我该怎么做?
最佳答案
如果您可以旋转图像,那么您只需要其中一个角位置(例如,右下角)以及要裁剪的图像的宽度和高度。
话虽如此,您可以设置 ROI(感兴趣区域)并裁剪
cv::Rect RegionOfInterest(top_left_x, top_left_y, rectangle_width, rectangle_height);
cv::Mat outputImage;
outputImage = originalImage(RegionOfInterest).clone();
top_left_x
和 top_left_y
是左上角坐标,rectangle_width
和 rectangle_height
是宽度和您感兴趣的矩形的高度提取。
关于c++ - 裁剪给定角度的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30464958/