计算机视觉笔记——图像变换

视觉github:https://github.com/g107904/Computer_Vision_task

线性几何变换

通常形式:

(1)   \begin{equation*} \left\{ \begin{array}{lc} x'= Gx(x,y)=a_{11}x+a_{12}y+b_{1}, & \\ y'=Gy(x,y)=a_{21}x+a_{22}y+b_{2} & \end{array} \right. \end{equation*}

矩阵形式:

    \[\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} b_{1} \\ b_{2} \end{bmatrix} = A_{2*2} \begin{bmatrix} x \\ y \end{bmatrix} + b_{2*1}\]

逆变换:

    \[\begin{bmatrix} x \\ y \end{bmatrix} = A^{-1} (\begin{bmatrix} x' \\ y' \end{bmatrix} - b_{2*1} )\]

平移变换:

    \[\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} b_{1} \\ b_{2} \end{bmatrix}\]

绕((x_{0},y_{0}) 旋转 \theta 度:

    \[\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} x_{0} \\ y_{0} \end{bmatrix}) + \begin{bmatrix} x_{0} \\ y_{0} \end{bmatrix}\]

欧几里得变换:

    \[\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} b_{1} \\ b_{2} \end{bmatrix}\]

相似变换:

    \[\begin{bmatrix} x' \\ y' \end{bmatrix} = s \begin{bmatrix} cos \theta & -sin \theta \\ sin \theta & cos \theta \end{bmatrix} \begin{bmatrix} x \\ y\end{bmatrix} + \begin{bmatrix} b_{1} \\ b_{2} \end{bmatrix}\]

仿射变换:

    \[\begin{bmatrix} x' \\ y' \end{bmatrix} = A_{2*2} \begin{bmatrix} x \\ y \end{bmatrix} + b_{2*1}\]

前向变换:
• 给定输入的数字图像:𝐼(𝑥, 𝑦)
• 其中𝑥 = 1,2, ⋯ , 𝑋;𝑦 = 1,2, ⋯ , 𝑌;
• 遍历输入图像𝐼的像素 (𝑥, 𝑦) ;
• 根据几何变换,生成相应像素点 (𝑥′, 𝑦′) ;
• 填充输出图像𝑂的相应位置的像素值:
𝑂(𝑥′, 𝑦′) = I(𝑥, 𝑦);
后向变换:
• 给定输入的数字图像:𝐼(𝑥, 𝑦)
• 其中𝑥 = 1,2, ⋯ , 𝑋;𝑦 = 1,2, ⋯ , 𝑌;
• 确定输出图像𝑂的区域 1 ⋯ 𝑋′ × 1 ⋯ 𝑌′
• 遍历输出图像𝑂的像素 (𝑥‘, 𝑦’) ;
• 根据逆变换,寻找输入图像中的相应像素位置 (𝑥, 𝑦) ;
• 填充输出图像𝑂的相应位置的像素值:
𝑂 (𝑥′, 𝑦′) = 𝐼 (𝑥, y)
灰度变换:
• 相等,图像反转,对数,指数,𝑛次幂,𝑛次根
• 从扩张/压缩的角度
• 相等和反转函数不改变原始图像的对比度
• 对数、𝑛次根在低灰度区扩展,高灰度区压缩
• 指数、𝑛次幂则相反
幂律变换:
• 幂律变换的形式:t = s^{\gamma}
• 其中𝑠, t均归一化到 0,1 之间
• 𝛾 = 1,𝑡 = 𝑠
• 𝛾 > 1,整体变暗,低灰度区压缩,高灰度区扩展
• 𝛾 < 1,整体变亮,低灰度区扩展,高灰度区压缩
直方图:

    灰度直方图是灰度等级的函数,描述的是图像中该灰度等级的像素个数,该灰度等级的像素出现频率;

    横坐标表示灰度等级,纵坐标表示图像中该灰度等级出现的个数或该灰度级像素出现的频率

直方图均衡:

    给定灰度图像,让表示𝑝𝑠灰度𝑠, 𝑠 = 0,1, ⋯ , 255的像素的出现的频率

    累计概率:c_{s} = \sum{i=0}^s p_{s},s=0,1,2,...,255,累计概率总是位于0到1之间

    灰度变换函数:t = T(s) = Round(255 * c_{s})

    通常采用:t = T(s) = Round((max − min)* c_{s} + min),其中max和min是原始图像的最大和最小像素值

模板运算与卷积:
模板运算:O(x,y)=\sum_{a=-m}^{m} \sum_{b=-n}^{n} I(x+a,y+b)*f(a,b)
卷积:O(x,y)=\sum_{a=-m}^{m} \sum_{b=-n}^{n} I(x-a,y-b)*h(a,b) => \sum_{a'=-m}^{m} \sum_{b'=-n}^{n} I(x+a',y+b')*h(-a',-b')
模板不需要进行滤波器翻转。
模板运算与卷积的性质:
可加性:

    \[f \bigotimes (h_1+h_2) = f \bigotimes h_1 + f \bigotimes h_2\]

