Zooming Images Using Interpolation Techniques
Zooming Images Using Interpolation Techniques
Zooming Images Using Interpolation Techniques
Abstract
In this report, we did analysis on converting small scale images to large scale images using
bilinear interpolation on MATLAB. We explained the code for zooming images and gave few
examples clearly showing the difference between the original and zoomed version of the image.
Bilinear Interpolation
In mathematics, bilinear interpolation is the extension of linear interpolation for interpolating
functions of two variable on a regular 2D grid. The key idea is to perform linear interpolation
first in one direction and then again in the other direction. Although each step is linear in the
sampled values and in the position, the interpolation as whole is not linear rather quadratic in
sample location.
Algorithm
Interpolation problem can be written as
𝑓(𝑥, 𝑦) ≈ 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑦 + 𝑎3 𝑥𝑦
Where the coefficients can be written as:
Code Explanation
1. We made a code(function) for bilinear zooming, which takes the image and zooming factor
as input.
2. Reading the image file of the types (.jpg, .png etc.) using imread command which gives us
an array of class uint8, values range from 0 to 28-1 (255).
3. Converting the data type of image into class of int16, values range from -215 to 215-1
(32767) using cast command because class uint8 does not support negative values and
integers greater than 255. So, cast command trim values in image too large to be mapped
into int16.
4. Then we used imshow command which reads grayscale image and specifies display range
and since it does not support class int16 so, we converted it into class uint8 and executed
the command.
5. After that we get the size of image by using size command and stored height, width and
depth of the image.
6. Then we applied for loops to map the pixels of the image to a new zoomed array leaving
gap between them equal to the zooming factor and using imshow command the new
mapped image is displayed.
7. Now, using bilinear interpolation the unknown pixels are calculated. The code is written
such that already mapped values are not recalculated and the unknown pixels are
approximated to the nearest known pixels. The coordinates of unknown pixels are
calculated.
8. Using the equation of bilinear interpolation, we get the final array of zoomed image and
displayed it.
9. At last we saved this image with new name using imwrite command.
Examples
Conclusion
After writing this report, we are able to explain what bilinear interpolation is and how can we
relate it to the large scale imaging. There are vast applications of numerical analysis techniques
in digital technology and this is one of those applications. Hence we used this technique to
zoom in various images.