Professional Documents
Culture Documents
IP Manual
IP Manual
figure();
imshow(I_ip);
title('Input image');
[m,n] = size(I_ip);
figure();
imshow(I_fh,[]);
title('Horizontally flipped image');
figure();
imshow(I_fv,[]);
title('Vertically flipped image');
Result:
Aim:
To write a MATLAB program to crop an image.
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
Clc;
clear all;
close all;
[m,n] = size(I_ip);
imtool(I_ip);
figure(); imshow(I_cr,
[]); title('Cropped
image');
Input (Imtool):
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
Output (Figure):
Result
To write a MATLAB program to calculate the mean, variance and histogram of your image.
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
Clc;
clear all;
close all;
I = input('Enter the input image name:');
I_i = imread(I);
I_ip = .2989*I_i(:,:,1) + .5870*I_i(:,:,2) +.1140*I_i(:,:,3);
figure();
imshow(I_ip);
title('Input image');
[m,n] = size(I_ip);
sum1 = 0; for
i = 1:1:m
for j = 1:1:n
I(i,j) = I_ip(i,j);
sum1 = sum1 + I(i,j);
end
end
mean_of_the_image = sum1/(m*n)
var_sum1 = 0;
for i = 1:1:m
for j = 1:1:n
I(i,j) = I_ip(i,j);
var_sum1 = var_sum1 + power((I(i,j)-mean_of_the_image),2);
end
end
variance_of_the_image = var_sum1/(m*n)
h = zeros(256,1);
figure();
subplot(1,2,1);
imshow(I_ip);
title('Input Image');
subplot(1,2,2);
bar(h);
title('Histogram');
xlabel('Intensity value');
ylabel('Number of pixels');
mean_of_the_image =
variance_of_the_image=
Output (Figure):
Result:
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
Clc;
clear all;
close all;
I_i = imread(filename);
I_ip = .2989*I_i(:,:,1) + .5870*I_i(:,:,2) +.1140*I_i(:,:,3);
[m,n] = size(I_ip);
for i = 1:1:m
for j =
1:1:n
I_sqt(i,j) =
sqrt(double(I_ip(i,j)));
I_rndsqt(i,j) = round(I_sqt(i,j));
end
end
I_nrmrndsqt = normr(I_rndsqt);
for i = 1:1:m
for j =
1:1:n
I_Hnrmrndsqt(i,j) = ceil(I_nrmrndsqt(i,j));
end
end
figure();
subplot(2,2,1);
imshow(I_ip,[]);
title('Original
image');
subplot(2,2,2);
bar(jkhist(I));
title('Histogram of Original image');
subplot(2,2,3);
imshow(I_sqt,[]);
title('Square root of Original image');
subplot(2,2,4);
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
bar(jkhist(I_sqt));
title('Histogram of Square rooted image');
figure();
subplot(2,2,1);
imshow(I_rndsqt,[]);
title('Rounded Square root of Original image');
subplot(2,2,2);
bar(jkhist(I_rndsqt));
title('Histogram of Rounded Square rooted image');
subplot(2,2,3);
imshow(I_nrmrndsqt,[]);
title('Normalised Rounded Square root of Original image');
subplot(2,2,4);
bar(jkhist(I_Hnrmrndsqt));
title('Histogram of Normalized Rounded Square rooted image');
end
function h = jkhist(I_ip)
h = zeros(256,1);
[m,n] = size(I_ip);
Input (Browser):
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
Output (Figure):
Result:
Clc;
clear all;
close all;
I_i = imread(filename);
I_ip = .2989*I_i(:,:,1) + .5870*I_i(:,:,2) +.1140*I_i(:,:,3);
[m,n] = size(I_ip);
for i = 1:1:m
for j =
1:1:n
I_sqt(i,j) =
sqrt(double(I_ip(i,j)));
I_rndsqt(i,j) = round(I_sqt(i,j));
end
end
I_nrmrndsqt = normr(I_rndsqt);
for i = 1:1:m
for j =
1:1:n
I_Hnrmrndsqt(i,j) = ceil(I_nrmrndsqt(i,j));
end
end
figure();
subplot(2,2,1);
imshow(I_ip,[]);
title('Original
image');
subplot(2,2,2);
bar(jkhist(I));
title('Histogram of Original image');
subplot(2,2,3);
imshow(I_sqt,[]);
title('Square root of Original image');
subplot(2,2,4);
bar(jkhist(I_sqt));
title('Histogram of Square rooted image');
figure();
subplot(2,2,1);
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
imshow(I_rndsqt,[]);
title('Rounded Square root of Original image');
subplot(2,2,2);
bar(jkhist(I_rndsqt));
title('Histogram of Rounded Square rooted image');
subplot(2,2,3);
imshow(I_nrmrndsqt,[]);
title('Normalised Rounded Square root of Original image');
subplot(2,2,4);
bar(jkhist(I_Hnrmrndsqt));
title('Histogram of Normalized Rounded Square rooted image');
end
function h = jkhist(I_ip)
h = zeros(256,1);
[m,n] = size(I_ip);
Input (Browser):
Output (Figure):
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
Result:
Output (Figure):
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
Result:
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
Clc;
clear all;
close all;
[filename, pathname] = uigetfile(('*.tif;*.jpg;*.bmp;*.png'),
'Select the image');
if isequal(filename,0) |
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
I_i = imread(filename);
[m,n] = size(I_ip);
for i = 1:1:m
for j =
1:1:n
I_log(i,j) = log10(double(I_ip(i,j))+1);
end
end
B = normr(I_log);
figure();
subplot(2,2,1);
imshow(I_ip,[]);
title('Input
image');
subplot(2,2,2);
imshow(B,[]);
title('Normalized logarithmic image');
subplot(2,2,3);
bar(jkhist(I_ip));
title('Histogram of Input
image');
for i = 1:1:m for
j = 1:1:n
BH(i,j) = ceil(B(i,j));
end
end
subplot(2,2,4);
bar(jkhist(BH));
title('Histogram of Normalized logarithmic image');
end
function h = jkhist(I_ip)
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
h = zeros(256,1);
[m,n] = size(I_ip);
Output (Figure):
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
Result:
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
clc;
clear all;
close all;
RGB=imread('moon.jpg');
I = rgb2gray(RGB);
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
figure();
imshow(I,[]);
title('Original
Image');
figure();
J = dct2(I);
subplot(1,2,1
);
imshow(abs(J)
);
title('DCT');
i = idct2(J);
subplot(1,2,2
); imshow(i,
[]);
title('Reconstructed from DCT');
figure()
; J =
dst(I);
subplot(1,2,1);
imshow(abs(J));
title('DST');
i = idst(J);
subplot(1,2,2
); imshow(i,
[]);
title('Reconstructed from DST');
figure()
J =
fwht(double(I));
subplot(1,2,1);
imshow(abs(J)); title('Walsh-
Hadamard Transform'); i =
ifwht(J);
subplot(1,2,2);
imshow(i,[]);
title('Reconstructed from Walsh-Hadamard Transform');
figure()
J = radon(I,0:179);
subplot(1,2,1);
imshow(abs(J));
title('RADON Transform');
i = iradon(J,0:179);
subplot(1,2,2); imshow(i,
[]);
title('Reconstructed from Radon Transform');
figure();
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
[A,H,V,D] = dwt2(I,'db4');
dec=[...
A,H
V,D
...
];
subplot(1,2,1);
imshow(dec,[]);
title('WAVELET Transform');
i = idwt2(A,H,V,D,'db4');
subplot(1,2,2); imshow(i,
[]);
title('Reconstructed from Wavelet Transform');
Output (Figure):
Result:
6 7 8
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
clc;
clear all;
close all;
i_p = input('Enter the input signal:');
d_m = jkdftmtx(size(i_p));
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
D_T = d_m*i_p*(d_m)';
disp('The DFT of the given signal is;');
disp(D_T);
function D = jkdftmtx(N)
f = 2*pi./N;
w = (0:f:2*pi-f/2).' * 1i;
x = 0:N-1;
D = exp(-w*x);
end
Result:
Result:
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
clc;
closeall;
clearall;
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
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
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
figure();
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
Output (Figure):
Result:
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
clc;
clearal1
;
A = input('Enter the matrix
(A):'); AT = A';
AH = conj(AT);
if (round(A^(-1) - AH) == zeros(size(A)))
disp('The given matrix is Unitary
Matrix');
else
disp('The given matrix is not an Unitary matrix');
end
disp('A='
);
disp(A);
disp('A*AH(for Unitary it must be I) =
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
'); disp(A*AH);
Result:
Result:
Apparatus:
PC loaded with MATLAB 7.0 or above.
Program:
clc; clear
all; close
all;
c = jkdctmtx(N);
s = jkdstmtx(N);
function c = jkdctmtx(N)
[n,k] = meshgrid(0:N-1);
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
c = sqrt(2/N) * cos(pi*(2*n+1).*k/(2*N));
c(1,:) = c(1,:) / sqrt(2);
end
function s = jkdstmtx(N)
[n,k] = meshgrid(0:N-1);
s = sin(pi.*k.*n/(N+1));
end
Result:
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
PROGRAM:
clc;
clear all;
close all;
a=imread('cameraman.tif');
b=fliplr(a);
subplot(2,2,1);
imshow(a);
title('original image');
subplot(2,2,2);
imshow(b);
title('flipped image');
subplot(2,2,3);
imhist(a);
subplot(2,2,4);
imhist(b);
output:
Result:
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
INPUT
OUTPUT:
RESULT:
3.c)Median filtering
AIM:
To write a MATLAB program show that median filter is effective tool to minimize salt and
pepper noise
PROGRAM
clc;
clear all;
close all;
I=imread('eight.tif');
figure()
imshow(I);
title('original image');
J=imnoise(I,'salt & pepper',0.02);
figure()
subplot(1,2,1)
imshow(J);
title('salt and pepper noise');
L=medfilt2(J);
subplot(1,2,2);
imshow(L);
title('removing salt and pepper noise by median filter');
INPUT
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
OUTPUT:
RESULT:
3.d)Homomorphic Filtering
AIM:
To write a MATLAB program apply homomorphic filtering to an image
PROGRAM:
clc;
close all;
clear all;
d=10;
order=2;
im=double(imread('cameraman.tif'));
subplot(2,2,1);
imshow(im./255);
title('input image');
[r,c]=size(im);
homofil(im,d,r,c,order);
function homofil(im,d,r,c,n)
A=zeros(r,c);
for i=1:r
for j=1:c
A(i,j)=(((i-r/2).^2+(j-c/2).^2)).^(.5);
H(i,j)=1/(1+((d/A(i,j))^(2*n)));
end
end
alphaL=0.0999;
alphaH=1.01;
H=((alphaH-alphaL).*H)+alphaL;
H=1-H;
%log of image
im_1=log2(1+im);
%dft of logged image
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
im_f=fft2(im_1);
%filter applying dft image
im_nf=H.*im_f;
%inverse dft of filtered image
im_n=abs(ifft2(im_nf));
%inverse log
im_e=exp(im_n);
subplot(1,2,2);
imshow((im_e),[]);
title('output image');
figure();
imshow(H);
title('output of butterworth hpf');
OUTPUT:
RESULT:
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
3.e)Histogram Equalization
AIM:
To write a MATLAB program apply histogram equalization of an image.
PROGRAM:
clc;
clear all;
close all;
I1= imread('cameraman.tif');
[m,n] = size(I1);
disp(m);
disp(n);
for i = 1:1:m
for j = 1:1:n
I2(i,j) = sqrt(double(I1(i,j)));
end
end
I3 = normr(I2);
figure();
subplot(2,2,1);
imshow(I1,[]);
title('Original image');
subplot(2,2,2);
imhist(I1);
title('Histogram of Original image');
subplot(2,2,3);
imshow(I2,[]);
title('Square root of Original image');
subplot(2,2,4);
imhist(I2);
title('Histogram of Square rooted image');
figure,
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
subplot(1,2,1);
imshow(I3,[]);
title('Normalised Square root of Original image');
subplot(1,2,2);
imhist(I3);
title('Histogram of Normalized Square rooted image');
OUTPUT:
RESULT:
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
PROGRAM:
clc;
clear all;
close all;
a=imread('coloredChips.png');
a=rgb2gray(a);
b=edge(a,'roberts');
c=edge(a,'sobel');
d=edge(a,'prewitt');
e=edge(a,'log');
f=edge(a,'canny');
figure();
subplot(2,3,1);
imshow(a);
title('input image');
subplot(2,3,2);
imshow(b);
title('roberts detection');
subplot(2,3,3);
imshow(c);
title('sobel detection');
subplot(2,3,4);
imshow(d);
title('prewitt detection');
subplot(2,3,5);
imshow(e);
title('log detection');
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
subplot(2,3,6);
imshow(f);
title('canny detection');
OUTPUT:
RESULT:
4.b)IMAGE TECHNIQUES
AIM:
To write a MATLAB program apply dilation,erosion,opening ,closing of an image with a black
background [0000000;0011000;0001000;0001100;0011110;0011110;0011100;0000000]
PROGRAM:
clc;
clear all;
close all;
BW=[0 0 0 0 0 0 0;0 0 1 1 0 0 0;0 0 0 1 0 0 0;0 0 0 1 1 0 0;0 0 1 1 1 1 0;0 0 1 1 1 1 0;0 0 1 1 1 0
0;0 0 0 0 0 0 0];
figure();
imshow(BW);
SE1=strel('line',3,0);
N=imdilate(BW,SE1);
figure();
imshow(N);
N2=imerode(BW,SE1);
figure();
imshow(N2);
N3=imopen(BW,SE1);
figure();
imshow(N3);
N4=imclose(BW,SE1);
figure();
imshow(N4);
INPUT:
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
OUTPUT:
RESULT:
4.c)EROSION
AIM:
To write a MATLAB program for erode using structure element
BW= [0 0 0 0 0 0 0 0 0 ;0 0 0 0 0 1 0 0 0 0; 0 0 1 0 0 1 0 0 0 0;0 0 1 1 1 1 1 0 0 0;0 0 1 0 1 1 0 0
0 0;0 0 1 0 1 1 0 0 0 0; 0 0 1 0 1 0 0 0 0 ; 0 1 1 1 1 1 1 1 0 0; 0 0 0 0 0 1 1 0 0 0;0 0 0 0 0 0 0 0 0
0]
SE=[1 0 0;1 0 1;0 0 0];
PROGRAM:
clc;
close all;
clear all;
BW=[0 0 0 0 0 0 0 0 0 0
0000010000
0010010000
0011111000
0010110000
0010110000
0010100000
0111111100
0000011000
0 0 0 0 0 0 0 0 0 0];
SE=[1 0 0
101
0 0 0];
I=imerode(BW,SE);
figure();
imshow(BW);
figure();
imshow(SE);
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
figure();
imshow(I);
INPUT:
OUTPUT:
RESULT:
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
5.a)BTC
AIM:
To write a MATLAB program read an image apply BTC using different block sizes
PROGRAM:
clc;
close all;
x=imread('coins.png');
x=imresize(x,[256 256]);
x1=x;
x=double(x);
[m1, n1]=size(x);
blk=input('block size');
for i=1:blk:m1
for j=1:blk:n1
y=x(i:i+(blk-1),j:j+(blk-1));
m=mean(mean(y));
sig=std2(y);
b=y>m;
k=sum(sum(b));
if (k~=blk^2)&&(k~=0)
m1=m-sig*sqrt(k\((blk^2)-k));
mu=m+sig*sqrt(((blk^2)-k)/k);
x(i:(i+(blk-1)),j:(j+(blk-1)))=b*mu+(1-b)*m1;
end
end
end
figure
imshow(x1);
title('original image');
figure
imshow(b);
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
title('reconstructed image');
OUTPUT:
RESULT:
5.b)DCT
AIM:
To write a MATLAB program apply DCT to an image
\
PROGRAM:
clc;
close all;
i=imread('coins.png');
i=double(i)/255;
subplot(211);
imshow(i);
title('original image');
img_dct=dct2(i);
img_pow=(img_dct).^2;
img_pow=img_pow(:);
[b,index]=sort(img_pow);
b=flipud(b);
index=flipud(index);
compressed_dct=zeros(size(i));
coeff=20000;
for k=1:coeff
compressed_dct(index(k))=img_dct(index(k));
end
im_dct=idct2(compressed_dct);
subplot(212)
imshow(im_dct);
title('dct compress image');
imwrite(im_dct,'compress.png');
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
OUTPUT:
RESULT:
5.c)WAVELET TRANSFORM
Aim:
To write a MATLAB program to decompose an image and then to reconstruct from the wavelet
transform
Program:
clc;
WLT = input('Enter the wavelet to apply on image(with quotes):');
disp('Reading input image....');
img = input('Enter the name of the input image (with quotes):');
x = imread(img);
xx = x;
disp('Applying the wavelet on the image....');
[cA,cH,cV,cD] = dwt2(x,WLT);
disp('Done.');
xRec = idwt2(cA, cH, cV, cD, WLT);
disp('Mean Square Error:');
disp('Peak Signal to Noise Ratio (dB):');
Out=uint8(xRec);
subplot(2,2,1);
title('Input image');
title('Transformed Image');
imshow(Out); title('Reconstructed image');
OUTPUT WINDOW
S V UNIVERSITY COLLEGE OF ENGINEERING,TIRUPATI
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
I M.Tech II Sem, Communication Systems Image Processing Lab Record Roll No:
OUTPUT FIGURE
RESULT