请你能帮我理解的代码从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里面到底是什么。
发布于 2013-12-06 18:40:26
您应该能够使用计算机视觉系统工具箱中的disparity函数,它实现了块匹配算法。
如果您只需要匹配点,您应该使用本地特征:在两个图像中检测一些感兴趣的点,比如角点或小块,从这些点周围的补丁中提取特征描述符,然后匹配这些描述符。这就是所谓的寻找对应,这种方法的优点是,您的图像不需要纠正。
这是一个寻找对应关系来估计一对图像之间的仿射变换的例子。这是一个立体声校正的对应查找实例。
https://stackoverflow.com/questions/20422440
复制相似问题