4

What is the method to use to rotate an image about a point that is not the image's center point using MATLAB?

Sulla
  • 7,631
  • 9
  • 45
  • 71

3 Answers3

5

Two rotations of the same angle are equal up to a translation. So you can just do rotation around the center, and then translate the image to put your own center of rotation at its old position.

Oli
  • 15,935
  • 7
  • 50
  • 66
  • "Two rotations of the same angle are equal up to a translation." Not quite. – denver Apr 29 '13 at 13:49
  • "Two rotations of the same angle are equal up to a translation." This depends on the center of the rotations and what other transformations are being performed and what order they are performed in. Two rotations of the same angle x by themselves equals one rotation of 2x - not a translation. I think you are trying to say the right thing, the way you say it however is unclear. – denver Apr 30 '13 at 14:24
0

The help to 'rotate' says:

ROTATE Rotate objects about specified origin and direction. ROTATE(H,[THETA PHI],ALPHA) rotates the objects with handles H through angle ALPHA about an axis described by the 2-element direction vector [THETA PHI] (spherical coordinates).
All the angles are in degrees. The handles in H must be children of the same axes.

...

ROTATE(...,ORIGIN) uses the point ORIGIN = [x0,y0,y0] as the center of rotation instead of the center of the plot box.

Msonic
  • 1,456
  • 15
  • 25
kaybe
  • 36
  • 1
0

To rotate about a point other than the origin you:

  1. Translate the point you want to rotate around to the origin. For example, if you want to rotate around (3,5), you would translate by (-3,-5).
  2. Perform your rotation.
  3. Undo the initial translation. So in my example you would now translate by (+3,+5).
denver
  • 2,863
  • 2
  • 31
  • 45
  • The two translations [are equivalent to a single translation](https://stackoverflow.com/questions/56728791/how-can-we-rotate-an-rgb-image-using-nearest-neighbor-interpolation-algorithm-ab/56730080#56730080). – Cris Luengo Nov 08 '19 at 01:36