0% found this document useful (0 votes)
14 views

Lecture 2

The document discusses different methods of interpolation used for discrete data such as digital images. It describes bilinear interpolation, which assumes linear variation between known data points, and bicubic interpolation, which enforces continuity of the first derivative to produce a smoother surface. Affine transformations that can be applied to images are also summarized, including translation, rotation, scaling, and shear operations. These transformations can be represented by matrix multiplication and applied to transform pixel locations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lecture 2

The document discusses different methods of interpolation used for discrete data such as digital images. It describes bilinear interpolation, which assumes linear variation between known data points, and bicubic interpolation, which enforces continuity of the first derivative to produce a smoother surface. Affine transformations that can be applied to images are also summarized, including translation, rotation, scaling, and shear operations. These transformations can be represented by matrix multiplication and applied to transform pixel locations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

2.1.

4 Interpolation

Discrete data such as digital images and related shiftmaps are by definition
known at discrete locations on a regular grid; they are functions of two variables, x and
y directions in this case and can be also referred as a surface since the value of the
function can be viewed as the z coordinate of a 3D point (x,y,z). Such functions can be
evaluated in between the discrete points using interpolation. A priori knowledge of the
behaviour of the actual data is beneficial in the choice of interpolation function, but
most can be interpolated using bilinear or better, bicubic interpolation. In image
processing, bicubic interpolation is preferred over bilinear as the former is better at
preserving fine details in scaling applications, while bilinear is far simpler to
implement. Bicubic interpolation is frequently used in the warping, scaling and
registration algorithms referred in this thesis.

O12 Q2 O22
Y2

y P

O11 Q1 O21
Y1

X1 x X2
Figure 2-4 Interpolation in a regular lattice.

Regardless of the order of the interpolation, the concept is to evaluate the value
of a point P which falls in between known values on a regular lattice as shown in Figure
2-4.

2.1.4.1 Bilinear Interpolation

In bilinear interpolation, it is assumed that values vary linearly along the grid
lines; however this is not true in any other direction, it takes a quadratic form as the
interpolation is performed in each direction in turn. The first step is to locate the four

34
closest points (O11, O12, O21, O22,) that surround P(x,y). The second step is to
interpolate along the x direction and evaluate the function at points Q1(x,Y1) and
Q2(x,Y2):
f(O 21 ) − f(O11 )
f(Q1 ) ≈ f(O11 ) + (x − X 1 )
X 2 − X1
2.3
f(O 22 ) − f(O12 )
f(Q 2 ) ≈ f(O12 ) + (x − X 1 )
X 2 − X1

Then the interpolation in the y direction is performed:


f(Q 2 ) − f(Q1 )
f(P) ≈ f(Q1 ) + ( y − Y1 ) 2.4
Y2 − Y1

Figure 2-5(a) shows the bilinear interpolation as a gray scale image in a 3 by 3


regular grid for which the values are shown; the same is plotted as surface mesh in
Figure 2-5(b), where the interpolated points (coarse mesh) are shown with an offset of
35 units on top of the uninterpolated points (fine mesh). Notice the curved surface on
the front right quadrant, and yet the corners of the patches are straight lines, indicating
that the surface curvature continuity is not maintained from one patch to the other, i.e.,
the interpolated surface is not continuous in its first derivative in all directions. Whilst a
grid of 3 by 3 points were used to demonstrate this shortcoming, the smallest grid that
can be interpolated using the bilinear method is 2 by 2, notable a single patch.

20 0 20

10 15 5

5 20 20
(a) (b)
Figure 2-5 Bilinear interpolation. (a) greyscale (b) mesh plot.

35
2.1.4.2 Bicubic Interpolation

Bicubic interpolation enforces the interpolated surface to be also continuous in


its first derivative in all directions, a significant improvement over the bilinear method.
However, the bicubic implementation requires at least 3 by 3 data points in order to
have enough constraints to calculate the x, y and xy cross derivatives. The interpolation
will be a 3rd order polynomial in the form:
3 3
f ( x, y ) ≈ ∑∑ aij x i y j 2.5
i =0 j =0

where the 16 coefficients aij are determined by imposing the continuity and first
derivative continuity constraints. Figure 2-6 shows the greyscale and mesh plot of the
same data points as for bilinear interpolation. The continuity of the first derivatives is
evident from the smoothness of the greyscale transition and from the surface curvature
of the mesh plot.

20 0 20

10 15 5

5 20 20
(a) (b)
Figure 2-6 Bicubic interpolation. (a) greyscale (b) mesh plot.

2.1.5 Affine Transformation

Mathematically speaking, an affine transformation is a linear transformation


followed by a translation in the form x a Ax + b . Affine transformation in the image
processing context is attributed to a set of simple transformations which are made
uniquely or as a combination of translation, rotation, scaling and shear. All these
transformations can be written in the form [92]:

36
x' = a11 x + a21 y + a31
2.6
y ' = a12 x + a22 y + a32

where the aij determine the mapping function of point (x,y) as mapped into point (x’,y’).
These coefficients can be collected and the two equations written in matrix form:
⎡ a11 a12 0⎤
[ x' y ' 1] = [ x y 1]⎢⎢a 21 a 22 0⎥⎥ = [ x y 1][T] 2.7
⎢⎣ a31 a32 1⎥⎦

The seemingly useless third column of the transformation matrix [T] is retained to allow
concatenation of multiple transformations by matrix multiplication.

The transformation matrix is applied to every pixel of an image unless


