Scaling Images Up Let s=source image and d = destination image. When an image is scaled up, this means that for width(w) and height(h) w_d >= w_s, h_d >= h_s General algorithm to scale an image up is for x_d in range (0, w_d-1) { for y_d in range(0, h_d-1) { alpha_w = w_s/w_d // width ratio alpha_h = h_s/h_d // height ratio I_d(x,y) = bilinear_interpolation(I_s, x_d*alpha_w, y_d*alpha_h) } } Scaling will interpolate the intermediate values Aliasing occurs when we do not sample enough Temporal aliasing = the "wagon wheel effect" How do we fix aliasing? There are 2 general approaches 1) Sample more 2) Remove the high frequency context - a.k.a. filtering Gaussian filter - is a separable filter, which means doing 2D filtering is equivalent to doing 1D filtering in the x and y direction separately When you downsize an image, blur first (to avoid aliasing). Also use linear interpolation The gradient is an operator that acts on a continuous function. To apply it to an image which has a discrete domain (i.e. the intensity value of an image is only known at discrete points or pixels), we must use an approximation approach. You can definite a vector field on the image as follows Ix = [ I(x+1, y) - I(x-1,y) ] / 2 Iy = [ I(x, y+1) - I(x, y-1) ] / 2 The length of this 2d vector is called the gradient magnitude and can be computed as follows sqrt(Ix*Ix + Iy*Iy) = gradient magnitude = || grad I || This funciton gives you the amount of change at a pixel.