Based on the image panorama stitching RANSAC

Based on the image panorama stitching RANSAC

RANSAC algorithm

RANSAC is an iterative algorithm, for the observed data to estimate the parameters of the mathematical model, based on the group they can be separated from the outliers. In general, the data is simply observed that often there will be a lot of noise, such as SIFT match would sometimes because different places have a similar pattern leading to mismatch. See all the data and after how much error is the RANSAC by repeated sampling, that is random number data to estimate the model parameters drawn from the entire observation data, and take the minimum error as the best and isolate the outliers.

 

Panorama stitching principle introduction

  • Taking multiple / sequence of images for a scene
  • Characterized by matching (matching SIFT) calculated by the following structural transformation between one image and the previous image.
  • Image map, the next image to a coordinate system superimposed on an image
  • Fusion after conversion / synthesis
  • Repeat the above steps

Two panoramic image mosaic of the most important steps:

  • Feature point matching

This part uses SIFT algorithm, before the introduction of the blog there is no longer described in detail, mainly in order to find the same two points and will be its image feature match.

  • Picture matching

Image matching is to find all of the overlapping portion between the images, which can be obtained after splicing a panorama.

 

Image registration

Image registration is transforming the image so that the image can be transformed coordinate system in good stitching on a picture in. To be able to image contrast and more sophisticated image analysis, image registration is an important step in the operation of the picture because there are different between the plane and the plane skew or two pictures of depth of field (near the far smaller), two images will be directly mapping transformation will lead to parts of the object in the picture there is ghosting (ghosting). To minimize this situation, the image registration algorithm is divided into small image areas, respectively, in the image matching and mapping small area

 

Global optimization and seamless

  • Panorama straightening: The corrected image capturing 3D camera relative rotation, is mainly due to the camera may not be at the same level, and different degrees of inclination to take a picture, skip this step may result in the panorama becomes wavy shape.
  • Graphic equalizer compensation: the global balance of light and tone all the pictures.
  • Image fusion band: engaging edge may still exist between the images, vignetting (lightness or saturation of the peripheral portion lower than the center of the image area), the parallax effect (since the camera lens movement cause) after step 4.

 

 Test code:

Data collection Pictures (5)

 

 

 

 

 Feature matching results:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Resulting in a skewed, gaps and shady, the first run is not satisfactory

可以发现,图片的拼接顺序出现了错误,最右侧的图片与左侧的图片直接相连接,调过来中间的图片,导致了三张图片堆积在左边,而右侧缺失了两张图片

大致猜想是因为5张图片的范围过小,导致每张图片之间的重叠部分过多,导致每张图片都有大量的特征点匹配,导致图片重叠,造成缺失。

建议图片范围取大一些,不要有太多的重叠部分。

 

调整照片后再次进行拼接:

 

 

 

 图片没有缝隙,很平滑,也没有明显的曝光,对比原图,位置是正确的,广告牌也拼接上了,但是左侧图片被拉伸了,虽然拉伸程度不大。可能是因为位移量不够,所以拉伸了图片进行填充

 

重新拍照后测试:

 没有发生图片错位,但是扭曲拉伸严重,大体上完成了拼接,不过效果一般,存才鬼影现象,比较模糊,提升原图清晰度可以有效改善此结果

 

 远近不同图片的拼接

 测试图片(2张)

远景:

 

 

 近景:

 

 

 运行结果:

 

 

 

 远景中的建筑物也被拼接进了近景中的图片,位置也是正确的,且没有明显的曝光的痕迹,相较于上一组实验,这组实验的照片较为稳定和清晰,特征点匹配的准确,拼接的顺滑,没有缝隙

 

总结

  • 图像配准虽然能够较好地完成配准,但非常依赖于特征点对。若图像高频信息较少,特征点对过少,配准将完全失效,并且对大尺度的图像进行配准,其效果也不是很好,特征点对的数量对拼接效果有很大的影响。
  • 拍摄时曝光不均导致画面分割明显
  • 拼接图像部分歪斜,可能是因为拍摄时角度的偏差,导致当该图像填充时目标图像中点的坐标也变化了。
  • 原始图片的像素值很大程度上决定了特征点的寻找,像素值太低,将导致寻找到的特征点过少,不利于后续的拼接效果,而像素值过高会导致代码的运行时间过长,加重算法的负荷,运行时间长达5分钟...个人建议别超过1M,不然真的运行太慢了,当然要是电脑好就当我没说
  • 全景拼接的一个关键点就是sift特征点的匹配,只有寻找到正确且数量较多的特征点,在后续的拼接中才能更好的完成,拼接的更自然。

  • 基于RANSAC算法的图像拼接存在的问题可以从上面的拼接结果看出来,不同图像之间的连接部分出现不连贯以及由于图像曝光不同而出现的边缘效应的情况。而且还可以看出RANSAC算法只是将图像进行简单的扭曲(从矩形变成四边形),导致图像拼接得非常生硬

  • 最好不要拍摄对称性很高的建筑物,以为两边的的特征点长的几乎一样的,这样会使算法的匹配出现失误,第一组实验就是间隔太小,导致最右侧的图片拼接到了最左边。

 

 

 

报错处理

 若代码出现次错误,进入到PCV\geometry\warp.py文件中,

1.将第一行的

import matplotlib.delaunay as md

替换成

from scipy.spatial import Delaunay

2.把以下代码

triangulate_points(x,y)

里面的代码替换成

tri = Delaunay(np.c_[x,y]).simplices

这样就能运行了

Guess you like

Origin www.cnblogs.com/bokeyuancj/p/12557404.html