示例#1
0
tp, fp = convert_points(2)  # Note: Reversed.
H_32 = homography.H_from_ransac(fp, tp, model)[0]
tic.k('32 homogd')

tp, fp = convert_points(3)  # Note: Reversed.
H_43 = homography.H_from_ransac(fp, tp, model)[0]
tic.k('43 homogd')

# FIXME: Consider using bundle adjustment and Levenberg-Marquardt instead of
# just concatenating homographies which accumulates errors.
delta = 600
H_delta2 = array([[1, 0, -2 * delta], [0, 1, 0], [0, 0, 1]])

im1 = array(Image.open(imname[1]))
im2 = array(Image.open(imname[2]))
im_12 = warp.panorama(H_12, im1, im2, delta, delta)
tic.k('12 warpd')

im0 = array(Image.open(imname[0]))
im_02 = warp.panorama(dot(H_12, H_01), im0, im_12, delta, 2 * delta)
tic.k('02 warpd')

im3 = array(Image.open(imname[3]))
# There are two images added on the left already, hence the H_delta2.
im_03 = warp.panorama(dot(H_32, H_delta2), im3, im_02, delta, 0)
tic.k('03 warpd')

im4 = array(Image.open(imname[4]))
im_04 = warp.panorama(dot(dot(H_32, H_43), H_delta2), im4, im_03, delta, 0)
tic.k('04 warpd')
示例#2
0
fp,tp = convert_points(0)
H_01 = homography.H_from_ransac(fp,tp,model)[0] #im 0 to 1 

tp,fp = convert_points(2) #NB: reverse order
H_32 = homography.H_from_ransac(fp,tp,model)[0] #im 3 to 2 

tp,fp = convert_points(3) #NB: reverse order
H_43 = homography.H_from_ransac(fp,tp,model)[0] #im 4 to 3    


# warp the images
delta = 2000 # for padding and translation

im1 = array(Image.open(imname[1]), "uint8")
im2 = array(Image.open(imname[2]), "uint8")
im_12 = warp.panorama(H_12,im1,im2,delta,delta)

im1 = array(Image.open(imname[0]), "f")
im_02 = warp.panorama(dot(H_12,H_01),im1,im_12,delta,delta)

im1 = array(Image.open(imname[3]), "f")
im_32 = warp.panorama(H_32,im1,im_02,delta,delta)

im1 = array(Image.open(imname[4]), "f")
im_42 = warp.panorama(dot(H_32,H_43),im1,im_32,delta,2*delta)


figure()
imshow(array(im_42, "uint8"))
axis('off')
show()
fp, tp = convert_points(0)
H_01 = homography.H_from_ransac(fp, tp, model)[0]  #im 0 to 1

tp, fp = convert_points(2)  #NB: reverse order
H_32 = homography.H_from_ransac(fp, tp, model)[0]  #im 3 to 2

tp, fp = convert_points(3)  #NB: reverse order
H_43 = homography.H_from_ransac(fp, tp, model)[0]  #im 4 to 3

# warp the images
delta = 2000  # for padding and translation

im1 = array(Image.open(imname[1]), "uint8")
im2 = array(Image.open(imname[2]), "uint8")
im_12 = warp.panorama(H_12, im1, im2, delta, delta)

im1 = array(Image.open(imname[0]), "f")
im_02 = warp.panorama(dot(H_12, H_01), im1, im_12, delta, delta)

im1 = array(Image.open(imname[3]), "f")
im_32 = warp.panorama(H_32, im1, im_02, delta, delta)

im1 = array(Image.open(imname[4]), "f")
im_42 = warp.panorama(dot(H_32, H_43), im1, im_32, delta, 2 * delta)

figure()
imshow(array(im_42, "uint8"))
axis('off')
show()
示例#4
0
model = homography.RansacModel()

fp, tp = convert_points(0)
H_01 = homography.H_from_ransac(fp, tp, model)[0]  # im 0 to 1

