Previous | Next --- Slide 49 of 69
Back to Lecture Thumbnails
marshmallow

Wouldn't it be the same if we interpolated vertically first? Since we're iterating linear interpolation, I don't think order matters.

keenan

@marshmallow Can you make this argument more formal by actually writing out some equations that show these two orderings are equivalent?

marshmallow

@keenan Yes! If we interpolate vertically first, we get:

(1-t)f(0,0) + tf(0,1) and (1-t)f(1,0)+tf(1,1)

Then, for the bilinear expression, we get:

(1-s)((1-t)f(0,0) + tf(0,1)) + s((1-t)f(1,0) + tf(1,1))

After distributing the s terms and rearranging, we get:

(1-s)(1-t)f(0,0) + s(1-t)f(1,0) + (1-s)tf(0,1) + stf(1,1)

Taking out (1-t) from the first two terms and t from the last two terms, we get:

(1-t)((1-s)f(0,0) + sf(1,0)) + t((1-s)f(0,1) + sf(1,1))

And this last expression is the same as the bilinear expression in the slide, which we got from interpolating horizontally first.

keenan

@marshmallow Great! :-)

rbunny

Would we always take the closest 4 points? What happens at the edges of the image?

keenan

@rbunny Yes, for bilinear interpolation you always take the four closest points (which always make a square), and construct a function interpolating the values at these four points. Except, as you say, at the boundary. Here you have to decide what boundary behavior you want. One possibility is to just use the boundary value "twice," e.g., if you fall of the left side of an image where the closest two values above and below are $a$ and $b$, then interpolate the four values

aa bb

Alternatively, in some contexts it makes sense to "wrap around" and grab the values from the other side of the image---consider for instance a repeating brick texture like the one we saw in our lecture on texture mapping. The OpenGL API, for instance, offers several possible behaviors for texture sampling (GL_REPEAT, GL_CLAMP_TO_EDGE, etc.).

OpenGL texture modes