1

请你能帮我理解 Matlab 帮助中关于立体视觉 - 基本块匹配的代码吗?

% Scan over all rows.
for m=1:nRowsLeft
    % Set min/max row bounds for image block.
    minr = max(1,m-halfBlockSize);
    maxr = min(nRowsLeft,m+halfBlockSize);
    % Scan over all columns.
    for n=1:size(leftI,2)
        minc = max(1,n-halfBlockSize);
        maxc = min(size(leftI,2),n+halfBlockSize);
        % Compute disparity bounds.
        mind = max( -disparityRange, 1-minc );
        maxd = min( disparityRange, size(leftI,2)-maxc );

        % Construct template and region of interest.
        template = rightI(minr:maxr,minc:maxc);
        templateCenter = floor((size(template)+1)/2);
        roi = [minc+templateCenter(2)+mind-1 ...
               minr+templateCenter(1)-1 ...
               maxd-mind+1 1];
        % Lookup proper TemplateMatcher object; create if empty.
        if isempty(tmats{size(template,1),size(template,2)})
            tmats{size(template,1),size(template,2)} = ...
                vision.TemplateMatcher('ROIInputPort',true);
        end
        thisTemplateMatcher = tmats{size(template,1),size(template,2)};

        % Run TemplateMatcher object.
        loc = step(thisTemplateMatcher, leftI, template, roi);
        Dbasic(m,n) = loc(1) - roi(1) + mind;
    end
    waitbar(m/nRowsLeft,hWaitBar);
end

根据Matlab帮助:loc包含左图像中点的位置坐标,roi包含[x y width height]右图像中x和y是左上角坐标的区域的位置坐标。

我想知道左右图像中的对应坐标。对于左图:x = loc(1)y = loc(2)对于右图:x = roi(1) - mind, y = loc(2)

这个对吗?我不确定 roi 里面到底是什么。

4

1 回答 1

0

您应该能够改用disparity计算机视觉系统工具箱中的函数,它实现了块匹配算法。

如果你只需要匹配点,你应该使用局部特征:检测两个图像中的一些兴趣点,如角落或斑点,从这些点周围的补丁中提取特征描述符,然后匹配描述符。这称为查找对应关系,这种方法的优点是您的图像不需要校正。

这是一个寻找对应关系以估计一对图像之间的仿射变换的示例。这是一个为立体声校正寻找对应关系的示例

于 2013-12-06T18:40:26.113 回答