Medical Image Registration - Transformation matrix in 2D

Gyuha Park·2021년 8월 26일
0

Medical Image Analysis

목록 보기
15/21
post-thumbnail

1. Transformation

1) Translation

[xy]=[xy]+[txty]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} t_x\\t_y \end{bmatrix}

2) Rotation

[xy]=[cosθsinθsinθcosθ][xy]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}

3) Scaling

[xy]=[s00s][xy]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} s & 0 \\ 0 & s \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}

4) Shearing

[xy]=[10λ1][xy]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} 1 & 0 \\ \lambda & 1 \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}

5) Rigid transformation

[xy]=[cosθsinθsinθcosθ][xy]+[txty]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} t_x\\t_y \end{bmatrix}

[xy]=[abba][xy]+[cd]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} a & -b \\ b & a \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} c\\d \end{bmatrix}

6) Similarity transformation

[xy]=[scosθssinθssinθscosθ][xy]+[txty]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} s\cos\theta & -s\sin\theta \\ s\sin\theta & s\cos\theta \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} t_x\\t_y \end{bmatrix}

[xy]=[abba][xy]+[cd]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} a & -b \\ b & a \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} c\\d \end{bmatrix}

7) Affine transformation

[xy]=[abcd][xy]+[ef]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} a & b \\ c & d \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} e\\f \end{bmatrix}

2. Pseudo Inverse

대응되는 (x,y)(x, y), (x,y)(x', y')이 주어졌을 때, transformation의 parameter를 찾기 위해 pseudo inverse를 이용한다.

[xy]=[abba][xy]+[cd]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} a & -b \\ b & a \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} c\\d \end{bmatrix}

a=scosθa=s\cos\theta

b=ssinθb=s\sin\theta

위 식을 (x,y)(x', y')에 대해 정리하면 식은 다음과 같다.

x=axby+cx'=ax-by+c

y=bx+ay+dy'=bx+ay+d

만약 nn개의 대응되는 (x,y)(x, y), (x,y)(x', y')이 주어졌을 때, 다음과 같이 식을 표현할 수 있다.

[x1y110y1x101x2y210y2x201xnyn10ynxn01][abcd]=[x1y1x2y2xnyn]\begin{bmatrix} x_1 & -y_1 & 1 & 0 \\ y_1 & x_1 & 0 & 1 \\ x_2 & -y_2 & 1 & 0 \\y_2 & x_2 & 0 & 1 \\ \vdots & \vdots & \vdots & \vdots \\ x_n & -y_n & 1 & 0 \\ y_n & x_n & 0 & 1 \end{bmatrix}\begin{bmatrix} a \\ b \\ c \\ d \end{bmatrix} = \begin{bmatrix} x_1' \\ y_1' \\ x_2' \\ y_2' \\ \vdots \\ x_n' \\ y_n' \end{bmatrix}

위 식을 치환하면 AX=BAX=B로 간단하게 표현할 수 있으며 AA의 역행렬이 존재하면 transformation parameter XX를 구할 수 있게 된다.

이 때, AA는 정방행렬이 아니므로 일반적인 방법으로는 역행렬을 구할 수 없다. 그러므로 pseudo inverse로 근사 값의 역행렬을 구한다.

X=A+BX=A^{+}B

X=(ATA)1ATBX=(A^TA)^{-1}A^TB

만약 (ATA)(A^TA)의 역행렬도 존재하지 않는다면 SVD를 이용한다.

A=UVTA=U\sum V^T

UVTX=BU\sum V^TX=B

(V+UT)(UVT)X=(V+UT)B(V\sum^+U^T)(U\sum V^T)X=(V\sum^+U^T)B

X=(V+UT)BX=(V\sum^+U^T)B

Affine transformation도 동일하게 pseudo inverse로 transformation parameter를 구할 수 있다.

[xy]=[abcd][xy]+[ef]\begin{bmatrix} x'\\y' \end{bmatrix}=\begin{bmatrix} a & b \\ c & d \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}+\begin{bmatrix} e\\f \end{bmatrix}

x=ax+by+ex'=ax+by+e

y=cx+dy+fy'=cx+dy+f

[x1y1001000x1y101x2y2001000x2y201xnyn001000xnyn01][abcdef]=[x1y1x2y2xnyn]\begin{bmatrix} x_1 & y_1 & 0 & 0 & 1 & 0\\ 0 & 0 & x_1 & y_1 & 0 & 1 \\ x_2 & y_2 & 0 & 0 & 1 & 0\\ 0 & 0 & x_2 & y_2 & 0 & 1 \\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ x_n & y_n & 0 & 0 & 1 & 0\\ 0 & 0 & x_n & y_n & 0 & 1 \end{bmatrix}\begin{bmatrix} a \\ b \\ c \\ d \\e \\ f \end{bmatrix} = \begin{bmatrix} x_1' \\ y_1' \\ x_2' \\ y_2' \\ \vdots \\ x_n' \\ y_n' \end{bmatrix}

X=A+BX=A^{+}B

X=(ATA)1ATBX=(A^TA)^{-1}A^TB

3. Transformation Matrix

1) Translation

[cosθsinθ0sinθcosθ0001]\begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}

2) Rotation

[10tx01ty001]\begin{bmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{bmatrix}

3) Scaling

[sx000sy0001]\begin{bmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 \end{bmatrix}

4) Shearing

[100λ10001]\begin{bmatrix} 1 & 0 & 0 \\ \lambda & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}

5) Similarity transformation

[xy1]=[abcbad001][xy1]\begin{bmatrix} x'\\y' \\ 1 \end{bmatrix}=\begin{bmatrix} a & -b & c \\ b & a & d \\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} x\\y\\1 \end{bmatrix}

6) Affine transformation

[xy1]=[abecdf001][xy1]\begin{bmatrix} x'\\y' \\ 1 \end{bmatrix}=\begin{bmatrix} a & b & e \\ c & d & f \\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} x\\y\\1 \end{bmatrix}

profile
Live on mission ✞

0개의 댓글