Beispiel #1
0
def test_RANSAC():
  im1=io.imread('pano/stata-1.png', 1.0)
  im2=io.imread('pano/stata-2.png', 1.0)
  correspondences=np.load('corrs.npy')
  H, inliers =a7.RANSAC(correspondences)
  io.imwrite(_magicDrawCorrespondences(correspondences, im1, im2, inliers), \
     'correspondence_ransac.png', 1.0)
def test_Poisson():

  y=50
  x=10
  useLog=True

  fg=io.imread('data/bear.png')
  bg=io.imread('data/waterpool.png')
  mask=io.imread('data/mask.png')


  h, w=fg.shape[0], fg.shape[1]
  mask[mask>0.5]=1.0
  mask[mask<0.6]=0.0
  bg2=(bg[y:y+h, x:x+w]).copy()
  out=bg.copy()
  if useLog:
      bg2[bg2==0]=1e-4
      fg[fg==0]=1e-4
      bg3=np.log(bg2)+3
      fg3=np.log(fg)+3
  else:
      bg3=bg2
      fg3=fg
  tmp=a8.Poisson(bg3, fg3, mask, 3000)

  if useLog:
      out[y:y+h, x:x+w]=np.exp(tmp-3)
  else: out[y:y+h, x:x+w]=tmp

  io.imwrite(out, 'poisson.png')
def my_test_PoissonCG40():

  y=20
  x=410
  useLog=True

  fg=io.imread('data/dog_frisbee.png')
  bg=io.imread('data/boston-skyline.png')
  mask=io.imread('data/dog_frisbee-mask.png')


  h, w=fg.shape[0], fg.shape[1]
  mask[mask>0.5]=1.0
  mask[mask<0.6]=0.0
  bg2=(bg[y:y+h, x:x+w]).copy()
  out=bg.copy()
  if useLog:
      bg2[bg2==0]=1e-4
      fg[fg==0]=1e-4
      bg3=np.log(bg2)+3
      fg3=np.log(fg)+3
  else:
      bg3=bg2
      fg3=fg
  tmp=a8.PoissonCG(bg3, fg3, mask, 40)

  if useLog:
      out[y:y+h, x:x+w]=np.exp(tmp-3)
  else: out[y:y+h, x:x+w]=tmp

  io.imwrite(out, 'my_poisson_CG40.png')
Beispiel #4
0
def test_PoissonCG():

  y=50
  x=10
  useLog=True

  fg=io.imread('data/bear.png')
  bg=io.imread('data/waterpool.png')
  mask=io.imread('data/mask.png')

  h, w=fg.shape[0], fg.shape[1]
  mask[mask>0.5]=1.0
  mask[mask<0.6]=0.0
  bg2=(bg[y:y+h, x:x+w]).copy()
  out=bg.copy()
  if useLog:
      bg2[bg2==0]=1e-4
      fg[fg==0]=1e-4
      bg3=np.log(bg2)+3
      fg3=np.log(fg)+3
  else:
      bg3=bg2
      fg3=fg
  tmp=a8.PoissonCG(bg3, fg3, mask, 150)

  if useLog:
      out[y:y+h, x:x+w]=np.exp(tmp-3)
  else: out[y:y+h, x:x+w]=tmp

  io.imwrite(out, 'poisson_CG.png')
Beispiel #5
0
def test_myown():
  y=150
  x=300
  useLog=True

  fg=io.imread('dolphin.png')
  bg=io.imread('bg.png')
  mask=io.imread('dolphin_mask.png')

  # out=a8.naiveComposite(bg, fg, mask, 50, 50)
  # io.imwrite(out, 'myownnative11.png')

  h, w=fg.shape[0], fg.shape[1]
  mask[mask>0.5]=1.0
  mask[mask<0.6]=0.0
  bg2=(bg[y:y+h, x:x+w]).copy()
  out=bg.copy()
  if useLog:
      bg2[bg2==0]=1e-4
      fg[fg==0]=1e-4
      bg3=np.log(bg2)+3
      fg3=np.log(fg)+3
  else:
      bg3=bg2
      fg3=fg
  tmp=a8.PoissonCG(bg3, fg3, mask, 150)

  if useLog:
      out[y:y+h, x:x+w]=np.exp(tmp-3)
  else: out[y:y+h, x:x+w]=tmp

  io.imwrite(out, 'myowncomposite.png')
