91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 34KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-07
  • 語言: Matlab
  • 標簽: matlab??kl變換??

資源簡介

用matlab實現的kl變換,自己測試可用

資源截圖

代碼片段和文件信息

%KL變換
clc;
clear;

%讀入圖像,預處理
I1=imread(‘lena.bmp‘);

I1=imresize(I1[256256]);

I1=double(I1);

figure(1);
imshow(I1/255);title(‘原始圖‘);
x=zeros(409616);
%將原始圖像劃分為4*4的塊,將每個塊排列成一個16維的數據x((m-1)*64+n(i-1)*4+j)一幅256*256的圖像可以產生64*64=4096個向量
????for?m=1:64
????????for?n=1:64
????????????for?i=1:4
????????????????for?j=1:4
????????????????????x((m-1)*64+n(i-1)*4+j)=I1((m-1)*4+i(n-1)*4+j);
????????????????end
????????????end
????????end
????end????
%對每一個矢量求矩陣的均值協方差矩陣
X=x‘;
mx=mean(mean(X));
cx=1/4096*(X*X‘)-mx*mx;

%求該矩陣的特征值和對應的特征向量
[VD]=eig(cx);
V=fliplr(V);%因為matlab計算出的特征值按照遞增順序排列所以做一個相應的變換使其做遞減的擺列
D=flipud(fliplr(D));

%求解KL正變換
g=zeros(409616);
for?i=1:4096
????g(i:)=(V‘*(x(i:)-mx)‘)‘;
end

%截短至8位
y=zeros(40968);
y=g(:(1:8));

W=V(:(1:8));

%反變換
x=zeros(409616);
for?i=1:4096
????x(i:)=(W*y(i:)‘+mx)‘;
end

%重組圖像
newpic=zeros(256256);
for?i=1:64
????for?n=1:64
????????for?j=1:4
????????????for?m=1:4
????????????????newpic((i-1)*4+j(n-1)*4+m)=x((i-1)*64+n(j-1)*4+m);
????????????end
????????end
????end
end

%截短至4位
y4=zeros(40964);
y4=g(:(1:4));

W4=V(:(1:4));

%反變換
x4=zeros(409616);
for?i=1:4096
????x4(i:)=(W4*y4(i:)‘+mx)‘;
end

%重組圖像
newpic4=zeros(256256);
for?i=1:64
????for?n=1:64
????????for?j=1:4
????????????for?m=1:4
????????????????newpic4((i-1)*4+j(n-1)*4+m)=x4((i-1)*64+n(j-1)*4+m);
????????????end
????????end
????end
end


figure(2);
imshow(uint8(newpic));
title(‘8位數據重建圖像‘);

figure(3);
imshow(uint8(newpic4));
title(‘4位數據重建圖像‘);

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????1734??2012-12-27?16:36??matlab實現kl變換\kl變換.m

?????文件??????47928??2012-12-26?10:21??matlab實現kl變換\lena.bmp

?????目錄??????????0??2013-01-04?11:59??matlab實現kl變換

-----------?---------??----------?-----??----

????????????????49662????????????????????3


評論

共有 條評論