K-L转换(Karhunen-Loève Transform)是建立在统计特性基础上的一种转换,它是均方差(MSE, Mean Square Error)意义下的最佳转换,因此在资料压缩技术中占有重要的地位。
K-L转换名称来自Kari Karhunen和Michel Loève。
K-L转换是对输入的向量x,做一个正交变换,使得输出的向量得以去除数据的相关性。
然而,K-L转换虽然具有均方差(MSE)意义下的最佳转换,但必须事先知道输入的讯号,并且需经过一些繁杂的数学运算,例如协方差(covariance)以及特征向量(eigenvector)的计算。因此在工程实践上K-L转换并没有被广泛的应用,不过K-L转换是理论上最佳的方法,所以在寻找一些不是最佳、但比较好实现的一些转换方法时,K-L转换能够提供这些转换性能的评价标准。
以处理图片为范例,在K-L转换途中,图片的能量会变得集中,有助于压缩图片,但是实际上,KL转算为input-dependent,即需要对每张输入图片存下一个转换机制,每张图都不一样,这在实务应用上是不实际的。
KL转换属于正交转换,其处输入讯号的原理如下:
对输入向量
做KL传换后,输出向量
之元素间(
,
和
为
之元素的index)的相关性为零,即:![{displaystyle E-{bar {X}})(X-{bar {X}})]=0}](https://wikimedia.org/api/rest_v1/media/math/render/svg/6fa3e39551afd861903189d10cbfef80dbd78395)
展开上式并做消去:
![{displaystyle EX]-{bar {X}}{bar {X}}=0}](https://wikimedia.org/api/rest_v1/media/math/render/svg/830842ca95706e3d58e9b08f5d24e15067a4c811)
如果
,因为KL转换式线性转换的关系,
,则可以达成以下式,所以这里得输入向量
之平均值
需为
,所以KLT是专门用于随机程序的分析:
![{displaystyle EX]=0}](https://wikimedia.org/api/rest_v1/media/math/render/svg/0b9c1d7acdfd201e804662dbedfd2fa4d6f1c2e4)
其中
,即输出向量不同元素相关性为
。
回到矩阵表示形式,令
为KL转换矩阵,使:

以
和
表示
之covariance矩阵:

因为
,
直接等于covariance矩阵:

其中
为
之covariance矩阵。
如果要使
,则
必须为对角线矩阵,即对角线上之值皆为
,所以
必须将传换成对角线矩阵,即
的每一行皆为
之特征向量。
K-L转换的目的是将原始数据做转换,使得转换后资料的相关性最小。若输入数据为一维:


其中en为输入讯号x共变异数矩阵(covariance matrix)Cx的特征向量(eigenvector)
若输入讯号x为二维:

二维之K-L转换推导系自原先输入信号之自协方矩阵

亦即

而得,此处假设输入信号x已经先减去平均值。
而当输入彼此具高度相关性,如影像等,则可假设其在水平与垂直方向上得以被分离,并以水平与垂直之相关系数
加以表示
假设
与
之水平和垂直距离分别为
则 
以一3x2之输入
为例
此时 
而对于任意尺寸的水平或垂直方向之协方差矩阵可以表示成

可发现其值仅与
有关,取其闭合形式,其基底元素
为

此处
为
之特征值

其中 
对于不同的输入影像,其
会有所不同,而若是令
,则此转换不必与输入相关,同时继承了K-L转换去除相关性的优异性质。
此时 
代入上式,得 KLT|
,
离散余弦转换较K-L转换在实务上较为有利,因其毋须纪录会随输入而改变的转换矩阵