On Teaching Digital Image Processing With MATLAB: January 2014
On Teaching Digital Image Processing With MATLAB: January 2014
On Teaching Digital Image Processing With MATLAB: January 2014
net/publication/275038286
CITATIONS READS
2 1,970
2 authors:
All content following this page was uploaded by JEBAMALAR LEAVLINE EPIPHANY on 13 December 2015.
1
Department of ECE, Bharathidasan Institute of Technology, Anna University, Tiruchirappalli – 24, Tamilnadu, India
2
Department of CSE, Bharathidasan Institute of Technology, Anna University, Tiruchirappalli – 24, Tamilnadu, India
Abstract In the new era of information technology, the use of visual aids in teaching and learning process is inevitable.
Image processing is an interesting field that studies about various processing techniques for digital images, which is the
backbone of the emerging visual communication. Teaching the image processing has been a challenge since it requires
imagination and creativity to some extent for the students to understand the concepts of image processing. MATLAB is a
computing platform that is suitable for developing and testing a number of applications. The major advantage of using
MATLAB is the graphical user interface (GUI) which can contribute positively to understand the concepts with ease. The
pictorial illustrations confer better understanding of the concepts with ease. This article addresses a novel method of teaching
the concepts of image processing with MATLAB. It also provides an insight to some of the basic image processing
techniques namely image restoration, image denoising, image segmentation and edge detection with examples using
MATLAB.
Keywords Digital Image Processing, Teaching and learning, MATLAB, Graphical User Interface
solution[4]. GUIDE (Graphical User Interface Development help of computer algorithms. There are a number of image
Environment), is the tool in MATLAB to lay out, design, processing methods based on the applications. In this paper,
and edit custom graphical user interfaces by including the issues in teaching image denoising, segmentation and
common controls such as list boxes, pull-down menus, and edge detection are addressed.
push buttons, as well as MATLAB plots. Graphical user
interfaces can also be created programmatically using 2.1. Image Denoising
MATLAB functions[5]. This interactive GUI helps the Digital images are corrupted by various types of noises
teacher to make the student understand in a better way the during acquisition and transmission. These noisy
concepts behind the image processing techniques. components must be eliminated before it can be used for
The rest of this article is organized as follows. Section 2 further process or analysis. The different types of noises that
reviews the image processing concepts namely image are most commonly encountered are gaussian noise[6] and
denoising, image segmentation and edge detection. Section salt and pepper noise[7]. Gaussian noise can easily be
3 presents the practical oriented teaching and learning eliminated by simple average filter/mean filter[4]. This noise
method for understanding the image processing concepts removal process is basically the convolution operation
with MATLAB. Finally, the paper is concluded in section 4. between the selected window of the image and the filter
kernel slide over the entire image. If f(i,j) is the processing
pixel, then the selected window of size 3X3 with the center
2. Review of Digital Image Processing pixel as processing pixel can be defined as W = {f(i-1,j-1),
Concepts f(i-1,j),f(i-1,j+1);f(i,j-1),f(i,j),f(i,j+1);f(i+1,j-1),f(i+1,j),f(i+1
,j+1)}. The filter kernel of a mean/average filter is defined as
An image is defined as the 2-D representation of the 3D
K = {k1, k2, k3; k4, k5, k6, k7, k8, k9}. The formation of
scene. A digital image is regarded as the numeric
window and a typical 3X3 mean/average filter are shown in
representation of the 2D image in a sampled and quantized
Figure 1. When the kernel ‘K’ is applied on the entire image
form. The basic picture element is called pixel and an MXN
in a pixel by pixel manner, each pixel is replaced by the
image has M rows of pixels and N columns of pixels. It can
average value of the 3X3 neighbourhood, hence the resulting
also be thought of a 2D grid or matrix whose elements are
image will be free from gaussian noise components[8]. The
represented by f(x,y), where x and y are the coordinates of
major drawback of average filter is that it may oversmooth
the grid or the indices of the matrix elements. Digital image
the edges so that the image is blurred.
processing deals with processing of digital images with the
(a) (b)
Figure 1. (a) 2D grid representation of a digital image showing a sample window in gray shade, (b) Typical 3X3 average filter kernel
American Journal of Signal Processing 2014, 4(1): 7-15 9
Salt and pepper noise is an impulsive type of noise that 2.3. Edge Detection
represents the presence of randomly occurring black and Edge detection is the common approach for detecting
white pixels. In an 8-bit image, if the gray level values ‘0’ or meaningful discontinuities in gray levels such as edges[10,
‘255’ exist then the corresponding pixel is considered to be a 11]. The basic idea behind this edge detection is that, edges
noisy pixel. The removal of impulse noise involves median can be understood as discontinuities that can be detected by
filter which is conceptually similar to that of the applying the first or second order partial derivatives. The
mean/average filter. The processing pixel is replaced by gradient (Sobel row-edge detector and & Prewitt column-
median of the 3X3 neighbourhood. If the selected 3X3 edge detector) or Laplacian of Gaussian edge detector can be
window is W = {12, 123, 0, 56, 0, 78, 45, 55, 55} with the applied on the image to detect edges. The sample kernel for
processing pixel as ‘0’, then the window elements are Sobel edge detector, Prewitt edge detector and Laplacian of
arranged in ascending order (W = {0, 0, 12, 45, 55, 55, 56, 78, Gaussian are shown in Figure 2 and 3X3 Laplacian mask and
123}), and the mid value is taken as median (i.e 55), and the 5X5 Laplacian of Gaussian mask are shown in Figure 3. The
processing pixel ‘0’ will be replaced by the median value Prewitt and Sobel operators are widely used in digital
‘55’. The major advantage of median filter is that it can gradient computation. Among these two the Sobel operator
preserve details of the image such as edges and contours[4, is preferred because of its higher noise suppression
7]. characteristics[4]. The Laplacian mask shown in Figure 3
2.2. Image Segmentation can also be used for detecting point discontinuities. From
Figure 2 and Figure 3 it is evident that all the edge detection
Image segmentation is a process of identifying masks are having elements that sums to zero, resulting in a
homogeneous regions in a digital image. The basic idea response of ‘0’ at smooth regions of the image.
behind segmentation is called thresholding which can be
classified as single thresholding and multiple thresholding[9].
Selecting an optimal threshold is a crucial process in
segmentation. In single thresholding, a simple thresholding
strategy is followed as given in equation (1).
(a) (b) (c) (d)
1, f (i, j ) > T
g (i, j ) = (1) Figure 2. (a,b) Prewitt mask, (c,d) Sobel mask for diagonal edge detection
0, f (i, j ) ≤ T
‘T’ is a predefined threshold, and the pixels replaced by ‘1’
belong to the object and the pixels replaced by ‘0’ belong to
the background of the image. If it is required to identify more
than two homogeneous regions in the image, the multiple
thresholding technique may be adopted. For example, two
threshold values T1, T2 with T1<T2, can segment the entire (a) (b) (c)
image into three homogeneous regions and for each region, Figure 3. (a,b) Laplacian mask, (c) Typical 5X5 Laplacian of gaussian
distinct gray level (G1, G2 and G3) may be assigned. The mask
multiple thresholding technique is mathematically
represented as equation (2).
3. Teaching Image Processing Concepts
G1 , f (i, j ) < T1 with Matlab – A Practical Approach
g (i, j ) = G 2 , T 1 ≤ f (i, j ) ≤ T2 (2) MATLAB consist of an excellent GUIDE and set of
, f (i, j ) > T functions for different applications in various disciplines.
G 3 2
This platform has four major components namely command
Segmentation could be used for object recognition, window, workspace, editor and product help as shown in
occlusion boundary estimation within motion or stereo Figure 4. For application development either the .m file
systems, image compression, image editing, or image editor or GUI can be used. MATLAB has been successfully
database look-up, Content-based image retrieval, Medical used as an effective tool to teach robotics[12], electrical
imaging, Locating tumours and other pathologies, Face engineering[13-17], communication[18] and data
detection, Fingerprint recognition, Iris recognition, Traffic analysis[19]. As evident from[3], visual based teaching
control systems and Video surveillance. Apart from methodologies can improve the understanding and
threshold based segmentation, there are other various performance of the students. This section addresses the
segmentation techniques including cluster based methods, practical use of MATLAB in teaching image processing
compression based method, histogram based methods, concepts. The discussion is restricted to the simple and
Region-growing methods, Split-and-merge methods, Partial widely used image processing concepts namely image
differential equation-based methods, level set method and denoising, segmentation and edge detection. Some features
watershed transformation[4, 9]. of MATLAB image processing toolbox are listed in Table 1.
10 E. Jebamalar Leavline et al.: On Teaching Digital Image Processing with MATLAB
Feature Support
Digital cameras, satellite and airborne sensors, medical imaging devices,
Image Source
microscopes, telescopes, and other scientific instruments.
Single-precision and double-precision floating-point and signed and
Data types
unsigned 8-bit, 16-bit, and 32-bit integers.
PEG, JPEG-2000, TIFF, PNG, HDF, HDF-EOS, FITS, Microsoft®
Image format
Excel®, ASCII, and binary files.
Resizing, rotating, and cropping, more complex 2D geometric
Simple operations
transformations such as affine and projective.
External applications and Languages C, C++, Java, .NET and Microsoft excel
3.1. Teaching the Concepts of Image Denoising with In the similar way, the MATLAB function medfilt2(I) that
MATLAB implements the 2D median filter can be used to teach the
The image processing toolbox has dedicated functions to concept of impulse noise removal. From Figure 6 the
read, write, and display images. Also for implementing influence of salt and pepper noise can be easily understood
image filtering the function imfilter(I,h) can be used where I by observing the black and white pixels. Also it can be
and h are the multidimensional array that represents the comfortably taught as the median filter is conceptually very
image and filter respectively[20]. A sample code for simple and it exhibits good noise removal performance at
teaching gaussian noise removal using a simple average filter low noise densities[4, 7]. This may be explained by
and the output images are shown ion Figure 5. On seeing comparing the denoised image at 5% noise and 20% noise. In
figure 5, it is clear that when 3X3 average filter is used the the later, even after denoising some black and white pixels
gaussian noise components in the background are not are left unchanged. Thus, it can be easily demonstrated that
removed completely where as when 5X5 average filter is the simple median filter is not suitable for images corrupted
used the output image looks much blurred compared that of with higher noise densities. In the similar way other variants
the 3X3 average filter. This simple exercise will be very of median filter such as adaptive median filter, switching
helpful to teach the effect of the filter kernel size on the median filter, weighted median filter, and directional median
filtered image[4,8,21]. filter can be efficiently taught.
American Journal of Signal Processing 2014, 4(1): 7-15 11
Figure 5. Output images and sample code for Gaussian noise removal using average filter
12 E. Jebamalar Leavline et al.: On Teaching Digital Image Processing with MATLAB
% Teaching salt and pepper noise removal using a simple median filter
clc;
clear all;close all;
Im = imread('cameraman.tif');
I5 = imnoise(Im,'salt & pepper', 0.05);
I20 = imnoise(Im,'salt & pepper', 0.2);
I1=medfilt2(I5); I2=medfilt2(I20);
subplot(3,3,1);imshow(Im,[]), title('Original Image');
subplot(3,3,2);imshow(I5,[]), title('Image with 5% salt & pepper noise ');
subplot(3,3,3);imshow(I20,[]), title('Image with 20% salt & pepper noise ');
subplot(3,3,4);imshow(I1,[]), title('Filtered Image (5%) ');
subplot(3,3,5);imshow(I2,[]), title('Filtered Image (20%)');
Figure 6. Output images and sample code for Salt & Pepper noise removal using simple median filter
Figure 7. Output images and sample code for simple thresholding based segmentation
American Journal of Signal Processing 2014, 4(1): 7-15 13
Figure 8. Output images and sample code for multiple thresholding based segmentation
14 E. Jebamalar Leavline et al.: On Teaching Digital Image Processing with MATLAB
Figure 9. Output images and sample code for demonstrating various edge detection operators
based concept mapping on the learning outcomes and [14] Pires, V. F., Martins, J. F., & Amaral, T. G. (2010).
cognitive processes of mobile learners. British Journal of Development of an experimental system for teaching
Educational Technology, 43(2), 307-320. induction motors with fault detection and diagnosis
capabilities. Computer Applications in Engineering
[4] Gonzalez, R. C., Woods, R. E., & Eddins, S. L. (2008). Education.
Digital image processing using MATLAB. Pearson
Education India. [15] Vahidi, B., Agheli, S. A., & Jazebi, S. (2010). Teaching short
circuit withstand test on power transformers to M. Sc.
[5] http://www.mathworks.in/products/datasheets/pdf/matlab.pd students and junior engineers using MATLAB/SIMULINK.
f Computer Applications in Engineering Education, 20(3),
484-492.
[6] Leavline, E. J., & Sutha, S. (2011, June). Gaussian noise
removal in gray scale images using fast Multiscale [16] Vahidi, B., & Arabshahi, M. M. (2010). Teaching current
Directional Filter Banks. In Recent Trends in Information tests on surge arresters to undergraduate students using
Technology (ICRTIT), 2011 International Conference on (pp. MATLAB–SIMULINK. Computer Applications in
884-889). IEEE. Engineering Education, 20(3), 391-399.
[7] Jebamalar, L. E., & Asir, A. G. D. (2013). Enhanced Modified [17] Benbouzid, M. E. H., & Diallo, D. (2012). Development of a
Decision Based Unsymmetric Trimmed Median Filter for Salt Matlab/Simulink® based wind turbine prototyping software
and Pepper Noise Removal. International Journal of Imaging through undergraduate student projects. Computer
and Robotics, 11 (3), 46-56. Applications in Engineering Education, 20(1), 78-87.
[8] Jebamalar, L. E., & Asir, A. G. D. (2011). Wavelet Domain [18] Bayilmis, C. (2010). Development of a web based educational
Shrinkage Methods for Noise Removal in Images: A interface using MATLAB builder NE with Web Figure for
Compendium. International Journal of Computer digital modulation techniques. Computer Applications in
Applications, 33(10), 28-32. Engineering Education.
[9] Osuna-Enciso, V., Cuevas, E., & Sossa, H. (2012). A [19] Carrasco Fernández, J. J., Soria Olivas, E., Gómez Sanchis, J.,
Comparison of Nature Inspired Algorithms for Serrano, A. J., Soriano, Asensi, A., & Guerrero Martínez, J. F.
Multi-threshold Image Segmentation. Expert Systems with (2012). MATLAB based educational software for exploratory
Applications. data analysis (EDA toolkit). Computer Applications in
Engineering Education, 20(2), 313-320.
[10] Nadernejad, E., Sharifzadeh, S., & Hassanpour, H. (2008).
Edge detection techniques: evaluations and comparisons. [20] Gonzalez, R. C., Woods, R. E., & Eddins, S. L. (2004).
Applied Mathematical Sciences, 2(31), 1507-1520. Digital image processing using MATLAB. Pearson
Education India.
[11] Mittal, A., Sofat, S., & Hancock, E. (2012). Detection of
edges in color images: a review and evaluative comparison of [21] Sutha, S., Jebamalar, L. E., & Asir, A. G. D. (2013). A
state-of-the-art techniques. Autonomous and Intelligent Comprehensive Study on Wavelet Based Shrinkage Methods
Systems, 250-259. for Denoising Natural Images. WSEAS Transactions on
Signal Processing. 9 (4), 203-215.
[12] Farrokhsiar, M., Krys, D., & Najjaran, H. (2010). A teaching
tool for the state of the art probabilistic methods used in [22] Jebamalar, L. E., & Asir, A. G. D. (2013). Hardware
localization of mobile robots. Computer Applications in Implementation of LZMA Data Compression Algorithm.
Engineering Education. International Journal of Applied Information Systems, 5 (4),
pp.52-56.
[13] Vahidi, B., & Khorsandi, A. (2010). Simulation of effect of
voltage sag on inrush current using MATLAB/SIMULINK
for educational purpose. Computer Applications in
Engineering Education.