Beispiel #6
0
def castle_autostitch():
  im1=io.imread('pano/castle-1.png', 1.0)
  im2=io.imread('pano/castle-2.png', 1.0)
  im3=io.imread('pano/castle-3.png', 1.0)
  im4=io.imread('pano/castle-4.png', 1.0)
  im_list=[im1, im2, im3, im4]
  out=a7.autostitch(im_list, 1) 
  io.imwrite(out, 'output/castle_panorama.png', 1.0)
Beispiel #7
0
def test_autostitch2():
  im1=io.imread('pano/guedelon-1.png', 1.0)
  im2=io.imread('pano/guedelon-2.png', 1.0)
  im3=io.imread('pano/guedelon-3.png', 1.0)
  im4=io.imread('pano/guedelon-4.png', 1.0)
  im_list=[im1, im2, im3, im4]
  out=a7.autostitch(im_list, 1)
  io.imwrite(out, 'panorama2.png', 1.0)
Beispiel #8
0
def castle_two_scale_blending2():
  im1=io.imread('pano/castle-1.png', 1.0)
  im2=io.imread('pano/castle-2.png', 1.0)
  im3=io.imread('pano/castle-3.png', 1.0)
  im4=io.imread('pano/castle-4.png', 1.0)
  im_list=[im1, im2, im3, im4]
  out=a7.two_scale_blending(im_list, 1) 
  io.imwrite(out, 'output/castle_two_blending.png', 1.0)
Beispiel #9
0
def test_two_scale_blending2():
  im1=io.imread('pano/guedelon-1.png', 1.0)
  im2=io.imread('pano/guedelon-2.png', 1.0)
  im3=io.imread('pano/guedelon-3.png', 1.0)
  im4=io.imread('pano/guedelon-4.png', 1.0)
  im_list=[im1, im2, im3, im4]
  out=a7.two_scale_blending(im_list, 1) 
  io.imwrite(out, 'output/two_scale_blending2.png', 1.0)
Beispiel #10
0
def test_linear_blending2():
  im1=io.imread('pano/guedelon-1.png', 1.0)
  im2=io.imread('pano/guedelon-2.png', 1.0)
  im3=io.imread('pano/guedelon-3.png', 1.0)
  im4=io.imread('pano/guedelon-4.png', 1.0)
  im_list=[im1, im2, im3, im4]
  out=a7.linear_blending(im_list, 1)
  io.imwrite(out, 'linear_blending2.png', 1.0)
Beispiel #11
0
def test_two_scale_blending2():
  im1=io.imread('pano/guedelon-1.png', 1.0)
  im2=io.imread('pano/guedelon-2.png', 1.0)
  im3=io.imread('pano/guedelon-3.png', 1.0)
  im4=io.imread('pano/guedelon-4.png', 1.0)
  im_list=[im1, im2, im3, im4]
  out1=a7.two_scale_blending(im_list, 0)
  io.imwrite(out1, 'two_scale_blending2-1.png', 1.0)
  out2=a7.two_scale_blending(im_list, 1)
  io.imwrite(out2, 'two_scale_blending2-2.png', 1.0)
Beispiel #12
0
def test_findCorrespondence():
  im1=io.imread('pano/stata-1.png', 1.0)
  im2=io.imread('pano/stata-2.png', 1.0)
  corners1=a7.HarrisCorners(im1)
  features1=a7.computeFeatures(im1, corners1)
  corners2=a7.HarrisCorners(im2)
  features2=a7.computeFeatures(im2, corners2)
  correspondences = a7.findCorrespondences(features1, features2)
  np.save('corrs', correspondences)
  io.imwrite(_magicDrawCorrespondences(correspondences, im1, im2), \
     'correspondence.png', 1.0)
Beispiel #13
0
def test_weight_map():
  im1=io.imread('pano/castle-1.png', 1.0)
  im2=io.imread('pano/castle-2.png', 1.0)
  im3=io.imread('pano/castle-3.png', 1.0)
  im4=io.imread('pano/castle-4.png', 1.0)
  im_list=[im1, im2, im3, im4]
  square=a7.weight_map(750, 750)
  long=a7.weight_map(750, 350)
  wide=a7.weight_map(350, 750)
  io.imwrite(square, 'output/weight_map_squre.png', 1.0)
  io.imwrite(long, 'output/weight_map_long.png', 1.0)
  io.imwrite(wide, 'output/weight_map_wide.png', 1.0)
