function [Interpol] = BiCubicConvolution(Img, sx, sy)

%Metoda bikubicke konvoluce pro interpolaci bodu obrazu lezicich mimo
%diskretni sit obrazu Img (body sx, sy)

sxr = round(sx);                                                            %pripraveni hodnot pro bikubickou konvoluci a jeji realizace (Close Range Photogrammetry, str. 353)                                            
syr = round(sy);                                                
dx = ((sx-0.5)-floor(sx-0.5));                                          
dy = ((sy-0.5)-floor(sy-0.5));

for i = 1:4;
    param = [dx+1,dx,dx-1,dx-2,dy+1,dy,dy-1,dy-2];
    for m = 1:8;
        if abs(param(1,m))<1;
            param1(1,m) = abs(param(1,m))^3-2*abs(param(1,m))^2+1;
        elseif abs(param(1,m))>=1 && param(1,m)<2
            param1(1,m) = -abs(param(1,m))^3+5*abs(param(1,m))^2-8*abs(param(1,m))+4;
        else
            param1(1,m) = 0;
        end
    end
    a(i)=Img(round(sx)-2,round(sy)-3+i)*(param1(1,1)) + Img(round(sx)-1,round(sy)-3+i)*(param1(1,2))+ Img(round(sx),round(sy)-3+i)*(param1(1,3))+ Img(round(sx)+1,round(sy)-3+i)*(param1(1,4));
end

Interpol = (a(1)*param1(1,5)+a(2)*param1(1,6)+a(3)*param1(1,7)+a(4)*param1(1,8));

end

