function xdep = DepthComp(xdep, xs, xe, ys, ye, p, H)

[s, m, n] = size(xdep);
  
fguess = 720; % max(xdim,ydim);
Aguess = [fguess 0 n/2; 0 fguess m/2; 0 0 1];

%----------------------------
% Normalize the measurements

for i = xs: xe
    for j = ys:ye
        x = inv(Aguess)*[j; i; 1];
        IH = inv(H);
        lambda = (IH(4, 4) - IH(1:3, 4)'*p)/((IH(1:3, 1:3)*x)'*p-IH(4,1:3)*x);
        X = [lambda*x; 1];
        xdep(:,i,j) = X;
    end
end

