To
perform Wavelet Transform on given image using Matlab.
clc;
close;
[namefile,pathname]=uigetfile({'*.bmp;*.tif;*.tiff;*.jpg;*.jpeg;*.gif','IMAGE
Files;(*.bmp,*.tif,*.tiff,*.jpg,*.jpeg,*.gif)'},'Chose GrayScale Image');
X=imread(strcat(pathname,namefile));
if(size(X,3)==3)
X=rgb2gray(X);
end
imshow(X);
title('Original RGB image converted
to Grayscale image');
%
Perform wavelet decomposition at level 2.
[c,s]
= wavedec2(X,2,'db1');
figure;
plot(c)
, title('Wavelet
decomposition data generated by wavedec2');
figure;
%Calculate
first level approx. and detail components
ca1
= appcoef2(c,s,'db1',1);
subplot(2,2,1);imshow(ca1,[]);title('First level approx');
ch1
= detcoef2('h',c,s,1);
subplot(2,2,2);imshow(ch1,[]);title('First level horixontal detail');
cv1
= detcoef2('v',c,s,1);
subplot(2,2,3);imshow(cv1,[]);title('First level vertical detail');
cd1
= detcoef2('d',c,s,1);
subplot(2,2,4);imshow(cd1,[]);title('First level diagonal detail');
%Calculate
second level approx. and detail components
figure;
ca2
= appcoef2(c,s,'db1',2);
subplot(2,2,1);imshow(ca2,[]);title('Second level approx');
ch2
= detcoef2('h',c,s,2);
subplot(2,2,2);imshow(ch2,[]);title('Second level horizontal detail');
cv2
= detcoef2('v',c,s,2);
subplot(2,2,3);imshow(cv2,[]);title('Second level vertical detail');
cd2
= detcoef2('d',c,s,2);
subplot(2,2,4);imshow(cd2,[]);title('Second level diagonal detail');
figure;
a0
= waverec2(c,s,'db1');
imshow(a0,[]);title('Reconstructed image using inverse wavelet
transform');
No comments:
Post a Comment