function M = cubic_interpolate(image);
% optimal cubic interpolation 


[row,col] = size(image);

M = zeros(2*row,2*col);
avg1 = [-1 9 9 -1]/16;
avg2 = [1 -9 -9 1; -9 81 81 -9; -9 81 81 -9; 1 -9 -9 1]/256;

M(1:2:2*row,1:2:2*col) = image;
M(1:2:2*row,2:2:2*col) = replicateConv(image, avg1);
M(2:2:2*row,1:2:2*col) = replicateConv(image, avg1');
M(2:2:2*row,2:2:2*col) = replicateConv(image, avg2);
