Lab Manual DIP 6CS4-21
Lab Manual DIP 6CS4-21
B.Tech. VI Semester
Course
PO PO PO
Outcom PO1 PO3 PO5 PO6 PO8 PO9 PO10 PO11 PO12
2 4 7
e
CO1 2 1 1 1 2 0 0 0 0 0 0 0
CO2 2 2 2 1 2 0 0 0 0 0 0 0
CO3 1 2 2 1 2 0 0 0 0 0 0 0
CO4 2 2 2 1 2 0 0 0 0 0 0 0
CO5 2 1 2 1 2 1 0 0 0 0 0 0
C36402
2.25 1.75 2.25 1.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
(AVG)
Experiments List:
MATLAB CODE:
Result or Output
2. Write the MATLAB code for plot the histogram of gray image.
MATLAB CODE:
img=rgb2gray(img);
[rows cols]=size(img);
hist(1:256)=0;
for i=1:rows
for j=1:cols
k=img(i,j)+1;
hist(k)=hist(k)+1;
end
end
subplot(2,1,2);plot(hist);title('Histogram ');
grid on ;
% figure;
% bar(hist);
Result or Output
3. Write the MATLAB code for plot the histogram of colour image.
MATLAB CODE:
hist1(1:256)=0;
hist2(1:256)=0;
hist3(1:256)=0;
for i=1:rows
for j=1:cols
k=img(i,j,1)+1;
hist1(k)=hist1(k)+1;
l=img(i,j,2)+1;
hist2(l)=hist2(l)+1;
m=img(i,j,3)+1;
hist3(m)=hist3(m)+1;
end
end
hold on;
hold off;
Result or Output
4. Write the MATLAB code for plot the multiple thresholding of colour image.
MATLAB CODE:
MATLAB CODE:
hist(1:256)=0;
for i=1:r
for j=1:c
k=img(i,j)+1;
hist(k)=hist(k)+1;
end
end
subplot(3,1,2);plot(hist,'r');title('Histrogram of Red Colour');
for k=2:256
hist(k)=hist(k)+hist(k-1); %Running Sum
end
subplot(3,1,3);plot(hist,'r'); title('Histrogram of Red Colour after Equlaization');
Result or Output
6. Write the MATLAB code for plot the extraction of colour image.
MATLAB CODE:
clear all; close all; clc
A=imread('C:\Users\VLSI LAB\Desktop\Lab File\image\lenacolor.bmp');
% A=rgb2gray(A);
% A=imread('cameraman.tif');
b1=double(bitget(A,8));
b2=double(bitget(A,7));
b3=double(bitget(A,6));
b4=double(bitget(A,5));
b5=double(bitget(A,4));
b6=double(bitget(A,3));
b7=double(bitget(A,2));
b8=double(bitget(A,1));
subplot(3,3,1);imshow(uint8(A));title('Original Image');
subplot(3,3,2);imshow((b1));title('Bit1(Msb) Image');
subplot(3,3,3);imshow((b2));title('Bit2 Image');
subplot(3,3,4);imshow((b3));title('Bit3 Image');
subplot(3,3,5);imshow((b4));title('Bit4 Image');
subplot(3,3,6);imshow((b5));title('Bit5 Image');
subplot(3,3,7);imshow((b6));title('Bit6 Image');
subplot(3,3,8);imshow((b7));title('Bit7 Image');
subplot(3,3,9);imshow((b8));title('Bit8{Lsb) Image');
Result or Output
7. Write the MATLAB code for rotation of image.
MATLAB CODE:
subplot(4,1,1);imshow(I)
title('Original Image')
J = imrotate(I,90,'bilinear','crop');
subplot(4,1,2);imshow(J)
K = imrotate(I,180,'bilinear','crop');
subplot(4,1,3);imshow(K)
L = imrotate(I,270,'bilinear','crop');
subplot(4,1,4);imshow(L)
Result or Output
8. Write the MATLAB code for scaling the intensity level of image.
MATLAB CODE:
J = imadjust(I,[.2 .3 0; .6 .7 1],[]);
K=rgb2gray(I)
subplot(1,3,2);imshow(J);title('Modified Image')
subplot(1,3,3);imshow(K);title('Gray Image')
Result or Output
9. Write the MATLAB code for plot the single thresholding of colour image.
MATLAB CODE:
n=size(i);
th1=127;
for k=1:n(1)
for l=1:n(2)
if(i(k,l)<th1)
j(k,l)=0;
else
j(k,l)=255;
end
end
end
subplot(1,2,1);
imshow(i);
subplot(1,2,2);
imshow(uint8(j));
title('Modified Image')
Result or Output
10 Write the MATLAB code for 2 D Fourier transform image.
MATLAB CODE:
P = peaks(20);
X = repmat(P,[5 10]);
subplot(3,1,1);imagesc(X)
Y = fft2(X);
subplot(3,1,2);imagesc(abs(fftshift(Y)))
Z = fft2(X,2^nextpow2(100),2^nextpow2(200));
subplot(3,1,3);imagesc(abs(fftshift(Z)));
Result or Output
11 Write the MATLAB code for linear convolution.
MATLAB CODE:
x1=1:5;
x2=1:5;
y1=1:5;
y2=1:5;
x=(min(x1)+min(x2)):max((x1)+max(x2));
y=conv(y1,y2);
Result or Output
12 Write the MATLAB code for highly selectively Filter.
MATLAB CODE:
b = fir1(48,[0.35 0.65]);
figure
freqz(b,1,512)
%Load chirp.mat. The file contains a signal, y, that has most of its power above Fs/4,
%or half the Nyquist frequency. The sample rate is 8192 Hz.
%signal below Fs/4. Use a cutoff frequency of 0.48 and a Chebyshev window with 30 dB
%of ripple.
load chirp
t = (0:length(y)-1)/Fs;
bhi = fir1(34,0.48,'high',chebwin(35,30));
figure
freqz(bhi,1)
figure
freqz(b,1,512)
MATLAB CODE:
subplot(2, 4, 1),
imshow(I);
J = edge(I, 'Sobel');
subplot(2, 4, 2),
imshow(J);
title('Sobel');
K = edge(I, 'Prewitt');
subplot(2, 4, 3),
imshow(K);
title('Prewitt');
L = edge(I, 'Roberts');
subplot(2, 4, 4),
imshow(L);
title('Robert')
subplot(2, 4, 5),
imshow(M);
title('Log')
M = edge(I, 'zerocross');
subplot(2, 4, 6),
imshow(M);
title('Zerocross')
N = edge(I, 'Canny');
subplot(2, 4, 7),
imshow(N);
title('Canny')
Result or Output
14 Write the MATLAB Code for Morphological operation on Image.
MATLAB CODE:
subplot(2, 3, 1),
imshow(I);
title('Original image')
% Dilated Image
se = strel('line', 7, 7);
subplot(2, 3, 2),
imshow(dilate);
title('Dilated image')
% Eroded image
subplot(2, 3, 3),
imshow(erode);
title('Eroded image')
% Opened image
subplot(2, 3, 4),
imshow(open);
title('Opened image');
% Closed image
imshow(close);
title('Closed image');
Result or Output
TECHNO INDIA NJR INSTITUTE OF TECHNOLOGY UDAIPUR
Computer Science and Engineering
B. TECH III– YEAR (VI Sem)
SUBJECT 6CS301
VIVA
Q 1. Define Image?
Q 3. Define Quantization ?
Q5.Define Brightness?
Q10. Write The Expression To Find The Number Of Bits To Store A Digital
Image?
Quiz
1.What is Digital Image Processing?
a) It’s an application that alters digital videos
b) It’s a software that allows altering digital pictures
c) It’s a system that manipulates digital medias
d) It’s a machine that allows altering digital images
2. Which of the following process helps in Image enhancement?
a) Digital Image Processing
b) Analog Image Processing
c) Both a and b
d) None of the above
3. Among the following, functions that can be performed by digital image
processing is?
a) Fast image storage and retrieval
b) Controlled viewing
c) Image reformatting
d) All of the above
4. Which of the following is an example of Digital Image Processing?
a) Computer Graphics
b) Pixels
c) Camera Mechanism
d) All of the mentioned
5. What are the categories of digital image processing?
a) Image Enhancement
b) Image Classification and Analysis
c) Image Transformation
d) All of the mentioned
6. How does picture formation in the eye vary from image formation in a
camera?
a) Fixed focal length
b) Varying distance between lens and imaging plane
c) No difference
d) Variable focal length
7. What are the names of the various colour image processing categories?
a) Pseudo-color and Multi-color processing
b) Half-color and pseudo-color processing
c) Full-color and pseudo-color processing
d) Half-color and full-color processing
11.Which of the following is the first and foremost step in Image Processing?
a) Image acquisition
b) Segmentation
c) Image enhancement
d) Image restoration
18.The digitization process, in which the digital image comprises M rows and N
columns, necessitates choices for M, N, and the number of grey levels per
pixel, L. M and N must have which of the following values?
a) M have to be positive and N have to be negative integer
b) M have to be negative and N have to be positive integer
c) M and N have to be negative integer
d) M and N have to be positive integer
20. The effect caused by the use of an insufficient number of intensity levels in
smooth areas of a digital image _____________
a) False Contouring
b) Interpolation
c) Gaussian smooth
d) Contouring
21.What is the procedure done on a digital image to alter the values of its
individual pixels known as?
a) Geometric Spacial Transformation
b) Single Pixel Operation
c) Image Registration
d) Neighbourhood Operations
22.Points whose locations are known exactly in the input and reference images
are used in Geometric Spacial Transformation.
a) Known points
b) Key-points
c) Réseau points
d) Tie points
28. Which of the following filter’s responses is based on the pixels ranking?
a) Sharpening filters
b) Nonlinear smoothing filters
c) Geometric mean filter
d) Linear smoothing filters
30.Which of the following operation is done on the pixels in sharpening the image,
in the spatial domain?
a) Differentiation
b) Median
c) Integration
d) Average
Q1. B Q2. C Q3. D Q4. D Q5. D Q6 D Q7. C Q8. A Q9. D Q10. D Q11. A Q12. C Q13. B
Q14. C Q15. D Q16. A Q17. B Q18. D Q19. C Q20. A Q21. B Q22. D Q23. C Q24. A Q25 B
Q26. A Q27. D Q28. B Q29. D Q30. C