1 / 5

# x 1

The green polygon represents the position of an image after it has been arbitrarily translated, rotated, and scaled with respect to the original x1y1 coordinate system. All of the values shown here are known. Note the width of the polygon is (xmax-xmin) and the height is (ymax-ymin). x 1. ymin.

## x 1

E N D

### Presentation Transcript

1. The green polygon represents the position of an image after it has been arbitrarily translated, rotated, and scaled with respect to the original x1y1 coordinate system. All of the values shown here are known. Note the width of the polygon is (xmax-xmin) and the height is (ymax-ymin) x1 ymin xmax - xmin p py ymax h x2 y2 ymax - py xmin px xmax - px xmax y1 w

2. The green polygon now represents the new position of the image after it has been auto-scaled and auto-translated such that it has the maximum size possible in order to fit within the window as well as to be centered within the window. The position q of the polygon’s origin at x2y2 with respect to x1y1 is unknown, as are the distances d and e. e x1 d q qy d x2 y2 s’ (ymax – py) qx s’ (xmax – px) y1 e

3. We know the new scale factor s’ from min( h/(ymax-ymin), w/(xmax-xmin) ). Applying this scale factor, the total width of the scaled image is s’(xmax-xmin) and the total height is s’(ymax-ymin). The distances shown in blue are also just the scaled values we knew from before. e x1 d q qy d x2 y2 s’ (ymax – py) qx s’ (xmax – px) y1 e

4. Solving for qx and qy Known quantities: xmax, xmin, ymax, ymin, px, py, w, h Computed quantities: s’=min( w/(xmax-xmin), h/(ymax-ymin) 4 unknown quantities: d, e, qx, qy From inspection: w = qx + s’(xmax-px) + d h = qy + s’(ymax-py) + e Also: w = 2d + s’(xmax-xmin) or d = ½ (w – s’(xmax-xmin) ) h = 2e + s’(ymax-ymin) or e = ½ (h – s’(ymax-ymin) ) 4 equations in 4 unknowns can be solved by substituting the equations for d and e into the first two equations above: w = qx + s’(xmax-px) + ½ (w – s’(xmax-xmin) ) h = qy + s’(ymax-py) + ½ (h – s’(ymax-ymin) ) Rearranging terms: qx = w - s’(xmax-px) - ½ (w – s’(xmax-xmin) ) qy = h - s’(ymax-py) - ½ (h – s’(ymax-ymin) )

5. Final step Now that qx and qy are solved for, you can use them to replace the values px and py in the transformation matrix. However, the computed scaling factor s’ should not simply be substituted into the existing scaling matrix, since the original scaling matrix already contains some existing scaling factor s. Instead, the new scaling factor should be computed as s * s’. The value of this product becomes the new scaling factor in the scaling matrix.

More Related