Image Processing Lab Manual
Image Processing Lab Manual
LAB MANUAL
Aim:
To read , access and display digital image
Program 1:
Output 1:
Result: Thus the program to read, access and displaying the images are executed successfully.
Ex.No: 2
Date: Sampling
Aim:
To sample the spatial resolution of digitized image.
Program 1:
clc;
clear all;
close all;
n=8;
img = rgb2gray(imread('D:\flower.jpg'));
a=size(img);
w=a(2);
h=a(1);
im=zeros(100);
for i=1:n:h
for j=1:n:w
for k=0:n-1
for l=0:n-1
im(i+k,j+l)=img(i,j);
end
end
end
end
subplot(1,2,1);
imshow(uint8(img));title('Original Image');
subplot(1,2,2);
imshow(uint8(im));title('Sampled Image');
Output :
Result:
Thus the program for sampling has been executed successfully
Ex.No: 3a
Date: Neighbourhood metrics
Aim:
1. Neighborhood Operations - To learn about neighborhood operations and use them for i)
Linear filtering ii) Non-linear filtering
2. Neighborhood Operations –To study the effect of the size of neighborhood on the result
of processing
Program 1:
I = rgb2gray(imread('D:\flower.jpg'));
I_noise=imnoise(I,'salt & pepper');
subplot(2,3,1);
title('original image')
imshow(I)
subplot(2,3,2);
title('noisy image')
imshow(I_noise)
flinear1=1/25*ones(5,5);
Ilinear1=imfilter(I_noise,flinear1);
subplot(2,3,3);
title('Linear average filtered ')
imshow(Ilinear1)
hsize=[5,5];
sigma=1;
flinear2=fspecial('gaussian',hsize,sigma );
Ilinear2=imfilter(I_noise,flinear2);
subplot(2,3,4);
title('Linear Gaussian Filtered')
imshow(Ilinear2)
fnonlinear=[3,3];
Inonlinear=immedian(I_noise,fnonlinear);
subplot(2,3,5);
title('Median Filtered(Non-Linear)')
imshow(Inonlinear)
Output 1:
Program 2:
clc;
clear all;
close all;
I = rgb2gray(imread('D:\flower.jpg'));
I_noise=imnoise(I,'salt & pepper');
FilterSize = [3 3];
I_3x3 = immedian ( I_noise , FilterSize ) ;
I_5x5 = immedian ( I_noise ,[5 5]) ;
I_7x7 = immedian ( I_noise ,[7 7]) ;
I_9x9 = immedian ( I_noise ,[9 9]) ;
subplot(2,3,1);
title('original image')
imshow(I)
subplot(2,3,2);
title('noisy image')
imshow(I_noise)
subplot(2,3,3);
title('Filter size 3x3')
imshow(I_3x3)
subplot(2,3,4);
title('Filter size 5x5')
imshow(I_5x5)
subplot(2,3,5);
title('Filter size 7x7')
imshow(I_7x7)
subplot(2,3,6);
title('Filter size 9x9')
imshow(I_9x9)
Output 2:
Result: Thus the neighborhood operation on the pixels has been executed successfully