I have code, which for the sake of argument, looks like the code here:bestMatchIndex = sortedIndeces(1, 1);% Convert the 1-based index of this block back into an offset.% This is the final disparity value produced by basic block matching.d = bestMatchIndex + mind - 1;% Calculate a sub-pixel estimate of the disparity by interpolating.% Sub-pixel estimation requires a block to the left and right, so we % skip it if the best matching block is at either edge of the search% window.if ((bestMatchIndex == 1) || (bestMatchIndex == numBlocks))    % Skip sub-pixel estimation and store the initial disparity value.    DbasicSubpixel(m, n) = d;else    % Grab the SAD values at the closest matching block (C2) and it's     % immediate neighbors (C1 and C3).    C1 = blockDiffs(bestMatchIndex - 1);    C2 = blockDiffs(bestMatchIndex);    C3 = blockDiffs(bestMatchIndex + 1);    % Adjust the disparity by some fraction.    % We're estimating the subpixel location of the true best match.    DbasicSubpixel(m, n) = d - (0.5 * (C3 - C1) / (C1 - (2*C2) + C3));endNow, I also want to calculate an inverse disparity, to eliminate points at infinity, but I cannot find a suitable algorithm. Can anyone describe how it should be done?My research has suggested that instead of comparing L(x, y) with R(x..x+n, y) it should be comparing L(x, y) with R(x-n..x, y), but am I correct?(My actual situation is C++ code with a buggy inverse disparity calculation which I cannot find a reference for to discover how the code should be.)
Calculating inverse disparity of a stereo image
algorithm;matlab