how to write code for finding KL transform in Matlab
10 views (last 30 days)
Show older comments
about image compression using KL transform in matlab
2 Comments
Answers (1)
B.k Sumedha
on 25 May 2015
Well here is the code
clc;
close all;
clear all;
I=imread('cameraman.tif');
I=im2double(I);
m=1;
for i=1:8:256
for j=1:8:256
for x=0:7
for y=0:7
img(x+1,y+1)=I(i+x,j+y);
end
end
k=0;
for l=1:8
img_expect{k+1}=img(:,l)*img(:,l)';
k=k+1;
end
imgexp=zeros(8:8);
for l=1:8
imgexp=imgexp+(1/8)*img_expect{l};%expectation of E[xx']
end
img_mean=zeros(8,1);
for l=1:8
img_mean=img_mean+(1/8)*img(:,l);
end
img_mean_trans=img_mean*img_mean';
img_covariance=imgexp - img_mean_trans;
[v{m},d{m}]=eig(img_covariance);
temp=v{m};
m=m+1;
for l=1:8
v{m-1}(:,l)=temp(:,8-(l-1));
end
for l=1:8
trans_img1(:,l)=v{m-1}*img(:,l);
end
for x=0:7
for y=0:7
transformed_img(i+x,j+y)=trans_img1(x+1,y+1);
end
end
mask=[1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 ];
trans_img=trans_img1.*mask;
for l=1:8
inv_trans_img(:,l)=v{m-1}'*trans_img(:,l);
end
for x=0:7
for y=0:7
inv_transformed_img(i+x,j+y)=inv_trans_img(x+1,y+1);
end
end
end
end
imshow(transformed_img);
figure
imshow(inv_transformed_img);
2 Comments
mohammed abdul wadood
on 18 Jun 2017
hi. i have a set of multi-spectral satellite images and i want to reduce dimensional of this images by using (KLT) in matlab. please can you give me matlab code of (KLT) if you have it, and send it on this email please ( donquixotedoflamingo695@yahoo.com ). thank you so much.
Walter Roberson
on 18 Jun 2017
Edited: Walter Roberson
on 18 Jun 2017
Note that B.k Sumedha and Ramessh Naiidu will not be notified of your posting.
Did you look at the File Exchange link I posted above?
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!