def test_grad_descent():
  im=io.imread('data/pru.png')
  kernel=a8.gauss2D(1)
  im_blur=a8.convolve3(im, kernel)

  io.imwrite(im_blur, 'pru_blur.png')
  im_sharp=a8.deconvGradDescent(im_blur, kernel);
  io.imwrite(im_sharp, 'pru_sharp.png')
Beispiel #15
0
def test_conjugate_grad_descent():
  im=io.imread('data/pru.png')
  kernel=a8.gauss2D(1)
  im_blur=a8.convolve3(im, kernel)

  io.imwrite(im_blur, 'output/pru_blur.png')
  im_sharp=a8.deconvCG(im_blur, kernel);
  io.imwrite(im_sharp, 'output/pru_sharp_CG.png')
Beispiel #16
0
def test_grad_descent():
  im=io.imread('data/pru.png')
  kernel=a8.gauss2D(1)
  im_blur=a8.convolve3(im, kernel)

  io.imwrite(im_blur, 'pru_blur.png')
  im_sharp=a8.deconvGradDescent(im_blur, kernel);
  io.imwrite(im_sharp, 'pru_sharp.png')
Beispiel #17
0
def test_real_psf():
  im=io.imread('data/pru.png')
  f=open('psf', 'r')
  psf=[map(float, line.split(',')) for line in f ]
  kernel=np.array(psf)
  im_blur=a8.convolve3(im, kernel)
  #kernel=kernel[::-1, ::-1]
  io.imwrite(im_blur, 'pru_blur_real.png')
  io.imwriteGrey(kernel/np.max(kernel), 'psf.png')
  im_sharp=a8.deconvCG(im_blur, kernel, 20);
  io.imwrite(im_sharp, 'pru_sharp_CG_real.png')
def test_real_psf25():
  im=io.imread('data/pru.png')
  f=open('psf', 'r')
  psf=[map(float, line.split(',')) for line in f ]
  kernel=np.array(psf)
  im_blur=a8.convolve3(im, kernel)
  #kernel=kernel[::-1, ::-1]
  io.imwrite(im_blur, 'pru_blur_real25.png')
  io.imwriteGrey(kernel/np.max(kernel), 'psf25.png')
  im_sharp=a8.deconvCG(im_blur, kernel, 25);
  io.imwrite(im_sharp, 'pru_sharp_CG_real25.png')
Beispiel #19
0
def test_conjugate_grad_descent_reg():
  im=io.imread('data/pru.png')
  kernel=a8.gauss2D(1)
  im_blur=a8.convolve3(im, kernel)
  noise=np.random.random(im_blur.shape)-0.5
  im_blur_noisy=im_blur+0.05*noise

  io.imwrite(im_blur_noisy, 'pru_blur_noise.png')
  im_sharp=a8.deconvCG_reg(im_blur_noisy, kernel);
  im_sharp_wo_reg=a8.deconvCG(im_blur_noisy, kernel);
  io.imwrite(im_sharp, 'pru_sharp_CG_reg.png')
  io.imwrite(im_sharp_wo_reg, 'pru_sharp_CG_wo_reg.png')
def test_conjugate_grad_descent_reg():
  im=io.imread('data/pru.png')
  kernel=a8.gauss2D(1)
  im_blur=a8.convolve3(im, kernel)
  noise=np.random.random(im_blur.shape)-0.5
  im_blur_noisy=im_blur+0.05*noise

  io.imwrite(im_blur_noisy, 'pru_blur_noise.png')
  im_sharp=a8.deconvCG_reg(im_blur_noisy, kernel);
  im_sharp_wo_reg=a8.deconvCG(im_blur_noisy, kernel);
  io.imwrite(im_sharp, 'pru_sharp_CG_reg.png')
  io.imwrite(im_sharp_wo_reg, 'pru_sharp_CG_wo_reg.png')
