Bilinear Interpolation
To compare pixels that are not at integer grid points, we resample the image.
Assume image is locally bilinear. 
I(x,y) = ax + by + cxy + d = 0.  Given the value of the image at four points: I(x,y), I(x+1,y), I(x,y+1), I(x+1,y+1) we can solve for a,b,c,d linearly.  Then, for any u between x and x+1, for any v between y and y+1, we use this equation to find I(u,v).