function [ vMY, vMU, vMV, holesV ] = computeVVInv2F(Yl, Ul, Vl, vMY, vMU, vMV, Yr, Ur, Vr, holesV, nShiftL, nShiftR, width, zInvL, f, l, zInvR, sz )
% Fills the missing information from the left and right VVs with the help
% of nShiftL and nShiftR tables
%% Compute the virtual view left
nShiftL = medfilt2(nShiftL,[sz sz]);
nShiftR = medfilt2(nShiftR,[sz sz]);
[xindx yindx] = find(holesV == 0);

for k=1:size(xindx)
    i = xindx(k);   % row number
    j = yindx(k);   % column number
    jj = nShiftL(i,j);
    if jj <= width && jj > 0
        ih = round(i/2);
        jh = round(j/2);
        vMY(i, j) = Yl(i,jj);
        vMU(ih, jh) = Ul(ih, round(jj/2));
        vMV(ih, jh) = Vl(ih, round(jj/2));
        holesV(i, j) = 1;
    else
        nShiftL(i,j) = 0;
        jj = nShiftR(i,j);
        if jj <= width && jj > 0
            ih = round(i/2);
            jh = round(j/2);
            vMY(i, j) = Yr(i,jj);
            vMU(ih, jh) = Ur(ih, round(jj/2));
            vMV(ih, jh) = Vr(ih, round(jj/2));
            holesV(i, j) = 1;
        else
            nShiftR(i,j) = 0;
            %             The following code is inserted after the oberserving a sudden
            %             drop in PSNR in dancer sequence and poznan hall sequnce. The
            %             problem was that a number of hole went undefined and
            %             hole-fill procedure cannot solve this mystry.
            %             display('a hole left');
            jj = round(j + zInvL(i,j) * f * l); % Now we have to be a bit rude. The value is back-propagated based on its forward difference
            if (jj <= width && jj > 0)
                ih = round(i/2);
                jh = round(j/2);
                vMY(i, j) = Yl(i,jj);
                nShiftL(i,j) = jj;
                vMU(ih, jh) = Ul(ih, round(jj/2));
                vMV(ih, jh) = Vl(ih, round(jj/2));
                holesV(i, j) = 1;
            else
                jj = round(j - zInvR(i,j) * f * l);
                if (jj <= width && jj > 0)
                    ih = round(i/2);
                    jh = round(j/2);
                    vMY(i, j) = Yr(i,jj);
                    vMU(ih, jh) = Ur(ih, round(jj/2));
                    vMV(ih, jh) = Vr(ih, round(jj/2));
                    holesV(i, j) = 1;
                    nShiftR(i,j) = jj;
                end
            end
        end
        
        
    end
end

