Bilinear Interpolation


Like most pixel-wise operations, bilinear interpolation can be quite expensive. Referring to Equation 1, suppose that x = 3.14 and y = 5.9. Bitmap images are typically represented as two-dimensional arrays. However, here the image rotation algorithm needs an indexing operation equivalent to f[3.14][5.9]. Clearly, such an operation is not valid with standard “plain-jane” C code. (It could, however, provide one with an interesting use of operator overloading, given access to a C++ image class.) Hence, the rotation algorithm needs to compute a pixel value approximating what it would be if it had the necessary precision to directly access the image intensity at f[3.14][5.9].

Essentially, bilinear interpolation is nothing more than a weighted mean. A local neighborhood is constructed, and weight factors a and b are computed (see Figure 4).

For this example, a = .14, b = .9, (ULx,ULy)=(3,5), (URx,URy)=(4,5), (LLx,LLy)=(3,6), and (LRx,LRy)=(4,6). Using these definitions, to compute the pixel intensity f(x,y), where x and y are not integers, the following set of equations hold:

g1 = (1-a) f(ULx,ULy)+(a) f(URx,URy)

g2 = (1-a) f(LLx,LLy)+(a) f(LRx,LRy)

f(x,y) = (1-b)g1 + (b)g2

Higher-order interpolative methods, such as “bi-cubic interpolation,” or cruder, but computationally faster interpolation methods, such as “nearest-neighbor interpolation,” are alternatives. Higher-order interpolation methods use polynomial functions in order to compute pixel intensities. Nearest-neighbor interpolation, as its name suggests, simply returns the closest (in proximity) pixel value. For example, here nearest-neighbor would return f(3,5). The OpenGL function glTexParameteri allows the programmer to specify the interpolation method OpenGL should use when scaling texture maps.