Scaling

A scaling transformation alters the size of an object.

This operation can be carried out for polygons (or you pixel-image) by multiplying the coordinate values (x,y) of each vertex (or each pixel) by scaling factors xScale, yScale to produce the transformed coorinates(x', y').

Scaling relative to the origin (0,0) :

x'= x*xScale

y'= y*yScale

, where xScale and yScale are the scaling factors in the x and y directions respectively.

Scale Up

Objects transformed with the above equation are both scaled and repositioned.

Also, it will create many "holes" in the resulting image. We need to decide how to fill these "holes" in order to maintain the relative object proportions.

We can also represent this equation by using programming syntax:

new_pixel[x*xScale][y*yScale]= orginial [x][y]

Let's apply the scaling to a digital image. That mean, every pixel of the image is scaled by the scale factors.

Example: xScale=2, yScale=2

For example:

The new position of pixel (3,3) with xScale=2, yScale=2:

new_pixel[3*2][3*2]= orginial [3][3]

==> new_pixel[6][6]= orginial [3][3]

That mean, the pixel at point (3,3) will be copied to point (6,6)

Handling Empty Pixels - Copying

Solution --- Copy pixel values from neighbours

But if there are eight neighbours, which one to copy?

Common approach - just copy any one!

Result:

Example: xScale=2, yScale=2 with pivot point = (0,0)


Actually, different software have different algorithms to solve this problem (Interpolation is a mathematical method of creating missing data):


Nearest Neighbor vs Bilinear

Let's do it by using pen and graph paper:

8X Zoom

1X Zoom