图像变换
变换矩阵
- 缩放
T = ( a 0 0 b ) T = \left( \begin{matrix} a& 0 \\ 0&b \end{matrix} \right) T=(a00b)
- 翻转:
- 关于x轴:
T x = ( 1 0 0 − 1 ) T_x = \left( \begin{matrix} 1&0\\0&-1 \end{matrix} \right) Tx=(100−1)
- 关于y轴:
T y = ( − 1 0 0 1 ) T_y = \left( \begin{matrix} -1 & 0\\0 & 1\end{matrix} \right) Ty=(−1001)
- 关于原点对称:
T = ( − 1 0 0 − 1 ) = T y ∗ T x T = \left( \begin{matrix} -1&0\\0 &-1 \end{matrix} \right) = T_y * T_x T=(−100−1)=Ty∗Tx
- 错切:
- 沿x轴错切:y不变,x=x+ay
T = ( 1 a 0 1 ) T = \left( \begin{matrix} 1&a\\0&1 \end{matrix} \right) T=(10a1)
即对应方程组:
{ x ′ = 1 ∗ x + a ∗ y y ′ = 0 ∗ x + y \left\{ \begin{array}{lr}x' = 1*x + a*y\\y' = 0*x + y \end{array} \right. {x′=1∗x+a∗yy′=0∗x+y
- 沿y轴错切:x不变,y=bx+y
T = ( 1 0 b a ) T = \left( \begin{matrix} 1&0\\b&a\end{matrix}\right) T=(1b0a)
- 旋转变换:
(x, y) 顺时针旋转 θ \theta θ度:
已知:
tan
α
=
y
x
\tan{\alpha} = \frac{y}{x}
tanα=xy
x
=
cos
α
∗
d
x = \cos{\alpha}*d
x=cosα∗d
y
=
sin
α
∗
d
y = \sin{\alpha}*d
y=sinα∗d
↓
\downarrow
↓
x
′
=
d
∗
cos
(
α
−
θ
)
=
d
∗
(
cos
α
cos
θ
+
sin
α
sin
θ
)
=
cos
θ
∗
x
+
sin
θ
∗
y
x' = d*\cos{(\alpha-\theta)}\\ = d*(\cos{\alpha}\cos{\theta}+\sin{\alpha}\sin{\theta}) \\=\cos{\theta}*x+\sin{\theta}*y
x′=d∗cos(α−θ)=d∗(cosαcosθ+sinαsinθ)=cosθ∗x+sinθ∗y
同理:
y
′
=
d
∗
sin
(
α
−
θ
)
=
cos
θ
∗
y
−
sin
θ
∗
x
y' = d*\sin{(\alpha-\theta)} = \cos{\theta} * y - \sin{\theta}*x
y′=d∗sin(α−θ)=cosθ∗y−sinθ∗x
整理得:
(x, y) --顺时针旋转
θ
\theta
θ度–> (
cos
θ
∗
x
+
sin
θ
∗
y
\cos{\theta}*x+\sin{\theta}*y
cosθ∗x+sinθ∗y,
−
sin
θ
∗
x
+
cos
θ
∗
y
-\sin{\theta}*x + \cos{\theta} * y
−sinθ∗x+cosθ∗y)
TIPS:三角公式
- sin(α+β)=sinαcosβ+cosαsinβ
- cos(α+β)=cosαcosβ-sinαsinβ
T = ( cos θ sin θ − sin θ cos θ ) T = \left( \begin{matrix} \cos{\theta} & \sin{\theta}\\-\sin{\theta} & \cos{\theta} \end{matrix} \right) T=(cosθ−sinθsinθcosθ)
- 平移:引入仿射变换
单位矩阵 I (Identity):
I 2 = ( 1 0 0 1 ) . . . I_2 = \left( \begin{matrix} 1 & 0 \\ 0 & 1\end{matrix}\right) ... I2=(1001)...
矩阵的逆
- 定义:
AB = BA = I, 则称B是A的逆矩阵, B = A-1
A称为可逆矩阵(非奇异矩阵 non-singular)
不可逆矩阵(奇异矩阵 singular) 少
A0 = I
A-1 逆矩阵
BA = I
⇒
\Rightarrow
⇒ B是A的左逆矩阵
AC = I
⇒
\Rightarrow
⇒ C是A的右逆矩阵
如果A即存在B又存在C
⇒
\Rightarrow
⇒ B = C
推论:A可逆矩阵一定是方阵
- 性质:
(A-1)-1 = A
(BA)-1 = B-1A-1
看待矩阵的四个视角
一、二维数据:
每一行:样本
每一列: 特征
二、系统:
线性系统,方程组
三、向量的函数:
变换:输入向量,输出向量
仿射变换:任意变换 --> 矩阵参数求解
四、空间:
线性空间
坐标
图形变换:原图形放到新的空间中
由图形位置反推出空间矩阵