資源簡介
KL變換,matlab實現(xiàn),可以繼續(xù)修改,有圖片

代碼片段和文件信息
%KL變換
MS=imread(‘Image1.bmp‘);?%?multi-band?image;
figure;
subplot(331);
imshow(MS);?
title(‘original?image‘);
MS=im2double(MS);
subplot(334);
imshow(MS(::1)[]);
title(‘R?image‘);
subplot(335);
imshow(MS(::2)[]);
title(‘G?image‘);
subplot(336);
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(B1)???????%?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(337);
imshow(MA(::1)[]);
title(‘?the?Num?1?feature?image‘);
subplot(338);?imshow(MA(::2)[]);
title(‘?the?Num?2?feature?image‘);
subplot(339);imshow(MA(::3)[]);
title(‘?the?Num?3?feature?image‘);
%?Reconstruct?with?full?features
???MA=reshape(MA[npixelsnbands]);
???MS=MA*U‘;
???MS=reshape(MS[r?c?nbands]);
???subplot(332);
%????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(333);
?imshow(abs(JIANG));
?title(‘only?one?feature?is?used‘);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????308278??2007-09-05?17:20??KL\CalibIm1.bmp
?????文件?????921654??2007-09-06?11:39??KL\CalibIm11.bmp
?????文件?????921654??2007-09-06?12:53??KL\Image1.bmp
?????文件???????1753??2007-09-07?20:26??KL\KL.m
?????文件?????390486??2007-09-06?12:54??KL\未命名.bmp
?????目錄??????????0??2007-09-07?20:27??KL
-----------?---------??----------?-----??----
??????????????2544043????????????????????7
- 上一篇:matlab SIRT CT重建算法
- 下一篇:TAODV_matlab代碼
評論
共有 條評論