定義
2D單應性變換定義為從一個平面到另一個平面的投影映射, 單應矩陣形式如下:
\[H= \begin{bmatrix} h_{00} & h_{01} & h_{02} \\ h_{10} & h_{11} & h_{12} \\ h_{20} & h_{21} & h_{22} \end{bmatrix} \]
坐標 \((x, y)\) 通過單應性變換映射到 \((u, v)\), 使用齊次坐標即為 \((x, y, 1)\), \((u, v, 1)\), 具有如下變換 \(\bf{x'=Hx}\)
\[s\begin{bmatrix}u\\v\\1\end{bmatrix} = \begin{bmatrix} h_{00} & h_{01} & h_{02} \\ h_{10} & h_{11} & h_{12} \\ h_{20} & h_{21} & h_{22} \end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix} \]
計算單應變換H需要多少對應點?
一方面矩陣H有9個參數, 但只確定到相差一個尺度因子s, 不妨約束 \(\|H\|\) = 1, 來避免h=0的解. 因此2D攝影變換的自由度是8,需要4個點對(任意3點不共線, 線性不相關)
直接線性變換(DLT)解法
齊次解
給予4個點對, 求齊次解
\[\begin{equation} \left\{ \begin{aligned} su&=h_{00}x + h_{01}y + h_{02}\\ sv&=h_{10}x + h_{11}y + h_{12}\\ s&=h_{20}x + h_{21}y + h_{22} \\ \end{aligned} \right. \end{equation} \]
\[\begin{equation} \label{eq2} \begin{bmatrix} -x & -y &-1&0&0&0&xx_1&yx_1&x_1 \\ 0&0&0& -x & -y &-1&xy_1&yy_1&y_1 \\ \end{bmatrix} \begin{bmatrix}h_{00}\\h_{01}\\h_{02}\\h_{10}\\h_{11}\\h_{12}\\h_{20}\\h_{21}\end{bmatrix}=0 \end{equation} \\ Ah = 0 \]
矩陣 \(A \in \bf R^{8\times9}\), 最大可能秩為8, 那么齊次方程組有一個1維零空間, h的這樣一個解只能在相差一個非零尺度因子下確定
超定解
如果給出的點對超過4, 矩陣 \(A \in \bf R^{m\times9, \space m>8}\)
如果點的位置精確的話, A的秩依然是8. 解法參上
如果圖像測量點位置存在誤差, 我們試圖尋找一個近似解, 解為A的右奇異矩陣最小奇異值對應的特征向量, 解法詳解
非齊次解
給予4個點對, 既然允許解相差任意一個尺度因子, 自然可以選擇尺度因子值使得 \(h_j=1\), 不妨設 \(h_{22}=1\),
\[H= \begin{bmatrix} h_{00} & h_{01} & h_{02} \\ h_{10} & h_{11} & h_{12} \\ h_{20} & h_{21} & 1 \end{bmatrix} \]
即
\[s\begin{bmatrix}u\\v\\1\end{bmatrix} = \begin{bmatrix} h_{00} & h_{01} & h_{02} \\ h_{10} & h_{11} & h_{12} \\ h_{20} & h_{21} & 1 \end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix} \]
線性方程組如下:
\[\begin{equation} \left\{ \begin{aligned} su&=h_{00}x + h_{01}y + h_{02}\\ sv&=h_{10}x + h_{11}y + h_{12}\\ s&=h_{20}x + h_{21}y + 1 \\ \end{aligned} \right. \end{equation} \]
化簡可得
\[\begin{equation} \begin{bmatrix}x & y &1&0&0&0&-xu&-yu \\ 0&0&0& x & y &1&-xv&-yv \\ \end{bmatrix} \begin{bmatrix}h_{00}\\h_{01}\\h_{02}\\h_{h10}\\h_{11}\\h_{12}\\h_{20}\\h_{21}\end{bmatrix} = \begin{bmatrix}u\\v\end{bmatrix} \end{equation} \\ Ah = b\\ h = A^{-1}b \]
但是, 如果事實上真正解 \(h_j=0\), 那么不存在 \(kh_j=1\), 意味着令 \(h_j=1\) 得不到真正的解, 那么如果被選的\(h_j\)真正解接近於0, 該方法將導致不穩定解.