Beispiel #21
0
def test_linear_blending():
  im1=io.imread('pano/stata-1.png', 1.0)
  im2=io.imread('pano/stata-2.png', 1.0)
  im_list=[im1, im2]
  out=a7.linear_blending(im_list, 0)
  io.imwrite(out, 'linear_blending.png', 1.0)
Beispiel #22
0
def test_ComputeTensor():
  im=io.imread('pano/stata-1.png', 1.0)
  tensor=a7.computeTensor(im)
  foo=max(tensor.flatten())
  io.imwrite(tensor/foo, 'tensor_vis.png', 1.0)
Beispiel #23
0
def test_naive_composite():
  fg=io.imread('data/bear.png')
  bg=io.imread('data/waterpool.png')
  mask=io.imread('data/mask.png')
  out=a8.naiveComposite(bg, fg, mask, 50, 1)
  io.imwrite(out, 'naive_composite.png')
Beispiel #24
0
def lucien_two_scale_blending2():
  im1=io.imread('pano/lucien_1.png', 1.0)
  im2=io.imread('pano/lucien_2.png', 1.0)
  im_list=[im1, im2]
  out=a7.two_scale_blending(im_list, 1) 
  io.imwrite(out, 'output/lucien_two_blending.png', 1.0)  
Beispiel #25
0
def test_autostitch():
  im1=io.imread('pano/stata-1.png', 1.0)
  im2=io.imread('pano/stata-2.png', 1.0)
  im_list=[im1, im2]
  out=a7.autostitch(im_list, 0)
  io.imwrite(out, 'panorama1.png', 1.0)
def test_autostitch3():
  im1=io.imread('pano/mit1.png', 1.0)
  im2=io.imread('pano/mit0.png', 1.0)
  im_list=[im1, im2]
  out=a7.autostitch(im_list, 1) 
  io.imwrite(out, 'panoramaMine.png', 1.0)
Beispiel #27
0
def test_computeFeatures():
  im=io.imread('pano/stata-1.png', 1.0)
  corners=a7.HarrisCorners(im)
  features=a7.computeFeatures(im, corners)
  io.imwrite(_magicShowFeatures(features, im*0.5, 4), 'features.png', 1.0)
Beispiel #28
0
def test_HarrisCorners():
  im=io.imread('pano/stata-1.png', 1.0)
  corners=a7.HarrisCorners(im)
  io.imwrite(_magicCorners(corners, im), 'corners.png', 1.0)
Beispiel #29
0
def test_cornerResponse():
  im=io.imread('pano/stata-1.png', 1.0)
  resp=a7.cornerResponse(im)
  foo=max(resp.flatten())
  io.imwrite(_magic123(resp/foo),'resp.png', 1.0)
def test_linear_blending3():
  im1=io.imread('pano/mit1.png', 1.0)
  im2=io.imread('pano/mit0.png', 1.0)
  im_list=[im1, im2]
  out=a7.linear_blending(im_list, 1) 
  io.imwrite(out, 'linear_blendingMine.png', 1.0)
Beispiel #31
0
def test_two_scale_blending():
  im1=io.imread('pano/stata-1.png', 1.0)
  im2=io.imread('pano/stata-2.png', 1.0)
  im_list=[im1, im2]
  out=a7.two_scale_blending(im_list, 0)
  io.imwrite(out, 'two_scale_blending.png', 1.0)
def test_naive_composite():
  fg=io.imread('data/bear.png')
  bg=io.imread('data/waterpool.png')
  mask=io.imread('data/mask.png')
  out=a8.naiveComposite(bg, fg, mask, 50, 1)
  io.imwrite(out, 'naive_composite.png')
Beispiel #33
0
def test_myPano():
  im1 = io.imread('pano/house1.png', 1.0)
  im2 = io.imread('pano/house2.png', 1.0)
  im3 = io.imread('pano/house3.png', 1.0)
  im_list = [im1, im2, im3]
  io.imwrite(a7.autostitch(im_list, 1), 'auto_stitch_house.png', 1.0)
def my_test_naive_composite():
  fg=io.imread('data/dog_frisbee.png')
  bg=io.imread('data/boston-skyline.png')
  mask=io.imread('data/dog_frisbee-mask.png')  
  out=a8.naiveComposite(bg, fg, mask, 20, 410)
  io.imwrite(out, 'my_naive_composite.png')