Digital Image Processing Lab File ECS-752: Shree Bankey Bihari Institute of Technology (SB-BIT) - Meerut
Digital Image Processing Lab File ECS-752: Shree Bankey Bihari Institute of Technology (SB-BIT) - Meerut
Digital Image Processing Lab File ECS-752: Shree Bankey Bihari Institute of Technology (SB-BIT) - Meerut
LAB FILE
ECS-752
Prepared
By
Jay Kant Pratap RAJESH KUMAR
Yadav
Page 2
Digital Image Processing Lab
PROGRAM NO. 1
clc
clear all
close all
a=imread('onion.png')
b=a*0.4
c=a*2
subplot(1,3,1),imshow(a),title('Original Image')
subplot(1,3,2),imshow(b),title('Decrease in Contrast')
subplot(1,3,3),imshow(c),title('Increase in Contrast')
Page 3
OUTPUT :
1b) HISTOGRAM EQUALIZATION
clc
clear all
close all
a=imread('coins.png')
b=histeq(a)
subplot(2,2,1),imshow(a),title('Original Image')
subplot(2,2,3),imhist(a),title('Original Image')
clc
clear all
close all
a=imread('coins.png')
[m,n]=size(a)
for i=1:m
for j=1:n
if a(i,j)<t
b(i,j)=0;
else
b(i,j)=255;
end
end
end
figure,imshow(a),title('Original image'),pixval on
figure,imshow(b),title('threshold image'),pixval on
OUTPUT :
1d) SPATIAL DOMAIN FILTERING
clc
clear all
close all
a=imread('coins.png')
h1=1/9*ones(3,3)
h2=1/25*ones(5,5)
b1=conv2(a,h1);
b2=conv2(a,h2);
imshow(a),title('original image')
clc
clear all
close all
a=imread('coins.png')
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),title('original image')
subplot(2,2,4),imhist(b),title('flipped image')
OUTPUT :
PROGRAM NO. 2
clear all
close all
a=imread('circles.png')
b=imread('cameraman.tif')
c=double(a)+double(b)
clc
clear all
close all
a=imread('circles.png')
b=imread('cameraman.tif')
c=double(a)-double(b)
clc
clear all
close all
a=imread('cameraman.tif');
b=imread('coins.png');
b=imresize(b,[256 256]);
[m n]=size(a);
for i=1:m
for j=1:n
c1(i,j)=(1-alpha1)*a(i,j)+alpha1*b(i,j);
c2(i,j)=(1-alpha2)*a(i,j)+alpha2*b(i,j);
c3(i,j)=(1-alpha3)*a(i,j)+alpha3*b(i,j);
c4(i,j)=(1-alpha4)*a(i,j)+alpha4*b(i,j);
end
end
subplot(2,2,1),imshow(c1),title('blended image')
xlabel(sprintf('alpha value is %g',alpha1))
subplot(2,2,2),imshow(c2),title('blended image')
xlabel(sprintf('alpha value is %g',alpha2))
subplot(2,2,3),imshow(c3),title('blended image')
xlabel(sprintf('alpha value is %g',alpha3))
subplot(2,2,4),imshow(c4),title('blended image')
xlabel(sprintf('alpha value is %g',alpha4))
OUTPUT :
PROGRAM NO. 3
clc
clear all
close all
a=imread('onion.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,imshow(a),title('original image')
figure,imshow(b),title('robert')
figure,imshow(c),title('sobel')
figure,imshow(d),title('prewitt')
figure,imshow(e),title('log')
figure,imshow(f),title('canny')
OUTPUT :
PROGRAM NO. 4
clc
clear all
close all
a=imread('text.png')
a1=imdilate(a,b)
a2=imerode(a,b)
figure,imshow(a),title('original image')
figure,imshow(a1),title('dilute image')
figure,imshow(a2),title('eroded image')
OUTPUT :
4b) BOUNDARY DETECTOR
clc
clear all
a=imread(‘text.png’)
a1=imdilate(a,b)
a2=imerode(a,b)
a3=a1-a2
a4=a1-a
a5=a1-a2
OUTPUT :
PROGRAM NO. 5
Implement Colour Image Processing in MAT Lab.
clc
clear all
close all
rgb=imread('onion.png')
r=rgb
g=rgb
b=rgb
r( : , : , 2 )=0
r( : , : , 2 )=0
b( : , : , 1 )=0
b( : , : , 3 )=0
g( : , : , 1 )=0
g( : , : , 2 )=0
imshow(rgb),title)'original image')
figure,imshow(r),title('red component')
figure,imshow(g),title('green component')
figure,imshow(b),title('blue component')
OUTPUT :
5b) TO REMOVE THE RGB PLANE
clc
clear all
close all
a=imread('onion.png')
a1=a
b1=a
c1=a
a1(:,:,1)=0
b1(:,:,2)=0
c1(:,:,3)=0
imshow(a),title('original image')
figure,imshow(a1),title('gb sector')
figure,imshow(b1),title('br sector')
figure,imshow(c1),title('rg sector')
OUTPUT :
5c) HISTOGRAM EQUALIZATION OF COLOURED IMAGE
clc
clear all
a=imread('onion.png')
b=rgb2ntsc(a);
c=ntsc2rgb(b);
imshow(a),title('original image')
Original Image
Histogr
am equalized image
5d) PERFORM THE MEDIAN FILTERING OF COLOUR
IMAGE
clc
clear all
close all
a=imread('onion.png')
c( : , : , 1 )=medfilt2(b( : , : , 1 ))
c( : , : , 2 )=medfilt2(b( : , : , 2 ))
c( : , : , 3 )=medfilt2(b(: , : , 3 ))
imshow(a),title('original image')
figure,imshow(b),title('corrupted image')
clc
clear all
a=imread(‘onion.png’)
b=rgb2ycbr(a)
mask=b( : , : , 2)>120
imshow(a),title(‘Original image’)
figure,imshow(mask),title(‘Segmented Image’)
OUTPUT :
Original Image
Segmented image