Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating an image in C/C++

I need code for rotating an image in C++ which functions like imrotate function of matlab. Please suggest a good link. Or if someone can provide the code for imrotate.

Or at least please explain the algorithm.

Its not a homework. I need this code for my project. And we can use any external library or code.

like image 367
avd Avatar asked Feb 17 '10 04:02

avd


People also ask

How do I rotate an image in C sharp?

<asp:ListItem>Rotate 180 degree Clockwise with a horizontal flip and vertical flip</asp:ListItem> <asp:ListItem>Rotate 180 degree Clockwise with a vertical flip</asp:ListItem> <asp:ListItem>Rotates 270 degree Clockwise but not flip the image</asp:ListItem>

What command rotates images?

rotate left: Shift + Ctrl + R or [ rotate right: Ctrl + R or ]


2 Answers

OpenCV2.0 has several computer vision and image processing tools. Specifically warpAffine (by defining the rotation matrix) will solve your problem with rotating an image.

The 2x3 transformation matrix mentioned in the documentation is as follows: alt text

where θ is the angle of rotation and tx and ty is the translation along the x and y axes respectively.

You can get the source code here.

Also, OpenCV2.0 has many MATLAB-esque functions like imread, etc.

like image 78
Jacob Avatar answered Sep 17 '22 23:09

Jacob


Magick can help you. Read this PDF and search for rotate.

like image 29
vpram86 Avatar answered Sep 21 '22 23:09

vpram86