I have a tif image which I need to rotate by an angle theta keeping the cg and coordinate axes constant.(i have attached my .tif image). In the example given below, i have rotated the image by 45 degree anticlockwise but it is getting distorted and the cg is also moving. Any help is appreciated.
to

8 Comments

What is "the cg"?
What does keeping the coordinate axes constant mean?
In what way is your image distorted?
How do you rotate the image?
Jan
Jan on 7 Feb 2018
Edited: Jan on 7 Feb 2018
Please attach the image instead of posting it on an external service. Otherwise the thread becomes meaningless, if you drive is cleaned up.
How did you apply the rotation yet? How can you keep the coordinate axes constant if you rotate this image? Do you want to crop the pixels outside the original dimensions?
Busy Bee
Busy Bee on 7 Feb 2018
It is a .tif image. I tried to attach it but the site won't accept it. If there's any other way, please tell me. I will upload it.
Busy Bee
Busy Bee on 7 Feb 2018
Edited: Busy Bee on 7 Feb 2018
Cg=Centre of the polygon. Say it is at (a,b). After rotation, the centre of the rotated polygon will remain at (a,b). I understand that the axes will change. sorry for that.
Rotating the image means I just need to rotate the image at the centre around the z axis. (Assuming that x and y axes are as shown in the above image.)
Busy Bee
Busy Bee on 7 Feb 2018
I extracted the perimeter pixels and then individually rotated them using the rotation matrix and then plotted them. But the area of the polygon is changing in that process.
Are we talking about rotating an image around an arbitrary point (which is not the centre of the rectangular image) or rotating a polygon whose vertices are known around its centroid?
The two are fundamentally different.
Busy Bee
Busy Bee on 7 Feb 2018
Rotating the polygon whose vertices are known around its centroid.
Jan
Jan on 7 Feb 2018
@Busy Bee: Really? You have the coordinates of the vertices? (By the way: coordinates are not "known around a centroid") And you want to attach a TIF file? Why not providing the positions as code?

Sign in to comment.

 Accepted Answer

Guillaume
Guillaume on 7 Feb 2018
Edited: Guillaume on 8 Feb 2018
"Rotating the polygon whose vertices are known around its centroid."
Not sure why a tif image was mentioned then.
Assuming you're on R2017b or later:
polygon = polyshape(vertices); %vertices is a Nx2 matrix of points
[centroidx, centroidy] = centroid(polygon);
rotated_polygon = rotate(polygon, angle, [centroidx centroidy]);
plot([polygon rotated_polygon])

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Asked:

on 7 Feb 2018

Edited:

on 8 Feb 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!