flipkart ads

MATLAB TUTORIAL FIVE

Image Enhancement in Frequency Domain.

GuassianNoise ,  Salt & Pepper Noise,  Laplacian Noise


clc;
clearall;
closeall;
a = imread('Arjunlamborghini.jpg');

subplot(2,2,1);
imshow(a); title('Original image');

b = imnoise(a,'gaussian',0.1);
subplot(2,2,2);
imshow(b);  title('Gaussian Noise added');

c =imnoise(a,'salt& pepper',0.1);
subplot(2,2,3);
imshow(c);  title('Salt & Pepper Noise added');

d =fspecial('laplacian',0.2);
e=imfilter(a,d,'replicate');

subplot(2,2,4);
imshow(e);  title('Laplacian Noise added');










Histgrams of GuassianNoise ,  Salt & Pepper Noise,  Laplacian Noise images




clc;
clearall;
closeall;
a1 = imread('lamborghini.jpg');
a = rgb2gray(a1);
b = imnoise(a,'gaussian',0.1);
c =imnoise(a,'salt& pepper',0.1);
d =fspecial('laplacian',0.2);
e=imfilter(a,d,'replicate');
subplot(2,2,1);
imhist(a);  title('Histogram of Gray image');
subplot(2,2,2);
imhist(b);  title('Histogram of Gaussian Noise image added');
subplot(2,2,3);
imhist(c);  title('Histogram of salt & Pepper noise added image');
subplot(2,2,4);
imhist(e);  title('Histogram of Laplacian noise added image');






Rayleigh Noise & Histograms


clc;
clearall;
closeall;

a=1;b=0.25;
i = imread('lamborghini.jpg');
f = rgb2gray(i);
f1 = double(f);
[r, c]=size(f);
R = a+(-b*log(1-rand(r,c))).^0.5;  %RAYLEIGH NOISE EQUATION
mmax=max(max(R));
mmin=min(min(R));
const=100/(mmax-mmin);
for x = 1:1:r;
for y = 1:1:c;
noise(x,y)=const*(R(x,y)-mmin);
end
end
noisy_image=f1+noise;

subplot(2,3,1);
imshow(i),title('ORIGINAL IMAGE');
subplot(2,3,2);
imshow(f),title('GRAYSCALE IMAGE');
subplot(2,3,3);
imshow(uint8(noisy_image)),title('IMAGE WITH ADDED RAYLEIGH NOISE');
subplot(2,3,4);
imhist(f), title('HISTROGRAM OF GRAYSCALE IMAGE');
subplot(2,3,5);
hist(noise), title('HISTOGRAM OF RAYLEIGH NOISE')
subplot(2,3,6);
hist(noisy_image),title('HISTOGRAM OF IMAGE WITH RAYLEIGH NOISE')



 Uniform Noise & Histograms

clc;
clearall;
closeall;

a=1;b=0.25;
i = imread('lamborghini.jpg');
f = rgb2gray(i);
f1 = double(f);
[r, c]=size(f);
U = a + (b-a)*rand(r,c); % UNIFORM NOISE EQUATION
mmax=max(max(U));
mmin=min(min(U));
const=100/(mmax-mmin);
for x = 1:1:r;
for y = 1:1:c;
noise(x,y)=const*(U(x,y)-mmin);
end
end
noisy_image=f1+noise;

subplot(2,3,1);
imshow(i),title('ORIGINAL IMAGE');
subplot(2,3,2);
imshow(f),title('GRAYSCALE IMAGE');
subplot(2,3,3);
imshow(uint8(noisy_image)),title('IMAGE WITH ADDED UNIFORM NOISE');
subplot(2,3,4);
imhist(f), title('HISTROGRAM OF GRAYSCALE IMAGE');
subplot(2,3,5);
hist(noise), title('HISTOGRAM OF UNIFORM NOISE')
subplot(2,3,6);
hist(noisy_image),title('HISTOGRAM OF IMAGE WITH UNIFORM NOISE')





Exponential Noise & Histograms


clc;
clearall;
closeall;

a=1;b=0.25;
i = imread('lamborghini.jpg');
f = rgb2gray(i);
f1 = double(f);
[r, c]=size(f);
E = -log(1.12-rand(r,c)); %EXPONENTIAL NOISE EQUATION
mmax=max(max(E));
mmin=min(min(E));
const=100/(mmax-mmin);
for x = 1:1:r;
for y = 1:1:c;
noise(x,y)=const*(E(x,y)-mmin);
end
end
noisy_image=f1+noise;

subplot(2,3,1);
imshow(i),title('ORIGINAL IMAGE');
subplot(2,3,2);
imshow(f),title('GRAYSCALE IMAGE');
subplot(2,3,3);
imshow(uint8(noisy_image)),title('IMAGE WITH ADDED EXPONENTIAL NOISE');
subplot(2,3,4);
imhist(f), title('HISTROGRAM OF GRAYSCALE IMAGE');
subplot(2,3,5);
hist(noise), title('HISTOGRAM OF EXPONENTIAL NOISE')
subplot(2,3,6);
hist(noisy_image),title('HISTOGRAM OF IMAGE WITH EXPONENTIAL NOISE')




Lognormal Noise & Histograms


clc;
clearall;
closeall;

a=1;b=0.25;
i = imread('lamborghini.jpg');
f = rgb2gray(i);
f1 = double(f);
[r, c]=size(f);
L = a*exp(b*randn(r,c)); %LOGNORMAL NOISE EQUATION
mmax=max(max(L));
mmin=min(min(L));
const=100/(mmax-mmin);
for x = 1:1:r;
for y = 1:1:c;
noise(x,y)=const*(L(x,y)-mmin);
end
end
noisy_image=f1+noise;

subplot(2,3,1);
imshow(i),title('ORIGINAL IMAGE');
subplot(2,3,2);
imshow(f),title('GRAYSCALE IMAGE');
subplot(2,3,3);
imshow(uint8(noisy_image)),title('IMAGE WITH ADDED LOGNORMAL NOISE');
subplot(2,3,4);
imhist(f), title('HISTROGRAM OF GRAYSCALE IMAGE');
subplot(2,3,5);
hist(noise), title('HISTOGRAM OF LOGNORMAL NOISE')
subplot(2,3,6);
hist(noisy_image),title('HISTOGRAM OF IMAGE WITH LOGNORMAL NOISE')





Blur Images , Restoration and Histograms


clc;
clearall;
closeall;

a = im2double(imread('lamborghini.jpg'));
a1= rgb2gray(a);
PSF = fspecial('motion', 21, 11);
blurred = imfilter(a1, PSF, 'conv', 'circular');
noise_var = 0.0001;
estimated_nsr = noise_var/var(a1(:));
wnr3 = deconvwnr(blurred, PSF, estimated_nsr);

subplot(2,3,1);
imshow(a1),title('Grayscale Image');
subplot(2,3,2);
imshow(blurred),title('Blurred Image');
subplot(2,3,4);
imhist(a1),title('Histogram of Grayscale Image');
subplot(2,3,5);
imhist(blurred),title('Histogram of Blurred Image');
subplot(2,3,3);
imshow(wnr3)
title('Restoration of Blurred Image');
subplot(2,3,6);
imhist(wnr3);
title('Histogram of Restoration Image');




No comments:

Post a Comment

flipkart products