subregions have been defined; therefore the output image may or may not fit inside the
original image boundaries. These boundaries may need to be enlarged for intermediate
operations to avoid truncation, and then cropped back to the original size of the image.

2.1.5.1 Translation

Translation is simply the offsetting of all points in the x and y directions by


adding Tx and Ty to x and y, respectively:
⎡1 0 0⎤
⎢ ⎥
T=⎢0 1 0⎥ 2.8
⎢Tx Ty 1⎥⎦

2.1.5.2 Rotation

Rotation is carried out about the origin of the image. All points in the xy-plane
are rotated counter clockwise by an angle θ :
⎡ cos θ sin θ 0⎤
R = ⎢⎢− sin θ cos θ 0⎥⎥ 2.9
⎢⎣ 0 0 1⎥⎦

In the case of rotating an image, it is understood that it is rotated about its


centre point, therefore to perform such a rotation the image should be first translated
from its centre to its origin, rotated then moved back to its old centre.

37
2.1.5.3 Scale

Similarly to rotation, scaling works about the origin of the image, i.e., all the
distances are scaled with respect to the origin. The scale factors Sx and Sy in the x and y
directions can be different, therefore resulting in a differentially scaled image. Positive
scale factors less than unity have the effect of reducing whilst scale factors greater than
unity enlarge the image. Mirroring can be achieved by negative scale factors:
⎡S x 0 0⎤
S = ⎢⎢ 0 Sy 0⎥⎥ 2.10
⎢⎣ 0 0 1⎥⎦

Again, just like in rotation, it is understood that reducing or enlarging an image


is generally about its centre point, therefore to perform such a scaling the image should
be first translated to the origin, scaled then moved back to the centre.

2.1.5.4 Shear

The shear transform is analogous to distorting a rectangle into a parallelogram


by offsetting each row (column) proportional to its location to the first row (column).
Therefore, the shear transform along the x-axis keeps the y coordinates constant whilst
linearly translating the x coordinates with respect to y:
⎡ 1 0 0⎤
Hx = ⎢⎢ H x 1 0⎥⎥ 2.11
⎢⎣ 0 0 1⎥⎦

Similarly, the shear transform along the y-axis keeps the x coordinates constant
whilst linearly translating the y coordinates with respect to x:
⎡1 H y 0⎤
Hy = ⎢⎢0 1 0⎥⎥ 2.12
⎢⎣0 0 1⎥⎦

A combination of shear transforms is often used as a faster alternative to the simple


rotation transform [69].

38
Affine Transformation Examples

Type your text

Type your text

Type your text


both spatially and in amplitude. Typically, a frame grabber or digitizer is used to sample and
quantize the analogue video signal. Hence in order to create an image which is digital, we need
to covert continuous data into digital form. There are two steps in which it is done:
 Sampling
 Quantization
The sampling rate determines the spatial resolution of the digitized image, while the
quantization level determines the number of grey levels in the digitized image. A magnitude of
the sampled image is expressed as a digital value in image processing. The transition between
continuous values of the image function and its digital equivalent is called quantization.
The number of quantization levels should be high enough for human perception of fine shading
details in the image. The occurrence of false contours is the main problem in image which has
Image Sampling and Quantization:
The output of most sensors is a continuous voltage waveform whose amplitude and spatial
behavior are related to the physical phenomenon being sensed. To create a digital image, we
need to convert the continuous sensed data into digital form. This involves two processes:
sampling and quantization.

Basic Concepts in Sampling and Quantization:


The basic idea behind sampling and quantization is illustrated in Fig. 1. Fig. 1(a) shows a
continuous image, f(x, y), that we want to convert to digital form. An image may be
continuous with respect to the x- and y-coordinates, and also in amplitude. To convert it to
digital form, we have to sample the function in both coordinates and in amplitude. Digitizing
the coordinate values is called sampling. Digitizing the amplitude values is called
quantization.

The one-dimensional function shown in Fig. 1(b) is a plot of amplitude (gray level) values of
the continuous image along the line segment AB in Fig. 1(a). The random variations are due
to image noise. To sample this function, we take equally spaced samples along line AB, as
shown in Fig. 1(c). The location of each sample is given by a vertical tick mark in the bottom
part of the figure. The samples are shown as small white squares superimposed on the
function. The set of these discrete locations gives the sampled function. However, the values
of the samples still span (vertically) a continuous range of gray-level values. In order to form
a digital function, the gray-level values also must be converted (quantized) into discrete
quantities. The right side of Fig. 1(c) shows the gray-level scale divided into eight discrete
levels, ranging from black to white. The vertical tick marks indicate the specific value
assigned to each of the eight gray levels. The continuous gray levels are quantized simply by
assigning one of the eight discrete gray levels to each sample. The assignment is made
depending on the vertical proximity of a sample to a vertical tick mark. The digital samples
resulting from both sampling and quantization are shown in Fig. 1(d). Starting at the top of
the image and carrying out this procedure line by line produces a two-dimensional digital
image.

Fig. 2(a) shows a continuous image projected onto the plane of an array sensor. Fig. 2(b)
shows the image after sampling and quantization. Clearly, the quality of a digital image is
determined to a large degree by the number of samples and discrete gray levels used in
sampling and quantization.
Fig. 1: Generating a digital image (a) Continuous image (b) A scan line from A to B in the
continuous image, used to illustrate the concepts of sampling and quantization (c) Sampling
and quantization. (d) Digital scan line.

Fig. 2: (a) Continuous image projected onto a sensor array (b) Result of image sampling and
quantization.

You might also like