Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why does this rotate method give the image dead space? OpenCV

I am using this method to rotate a cvMat, whenever I run it I get back a rotated image however there is a lot of deadspace below it.

void rotate(cv::Mat& src, double angle, cv::Mat& dst)
    int len = std::max(src.cols, src.rows);
    cv::Point2f pt(len/2., len/2.);
    cv::Mat r = cv::getRotationMatrix2D(pt, angle, 1.0);

    cv::warpAffine(src, dst, r, cv::Size(len, len));


When given this image:

enter image description here

I get this image:

enter image description here

The image has been rotated but as you can see some extra pixels have been added, how can I only rotate the original image and not add any extra pixels?

Method call:

rotate(src, skew, res); res being dst.