This chapter does not appear in the book.
Java supports the well-known affine operations: translation, scaling, and rotation, so named because parallel lines in the image stay parallel after a transformation, although lengths and angles may change. But there are occasions when affine transformations aren't enough, especially in many computer vision applications where a perspective view of a scene needs to be manipulated. The perspective transformation is known by various names, including perspective warping, projectivity, collineation, and homography. A simple example is shown below.
A computer vision related way of understanding the transformation is in terms of adjusting the view of a 3D scene. The viewpoint in the source image is facing into the scene, while the destination image has moved the viewpoint so it is 'looking' at the scene from an angle.
A common use for perspective transformation is to 'correct' an angled view so the viewpoint is pointing directly into the scene (as below).
I've implemented this kind of transformation in my Warper application (see below). The user selects four points in the left-hand image, and the quadrilateral is transformed into a rectangle (or square) displayed in the right-hand panel.
In terms of viewpoints, the camera position in the source image is off to the left while in the destination image the viewpoint is facing the building.
Perspective transformation isn't available in Java, so I'll be employing the Java Advanced Imaging (JAI) library (where it's known as perspective warping). JAI supports several interesting kinds of warping, including polynomial and grid warping, which allows for more flexible distortion effects to be applied to an image.