The main goal of this computer lab is to understand the geometrical transformation of image spatial coordinates. We concentrate on the global transformations which means that all coordinates undergo the same transform. For simplicity we narrow to image rotations.
The secondary goal is to use the Fourier analysis to estimate the angle of rotation automatically. Modern consumer oriented devices are often without optical viewfinder and too small to be held firmly during acquisition. This frequently results in "falling horizon". The image is softly slanted which is easily correctable by a post-processing.
The process can be split in two parts: geometrical transformation of spatial coordinates and intensity interpolation. For details, look at the lecture slides (slides 61-90).
2D Rotation
Rotations of coordinates
Note that, in Matlab, we can realize the above transform by a matrix multiplication. If we organize the set of all coordinates in a [2xN] matrix the result will be again [2xN] matrix of transformed coordinates. It is much faster than to loop over all coordinates. The code is more readable, too. |
You can implement your own, option nearest neighbour is
fairly straightforward, optinally you may employ the Matlab function
interp2
.
There is hardly a method that would work for any
image. However, if we assume that the image contains relevant strong
edges in particular direction we design a simple approach based on an
analysis of the Fourier spectra. For this, we employ the radon
transform, see the Matlab function radon
.
input image | log(im_Pfft) | Radon transform | projections through the image center |
The graphical Matlab help, doc radon
, provides the
necessary explanation we need. We will not go into theoretical details
of the transform.
Assignment
We recommend to start working on it already during the lab.