Digital Image Processing: Jawaharlal Nehru Engineering College Aurangabad
Digital Image Processing: Jawaharlal Nehru Engineering College Aurangabad
Digital Image Processing: Jawaharlal Nehru Engineering College Aurangabad
Laboratory Manual
For
As a student, many of you may be wondering with some of the questions in your
mind regarding the subject and exactly what has been tried is to answer through
this manual.
Visual information plays an important role in almost all areas of our life. Today,
much of this information is represented and processed digitally. Digital image
processing is ubiquitous, with applications ranging from television to
tomography, from photography to printing, from robotics to remote sensing.
This is a graduate-level introductory course to the fundamentals of digital image
processing. It emphasizes general principles of image processing, rather than
specific applications.
As you may be aware that MGM has already been awarded with ISO 9000
certification and it is our endure to technically equip our students taking the
advantage of the procedural aspects of ISO 9000 Certification.
Faculty members are also advised that covering these aspects in initial stage
itself, will greatly relived them in future as much of the load will be taken care by
the enthusiasm energies of the students once they are conceptually clear.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
1. Introduction to MATLAB.
1. Submission related to whatever lab work has been completed should be done
during the next lab session. The immediate arrangements for printouts related to
submission on the day of practical assignments.
2. Students should be taught for taking the printouts under the observation of
lab teacher.
Commands Explaination
who List current variables
whos List current variables, long form
clear Clear variables and functions from memory.
functions Explanation/Example
Sqrt(x) Sqrt(81)
exp(x) exp(10)
abs(x) abs(-67)
log(x) log(1000) natural logarithm base e
log10(x) log10(x) natural logarithm base 10
factorial(x) factorial(5)
sin(x) sin(5)
round(x) round(17/5)
fix(x) fix(13/5)
ceil(x) ceil(11/5)
floor(x) floor(-9/4)
rem(x) rem(13,5)
sign(x) sign(5)
1. cropping
2. Zooming Image
3. Brightness Enhancement
4. Contrast Manipulations
5. Arithmetic Operations :- Adding , Subtracting ,Multiplying , Dividing
Images
WARMUP EXCERCISES:
1. What do you mean by Point Processing or intensity operations.
2. Which are the Point Processing operations .
Or
Which are the intensity transformations.
Theory:
Image enhancement:
Enhancing an image provides better contrast and a more detailed image as
compare to non enhanced image. It is used to enhance medical images ,
images captured in remote sensing , images from satellite . The transformation
function has been given below
s=T(r)
where r is the pixels of the input image and s is the pixels of the output image.
T is a transformation function that maps each value of r to each value of s.
a=imread('c:\crow.jpg');
L=255;
c=L/log10(1+L);
d=c*log10(1+double(a));
subplot(1,2,1);
imshow(a),title('original image')
subplot(1,2,2);
imshow(uint8(d)),title('Log transformation image')
Thresholding Of Image:-
clear all;
I=imread('rice.png');
[R C]=size(I);
for i=1:R
for j=1:C
if (I(i,j)<=128)
J(i,j)=0;
else
J(i,j)=255;
end
end
end
subplot(1,2,1)
imshow(I)
title('original image')
subplot(1,2,2)
imshow(J)
title('image after thresholding')
Algorithm :-
1. Open any gray image say of resolution MxN e.g 256x256.Total no of pixels will be 65536
Here image will be of class uint8.
2. For an 8bit image the gray levels will be in the range [0,255].
3. Create an array of size 1x65536.
4. Read image intensity values starting from first pixel to last.
5. Use a counter 0 to 255 to keep track how many pixels belongs to that intensity.
6. Use plot function to display intensity levels on X-Axis and Number of Pixels of that
intensity on Y Axis give proper title to the corresponding axis.
7. Display Image and corresponding Histogram.
8. Display Equalized histogram and enhanced image.
1600
1400
1200
1000
800
600
400
200
3000
2500
2000
1500
1000
500
2000
1500
1000
500
Enhanced Image
Equalized Image
Objective :-
The purpose of this assignment is to study image filtering in spatial
domain. Spatial filtering is performed by convolving the image with a mask or a
kernel.Spatial filters include sharpening, smoothing, edge detection, noise
removal, etc.
It consists of four parts the first one discusses the spatial filtering of an
image using a spatial mask .3x3, 5x5, and then this mask is used in blurring
filter . The second part studies the order statistics filters, specially the median
filter.
The output of a smoothing spatial filter is simply the average of the pixels
contained in the neighborhood of the filter mask.
- These filters are sometimes called averaging filters and also lowpass filters
- Two types of masks of the spatial filter
• Order statistics filters are nonlinear spatial filters whose response is based on
ordering (ranking) the pixels contained in an area covered by the filter
• The best known example in this category is median filter
• median filter
- Median filters replace the value of the pixel by the median of the gray levels
in the neighborhood of that pixel
Spatial domain sharpening filters are also called as High Pass Filters
Laplacian Filters
Study following functions and use on various images with all possible
parameters.
Value Description
h = fspecial(type, parameters)
accepts the filter specified by type plus additional modifying parameters
particular to the type of filter chosen. If you omit these arguments, fspecial uses
default values for the parameters. The following list shows the syntax for each
filter type. Where applicable,
h = fspecial('average', hsize)
returns an averaging filter h of size hsize. The argument hsize can be a
vector specifying the number of rows and columns in h, or it can be a scalar, in
which case h is a square matrix. The default value for hsize is [3 3].
h = fspecial('gaussian', hsize, sigma) :-
returns a rotationally symmetric Gaussian lowpass filter of size hsize with
standard deviation sigma (positive). hsize can be a vector specifying the number
of rows and columns in h, or it can be a scalar, in which case h is a square
matrix. The default value for hsize is [3 3]; the default value for sigma is 0.5.
h = fspecial('laplacian', alpha) returns a 3-by-3 filter approximating the shape
of the two-dimensional Laplacian operator. The parameter alpha controls the
shape of the Laplacian and must be in the range 0.0 to 1.0. The default value for
alpha is 0.2.
h = fspecial('log', hsize, sigma) returns a rotationally symmetric Laplacian of
Gaussian filter of size hsize with standard deviation sigma (positive). hsize can
be a vector specifying the number of rows and columns in h, or it can be a scalar,
in which case h is a square matrix. The default value for hsize is [5 5] and 0.5
for sigma.
h = fspecial('prewitt')
h = fspecial('sobel')
Median Filter :- Median filters replace the value of the pixel by the median
of the gray levels in the neighborhood of that pixel
Algorithm:
Butterworth low pass filter:
1. Read the i/p image & its size.
2. Read the cutoff frequency do
3. Find center of image
4. Implement the function d
5. Find FFT 2- DFT of i/p image.
6. Shift 2D FFT image
7. Multiply with H
8. Take absolute multiple value of image
9. Display Butterworth low pass image.
fc=20;%Cutoff frequency
n=1;
[co,ro] = size(im);
cx = round(co/2); % find the center of the image
cy = round (ro/2);
imf=fftshift(fft2(im1));
Objective: Student should be able to develop a program by using high pass filter
in frequency domain.
Theory:
Sharpening Frequency-Domain Filters
• Butterworth High pass Filter (BHPF): The transfer function of BHPF of order n
and with specified cutoff frequency is given by:
Perspective plot of BHPF Image representation of BHPF Cross section of BHPF
High-pass filter: A filter that attenuates low frequencies while passing high
frequencies is used for sharpening
Output:
Butterworth Highpass Filter (BHPF): Smoother results are obtained in BHPF
when compared IHPF. There is almost no ringing artifacts.
Aim :- Write Programs for image segmentation. Program for detecting edges
in an image using Roberts cross gradient operator and sobel operator.
Algorithm:
1. Read i/p image & its size
2. Apply Roberts, Prewitt, Sobel & canny edge masks on i/p image
3. Display i/p image & edge detected image.
Erosion:
The basic idea of erosion is just like soil erosion only, it erodes away the
boundaries of foreground object (Always try to keep foreground in white). The
kernel slides through the image (as in 2D convolution). A pixel in the original
image (either 1 or 0) will be considered 1 only if all the pixels under the kernel is
1, otherwise it is eroded (made to zero).All the pixels near boundary will be
discarded depending upon the size of kernel. So the thickness or size of the
foreground object decreases or simply white region decreases in the image. It is
useful for removing small white noises detach two connected objects.
Conclusion:
It is a tool for extracting image components that are useful in representation &
description region shape. Dialation :It is also useful in joining broken parts of an
object.Erosion : It is useful for removing small white noises detach two connected
objects. Opening is useful in removing noise. Closing is useful in closing small
holes inside the foreground objects,
Study Displaying
following functions
Histogramand
of use on
image andvarious images
Histogram with all possible
equalization.
parameters.
Part I:- Displaying RGB Components of color Image and combing to form RGB
Image.
RGB=imread('C:\Program Files\MATLAB\R2010a\toolbox\images\imdemos\peppers.png');
R=RGB;
G=RGB;
B=RGB;
R(:,:,2)=0;
R(:,:,3)=0;
G(:,:,1)=0;
G(:,:,3)=0;
B(:,:,1)=0;
B(:,:,2)=0;
subplot(2,2,1),imshow(RGB),title('original image')
subplot(2,2,2),imshow(R),title('Red Component')
subplot(2,2,3),imshow(G),title('Green Component')
subplot(2,2,4),imshow(B),title('Blue Component')
clc
clear all
close all
a=imread('C:\Program Files\MATLAB\R2010a\Images\fl1.bmp');
a1=a;
b1=a;
c1=a;
a1(:,:,1)=0;
b1(:,:,2)=0;
c1(:,:,3)=0;
imshow(a),title('original image')
figure,imshow(a1),title('Red Missing!')
figure,imshow(b1),title('Green Missing!')
Department of Information Technology Lab Manual prepared by Vijaya Ahire Page 32
figure,imshow(c1),title('Blue Missing!')
clc
clear all
close all
a=imread('C:\Program Files\MATLAB\R2010a\Images\f1.bmp');
b=imnoise(a,'salt & pepper',0.2);
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')
figure,imshow(c),title('Median filtered image')
Teacher should oral exams of the students with full preparation. Normally, the objective questions
with guess are to be avoided. To make it meaningful, the questions should be such that depth of the
students in the subject is tested Oral examinations are to be conducted in co-cordial environment
amongst the teachers taking the examination. Teachers taking such examinations should not have
ill thoughts about each other and courtesies should be offered to each other in case of difference of
opinion, which should be critically suppressed in front of the students.
13. Submission:
Document Standard:
A] Page Size A4 Size
B] Running text Justified text
C] Spacing 1 Line
D] Page Layout and Margins (Dimensions in Cms)
Normal Page Horizantal
2.0
2.5
2.0
2.5 2.0
2.0
0.7”
0.7”
2.0
2.0
Basic honesty in the evaluation and marking system is absolutely essential and in the process
impartial nature of the evaluator is required in the examination system to become popular amongst
the students. It is a wrong approach or concept to award the students by way of easy marking to get
cheap popularity among the students to which they do not deserve. It is a primary responsibility of
the teacher that right students who are really putting up lot of hard work with right kind of
intelligence are correctly awarded.
The marking patterns should be justifiable to the students without any ambiguity and teacher should
see that students are faced with unjust circumstances.