function Ip = predictive_coding(I, predictor)

    I = double(I);
    Ip = I;
    
    predictor(end, end) = 0;
    
    for i = size(predictor, 1):size(I,1)
        for j = size(predictor, 2):size(I,2)
            Ip(i,j) = I(i,j) - round(sum(sum(predictor.*I(i-size(predictor,1)+1:i, j-size(predictor,2)+1:j))));
        end
    end
    
    Ip = int16(Ip);

end