Rotating an image in C/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.

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:
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.

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

Check this hope it helps .
Other questions on stack overflow on the same topic experts opinion on it.

libgd has image rotation functions.

There is no built-in way of accomplishing this in C++, short of writing your own function for manipulating binary data, which yields other problems like "How do I decompress a jpg/png in C++?"
Your best bet is a 3rd party graphics library such as libSDL

Related

Visual Odometry in opencv (possibly using RGBD)

I am attempting to implement a visual odometry solution in opencv, and running into a few problems. This is quite a broad question, so I apologise in advance, however I have a number of questions.
My understanding of the problem currently is:
Obtain some model to represent the correspondence between two successive images, be that optical flow or feature matching.
Obtain the fundamental (and then essential if needed) matrix from these point correspondences.
Calculate [R|t] from that.
I am aware of the findFundamentalMat function in openCV, but I think that only takes 2D point matches? In Scaramuzza and Fraundorfers paper 'Visual Odometry - pt1' they suggest that 3-D to 2-D correspondences will be most accurate.
I guess then my question is can I use the depth data retrieved from a kinect, giving me 3-D feature points, be used in opencv to give me an egomotion estimation?
I've also taken a look at solvePnP, but as far as I'm aware this only solves for a single frame (for when you know the real model space coordinates of features, like with a fiducial marker)
Although I did consider if I track 3D points between two frames, solving the perspective in the first frame, then in the second frame with the same points should give me a transformation between the two?
I apologize for this badly formulated question, I am still new to computer vision. Rather than attempting to answer this question if it is too much of a minefield, I would be appreciative of a point to any related literature or opencv tutorials for odometry. Thanks.
There is an example rgbdodometry.cpp in opencv\samples\cpp folder.
Have you seen it?

C++: Creating Polygons from images' transparency

Alright guys..
I'm at a loss here. I've been trying to code an image to polygon converter to no avail, it's really bugging me. It's supposed to create a polygon from the transparency of an image (the non transparent part is the polygon). I've seen programs that do it, but they were closed-source and really expensive. It's not just edge-detection, it's polygon generalization and hole-detection as well, all this in a Box2D compatible, triangulated polygon.
Please hand me some tips on this, or a library name, or an algorithm or something..
Thanks!
I suggest looking at the openCV library. It has several useful algorithms and tools for
image processing. I think you can accomplish your goal with it.
Good luck.

Implementing the warp/liquify tool in C++

Im looking for a way to warp an image similar to how the liquify/IWarp tool works in Photoshop/Gimp.
I would like to use it to move a few points on an image to make it look wider than it was originally.
Anyone have any ideas on libraries that could be used to do this? I'm currently using OpenCV in the same project so if theres a way using that it would be easiest but I'm open to anything really
Thanks.
EDIT: Heres an example of what im looking to do http://i.imgur.com/wMOzq.png
All I've done there is pulled a few points out sideways and thats what im looking to do from inside my application
From this search 'image warp operator source c++' i get:
..... Added function 'CImg ::[get_]warp()' that can warp an image using a deformation .... Added function 'CImg ::save_cpp()' allowing to save an image directly as a C/C++ source code. ...
then CImg could do well for you.
OpenCV's remap can accomplish this. You only have to provide x and y displacement maps. I would suggest you can create the displacement map directly if you are clever, and this would be good for brush-stroke manipulation similar to Photoshop's liquify. The mesh warp and sparse point map approach is another option, but essentially computes the displacement map based on interpolation.
You may want to take a look at http://code.google.com/p/imgwarp-opencv/. This library seems to be exactly what you need: image warping based on a sparse grid.
Another option is, of course, generate displacements yourself and use cv::Remap() function of OpenCV.

Scaling Rotation Shearing Reflection algorithms

i use EASYBMP library and i want to know the most effective way to scale , rotate , shear and reflect algorithm. i want the most optimized to do it.
The most effective way to scale, rotate, shear and reflect is to use the power of your graphics card - for example through OpenGL.
If you still want to do bitmap pixel operations yourself, typically you do this using linear algebra. This is not super easy to figure out, so I recommend finding some good study material, for example this book.
Instead of telling you how to use EASYBMP (which looks like crap), I'm going to suggest you use Magick++ instead. It supports BMP and has all the methods you ask for built-in.
Please refer to the Wikipedia link for the transformation matrices

C++ library for rotating a point over a given axis?

Does anyone know of a graphing library for simple transformation of a point from one coordinate system to another coordinate system which is rotated by a angle and some point transformation and just for 2d?
And any graphing tool for plotting and verifying the same visually?
double[3][3]
GDAL includes pretty much every graphic transform you could ask for, and while it is big and hence takes some time to get used to, it is a great framework to move forward with.
This isn't a library, but it's a blog by someone who does this kind of thing:
http://polymathprogrammer.com/
It's got some good theory if you want to know the "behind the scenes".
The Angtigrain Geometry library contains code that can do this, and you can also go farther and use it for drawing as well, but you don't have to. You should look at the agg::trans_affine class in the agg_trans_affine.h file.
Dave