Q.
1)Write a program to display Monochrome image and Color
image.
clear all;
close all;
i=imread('cameraman.tif');
figure,
imshow(i);
title('Monochrome Image');
j=imread('peppers.png');
figure,
imshow(j);
title('Color Image');
Monochrome Image Color Image
Q.2)Write a program for color model conversion
i)RGB2HSV and HSV2RGB
clear all;
close all;
i=imread('peppers.png');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=rgb2hsv(i);
figure,
imshow(j);
title('RGB2HSV');
k=hsv2rgb(j);
figure,
imshow(k);
title('HSV2RGb');
RGB2HSV HSV2RGb
ORIGINAL IMAGE
ii)RGB2YCBCR and YCBCR2RGB
clear all;
close all;
i=imread('football.jpg');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=rgb2ycbcr(i);
figure,
imshow(j);
title('RGB2YCBCR');
k=ycbcr2rgb(j);
figure,
imshow(k);
title('YCBCR2RGB');
ORIGINAL IMAGE RGB2YCBCR YCBCR2RGB
iii)RGB2NTSC and NTSC2RGB
clear all;
close all;
i=imread('office_5.jpg');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=rgb2ntsc(i);
figure,
imshow(j);
title('RGB2NTSC');
k=ntsc2rgb(j);
figure,
imshow(k);title('NTSC2RGB');
ORIGINAL IMAGE RGB2NTSC NTSC2RGB
Q.3)Write a program to convert color image to grey level image
clear all;
close all;
i=imread('greens.jpg');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=rgb2gray(i);
figure,
imshow(j);
title('RGB2GRAY');
ORIGINAL IMAGE RGB2GRAY
Q.4)Write a program to display simple histogram of the image
clear all;
close all;
i=imread('tire.tif');
figure,
imshow(i);
figure,
imhist(i);
800
600
400
200
0 50 100 150 200 250
Q.5)Write a program to display simple histogram along with its
types
clear all;
close all;
i=imread('rice.png');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=i(1:10:255);
figure,
bar(j);
title('BAR HISTOGRAM');
figure,
stem(j);
title('STEM HISTOGRAM');
figure,
plot(j);
title('PLOT HISTOGRAM');
ORIGINAL IMAGE
BAR HISTOGRAM
200
180
160
140
120
100
80
60
40
20
0
0 5 10 15 20 25 30
STEM HISTOGRAM
200
180
160
140
120
100
80
60
40
20
0
0 5 10 15 20 25 30
PLOT HISTOGRAM
200
150
100
50
0 5 10 15 20 25 30
Q.6)Write a program to display equalised histogram of the
monochrome image.
clear all;
close all;
i=imread('moon.tif');
figure,
imshow(i);
figure,
imhist(i);
j=histeq(i);
figure,
imshow(j);
figure,
imhist(j);
ORIGINAL IMAGE
HISTOGRAM
7000
6000
5000
4000
3000
2000
1000
0 50 100 150 200 250
HISTOGRAM EQUALISATION
HISTOGRAM EQUALISATION
8000
7000
6000
5000
4000
3000
2000
1000
0 50 100 150 200 250
Q.7)Write a program to rotate monochrome image.
clear all;
close all;
i=imread('kids.tif');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=imrotate(i,50,'nearest');
figure,
imshow(j);
title('ROTATED IMAGE');
ORIGINAL IMAGE ROTATED IMAGE
Q.8)Write a program to implement median filter.
clear all;
close all;
i=imread('cameraman.tif');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=imnoise(i,'salt & pepper',0.1);
figure,
imshow(j);
title('MEDIAN FILTER');
k=medfilt2(j);
figure,
imshow(k);
TITLE('medfilt2');
ORIGINAL IMAGE MEDIAN FILTER MEDFILT2
Q.9)Write a program in matlab to obtain the complement of the
image using imadjust() function.
clear all;
close all;
i=imread('tire.tif');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=imadjust(i,[0,1],[1,0]);
figure,
imshow(j);
title('COMPLEMENT OF THE IMAGE');
ORIGINAL IMAGE
COMPLEMENT OF THE IMAGE
Q.10)Write a program to obtain image complement by using
imcomplement function.
clear all;
close all;
i=imread('football.jpg');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=imcomplement(i);
figure,
imshow(j);
title('Using IMCOMPLEMENT');
ORIGINAL IMAGE Using IMCOMPLEMENT
Q.12)Write a program to demonstrate the noise model.
clear all;
close all;
i=imread('cameraman.tif');
figure,
imshow(i);
title('ORIGINAL IMAGE');
j=imnoise(i,'gaussian',0.3,0.05);
figure,
imshow(j);
title('GAUSSIAN');
k=imnoise(i,'salt & pepper',0.02);
figure,
imshow(k);
title('SALT & PEPPER');
l=imnoise(i,'speckle',0.05);
figure,
imshow(l);
title('SPECKLE'); ORIGINAL IMAGE
x=imnoise(i,'poisson');
figure,
imshow(x);
title('POISSON');
GAUSSIAN SALT & PEPPER
SPECKLE POISSON
Q.13)Write a program to implementtwo dimensional 2D DFT in matlab.
clear all;
close all;
i=imread('cameraman.tif');
figure,
imshow(i);
title('ORIGINAL IMAGE');
i1=fft2(i);
figure,
imshow(i1);
title('FFT');
i2=abs(i1),
i3=fftshift(i2);
figure,
imshow(mat2gray(i3));
title('FFTSHIFT');
i4=log(1+abs(i3));
figure,
imshow(mat2gray(i4));
ORIGINAL IMAGE
title('ABSOLUTE');
i5=ifftshift(i3);
i6=ifft2(i1);
figure,
imshow(mat2gray(i6));
title('IFFT2');
FFT FFTSHIFT
ABSOLUTE IFFT2