Reproduced (http://www.cnblogs.com/HappyXie/archive/2011/03/02/1969434.html)//opencv 4 The rotation of the image at any angle
Need the support of inter Company's OPENCV.
OpenCV 4 rotation of an image at any angle
Image to be rotated iplimage* img_old
Returns the rotated image iplimage* img_tmp.
The angle of rotation, the unit degree.
Three different methods. Method Two is not fully tested, method one can meet most of the needs
Iplimage * Fitrotate (iplimage* img_old, double Angle,int method)
Method one extracts pixel quadrilateral, using sub-pixel precision
}
if (2==method)
{
Method Two The problem of affine transformation matrix using two-dimensional rotation requires that the input and output images be the same large rotation center is wrong
Cvwarpaffine (Img_old, DST, &m,cv_inter_linear,cvscalarall (0));//Small map
Small target image
To extend an image
Can only be treated differently in different quadrants within a certain angle
int Dx=int ((newwidth-img_old->width)/2+0.5);
int Dy=int ((newheight-img_old->height)/2+0.5);
uchar* old_ptr,*temp_ptr;
for (int y=0; yheight; y++)//In order not to cross the border
{
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.