Digital Image Processing Laboratory
1. Some commands and programs in MATLAB
i. Declaring matrices, declaring variables/matrices
A = [123; 456; 789]
ii. Keep following things in mind while declaring variables/matrices:
• No spaces
• Don’t start with a number
• Variable names are case sensitive
iii. Populating matrix elements with zeros:
B = zeros(3; 3)
iv. Knowing size of matrix:
[rows; cols] = size(A)
v. Reading Image file
myImage=imread(‘File name with path’)
If name of the image file is test.bmp and if it is in /home/chv folder above commands
can bemwritten as: myImage=imread(‘/home/chv/test.bmp’)
vi. Displaying image
imshow (myImage);
vii. Knowing size of image in pixels:
[Rows, Cols] =size(myImage)
viii. Image resizing
imresize(myImage,[256,256])
ix. Converting Color image into Grayscale image:
myGrayImage=rgb2gray(myImage)
x. Converting Color image into Binary Image:
myBWImage=im2bw(myImage)
xi. Intensity profile along line given by two points on image
improfile(myImage,[0,150],[200,150])
xii. Separate color image into three separate R,G,B planes
myImage=imread(‘RGBBar.bmp’);
RED=myImage(:,:,1);
GREEN=myImage(:,:,2);
BLUE=myImage(:,:,3);
xiii. Combine three separate R,G,B planes to create color image
newImage=cat(3,RED,BLUE,GREEN)
Experiment 1: Scan your own signature and make it clean with thresholding. Run above program for
different threshold values and find out optimum threshold value for which you are getting better result.
Experiment 2: Write Program to read any image, resize it to 256 × 256. Apply square mask shown in
following figure so that only middle part of the image is visible.
Experiment 3: Write your own matlab function addbrightness() and use it to increase brightness of
given image.
Experiment 4: Write a program to demonstrate watermarking using EX-OR operation. Prepare any
two images of size 256 × 256 in paint. Save it in JPEG format 256 gray levels. Perform logical NOR,
NAND operations between two images. Write program and paste your results.
Experiment 5: Write a program to compute the histogram of an input image. Also write program for
calculation and equalisation of the histogram
Experiment 6: Take your own photograph in dark area. Improve its appearance using histogram
equalization technique.
Experiment 7: Write and execute program for geometric transformation of image
(a) Translation
(b) Scaling
(c) Rotation
(d) Shrinking
(e) Zooming
Experiment 8: write programs for image restoration
(a) Remove Salt and Pepper Noise
(b) Minimize Gaussian noise
(c) Median filter and Weiner filter
Experiment 9: Write and execute programs to remove noise using spatial filters
(a) Understand 1-D and 2-D convolution process
(b) Use 3x3 Mask for low pass filter and high pass filter
Experiment 10: Write a program to image restoration using the parametric wiener filter.
Experiment 11: Write and execute programs for image frequency domain filtering
(a) Apply FFT on given image
(b) Perform low pass and high pass filtering in frequency domain
(c) Apply IFFT to reconstruct image
Experiment 12: Write a program in MATLAB for edge detection using different edge detection mask.
Experiment 13: Write and execute program for image morphological operations erosion and dilation.
Experiment 14: Write and execute program for smoothing an image using opening and closing.
Experiment 15: To create a program for segmentation of an image using watershed transforms.