Spatial Resolution (down sampling and up sampling) in image processing
A digital image is a two-dimensional array of size M x N where M is the number of rows and N is the number of columns in the array. A digital image is made up of a finite number of discrete picture elements called a pixel. The location of each pixel is given by coordinates (x, y) and the value of each pixel is given by intensity value f. Hence, the elements in a digital image can be represented by f(x, y).
The term spatial resolution corresponds to the total number of pixels in the given image. If the number of pixels is more, then the resolution of the image is more.
In the down-sampling technique, the number of pixels in the given image is reduced depending on the sampling frequency. Due to this, the resolution and size of the image decrease.
The number of pixels in the down-sampled image can be increased by using up-sampling interpolation techniques. The up-sampling technique increases the resolution as well as the size of the image.
Some commonly used up-sampling techniques are
- Nearest neighbor interpolation
- Bilinear interpolation
- Cubic interpolation
In this article, we have implemented upsampling using Nearest neighbor interpolation by replicating rows and columns. As the sampling rate increases, artifacts will be seen in the reconstructed image.
However, by using bilinear interpolation or cubic interpolation, a better quality of the reconstructed image can be attained. Both Down sampling and Up Sampling can be illustrated in greyscale for better understandings because while reading images using OpenCV, some color values are manipulated, So we are going to convert the original input image into a black and white image.
The below program depicts the down sampled and up sampled representation of a given image:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course