Strangely, it seems that matlab’s builtin function
imresize does not reproduce the usual bilinear interpolation.
Let’s consider a toy 4×4 image:
F = matrixnormalize(magic(4));
BF = imresize(F,[256 256],'bilinear');
Compare that to explicitly computing the bilinear interpolation:
[X,Y] = meshgrid(1:size(F,2),1:size(F,1)); [BX,BY] = meshgrid(linspace(1,size(F,2),size(BF,2)),linspace(1,size(F,1),size(BF,1))); BF2 = interp2(X,Y,F,BX,BY,'bilinear');
The difference is obvious in the corners and along the edges. The
imresize result has some flat (piecewise constant) patches). Why? It actually looks as if the image was padded by repeated values before upsampling.