Yuerno
Yuerno

Reputation: 843

When rotating an image about its center, why do you need to add/subtract the centroid?

I'm learning about image processing in class, and it's all going quite fast so I'm having a bit of trouble wrapping my head around the different concepts. In rotation specifically, I understand that you need to multiply each of the pixel coordinates of an input image by the rotation matrix to get an output image. However, when you are rotating an image around its center, you need to do a translation to subtract the centroid, then rotate, then add the centroid back in. What is the logic behind this, how does it work?

Upvotes: 0

Views: 776

Answers (1)

I.Newton
I.Newton

Reputation: 1783

In general, when you rotate an object, you rotate it about origin (0,0). But if you want to rotate the object about some other point, which in your case is centroid, you move the origin to that point by subtracting it. After rotation, when you want the output in the same coordinate system as you began with, you bring back the origin to its normal position by adding it back.

The images below demonstrate it to make better sense-

The object to rotate initially.

When you rotate it by 135 degrees anticlock. Output1

enter image description here

But if you want to rotate about centroid, move the origin there.

enter image description here

How it now looks -

enter image description here

Rotating the same 135 degrees anticlock now-

enter image description here

Getting back to the old coordinate system by adding back the centroid - Output2

enter image description here

Clearly the Output1 and Output2 are not same right, so subtracting and adding the centroid or not depends on about which point you want to rotate.

Upvotes: 5

Related Questions