matlab获取视差图,Matlab生成视差图

本文介绍了如何使用Matlab进行双目视觉中的视差图生成,包括基本的块匹配方法、亚像素估计和动态规划优化。通过逐步改进,从基本的块匹配消除轮廓效应,到引入动态编程提升图像平滑度,再到利用图像金字塔和亚像素精度进一步提高匹配质量。最终,结合这些技术得到高质量的视差图。
摘要由CSDN通过智能技术生成

【实例简介】

双目视觉,根据块匹配方法的视差图生成。依据Matlab生成视差图。

Dbasic= zeros(size(leftI),'single')

disparity range 15;

Selects (2*halfBlocksize+1)-by-(2*halfBlocksize+1) block

halfblocksize =3

blocksize 2*halfblocksize+1

Allocate space for all template matchers

tats cell(blocksize)

g Scan over all rows

for m=1: size(leftI, 1)

Set min/max row bounds for image block

inr=max(l, m-halfBlocksize);

maxr min(size(leftI, 1), mthalfBlocksize)i

‰ Scan over a11 columns

for n=1: size(leftI, 2

minc =max(1, n-halfBlocksize);

maxc min(size(leftI, 2),nthalfBlocksize)

Compute disparity bounds

mind max( -disparityRange, 1-minc i

maxd min( disparityRange, size(leftI, 2)-maxc

9 Construct template and region of interest

template rightI(minr: maxr, minc: maxc);

templateCenter floor((size(template)+1)/2)

roi = [minr+template Center(1)-2

mincttemplateCenter(2)+mind-2

1 maxd-mind+1]

Lookup proper TemplateMatcher object, create if empty

if isempty( tmatssize(template, 1),size(template, 2)1)

tmatsisize(template, 1),size(template, 2)1

video. TemplateMatcher( ROIInputPort', true);

thisTemplateMatcher tmatsfsize(template, 1),size(template, 2));

Run TemplateMatcher object

loc step( thisTemplateMatcher, leftI, template, roi);

basic(m)

m,n)=1oc(2)-roi(2)

nd

end

end

In the results bclow, the basic block matching docs well, as the correct shape of thc stcrco

scene is recovered. However, there are noisy patches and bad depth estimates everywhere,

especially on the ceiling. These are caused when no strong image features appear inside of

the 7-by-7-pixel windows being compared. Then the matching process is subject to noise

since each pixel chooses its disparity independently of all the other pixels

For display purposes, we saturate the depth map to have only positive values. In general

slight angular misalignment of the stereo cameras used for image acquisition can allow both

positive and negative disparities to appear validly in the depth map In this case, however, the

stereo cameras were near perfectly parallel, so the true disparities have only one sign. Thus

this correction is valid

figure(3), clf;

imshow(Dbasic, []), axis image, colormap( jet), colorbar

caxis(lo disparity d);

title( ' depth map from basic block matching)

Depth map from basic black matching

10

Step 3. Sub-pixel estimation

The disparity estimates returned by block matching are all integer-valued so the above depth

map exhibits contouring effects where there

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值