fp, tp = convert_points(1)
H_12 = homography.H_from_ransac(fp, tp, model)[0]  # im 1 to 2

# warp the images
delta = 800

im0 = np.array(Image.open(imname[0]), "uint8")
im1 = np.array(Image.open(imname[1]), "uint8")
im2 = np.array(Image.open(imname[2]), "uint8")

im_01 = warp.panorama(H_01, im0, im1, delta, delta)
im_12 = warp.panorama(H_12, im1, im2, delta, delta)
im0 = np.array(Image.open(imname[0]), "f")
im_02 = warp.panorama(np.dot(H_12, H_01), im0, im_12, delta, delta)

plt.figure(figsize=(15, 15))
im0 = np.array(Image.open(imname[0]), "uint8")
plt.subplot(3, 2, 1), plt.imshow(im0), plt.axis('off'), plt.title('Image 1')
plt.subplot(3, 2, 2), plt.imshow(im1), plt.axis('off'), plt.title('Image 2')
plt.subplot(3, 2, 3), plt.imshow(im2), plt.axis('off'), plt.title('Image 3')
plt.subplot(3, 2, 4), plt.imshow(np.array(im_02, "uint8")), plt.axis('off')
plt.title('Panorama with 3 images')
plt.subplot(3, 2, 5), plt.imshow(np.array(im_01, "uint8")), plt.axis('off')
plt.title('Panorama with Image 1 and Image 2')
plt.subplot(3, 2, 6), plt.imshow(np.array(im_12, "uint8")), plt.axis('off')
plt.title('Panorama with Image 2 and Image 3')
示例#5
0
  H_12 = homography.H_from_ransac(fp, tp, model)[0]
else:
  # Assume all matches are correct.
  H_12 = homography.H_from_points(fp, tp)

tic.k('homogd')

# ...

delta = 600
im1 = array(Image.open(imname[0]).convert('L'))
im2 = array(Image.open(imname[1]).convert('L'))

tic.k('imloaded')

im_12 = warp.panorama(H_12, im1, im2, delta, delta, alpha=0.5)

tic.k('warpd')

if len(im1.shape) == 2:
  gray()
imshow(array(im_12, "uint8"))

is_left = H_12[0, 2] < 0
pdelta = delta if not is_left else 0
if False:
  # Overlay raw feature locations.
  def draw_circle(c, r, col):
    t = arange(0, 1.01, .01) * 2 * pi
    x = r * cos(t) + c[0]
    y = r * sin(t) + c[1]
示例#6
0
tp, fp = convert_points(2)  # Note: Reversed.
H_32 = homography.H_from_ransac(fp, tp, model)[0]
tic.k('32 homogd')

tp, fp = convert_points(3)  # Note: Reversed.
H_43 = homography.H_from_ransac(fp, tp, model)[0]
tic.k('43 homogd')

# FIXME: Consider using bundle adjustment and Levenberg-Marquardt instead of
# just concatenating homographies which accumulates errors.
delta = 600
H_delta2 = array([[1, 0, -2*delta], [0, 1, 0], [0, 0, 1]])

im1 = array(Image.open(imname[1]))
im2 = array(Image.open(imname[2]))
im_12 = warp.panorama(H_12, im1, im2, delta, delta)
tic.k('12 warpd')

im0 = array(Image.open(imname[0]))
im_02 = warp.panorama(dot(H_12, H_01), im0, im_12, delta, 2*delta)
tic.k('02 warpd')

im3 = array(Image.open(imname[3]))
# There are two images added on the left already, hence the H_delta2.
im_03 = warp.panorama(dot(H_32, H_delta2), im3, im_02, delta, 0)
tic.k('03 warpd')

im4 = array(Image.open(imname[4]))
im_04 = warp.panorama(dot(dot(H_32, H_43), H_delta2), im4, im_03, delta, 0)
tic.k('04 warpd')