特征变换(5)K-L变换
K-L变换也常称为主成分变换(PCA)或霍特林变换,是一种基于图像统计特性的变换,它的协方差矩阵除对角线以外的元素都是零,消除了数据之间的相关性,从而在信息压缩方面起着重要作用。 K-L变换的意义 在模式识别和图像处理中一个主要的问题就是降维,在实 际的模式识别问题中,我们选择的特征经常彼此相关,在识别这些特征时,数量很多,大部分都是无用的。
·
K-L变换也常称为主成分变换(PCA)或
霍特林变换,是一种基于图像统计特性的变换,它的协方差矩阵除对角线以外的元素都是零,消除了数据之间的相关性,从而在信息压缩方面起着重要作用。
K-L
变换的意义
在模式识别和图像处理中一个主要的问题就是降维,在实 际的模式识别问题中,我们选择的特征经常彼此相关,在识别这些特征时,数量很多,大部分都是无用的。如果我们能减少特征的数量,即减少特征空间的维数,那么我们将以更少的存储和计算复杂度获得更好的准确性。
如何寻找一种合理的综合性方法,使得:
1. 减少特征量的个数。
2.尽量不损失或者稍损失原特征中所包含的信息。
3.使得原本相关的特征转化为彼此不相关(用相关系数阵衡量)
K-L变换即主成分分析就可以简化大维数的数据集合。它还可以用于许多图像的处理应用中,例如:压缩、分类、特征选择等。
对于K-L变换中的矩阵A,必须满足以下要求:
A为n×n正交矩阵,A=[φ1,φ2,φ3,…,φn]
对正交矩阵A来说,取φi为X的协方差矩阵∑x的特征向量,协方差矩阵除对角线以外的元素都是零
变换Y=ATX与反变换X=AY即为K-L变换的变换公式。
MS=imread('1.jpg'); % multi-band image;
figure;
subplot(3,3,1);
imshow(MS);
title('original image');
MS=im2double(MS);
subplot(3,3,4);
imshow(MS(:,:,1),[]);
title('R image');
subplot(3,3,5);
imshow(MS(:,:,2),[]);
title('G image');
subplot(3,3,6);
imshow(MS(:,:,3),[]);
title('B image');
[r c nbands] = size(MS); % Save the shape
npixels = r * c; % Number of pixels
MS= reshape(MS,[npixels nbands]); % Reshape to numPixels-by-numBands
B = MS;
meanB = mean(B,1) % Mean pixel value in each spectral band
cov = (B' * B - npixels * meanB' * meanB)/(npixels - 1); % Sample covariance matrix
% cov=B'*B/n - meanB'*meanB; % have the same meaning as above
% [ U S V]=svd(cov);
[U D]=eig(cov);
for i=1:3
MS(:,i)=MS(:,i)-meanB(i);
end
MA=MS*U; % However, MA=-MS*U is also possible, as eig vector is optional
MA = reshape(MA, [r c nbands]);
subplot(3,3,7);
imshow(MA(:,:,1),[]);
title(' the Num 1 feature image');
subplot(3,3,8); imshow(MA(:,:,2),[]);
title(' the Num 2 feature image');
subplot(3,3,9);imshow(MA(:,:,3),[]);
title(' the Num 3 feature image');
% Reconstruct with full features
MA=reshape(MA,[npixels,nbands]);
MS=MA*U';
MS=reshape(MS,[r c nbands]);
subplot(3,3,2);
% x=min(MS);
imshow(abs(MS));
% truesize(MS);
title('full reconstruct images');
%Reconstruct with only one main features;
MA= reshape(MA,[r c nbands]);
MA(:,:,2)=0; %also you can use MA(:,:,1)=0, such that the image can't be roughly reconsturcted
MA(:,:,3)=0;
MA=reshape(MA,[npixels nbands]);
JIANG=MA*U';
JIANG = reshape(JIANG, [r c nbands]);
subplot(3,3,3);
imshow(abs(JIANG));
title('only one feature is used');
点击阅读全文
更多推荐
所有评论(0)