图像和其他信号一样,既能在空间域(空域)处理,也能在频率域(简称频域)处理。把图像信息从空域变换为频域,可以更好地分析、加工和处理。因为图像信息的频域处理具有如下的特点:
从信息的表现形式来讲,所有信息变换方法都可以用于图像变换,但鉴于图像信息数据量大,带宽宽等特点,只有既能大大减少运算量,也能压缩图像数据量,更有利于进一步处理的变换,才进而应用于图像变换中。
图像几何变换的一般表达式
图像几何变换就是建立一幅图像与其变换后的图像的个点之间的映射关系,用通用数学表示方式可表示为
[ u , v ] = [ X ( x , y ) , Y ( x , y ) ] [u,v]=[X(x,y),Y(x,y)] [u,v]=[X(x,y),Y(x,y)]
式中, [ u , v ] [u,v] [u,v]为变换后图像像素的笛卡尔坐标; [ x , y ] [x,y] [x,y]为原始图像中像素的笛卡尔坐标; X [ x , y ] X[x,y] X[x,y]和 Y [ x , y ] Y[x,y] Y[x,y]分别定义了在水平和垂直两个方向上的空间变换的映射函数。这样就得到了原始图像与变换后图像的像素的对应关系。如果 X [ x , y ] = x , Y [ x , y ] = y X[x,y]=x,Y[x,y]=y X[x,y]=x,Y[x,y]=y,则有 [ u , v ] = [ x , y ] [u,v]=[x,y] [u,v]=[x,y],即变换后图像仅仅是原图像的简单拷贝。
若图像像素点 ( x , y ) (x,y) (x,y)平移到 ( x + x 0 , y + y 0 ) (x+x_0,y+y_0) (x+x0,y+y0),则变换函数为 u = X ( x , y ) = x + x 0 , v = Y ( x , y ) = y + y 0 u=X(x,y)=x+x_0,v=Y(x,y)=y+y_0 u=X(x,y)=x+x0,v=Y(x,y)=y+y0,写成矩阵表达式为
[ u v ] = [ x y ] + [ x 0 y 0 ] \left[ \begin{matrix} u\\ v\\ \end{matrix} \right]= \left[ \begin{matrix} x\\ y\\ \end{matrix} \right]+ \left[ \begin{matrix} x_0\\ y_0\\ \end{matrix} \right] [uv]=[xy]+[x0y0]
式中, x 0 x_0 x0和 y 0 y_0 y0分别为 x x x和 y y y的坐标平移量。
若图像坐标 ( x , y ) (x,y) (x,y)缩放到 ( s x , s y ) (s_x,s_y) (sx,sy)倍,则变换函数为
[ u v ] = [ s x 0 0 s y ] [ x y ] \left[ \begin{matrix} u\\ v\\ \end{matrix} \right]= \left[ \begin{matrix} s_x&0\\ 0&s_y\\ \end{matrix} \right] \left[ \begin{matrix} x\\ y\\ \end{matrix} \right] [uv]=[sx00sy][xy]
式中, s x s_x sx, s y s_y sy 分别为 x x x 和 y y y 坐标的缩放因子,其大于1表示放大,小于1表示缩小。
将输入图像绕笛卡尔坐标系的原点逆时针旋转 θ \theta θ 角度,则变换后图像的坐标为
[ u v ] = [ c o s θ − s i n θ s i n θ c o s θ ] [ x y ] \left[ \begin{matrix} u\\ v\\ \end{matrix} \right]= \left[ \begin{matrix} cos\theta&-sin\theta\\ sin\theta&cos\theta\\ \end{matrix} \right] \left[ \begin{matrix} x\\ y\\ \end{matrix} \right] [uv]=[cosθsinθ−sinθcosθ][xy]
平移、比例缩放和旋转变换都是一种称为仿射变换的特殊情况。仿射变换的一般表达式为:
[ u v ] = [ a 2 a 1 a 0 b 2 b 1 b 0 ] [ x y 1 ] \left[ \begin{matrix} u\\ v\\ \end{matrix} \right]= \left[ \begin{matrix} a_2&a_1&a_0\\ b_2&b_1&b_0\\ \end{matrix} \right] \left[ \begin{matrix} x\\ y\\ 1\\ \end{matrix} \right] [uv]=[a2b2a1b1a0b0]⎣⎡xy1⎦⎤
仿射变换具有如下性质:
图像先进行平移,然后进行比例变换,最后进行旋转的复合几何变换表达式为
[ u v ] = [ s x 0 0 s y ] [ x y ] { [ x y ] + [ x 0 y 0 ] } = [ s x c o s θ − s y s i n θ s x s i n θ s y c o s θ ] + [ s x x 0 c o s θ − s y x 0 s i n θ s x x 0 s i n θ + s y y 0 c o s θ ] \left[ \begin{matrix} u\\ v\\ \end{matrix} \right]= \left[ \begin{matrix} s_x&0\\ 0&s_y\\ \end{matrix} \right] \left[ \begin{matrix} x\\ y\\ \end{matrix} \right] \left\{ \left[ \begin{matrix} x\\ y\\ \end{matrix} \right] + \left[ \begin{matrix} x_0\\ y_0\\ \end{matrix} \right] \right\}= \left[ \begin{matrix} s_xcos\theta&-s_ysin\theta\\ s_xsin\theta&s_ycos\theta \end{matrix} \right]+ \left[ \begin{matrix} s_xx_0cos\theta-s_yx_0sin\theta\\ s_xx_0sin\theta+s_yy_0cos\theta \end{matrix} \right] [uv]=[sx00sy][xy]{[xy]+[x0y0]}=[sxcosθsxsinθ−sysinθsycosθ]+[sxx0cosθ−syx0sinθsxx0sinθ+syy0cosθ]
显然上式是线性的,故可以表示成如下的线性表达式。
[ u v ] = [ a 2 a 1 b 2 b 1 ] [ x y ] + [ a 0 b 0 ] \left[ \begin{matrix} u\\ v \end{matrix} \right]= \left[ \begin{matrix} a_2&a_1\\ b_2&b_1 \end{matrix} \right] \left[ \begin{matrix} x\\ y \end{matrix} \right] + \left[ \begin{matrix} a_0\\ b_0 \end{matrix} \right] [uv]=[a2b2a1b1][xy]+[a0b0]
从上式可见,平移、比例缩放和旋转变换是仿射变换的特殊情况。设定加权因子 a i a_i ai和 b i b_i bi的值,可以得到不同的变换。例如,当选定 a 2 = b 1 = 1 a_2=b_1=1 a2=b1=1, b 2 = − 0.1 b_2=-0.1 b2=−0.1, a 1 = a 0 = b 0 = 0 a_1=a_0=b_0=0 a1=a0=b0=0,这种情况是图像剪切的一种列剪切。
参考:许录平.数字图像处理[M].北京:科学出版社,2007