The following code shows how to perform bilinear interpolation using INTERP2 :
A = [1 2; 3 4]; SCALE = 2; xi = linspace(1,size(A,2),SCALE*size(A,2)); %
the result is consistent with the output of the Octave code:
B = 1 1.3333 1.6667 2 1.6667 2 2.3333 2.6667 2.3333 2.6667 3 3.3333 3 3.3333 3.6667 4
I should mention that I have different results between MATLAB and Octave IMRESIZE output. For example, this is what I get when I do the following in MATLAB on the matrix A=[1 2; 3 4]
A=[1 2; 3 4]
:
>> B = imresize([1 2; 3 4], 2, 'bilinear') B = 1 1.25 1.75 2 1.5 1.75 2.25 2.5 2.5 2.75 3.25 3.5 3 3.25 3.75 4
which suggests that the MATLAB implementation does something extra ... Unfortunately, it is not easy to read the source code of IMRESIZE, especially since at some point it calls the function of the compiled MEX (without the form of the source code).
As a side note, there seems to be an older version of this function: IMRESIZE_OLD (purely implemented in m-code). From what I could understand, he performs some kind of affine transformation on the image. Perhaps someone more familiar with this technique may shed light on this subject ...
source share