function MIF = MIF(image);



% Median Interpolation filter

% reference : nonlinear filters in image pyramid generation

% scheme for imterpolation by 2 using a non linear non recursive filter
% based on the median

% seems a bit basic to me

[row,col] = size(image);
rep = replicateBounds(image, 1, 1);

s = [row, col];
x1 = getShift(rep, 0,0, s);
x2 = getShift(rep, 0,1, s);
x3 = getShift(rep, 1,1, s);
x4 = getShift(rep, 1,0, s);
z(:,:,1) = 0.5*(x1+x3);
z(:,:,2) = 0.5*(x2+x4);
z(:,:,3) = 0.25*(x1+x2+x3+x4);
mz = median(z, 3);

h(:,:,1) = x1;
h(:,:,2) = x2;
h(:,:,3) = x3;
h(:,:,4) = x4;
h(:,:,5) = mz;

MIF = zeros(2*row,2*col);
MIF(1:2:2*row,     1:2:2*col)     = image;
MIF((1:2:2*row)+1, 1:2:2*col)     = 0.5*(x3+x2);
MIF(1:2:2*row,    (1:2:2*col)+1)  = 0.5*(x2+x1);
MIF((1:2:2*row)+1,(1:2:2*col)+1)  = median(h,3);


