function output_img = myconv(input_img, kernel)
    k1 = (size(kernel,1)-1) / 2;
    k2 = (size(kernel,2)-1) / 2;
    P = padarray(input_img, [k1, k2], 'both');
    K3 = rot90(kernel, 2);
    output_img = zeros(size(input_img));
    for i1 = 1+k1:size(P,1)-k1
        for i2 = 1+k2:size(P,2)-k2
            IP = P(i1-k1:i1+k1,i2-k2:i2+k2);
            PR = IP .* K3;
            S = sum(PR(:));
            output_img(i1-k1,i2-k2) = S;
        end
    end   
end