比例关系:

    \[f \bigotimes (k*h) = k * (f \bigotimes h)\]

可交换性:

    \[f \bigotimes h = h \bigotimes f\]

结合律:

    \[f \bigotimes h \bigotimes g = f \bigotimes (h \bigotimes g)\]

微分性质:

    \[\frac{\partial}{\partial x} (f \bigotimes h) = \frac{\partial}{\partial x} f \bigotimes h\]

离散傅里叶变换:

    \[F(u,v) = \sum_{x=1}^{X} \sum_{y=1}^{Y} I(x,y)*e^{-2\pi j * \frac{(u-1)(x-1)}{X}} * e^{-2\pi j * \frac{(v-1)(y-1)}{Y}}\]

反变换:

    \[I(x,y) = \frac{1}{X*Y} \sum_{u=1}^{X} \sum_{v=1}^{Y} F(u,v)*e^{2\pi j * \frac{(u-1)(x-1)}{X}} * e^{2\pi j * \frac{(v-1)(y-1)}{Y}}\]

离散余弦变换:

    \[F(u,v) = \alpha_{u} * \alpha_{v} \sum_{x=0}^{X-1} \sum_{y=0}^{Y-1} I(x,y)*cos(\frac{\pi * (2*x+1) * u}{2*X}) * cos(\frac{\pi * (2*y+1) * v}{2*Y})\]

反变换:

    \[I(x,y) = \sum_{u=0}^{X-1} \sum_{v=0}^{Y-1} \alpha_{u} * \alpha_{v}*F(u,v)*cos(\frac{\pi * (2*x+1) * u}{2*X}) * cos(\frac{\pi * (2*y+1) * v}{2*Y})\]

其中,

    \[\alpha_{u}=\left\{ \begin{array}{rcl} \frac{1}{\sqrt{X}}       &      & {u = 0}\\ \frac{\sqrt{2}}{\sqrt{X}}     &      & {1 \leq u \leq X-1} \end{array} \right.\]

    \[\alpha_{v}=\left\{ \begin{array}{rcl} \frac{1}{\sqrt{Y}}       &      & {v = 0}\\ \frac{\sqrt{2}}{\sqrt{Y}}     &      & {1 \leq v \leq Y-1} \end{array} \right.\]

    \[F(u,v) = \sum_{x=0}^{X-1} \sum_{y=0}^{Y-1}  \alpha_{u} * \alpha_{v}*I(x,y)*cos(\frac{\pi * (2*x+1) * u}{2*X}) * cos(\frac{\pi * (2*y+1) * v}{2*Y})\]

• 本质上是正交变换
• 给定 u,v

    \[ \begin{split} \sum_{x=0}^{X-1} \sum_{y=0}^{Y-1}  (\alpha_{u} * \alpha_{v}*cos(\frac{\pi * (2*x+1) * u}{2*X}) * cos(\frac{\pi * (2*y+1) * v}{2*Y}))*\\ (\alpha_{u'} * \alpha_{v'}*cos(\frac{\pi * (2*x+1) * u'}{2*X}) * cos(\frac{\pi * (2*y+1) * v'}{2*Y})) = 0,u' \not= u,v' \not= v \end{split} \]

    \[ \begin{split} \sum_{x=0}^{X-1} \sum_{y=0}^{Y-1}  (\alpha_{u} * \alpha_{v}*cos(\frac{\pi * (2*x+1) * u}{2*X}) * cos(\frac{\pi * (2*y+1) * v}{2*Y}))*\\ (\alpha_{u} * \alpha_{v}*cos(\frac{\pi * (2*x+1) * u}{2*X}) * cos(\frac{\pi * (2*y+1) * v}{2*Y})) = 1 \end{split} \]

所以,可以分离计算

    \[ \begin{split} F(u,v) &= \sum_{x=0}^{X-1} \sum_{y=0}^{Y-1}  \alpha_{u} * \alpha_{v}*I(x,y)*cos(\frac{\pi * (2*x+1) * u}{2*X}) * cos(\frac{\pi * (2*y+1) * v}{2*Y}) \\ &= \sum_{x=0}^{X-1} \alpha_{u} * cos(\frac{\pi * (2*x+1) * u}{2*X}) ( \sum_{y=0}^{Y-1} \alpha_{v}*I(x,y)*cos(\frac{\pi * (2*y+1) * v}{2*Y}) ) \end{split} \]

发表评论

电子邮件地址不会被公开。 必填项已用*标注