How to manually rotate an image FH/FHV7
Introduction
Occasionally it is necessary to apply a rotation to an image without using the built in shape search or other position finding functions. Usually this is so the image is in the correct orientation for the operator. It is possible to accomplish this using the Position Compensation Unit.
Background
Let's say:
- w is the width of the image.
- h is the height of the image.
- is the angle of rotation in radians.
The image is rotated about the top left corner, so we can calculate the x and y offsets as:
Horizontal offset (xoffset):
xoffset = - (w cos(
Vertical offset (yoffset):
yoffset = - (w sin(
The below examples show how you might calculate a one-off static offset (manual calculation), or create an automated offset using the calculation unit.
For this example we will use a rotation of 180 degrees. We used an excel spreadsheet to calculate the offsets. Note that the dimensions of the image are 640x480.
X offset expression:
=-1*(B1*COS(RADIANS(B3))-B2*SIN(RADIANS(B3))-B1)/2
Y offset expression:
=-1*(B1*SIN(RADIANS(B3))+B2*COS(RADIANS(B3))-B2)/2
Set the position compensation unit to calculation mode. Use Bi-linear mode if 90 is not a factor of your rotation. Enter the offsets and rotation angle in the “Position” section.
The image will now be flipped 180 degrees.
For this example we will use a rotation of 22 degrees. We used the calculation unit to calculate the offsets. Note that the dimensions of the image are 640x480.
Flow:
Calculation unit:
X Offset Expression:
-(640*COS(U1.D00)-480*SIN(U1.D00)-640)/2
Y Offset Expression:
-(640*SIN(U1.D00)+480*COS(U1.D00)-480)/2
Position Compensation:
Result: