DIP Lab Manual Updated
DIP Lab Manual Updated
SN List of Experiments
Point-to-point transformation. This laboratory experiment provides for thresholding an
1 image and the evaluation of its histogram. Histogram equalization. This experiment
illustrates the relationship among the intensities (gray levels) of an image and its
histogram.
Geometric transformations. This experiment shows image rotation, scaling, and
2
translation. Two-dimensional Fourier transform
Ideal filters in the frequency domain. Non Linear filtering using convolutional masks.
4 Edge detection. This experiment enables students to understand the concept of edge
detectors and their operation in noisy images
Morphological operations: This experiment is intended so students can appreciate the
5 effect of morphological operations using a small structuring element on simple binary
images. The operations that can be performed are erosion, dilation, opening, closing,
open-close, close-open.
DO’S
1. Student should get the record of previous experiment checked before starting the new
experiment.
2. Read the manual carefully before starting the experiment.
3. Checked the program by the instructor.
4. Get your results checked by the teacher.
5. Computers must be handled carefully.
6. Maintain strict discipline.
7. Keep your mobile phone switched off or in vibration mode.
8. Students should get the experiment allotted for next turn, before leaving the lab.
DON’TS
1. Do not touch or attempt to touch the mains power supply Wire with bare hands.
2. Do not overcrowd the tables.
3. Do not tamper with equipments.
4. Do not leave the without permission from the teacher.
GENERAL INSTRUCTIONS
Maintain separate observation results for each laboratory.
Observations or readings should be taken only in the observation copy.
Get the readings counter signed by the faculty after the completion of the experiment.
Maintain Index column in the observation copy and get the signature of the faculty before
leaving the lab.
L T P
0 0 2
External Marks: 30 Internal Marks: 45 Total Marks: 75
(1) Program Description: To offer high quality education in the field of Electrical Engineering and to
prepare students abreast of latest global industrial and research requirements and fulfill responsibility
towards community.
PROGRAM OUTCOME
PSO
PO-1 PO-2 PO-3 PO-4 PO-5 PO-6 PO-7 PO-8 PO-9 PO-10 PO-11 PO-12
I 2 1 3 2 1 - - - - - - 3
II 1 1 2 2 - - - - - - - 2
CO-1 3 - - - - - - - - - - 1 1 -
CO-2 1 - - 2 - - - - - - - - - -
CO-3 - - - 3 - - - - - - - - - -
CO-4 - - - - - 1 - - - - - - - -
Fundamentals of
2 Reference
Anil K Jain Digital Image Prentice Hall
Processing
Object: To provides the thresholding an image and the evaluation of its histogram using
histogram equalization and illustrates the relationship among the intensities (gray levels) of an
image and its histogram.
Software: MATLAB
Theory :
Histogram is a graphical representation of the intensity distribution of an image. In simple terms,
it represents the number of pixels for each intensity value considered.
Histogram Equalization is a computer image processing technique used to improve contrast in
images. It accomplishes this by effectively spreading out the most frequent intensity values, i.e.
stretching out the intensity range of the image. This method usually increases the global contrast
of images when its usable data is represented by close contrast values. This allows for areas of
lower local contrast to gain a higher contrast.
A color histogram of an image represents the number of pixels in each type of color component.
Histogram equalization cannot be applied separately to the Red, Green and Blue components of
the image as it leads to dramatic changes in the image’s color balance. However, if the image is
first converted to another color space, like HSL/HSV color space, then the algorithm can be
applied to the luminance or value channel without resulting in changes to the hue and saturation
of the image.
Adaptive Histogram Equalization
Adaptive Histogram Equalization differs from ordinary histogram equalization in the respect that
the adaptive method computes several histograms, each corresponding to a distinct section of the
image, and uses them to redistribute the lightness values of the image. It is therefore suitable for
improving the local contrast and enhancing the definitions of edges in each region of an image.
Program:
clc;clear all;close all;
imgetfile;
u=imread(ans);
o=rgb2gray(u);
imshow(o);
figure;
imhist(o);
i=histeq(o);
figure;
imshow(i);
figure;
imhist(i);
Result: In this experiment provides for thresholding an image and the evaluation of its histogram
using Histogram equalization. This experiment illustrates the relationship among the intensities
(gray levels) of an image and its histogram.
Object: To shows image rotation, scaling, and translation using Geometric transformations.
Software: MATLAB
Theory:
Perform generic geometric transformations using the imwarp workflow. Geometric
transformations map pixel coordinates in the output image to coordinates in the input image. The
mapping process then interpolates the value of output pixels from the input image. Use these
functions to perform general 2-D, 3-D, and N-D geometric transformations. To perform a 2-D or
3-D geometric transformation, first create a geometric transformation object that stores
information about the transformation. Then, pass the image to be transformed and the geometric
transformation object to the imwarp function.
Functions
imwarp Apply geometric transformation to image
Result: We have done the operation on digital image and shown image rotation, scaling, and
translation using Geometric transformations.
Software: MATLAB
Theory:
The Fourier Transform is an important image processing tool which is used to decompose an
image into its sine and cosine components. The output of the transformation represents the image
in the Fourier or frequency domain, while the input image is the spatial domain equivalent. In the
Fourier domain image, each point represents a particular frequency contained in the spatial
domain image.
The Fourier Transform is used in a wide range of applications, such as image analysis, image
filtering, image reconstruction and image compression.
Program:
clc;
clear all;
close all;
imgetfile;
u=imread(ans);
oip=rgb2gray(u);
imshow(oip);
uiop=fft2(oip);
figure;
imshow(uiop);
uyiop=ifft2(uiop);
figure;
imshow(uint8(uyiop));
Software: MATLAB
Theory:
Linear filtering of an image is accomplished through an operation called convolution.
Convolution is a neighborhood operation in which each output pixel is the weighted sum of
neighboring input pixels. The matrix of weights is called the convolution kernel, also known as
the filter. A convolution kernel is a correlation kernel that has been rotated 180 degrees.
For example, suppose the image is
A = [ 17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9]
and the convolution kernel is
h=[8 1 6
3 5 7
4 9 2]
The following figure shows how to compute the (2,4) output pixel using these steps:
1. Rotate the convolution kernel 180 degrees about its center element.
2. Slide the center element of the convolution kernel so that it lies on top of the (2,4)
element of A.
3. Multiply each weight in the rotated convolution kernel by the pixel of A underneath.
4. Sum the individual products from step 3.
Program:
clc;
clear all;
close all;
imgetfile;
u=imread(ans);
imshow(u);
Hm = fspecial('motion',20,45);
MotionBlur = imfilter(u,Hm,'replicate');
figure;
imshow(MotionBlur);
Hb = fspecial('disk',10);
blurred = imfilter(u,Hb,'replicate');
figure;
imshow(blurred);
Result : We perform the Linear filtering using convolution in an image.
Object: Image Edge Detection Using Sobel Filtering and Canny Filtering.
Software: MATLAB
Theory:
Edge detection is an image processing technique for finding the boundaries of objects within
images. It works by detecting discontinuities in brightness. Edge detection is used for image
segmentation and data extraction in areas such as image processing, computer vision, and
machine vision. Common edge detection algorithms include Sobel, Canny, Prewitt, Roberts, and
fuzzy logic methods.
Method Description
'Sobel' Finds edges at those points where the gradient of the image I is maximum, using
the Sobel approximation to the derivative.
'Prewitt' Finds edges at those points where the gradient of I is maximum, using the
Prewitt approximation to the derivative.
'Roberts' Finds edges at those points where the gradient of I is maximum, using the
Roberts approximation to the derivative.
'log' Finds edges by looking for zero-crossings after filtering I with a Laplacian of
Gaussian (LoG) filter.
'zerocross' Finds edges by looking for zero-crossings after filtering I with a filter that you
specify, h
'approxcanny' Finds edges using an approximate version of the Canny edge detection algorithm
that provides faster execution time at the expense of less precise detection.
Floating point images are expected to be normalized in the range [0 1].
Program:
clc;clear all;close all;
po=imgetfile;
I = imread(po);%select coin
imshow(I)
BW1 = edge(I,'sobel');
BW2 = edge(I,'canny');
figure;
imshowpair(BW1,BW2,'montage');
title('Sobel Filter Canny Filter');
Result: we have perform the Image Edge Detection Using Sobel Filtering and Canny Filtering
Software: MATLAB
Theory:
Morphology is a broad set of image processing operations that process images based on shapes.
Morphological operations apply a structuring element to an input image, creating an output
image of the same size. In a morphological operation, the value of each pixel in the output image
is based on a comparison of the corresponding pixel in the input image with its neighbors.
The most basic morphological operations are dilation and erosion. Dilation adds pixels to the
boundaries of objects in an image, while erosion removes pixels on object boundaries. The
number of pixels added or removed from the objects in an image depends on the size and shape
of the structuring element used to process the image. In the morphological dilation and erosion
operations, the state of any given pixel in the output image is determined by applying a rule to
the corresponding pixel and its neighbors in the input image. The rule used to process the pixels
defines the operation as a dilation or an erosion. This table lists the rules for both dilation and
erosion.
Dilation and erosion are often used in combination to implement image processing operations.
For example, the definition of a morphological opening of an image is an erosion followed by a
dilation, using the same structuring element for both operations. We can combine dilation and
erosion to remove small objects from an image and smooth the border of large objects.
(b) dilation
clc;
clear all;
close all;
po=imgetfile;
I = imread(po);
se = strel('ball',5,5);
I2 = imdilate(I,se);
imshow(I), title('Original')
figure, imshow(I2), title('Dilated')
Software: MATLAB
Theory:
Morphological image processing is a collection of non-linear operations related to the
shape or morphology of features in an image. According to Wikipedia, morphological operations
rely only on the relative ordering of pixel values, not on their numerical values, and therefore are
especially suited to the processing of binary images. Morphological operations can also be
applied to greyscale images such that their light transfer functions are unknown and therefore
their absolute pixel values are of no or minor interest.
Morphological techniques probe an image with a small shape or template called a
structuring element. The structuring element is positioned at all possible locations in the image
and it is compared with the corresponding neighborhood of pixels. Some operations test whether
the element "fits" within the neighborhood, while others test whether it "hits" or intersects the
neighborhood:
Program:
(a) Opening
clc;
clear all;
close all;
po=imgetfile;
I = imread(po);
figure, imshow(I);
se = strel('disk',5);
(b) Closing
clc;clear all;close all;
po=imgetfile;
I = imread(po);
originalBW = I;
imshow(originalBW);
se = strel('disk',10);
closeBW = imclose(originalBW,se);
figure, imshow(closeBW);
Result: We have perform the opening and closing operations in an image.