1. 程式人生 > >仿射變換透射變換單應性矩陣

仿射變換透射變換單應性矩陣

  • estimateRigidTransform():計算多個二維點對或者影象之間的最優仿射變換矩陣 (2行x3列),H可以是部分自由度,比如各向一致的切變。
  • getAffineTransform():計算3個二維點對之間的仿射變換矩陣H(2行x3列),自由度為6.
  • warpAffine():對輸入影象進行仿射變換
  • findHomography: 計算多個二維點對之間的最優單對映變換矩陣 H(3行x3列) ,使用最小均方誤差或者RANSAC方法 。
  • getPerspectiveTransform():計算4個二維點對之間的透射變換矩陣 H(3行x3列)
  • warpPerspective(): 對輸入影象進行透射變換
  • perspectiveTransform():對二維或者三維向量進行透射變換,也就是對輸入二維座標點或者三維座標點進行投射變換。
  • estimateAffine3D:計算多個三維點對之間的最優三維仿射變換矩陣H (3行x4列)
  • transform():對輸入的N維向量進行變換,可用於進行仿射變換、影象色彩變換.
  • findFundamentalMat:計算多個點對之間的基矩陣H。
快速解決:
  • 問題1:如何計算3個二維點對之間的仿射變換矩陣?
答:使用getAffineTransform()。
  • 問題2:如何計算多個二維點對之間的仿射變換矩陣(使用誤差最小準則 )?
答:使用estimateRigidTransform()或者findHomography。
  • 問題3:如何計算4個二維點對之間的透射變換?
答:使用getPerspectiveTransform()。
  • 問題4:如何計算多個三維點對之間的仿射變換?
答:使用estimateAffine3D。
  • 問題5:如何對輸入影象進行仿射變換?
答:使用warpAffine()。
  • 問題6:如何對輸入影象進行透射變換?
答:使用perspectiveTransform()。
  • 問題7:如何對輸入的二維點對進行仿射變換?
答:使用transform()。
  • 問題8:如何對輸入的三維點對進行投射變換?
答:使用perspectiveTransform()。
findHomography 函式是求兩幅影象的單應性矩陣,它是一個3*3的矩陣,但這裡的單應性矩陣和3D重建中的單應性矩陣(透視矩陣3*4)是不一樣的。之前一直混淆了兩者的區別。 這裡求兩幅影象的單應性矩陣,只是利用多元方程組初步求解出H矩陣,然後利用迭代最小化反投影誤差的方式進一步精確計算出H。H=(h11,h12,h13; h21,h22,h23; h31,h32,h33) C++:
Mat findHomography(InputArray srcPoints, InputArray dstPoints, int method=0, double ransacReprojThreshold=3, OutputArray mask=noArray() )?
Parameters:
  • srcPoints – Coordinates of the points in the original plane, a matrix of the type CV_32FC2 orvector<Point2f> .
  • dstPoints – Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or avector<Point2f> .
  • method –

    Method used to computed a homography matrix. The following methods are possible:

    • 0 - a regular method using all the points
    • CV_RANSAC - RANSAC-based robust method
    • CV_LMEDS - Least-Median robust method
  • ransacReprojThreshold –

    Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). That is, if

    | texttt{dstPoints} _i -  texttt{convertPointsHomogeneous} ( texttt{H} * texttt{srcPoints} _i) |  >  texttt{ransacReprojThreshold}

    then the point i is considered an outlier. If srcPoints and dstPoints are measured in pixels, it usually makes sense to set this parameter somewhere in the range of 1 to 10.

  • mask – Optional output mask set by a robust method ( CV_RANSAC or CV_LMEDS ). Note that the input mask values are ignored.

程式碼移植,菜鳥請教:
1.此函式具體是怎樣求解方程的呢?單應性矩陣有8個獨立元素:H = h00 h01 h02      手動計算前兩行元素與函式輸出結
                                                                                                       h10 h11 h12
                                                                                                       h20 h21  1   
果接近,但h20和h21只能得到比例且比例與所選點座標有關,感覺解不唯一,請問大神可以告知這兩個元素是怎樣確定的嗎?
2.找不到cvFindHomography()原始碼,能告訴從哪裡能獲得嗎?或者直接發給我就更好啦!謝!

最近學習有關findhomography的呼叫,請問經過RANSAC挑選適合的特徵點後,
是用什麼方法求出八個引數? (Levenberg-Marquardt? gradient descent? 還是其他方法)






1、src_points,dst_points為N×2或者N×3的矩陣,N×2表示點是以畫素座標表示。N×3表示以齊次座標表示。

2、homography,為3*3大小的矩陣,用來儲存輸出的結果。