Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

(0,0) is the top left of the top left pixel. The bottom right of the bottom right pixel is at (cols, rows).

My first answer was wrong: (0,0) is the top left center of the top left pixel. pixel.

Code to show this:

cv::Mat img1, img2, affine;
img1.create(10, 10, CV_32F);
img1.setTo(1.0);
affine.create(2, 3, CV_64F);
affine.at<double>(0, 0) = cos(CV_PI);
affine.at<double>(0, 1) = sin(CV_PI);
affine.at<double>(0, 2) = 0;
affine.at<double>(1, 0) = -sin(CV_PI);
affine.at<double>(1, 1) = cos(CV_PI);
affine.at<double>(1, 2) = 0;

cv::warpAffine(img1, img2, affine, cv::Size(10, 10));

cv::imshow("img1", img1);
cv::imshow("img2", img2);
std::cout << img1 << "\n\n";
std::cout << img2 << "\n\n";
cv::waitKey();

Notice that the rotation by 180 degrees leaves the top left pixel perfectly intact. The bottom right So the center of the bottom right that pixel is at (cols, rows).(0,0).