How to zoom an image using K-times zooming

Zooming is one of the essential concepts of image processing. It means to enlarge an image so that the details of that image become more transparent and visible. There are many applications of zooming that ranges from doing it through some lens or to a digital image on some system.

There are three most common zooming methods in image processing:

  • Pixel replication or nearest neighbor interpolation

  • Zero-order hold method

  • Zooming K-times

Common zooming methods

Each of the methods has its pros and cons. In this answer, we'll learn about zooming in on an image using a K-times zooming method.

K-times zooming method

K-times zooming is the most widely used and precise method because it covers the limitations of both pixel replication and zero-order hold zooming. Let's see how this method works:

Methodology

K-times zooming is performed through the following steps:

  1. We pick two adjacent pixels and subtract the smaller pixel from the greater one. The result of subtraction is also known as OP.

  2. After this, we divide the output (OP) with k, the alphabet k from the name is the zooming factor, add the result to the smaller pixel picked earlier, and put this value between the adjacent pixels.

  3. Again add the value (OP) to the value we got from the previous step and put the new value next to the previous put value.

  4. We'll repeat this process till we successfully place k1k-1 values in the existing image.

Note: We apply this method first row-wise and then column-wise.

Example

We'll understand this method using a 2 * 3 matrix, or we can say through an image of the dimensions with two rows and three columns. Suppose we have the following matrix, and we have to zoom it thrice using the K-times zooming method:

15

30

15

30

15

30

The zooming factor (k) in this example is 33, so we'll insert k1k-1 values that are 31=23-1 = 2 values.

To apply K-times zooming, we'll follow two steps:

  1. Row-wise zooming

  2. Column-wise zooming

Row-wise zooming

In the row-wise zooming, we pick the adjacent pixels, 15 and 30.

  • Step 1: Subtract larger from smaller pixels: 3015=1530 - 15 = 15

  • Step 2: Divide the result by zooming factor: 15/k=15/3=515/k = 15/3 = 5 (OP)

  • Step 3: Add OP to a smaller picked pixel: 15+OP=15+5=2015 + OP = 15 + 5 = 20

  • Step 4: Add OP to the result of step 3: 20+OP=20+5=2520 + OP = 20 + 5 = 25

We repeat this process two times as we insert k1k-1 values. Repeat the same process for the next two adjacent columns.

The new image would be:

15

20

25

30

20

25

15

30

20

25

15

20

25

30

Once we have inserted the values, sort the inserted values in ascending order, so there remain symmetric between the pixels.

15

20

25

30

25

20

15

30

25

20

15

20

25

30

Column-wise zooming

We'll follow the same procedure column-wise as we did with the rows. We'll copy the column pixels to their adjacent new column. The new image would be:

15

20

25

30

25

20

15

20

21

21

25

21

21

20

25

22

22

20

22

22

25

30

25

20

15

20

25

30

Result

The dimensions produced by the K-times zooming are 4*7, and the input image has 2*3 dimensions. The formula for the new image dimensions would be:

Advantages

The advantages of the K-times zooming method are as follows:

  • This method can zoom the image by any zooming factor than the pixel replication.

  • The image produced by this method is less blurry than the zero-order hold method.

Disadvantages

The disadvantage of the K-times zooming method is as follows:

  • This algorithm has an overhead of sorting the values at the end, which is an additional step to previous algorithms.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved