不同像平面坐标系下的Brown畸变系数互转

不同像平面坐标系下Brown畸变系数转换

u , v u,v u,v为像素为单位的坐标,f为焦距,单位也是像素。

x , y x,y x,y为理想坐标。本文推导两种情况下的Brown畸变系数转换关系:

  1. 相同坐标系定义、不同的坐标单位(像素坐标与归一化坐标)的畸变系数关系
  2. 坐标系原点相同、y轴方向相反的坐标系之间畸变系数关系

像素坐标与归一化坐标的畸变系数的关系推导

像素为单位的畸变计算

使用像素坐标计算畸变值的公式为:

{ d u = u ( K 1 r 2 + K 2 r 4 + K 3 r 6 ) + P 1 ( r 2 + 2 u 2 ) + 2 P 2 u v d v = v ( K 1 r 2 + K 2 r 4 + K 3 r 6 ) + P 2 ( r 2 + 2 v 2 ) + 2 P 1 u v (A) \begin{cases} du = u(K_1 r^2+K_2 r^4+K_3 r^6)+P_1(r^2+2u^2)+2P_2 uv\\ dv = v(K_1 r^2+K_2 r^4+K_3 r^6)+P_2(r^2+2v^2)+2P_1 uv\\ \end{cases}\tag{A} {du=u(K1r2+K2r4+K3r6)+P1(r2+2u2)+2P2uvdv=v(K1r2+K2r4+K3r6)+P2(r2+2v2)+2P1uv(A)

计算机视觉的归一化坐标畸变计算

u , v u,v u,v为像素为单位的坐标,f为焦距,单位也是像素。计算机视觉使用归一化坐标:

{ x = u f y = v f (B) \begin{cases}x=\dfrac{u}{f}\\y=\dfrac{v}{f}\end{cases}\tag{B} x=fuy=fv(B)

计算畸变值的公式为:

{ d x = x ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) + p 1 ( r 2 + 2 x 2 ) + 2 p 2 x y d y = y ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) + p 2 ( r 2 + 2 y 2 ) + 2 p 1 x y (C) \begin{cases} dx=x(k_1 r^2+k_2 r^4+k_3 r^6)+p_1(r^2+2x^2)+2p_2 xy\\ dy=y(k_1 r^2+k_2 r^4+k_3 r^6)+p_2(r^2+2y^2)+2p_1 xy\\ \end{cases}\tag{C} {dx=x(k1r2+k2r4+k3r6)+p1(r2+2x2)+2p2xydy=y(k1r2+k2r4+k3r6)+p2(r2+2y2)+2p1xy(C)

推导过程

对比(A)(C)两个公式,将(C)式中的x,y按照(B)替换为u,v的表达式,得:
{ d u f = u f ( k 1 R 2 f 2 + k 2 R 4 f 4 + k 3 R 6 f 6 ) + p 1 ( R 2 f 2 + 2 u 2 f 2 ) + 2 p 2 u f v f d v f = v f ( k 1 R 2 f 2 + k 2 R 4 f 4 + k 3 R 6 f 6 ) + p 2 ( R 2 f 2 + 2 v 2 f 2 ) + 2 p 1 u f v f (D) \begin{cases} \dfrac{du}{f}=\dfrac{u}{f}(k_1 \dfrac{R^2}{f^2}+k_2 \dfrac{R^4}{f^4}+k_3 \dfrac{R^6}{f^6})+p_1(\dfrac{R^2}{f^2}+2\dfrac{u^2}{f^2})+2p_2 \dfrac{u}{f}\dfrac{v}{f}\\ \dfrac{dv}{f}=\dfrac{v}{f}(k_1 \dfrac{R^2}{f^2}+k_2 \dfrac{R^4}{f^4}+k_3 \dfrac{R^6}{f^6})+p_2(\dfrac{R^2}{f^2}+2\dfrac{v^2}{f^2})+2p_1 \dfrac{u}{f}\dfrac{v}{f}\\ \end{cases}\tag{D} fdu=fu(k1f2R2+k2f4R4+k3f6R6)+p1(f2R2+2f2u2)+2p2fufvfdv=fv(k1f2R2+k2f4R4+k3f6R6)+p2(f2R2+2f2v2)+2p1fufv(D)
其中, R 2 = u 2 + v 2 R^2=u^2+v^2 R2=u2+v2

整理得:
{ d u f = u f ( k 1 f 2 R 2 + k 2 f 4 R 4 + k 3 f 6 R 6 ) + p 1 f 2 ( R 2 + 2 u 2 ) + 2 p 2 f 2 u v d v f = v f ( k 1 f 2 R 2 + k 2 f 4 R 4 + k 3 f 6 R 6 ) + p 2 f 2 ( R 2 + 2 v 2 ) + 2 p 1 f 2 u v (E) \begin{cases} \dfrac{du}{f}=\dfrac{u}{f}( \dfrac{k_1}{f^2}R^2+ \dfrac{k_2}{f^4}R^4+ \dfrac{k_3}{f^6}R^6)+\dfrac{p_1}{f^2}(R^2+2u^2)+2 \dfrac{p_2}{f^2}uv\\ \dfrac{dv}{f}=\dfrac{v}{f}( \dfrac{k_1}{f^2}R^2+ \dfrac{k_2}{f^4}R^4+ \dfrac{k_3}{f^6}R^6)+\dfrac{p_2}{f^2}(R^2+2v^2)+2 \dfrac{p_1}{f^2}uv\\ \end{cases}\tag{E} fdu=fu(f2k1R2+f4k2R4+f6k3R6)+f2p1(R2+2u2)+2f2p2uvfdv=fv(f2k1R2+f4k2R4+f6k3R6)+f2p2(R2+2v2)+2f2p1uv(E)

(E)式两边乘f,得:
{ d u = u ( k 1 f 2 R 2 + k 2 f 4 R 4 + k 3 f 6 R 6 ) + p 1 f ( R 2 + 2 u 2 ) + 2 p 2 f u v d v = v ( k 1 f 2 R 2 + k 2 f 4 R 4 + k 3 f 6 R 6 ) + p 2 f ( R 2 + 2 v 2 ) + 2 p 1 f u v (F) \begin{cases} du=u( \dfrac{k_1}{f^2}R^2+ \dfrac{k_2}{f^4}R^4+ \dfrac{k_3}{f^6}R^6)+\dfrac{p_1}{f}(R^2+2u^2)+2 \dfrac{p_2}{f}uv\\ dv=v( \dfrac{k_1}{f^2}R^2+ \dfrac{k_2}{f^4}R^4+ \dfrac{k_3}{f^6}R^6)+\dfrac{p_2}{f}(R^2+2v^2)+2 \dfrac{p_1}{f}uv\\ \end{cases}\tag{F} du=u(f2k1R2+f4k2R4+f6k3R6)+fp1(R2+2u2)+2fp2uvdv=v(f2k1R2+f4k2R4+f6k3R6)+fp2(R2+2v2)+2fp1uv(F)

对比(C)(F)两式,即得:

K 1 = k 1 f 2 K 2 = k 2 f 4 K 3 = k 3 f 6 P 1 = p 1 f P 2 = p 2 f \begin{aligned}K_1 &= \dfrac{k_1}{f^2}\\ K_2 &= \dfrac{k_2}{f^4}\\ K_3 &= \dfrac{k_3}{f^6}\\ P_1 &= \dfrac{p_1}{f}\\ P_2 &= \dfrac{p_2}{f}\\\end{aligned} K1K2K3P1P2=f2k1=f4k2=f6k3=fp1=fp2

XRight-YUp 与 XRight-YDown的畸变系数的关系推导

摄影测量坐标系常用x轴向右y轴向上的像平面坐标系(XRight-YUp);计算机视觉常用x轴向右y轴向下的像平面坐标系(XRight-YDown)。
不同像平面坐标系下的Brown畸变系数互转_第1张图片

设XRightY-Down的图像坐标系中一点坐标为 ( x , y ) (x,y) (x,y),畸变改正数为 ( d x , d y ) (dx,dy) (dx,dy);在相同原点的XRight-YUp中坐标为 ( x , − y ) (x,-y) (x,y),畸变改正数为 ( d x , − d y ) (dx,-dy) (dx,dy)。它们计算畸变的公式形式相同,均符合(G)式:

{ d x = x ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) + p 1 ( r 2 + 2 x 2 ) + 2 p 2 x y d y = y ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) + p 2 ( r 2 + 2 y 2 ) + 2 p 1 x y (G) \begin{cases} dx=x(k_1 r^2+k_2 r^4+k_3 r^6)+p_1(r^2+2x^2)+2p_2 xy\\ dy=y(k_1 r^2+k_2 r^4+k_3 r^6)+p_2(r^2+2y^2)+2p_1 xy\\ \end{cases}\tag{G} {dx=x(k1r2+k2r4+k3r6)+p1(r2+2x2)+2p2xydy=y(k1r2+k2r4+k3r6)+p2(r2+2y2)+2p1xy(G)

设在XRightY-Down的图像坐标系中畸变参数为 k 1 , k 2 , k 3 , p 1 , p 2 k_1,k_2,k_3,p_1,p_2 k1,k2,k3,p1,p2;在XRightY-Up的图像坐标系中畸变参数为 k 1 ′ , k 2 ′ , k 3 ′ , p 1 ′ , p 2 ′ k'_1,k'_2,k'_3,p'_1,p'_2 k1,k2,k3,p1,p2,则我们有:

{ d x = x ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) + p 1 ( r 2 + 2 x 2 ) + 2 p 2 x y = x ( k 1 ′ r 2 + k 2 ′ r 4 + k 3 ′ r 6 ) + p 1 ′ ( r 2 + 2 x 2 ) + 2 p 2 ′ x ( − y ) − d y = − ( y ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) + p 2 ( r 2 + 2 y 2 ) + 2 p 1 x y ) = ( − y ) ( k 1 ′ r 2 + k 2 ′ r 4 + k 3 ′ r 6 ) + p 2 ′ ( r 2 + 2 ( − y ) 2 ) + 2 p 1 ′ x ( − y ) (H) \begin{cases} dx = x(k_1 r^2+k_2 r^4+k_3 r^6)+p_1(r^2+2x^2)+2p_2 xy=x(k'_1 r^2+k'_2 r^4+k'_3 r^6)+p'_1(r^2+2x^2)+2p'_2 x(-y)\\ -dy = -(y(k_1 r^2+k_2 r^4+k_3 r^6)+p_2(r^2+2y^2)+2p_1 xy)=(-y)(k'_1 r^2+k'_2 r^4+k'_3 r^6)+p'_2(r^2+2(-y)^2)+2p'_1 x(-y)\\ \end{cases}\tag{H} {dx=x(k1r2+k2r4+k3r6)+p1(r2+2x2)+2p2xy=x(k1r2+k2r4+k3r6)+p1(r2+2x2)+2p2x(y)dy=(y(k1r2+k2r4+k3r6)+p2(r2+2y2)+2p1xy)=(y)(k1r2+k2r4+k3r6)+p2(r2+2(y)2)+2p1x(y)(H)

整理得:

{ x ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) + p 1 ( r 2 + 2 x 2 ) + 2 p 2 x y = x ( k 1 ′ r 2 + k 2 ′ r 4 + k 3 ′ r 6 ) + p 1 ′ ( r 2 + 2 x 2 ) − 2 p 2 ′ x y − y ( k 1 r 2 + k 2 r 4 + k 3 r 6 ) − p 2 ( r 2 + 2 y 2 ) − 2 p 1 x y = − y ( k 1 ′ r 2 + k 2 ′ r 4 + k 3 ′ r 6 ) + p 2 ′ ( r 2 + 2 y 2 ) − 2 p 1 ′ x y (I) \begin{cases} x(k_1 r^2+k_2 r^4+k_3 r^6)+p_1(r^2+2x^2)+2p_2 xy=x(k'_1 r^2+k'_2 r^4+k'_3 r^6)+p'_1(r^2+2x^2)-2p'_2 xy\\ -y(k_1 r^2+k_2 r^4+k_3 r^6)-p_2(r^2+2y^2)-2p_1 xy=-y(k'_1 r^2+k'_2 r^4+k'_3 r^6)+p'_2(r^2+2y^2)-2p'_1 xy\\ \end{cases}\tag{I} {x(k1r2+k2r4+k3r6)+p1(r2+2x2)+2p2xy=x(k1r2+k2r4+k3r6)+p1(r2+2x2)2p2xyy(k1r2+k2r4+k3r6)p2(r2+2y2)2p1xy=y(k1r2+k2r4+k3r6)+p2(r2+2y2)2p1xy(I)

于是可得:

k 1 ′ = k 1 k 2 ′ = k 2 k 3 ′ = k 3 p 1 ′ = p 1 p 2 ′ = − p 2 \begin{aligned}k'_1&=k_1\\ k'_2& = k_2\\ k'_3 &= k_3\\ p'_1& = p_1\\ p'_2 &= -p_2\\\end{aligned} k1k2k3p1p2=k1=k2=k3=p1=p2

即,这两个坐标系中的畸变参数互转时仅需要将 p 2 p_2 p2取相反数,其他畸变系数可通用。

你可能感兴趣的:(数学,photoscan,计算机视觉)