Understanding MATLAB/Mathematica's bilinear interpolation I am trying to get a working understanding of how to resize images using bilinear and bicubic transformations. I coded a resizing function based on things I've read here and Wikipedia, etc., but I get different results than what MATLAB and Mathematica give.

A minimal working example is the image im=[100 50 0] in MATLAB or im={1, .5, 0} in Mathematica. My algorithm (and "common sense") tells me that resizing this image to 5 pixels should give
im=[100 75 50 25 0] and i={1, .75, .5, .25, 0}, respectively. However, I get
im=[100 80 50 20 0] and i={1, .8, .5, .2, 0} from MATLAB and Mathematica when forcing the bilinear method. Specifically, the MATLAB commands

im=[100 50 0];
imresize(im,[1,5],'bilinear')


returns

ans =  100.0000   80.0000   50.0000   20.0000         0


They are obviously doing the same, different thing than my code (and common sense). 

Can someone explain their algorithm to me? I am guessing it my mistakes relate to how to "index" the new image. The original image, with only one row, has a constant "y" value of 1, with columns x=1,2,3. I am assuming that the new image could be viewed as having columns indexed as x=1, 1.5, 2, 2.5, 3, and interpolation is needed to compute the values of f(1.5,1) and f(2.5,1).

Thanks.
imresize gets you different results on Matlab and Octave. The one in Octave calls the interp2 function, which with 'bilinear' method will return you [100 75 50 25 0].  

However, it seems like there is some extra processing in Matlab.  It performs affine transformation on the image. The interpolation is calculated on each pixel in the output image, then inverse map onto the indices of the pixels in the input image with the contributing weights. So I guess the mapped coordinates are not distributed uniformly (not exactly at 1.5 and 2.5 between [1,2], and [2,3] in your case).

Probably you can edit imresize_old to see more source code content than imresize.