Reputation: 63616
I rotated the image from the left to the image on the right using
image = cv2.warpAffine(image, R, dst_size, flags=cv2.INTER_LINEAR)
where dst_size
is (547, 363)
, and I've modified R so that the original image should fit in the new dimensions.
I show the image with cv2.imshow('rect post-rotation', img)
to show the image on the right. You can see that it appears clipped to a size of (363, 547)
, even though when I print out the img shape, I get (547, 363, 3)
.
Why does the shape of the image not reflect the shape of the displayed image?
Upvotes: 1
Views: 305
Reputation: 808
you need to set the destination size to the rotated size ie:
cv::Size dst_size(imOrig.size().height,imOrig.size().width);
alternatively you can use transpose and flip for 90 degree rotation:
cv::Mat imRot90 = imOrig.t();
cv::flip(imRot90 ,imRot90 ,1);
cheers
Upvotes: 1