Concept of Sampling
Sampling is done only on an independent variable. For example, if we digitize x-axis in sampling.
Sampling is divided into two parts:
- upsampling
- downsampling
There are variations in the sampled signal which is due to noise. To reduce the noise more samples are taken which means more data or pixel which result in a better image with less noise present in it.
In an image, pixel is the smallest element which is represented in the form of a matrix.
In sampling, the number of samples taken in X-axis is continuous and refers to a number of pixels in that image.
Oversampling
As we have seen above, there are two types of sampling, up-sampling, and down-sampling.
Up-sampling is also known as oversampling.
In an image, oversampling means using a high-resolution image sensor as compare to camera output image resolution.
One of the oversampling applications in image processing is known as zooming.
Zooming
Increasing pixel quantity is known as Zooming. When we zoom in an image, more detail can be seen.
Increasing the number of pixels is done using oversampling.
Zooming has two steps:
- In a new location, new pixels are created.
- And assignment of the gray level to a new location.
Another, way to zoom an image is by zooming optically using the motor movement of the lens, and then the image is captured.
Optical Zoom vs. digital Zoom
Optical Zoom | Digital Zoom |
---|---|
Optical zoom is used by Photographer to capture an image without moving physically closer to that object. | Digital zoom is a part of digital cameras. It can crop the entire image, and the portion of an image which is zoomed can be digitally enlarged. |
In a digital camera, the optical zoom ratio is used to measure lens, that how much it can be zoomed to make the object appear closer. Optical zoom enlarges an image, and it keeps the resolution and sharpness of the image high. | Digital zoom crops the image from the center with the same ratio from all the sides. And the image results in the original dimension of the pixel. As this method involves cropping, so the image quality and resolution are reduced. |
There is no relation between the optical zoom and the resolution of an image. Because the optical zoom is used to enlarge the image and its quality depends on the megapixel of the camera. | As the digital camera can crop a portion of an image and enlarge it to its original size. Due to this, the quality of the image is reduced as compared to the original image. |
Optical zoom is useful when an image is taken in landscape or if we want a closer view of an object without reducing the quality of the image. For example, taking a picture of the rainbow in the sky. | Digital zoom is used to take images from closer to the object when the photographer wants to take pictures of a particular object For example, clicking pictures at the birthday party of the birthday boy. |
Zooming methods
There are three types of methods used in zooming; they are as follows:
- Pixel replication or (Nearest neighbor interpolation)
- Zero-order hold method
- Zooming K times
Pixel replication
Pixel replication is also known as Nearest neighbor interpolation. In this method, a copy is produced of the neighboring pixels. This algorithm works the same as zooming.
Working:
In this method, new pixels are generated from the originally given pixel. Each pixel is copied from its neighboring pixel n time row and column-wise, and we get a zoomed image.
For example, we have 2 row and 2 columns of an image. And we zoom the image twice.
ROW WISE ZOOMING:
When an image is zoom row-wise, it copies the pixels from row to the new cell
COLUMN SIZE ZOOMING:
Next step is to copy the pixel column-wise to the new adjacent column.
As we can see that the original image was having2 rows and 2 columns, but after zooming the image, it is converted into 4 rows and 4 columns.
Advantages
It is very simple, and we have to copy the pixels.
Disadvantages
When we zoom an image, the output is very blurry. As a result, we have a full blurred image.
Zero order hold
It is another method of zooming. Zero order hold is also known as zoom in twice, as it can only be zoomed twice.
Working
In this method, two adjacent elements are taken from the row, then elements are added, and the result is divided by two. The result is placed in between the elements.
For example:
We have 2 rows and 2 columns of an image and we zoom in the image twice.
Row Wise Zooming
When an image is zooming in row-wise, then rows are added (5+6) =11 and then it is divided by 2. We will get 5.5 approximate to 5 and the operation is performed in the second row.
Column Wise Zooming
When an image is zoomed column-wise, then columns are added (5+7) = 12 and then it is divided by 2. We will get 6, and this operation is performed in all the columns.
As we can see that the original image was having 2 rows and 2 columns but after zooming, the image it is converted into 3 rows and 3 columns.
It is very simple and it does not create a blurry picture.
Disadvantage
It works on the power of 2.
Reasons behind Twice Zooming
As we have seen in the above example, we have an image of 2 rows and 2 columns. If we want to zoom in an image 7 or 9 times then it cannot be done.
It can only zoom in the power of 2 i.e 2, 4, 8, 16, 32, etc.
K-Times zooming
K-Times Zooming is the perfect zooming algorithm. In this algorithm, k stands for the zooming factor.
Following are the steps to get a zoomed image which are used in both row and column:
- Two adjacent pixels are taken.
- Greater pixel is subtracted by a smaller pixel and the result is called OP.
- Now, OP is divided by the zooming factor (k).
- Now, the result is added in smaller pixel, and then it is placed in between those pixels.
For example:
We have 2 rows and 3 columns of an image. And we have to zoom in the image thrice.
In this case, the zooming factor (k) is 3. So, the number of values to be inserted is k-1 = 3-1 = 2.
Row Wise Zooming
Let’s take 1st two adjacent pixels. i.e. 2 and 3.
Now, subtract 3 from 2.
3-2=1.
Divide 1 by k
1/3=0.3
Let 0.3 be OP.
Add OP with the lower number
0.3+2=2.3 (approx 2)
And again add OP with a higher number
0.3+3=3.3
Note: We have calculated two values because we have to insert k-1 values.
Now, repeat the above steps for the next two pixels.
Column Wise Zooming
In column wise zooming, the same steps are performed as done in row-wise zooming.
As, we can see that the original image was having 2 rows and 3 columns but after zooming, the image it is converted into 4 rows and 7 columns.
Advantages
It can be zoomed to any factor, thrice or four times or even more.
Disadvantages
Cost of computation is increased due to the additional step in the end.