Shape Coordinates用以描述Object剔除掉Euclidean Similarity Transformation(移动、旋转和缩放)变量后的Shape属性。本文介绍Bookstein Shape Coordinates在二维和三维数据中的应用。
Definition 1: Let ( x j , y j ) , j = 1 , … , k , (x_{j},y_{j}),j=1,\dots,k, (xj,yj),j=1,…,k, be k ≥ 3 k\ge3 k≥3 landmarks in a plane (m = 2 dimensions). Bookstein coordinates ( x j B , y j B ) T , j = 3 , … , k (x_{j}^{B},y_{j}^{B})^{T},j=3,\dots,k (xjB,yjB)T,j=3,…,k, are the remaining coordinates of an object after translating, rotating and rescaling the baseline to ( − 1 2 , 0 ) (-\frac{1}{2},0) (−21,0) and ( 1 2 , 0 ) (\frac{1}{2},0) (21,0) so that x j B = [ ( x 2 − x 1 ) ( x j − x 1 ) + ( y 2 − y 1 ) ( y j − y 1 ) ] / D 12 2 − 1 2 , y j B = [ ( x 2 − x 1 ) ( y j − y 1 ) + ( y 2 − y 1 ) ( x j − x 1 ) ] / D 12 2 , \begin{aligned} & x_{j}^{B} = [(x_{2}-x_{1})(x_{j}-x_{1}) + (y_{2}-y_{1})(y_{j}-y_{1})]/D_{12}^{2} -\frac{1}{2}, \\ & y_{j}^{B} = [(x_{2}-x_{1})(y_{j}-y_{1}) + (y_{2}-y_{1})(x_{j}-x_{1})]/D_{12}^{2}, \end{aligned} xjB=[(x2−x1)(xj−x1)+(y2−y1)(yj−y1)]/D122−21,yjB=[(x2−x1)(yj−y1)+(y2−y1)(xj−x1)]/D122,
where j = 3 , … , k j = 3,\dots,k j=3,…,k, D 12 2 = ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 > 0 D_{12}^{2} = (x_{2}-x_{1})^{2} +(y_{2}-y_{1})^2 \gt 0 D122=(x2−x1)2+(y2−y1)2>0 and − ∞ < x j B , y j B < ∞ -\infty \lt x_{j}^{B},y_{j}^{B} \lt \infty −∞<xjB,yjB<∞.
推导: Step 1: Translating(将 ( x 1 , y 1 ) T (x_{1},y_{1})^{T} (x1,y1)T移动到 ( x 1 B , y 1 B ) T = ( 0 , 0 ) T (x_{1}^{B},y_{1}^{B})^{T}=(0,0)^{T} (x1B,y1B)T=(0,0)T,得到所有landmarks坐标的平移向量) [ 0 0 ] − [ x 1 y 1 ] = [ − x 1 − y 1 ] \begin{bmatrix} 0 \\ 0 \end{bmatrix} - \begin{bmatrix} x_{1} \\ y_{1} \end{bmatrix} = \begin{bmatrix} -x_{1} \\ -y_{1} \end{bmatrix} [00]−[x1y1]=[−x1−y1]
Step 2: Rotation(借助旋转矩阵Rotation Matrix,将 ( x 2 , y 2 ) T (x_{2},y_{2})^{T} (x2,y2)T移动到X轴上 ( x 2 ′ , 0 ) T (x_{2}^{\prime},0)^{T} (x2′,0)T) 关于原点逆时针旋转 θ \theta θ的矩阵是: [ cos θ − sin θ sin θ cos θ ] \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} [cosθsinθ−sinθcosθ]
那么关于原点顺时针旋转 θ \theta θ的矩阵是: [ cos ( − θ ) − sin ( − θ ) sin ( − θ ) cos ( − θ ) ] = [ cos θ sin θ − sin θ cos θ ] \begin{bmatrix} \cos(-\theta) & -\sin(-\theta) \\ \sin(-\theta) & \cos(-\theta) \end{bmatrix} = \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} [cos(−θ)sin(−θ)−sin(−θ)cos(−θ)]=[cosθ−sinθsinθcosθ]
而 tan θ = y 2 − y 1 x 2 − x 1 \tan\theta = \frac{y_{2}-y_{1}}{x_{2}-x_{1}} tanθ=x2−x1y2−y1。因此,得到Bookstein coordinates的旋转矩阵: [ cos θ sin θ − sin θ cos θ ] = [ x 2 − x 1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 y 2 − y 1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 y 1 − y 2 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 x 2 − x 1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 ] = 1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 [ x 2 − x 1 y 2 − y 1 y 1 − y 2 x 2 − x 1 ] \begin{aligned} & \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} = \begin{bmatrix} \frac{x_{2}-x_{1}}{\sqrt{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2}} & \frac{y_{2}-y_{1}}{\sqrt{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2}} \\ \frac{y_{1}-y_{2}}{\sqrt{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2}} & \frac{x_{2}-x_{1}}{\sqrt{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2}} \end{bmatrix} \\ & = \frac{1}{\sqrt{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2}} \begin{bmatrix} x_{2}-x_{1} & y_{2}-y_{1} \\ y_{1}-y_{2} & x_{2}-x_{1} \end{bmatrix} \end{aligned} [cosθ−sinθsinθcosθ]=⎣⎡(x2−x1)2+(y2−y1)2 x2−x1(x2−x1)2+(y2−y1)2 y1−y2(x2−x1)2+(y2−y1)2 y2−y1(x2−x1)2+(y2−y1)2 x2−x1⎦⎤=(x2−x1)2+(y2−y1)2 1[x2−x1y1−y2y2−y1x2−x1]
Step 3: Scaling(将 ( x 2 ′ , 0 ) T (x_{2}^{\prime},0)^{T} (x2′,0)T移动到 ( x 2 B , y 2 B ) T = ( 1 , 0 ) T (x_{2}^{B},y_{2}^{B})^{T}=(1,0)^{T} (x2B,y2B)T=(1,0)T,使 ( x 1 B , y 1 B ) T (x_{1}^{B},y_{1}^{B})^{T} (x1B,y1B)T到 ( x 2 B , y 2 B ) T (x_{2}^{B},y_{2}^{B})^{T} (x2B,y2B)T的距离为1) 1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 \frac{1}{\sqrt{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2}} (x2−x1)2+(y2−y1)2 1
因此, [ x j B y j B ] = S c a l i n g ∘ R o t a t i o n ∘ T r a n s l a t i n g ( [ x j y j ] ) = 1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 [ x 2 − x 1 y 2 − y 1 y 1 − y 2 x 2 − x 1 ] ( [ x j y j ] + [ − x 1 − y 1 ] ) = 1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 [ ( x 2 − x 1 ) ( x j − x 1 ) + ( y 2 − y 1 ) ( y j − y 1 ) ( y 1 − y 2 ) ( x j − x 1 ) + ( x 2 − x 1 ) ( y j − y 1 ) ] \begin{aligned} & \begin{bmatrix} x_{j}^{B} \\ y_{j}^{B} \end{bmatrix} = Scaling \circ Rotation \circ Translating( \begin{bmatrix} x_{j} \\ y_{j} \end{bmatrix} ) \\ & = \frac{1}{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2} \begin{bmatrix} x_{2}-x_{1} & y_{2}-y_{1} \\ y_{1}-y_{2} & x_{2}-x_{1} \end{bmatrix} (\begin{bmatrix} x_{j} \\ y_{j} \end{bmatrix} + \begin{bmatrix} -x_{1} \\ -y_{1} \end{bmatrix}) \\ & = \frac{1}{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2} \begin{bmatrix} (x_{2}-x_{1})(x_{j}-x_{1}) + (y_{2}-y_{1})(y_{j}-y_{1}) \\ (y_{1}-y_{2})(x_{j}-x_{1}) + (x_{2}-x_{1})(y_{j}-y_{1}) \end{bmatrix} \end{aligned} [xjByjB]=Scaling∘Rotation∘Translating([xjyj])=(x2−x1)2+(y2−y1)21[x2−x1y1−y2y2−y1x2−x1]([xjyj]+[−x1−y1])=(x2−x1)2+(y2−y1)21[(x2−x1)(xj−x1)+(y2−y1)(yj−y1)(y1−y2)(xj−x1)+(x2−x1)(yj−y1)]
Step 4: 为了对称性,可将 ( x j B , y j B ) T (x_{j}^{B},y_{j}^{B})^{T} (xjB,yjB)T左移 1 2 \frac{1}{2} 21。
Step 1: Translating(将 ( x 1 , y 1 , z 1 ) T (x_{1},y_{1},z_{1})^{T} (x1,y1,z1)T移动到 ( x 1 B , y 1 B , z 1 B ) T = ( 0 , 0 , 0 ) T (x_{1}^{B},y_{1}^{B},z_{1}^{B})^{T}=(0,0,0)^{T} (x1B,y1B,z1B)T=(0,0,0)T,得到所有landmarks坐标的平移向量) [ 0 0 0 ] − [ x 1 y 1 z 1 ] = [ − x 1 − y 1 − z 1 ] \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix} - \begin{bmatrix} x_{1} \\ y_{1} \\ z_{1} \end{bmatrix} = \begin{bmatrix} -x_{1} \\ -y_{1} \\ -z_{1} \end{bmatrix} ⎣⎡000⎦⎤−⎣⎡x1y1z1⎦⎤=⎣⎡−x1−y1−z1⎦⎤
Step 2: Rotation(借助旋转矩阵Rotation Matrix,将 ( x 2 , y 2 , z 2 ) T (x_{2},y_{2},z_{2})^{T} (x2,y2,z2)T移动到X轴上 ( x 2 ′ , 0 , 0 ) T (x_{2}^{\prime},0,0)^{T} (x2′,0,0)T,并将 ( x 3 , y 3 , z 3 ) T (x_{3},y_{3},z_{3})^{T} (x3,y3,z3)T移动到 X − Y X-Y X−Y平面上 ( x 3 ′ , y 3 ′ , 0 ) T (x_{3}^{\prime},y_{3}^{\prime},0)^{T} (x3′,y3′,0)T)
( x 2 − x 1 , y 2 − y 1 , z 2 − z 1 ) T (x2-x1,y2-y1,z2-z1)^T (x2−x1,y2−y1,z2−z1)T绕 X X X轴(在 Y − Z Y-Z Y−Z平面)顺时针旋转: R x ( θ x ) = [ 1 0 0 0 cos θ x sin θ x 0 − sin θ x cos θ x ] R_{x}(\theta_{x}) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos{\theta_{x}} & \sin{\theta_{x}} \\ 0 & -\sin{\theta_{x}} & \cos{\theta_{x}} \end{bmatrix} Rx(θx)=⎣⎡1000cosθx−sinθx0sinθxcosθx⎦⎤
( x 2 − x 1 , y 2 − y 1 , z 2 − z 1 ) T (x2-x1,y2-y1,z2-z1)^T (x2−x1,y2−y1,z2−z1)T绕 Y Y Y轴(在 X − Z X-Z X−Z平面)顺时针旋转: R y ( θ y ) = [ cos θ y 0 − sin θ y 0 1 0 sin θ y 0 cos θ y ] R_{y}(\theta_{y}) = \begin{bmatrix} \cos{\theta_{y}} & 0 & -\sin{\theta_{y}} \\ 0 & 1 & 0 \\ \sin{\theta_{y}} & 0 & \cos{\theta_{y}} \end{bmatrix} Ry(θy)=⎣⎡cosθy0sinθy010−sinθy0cosθy⎦⎤
( x 2 − x 1 , y 2 − y 1 , z 2 − z 1 ) T (x2-x1,y2-y1,z2-z1)^T (x2−x1,y2−y1,z2−z1)T绕 Z Z Z轴(在 X − Y X-Y X−Y平面)顺时针旋转: R z ( θ z ) = [ cos θ z sin θ z 0 − sin θ z cos θ z 0 0 0 1 ] R_{z}(\theta_{z}) = \begin{bmatrix} \cos{\theta_{z}} & \sin{\theta_{z}} & 0 \\ -\sin{\theta_{z}} & \cos{\theta_{z}} & 0 \\ 0 & 0 & 1 \end{bmatrix} Rz(θz)=⎣⎡cosθz−sinθz0sinθzcosθz0001⎦⎤
Step 3: Scaling(将 ( x 2 ′ , 0 , 0 ) T (x_{2}^{\prime},0,0)^{T} (x2′,0,0)T移动到 ( x 2 B , y 2 B , z 2 B ) T = ( 1 , 0 , 0 ) T (x_{2}^{B},y_{2}^{B},z_{2}^{B})^{T}=(1,0,0)^{T} (x2B,y2B,z2B)T=(1,0,0)T,使 ( x 1 B , y 1 B , z 1 B ) T (x_{1}^{B},y_{1}^{B},z_{1}^{B})^{T} (x1B,y1B,z1B)T到 ( x 2 B , y 2 B , z 2 B ) T (x_{2}^{B},y_{2}^{B},z_{2}^{B})^{T} (x2B,y2B,z2B)T的距离为1)
1 ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 + ( z 2 − z 1 ) 2 \frac{1}{\sqrt{(x_{2}-x_{1})^{2} + (y_{2}-y_{1})^2 + (z_{2}-z_{1})^2}} (x2−x1)2+(y2−y1)2+(z2−z1)2 1
因此, [ x j B y j B z j B ] = S c a l i n g ∘ R x ( θ x ) ∘ R y ( θ y ) ∘ R z ( θ z ) ∘ T r a n s l a t i n g ( [ x j y j z j ] ) \begin{bmatrix} x_{j}^{B} \\ y_{j}^{B} \\ z_{j}^{B} \end{bmatrix} = Scaling \circ R_{x}(\theta_{x}) \circ R_{y}(\theta_{y}) \circ R_{z}(\theta_{z}) \circ Translating( \begin{bmatrix} x_{j} \\ y_{j} \\ z_{j} \end{bmatrix} ) ⎣⎡xjByjBzjB⎦⎤=Scaling∘Rx(θx)∘Ry(θy)∘Rz(θz)∘Translating(⎣⎡xjyjzj⎦⎤)