Esempio n. 1
0
from pylab import *
#Fig5-10
# im_l = array(Image.open('../data/cones/im0.ppm').convert('L'),'f')
# im_r = array(Image.open('../data/cones/im1.ppm').convert('L'),'f')
# #Fig5-11
im_l = array(Image.open('../data/cones/im0.ppm').convert('L'), 'f')
im_r = array(Image.open('../data/cones/im1.ppm').convert('L'), 'f')

# 开始偏移,并设置步长
steps = 12
start = 4

# ncc 的宽度
wid = 9

res1 = stereo.plane_sweep_ncc(im_l, im_r, start, steps, wid)

scipy.misc.imsave('../images/ch05/depth_ncc.png', res1)

res2 = stereo.plane_sweep_gauss(im_l, im_r, start, steps, wid)

scipy.misc.imsave('../images/ch05/depth_gauss.png', res2)

# 添加中文字体支持
from matplotlib.font_manager import FontProperties
font = FontProperties(fname="/System/Library/Fonts/PingFang.ttc", size=14)

figure()

subplot(221)
imshow(im_l)
Esempio n. 2
0
File: 0602.py Progetto: ta-oyama/PCV
import pickle

#reload(stereo)


im_l = np.array(Image.open('scene1.row3.col3.ppm').convert('L'),'f')
im_r = np.array(Image.open('scene1.row3.col4.ppm').convert('L'),'f')

#視差の開始値と調べる範囲
start = 4
steps = 12

#相互相関を調べるパッチの幅
wid = 9

res = stereo.plane_sweep_ncc(im_l,im_r,start,steps,wid)


import scipy.misc
scipy.misc.imsave('depth.png',res)




#ガウシアンフィルタ
im_l = np.array(Image.open('scene1.row3.col3.ppm').convert('L'),'f')
im_r = np.array(Image.open('scene1.row3.col4.ppm').convert('L'),'f')

#視差の開始値と調べる範囲
start = 4
steps = 12
from PIL import Image
import numpy
import stereo

im_l = numpy.array(Image.open('./data/ppm/scene1.row3.col3.ppm').convert('L'), 'f')
im_r = numpy.array(Image.open('./data/ppm/scene1.row3.col4.ppm').convert('L'), 'f')

steps = 12
start = 4
wid = 9

res1 = stereo.plane_sweep_ncc(im_l, im_r, start, steps, wid)
res2 = steps - 1 - stereo.plane_sweep_ncc(im_r, im_l, -start - steps + 1,
    steps, wid)

import scipy.misc
scipy.misc.imsave('./output/depth_twosided.png', res1)
scipy.misc.imsave('./output/depth_twosided2.png', res2)

res = (res1 == res2) * res1
scipy.misc.imsave('./output/depth_twosided_c_sparse.png', res)

# Use first disparity image to align second disparity with first.
ir, ic = numpy.mgrid[:res1.shape[0], :res1.shape[1]]
mv = res2[ir, (ic + res1) % res1.shape[1]]
scipy.misc.imsave('./output/tmp.png', mv)

res = (res1 == mv) * res1
scipy.misc.imsave('./output/depth_twosided_c.png', res)
Esempio n. 4
0
from PIL import Image
import numpy
import stereo

im_l = numpy.array(Image.open('out_stereo1.ppm').convert('L'), 'f')
im_r = numpy.array(Image.open('out_stereo2.ppm').convert('L'), 'f')

steps = 12
start = 4
wid = 9

res1 = stereo.plane_sweep_ncc(im_l, im_r, start, steps, wid)
res2 = steps - 1 - stereo.plane_sweep_ncc(im_r, im_l, -start - steps + 1,
                                          steps, wid)

import scipy.misc
scipy.misc.imsave('out_depth_twosided.png', res1)
scipy.misc.imsave('out_depth_twosided2.png', res2)

res = (res1 == res2) * res1
scipy.misc.imsave('out_depth_twosided_c_sparse.png', res)

# Use first disparity image to align second disparity with first.
ir, ic = numpy.mgrid[:res1.shape[0], :res1.shape[1]]
mv = res2[ir, (ic + res1) % res1.shape[1]]
scipy.misc.imsave('out_tmp.png', mv)

res = (res1 == mv) * res1
scipy.misc.imsave('out_depth_twosided_c.png', res)