You are on page 1of 51

EDGE DETECTION USING

EVOLUTIONARY ALGORITHMS
A Project Report submitted in partial fulfillment of the requirement
For the award of degree of
BACHELOR OF TECHNOLOGY
IN
INFORMATION TECHNOLOGY
Submitted By
ADITI BANSAL
(2K10/IT/005)
AKHIL MITTAL
(2K10/IT/009)
ANISH PRASAD
(2K10/IT/015)
GAURAV AHUJA
(2K10/IT/027)
Under the esteemed guidance of
Mr. Anil Singh Parihar
Assistant Professor

DEPARTMENT OF INFORMATION TECHNOLOGY


DELHI TECHNOLOGICAL UNIVERSITY

(Formerly, Delhi College of Engineering)


DELHI, INDIA
2014
CERTIFICATE
This is to certify that the project entitled , Edge detection using evolutionary algorithms by
Aditi Bansal, Anish Prasad, Akhil Mittal and Gaurav Ahuja is a record of work carried out by
him/them, in the department of Information Technology, Delhi Technological University
(formerly Delhi College Of Engineering ), New Delhi, under my supervision and guidance in
partial fulfillment of requirement for the award of the degree of Bachelor of Technology in
Information Technology, Delhi Technological University in the academic year 2013-2014.

Mr. Anil Singh Parihar


Assistant Professor
Information Technology Department
Delhi Technological University

(i)
ACKNOWLEDGEMENT
We wish to express our sincere gratitude to our supervisor Mr. Anil Singh Parihar (Assistant
Professor, Department of Information Technology) for providing his invaluable advice and
frequent suggestions that were incorporated during the course of the project and monitoring our
progress throughout the project.

PROJECT MEMBERS
Aditi Bansal, Roll No: 2K10/IT/005
Akhil Mittal, Roll No.: 2K10/IT/009
Anish Prasad, Roll No.: 2K10/IT/015
Gaurav Ahuja, Roll No.: 2K10/IT/027

(ii)
ABSTRACT
Edge detection identifies points in a digital image where the image brightness changes sharply or
has discontinuities with the help of mathematical methods. Vision systems and object recognition
systems require edge detection. There are a lot of edge detection operators such as the gradient
operator and the Laplacian operator that are based on the assumption that edges in various
images are step intensity edges. Due to this, thick and fragmented edges are detected. It is still a
difficult task to find true edges in an image.
The quality of edge detection depends on a lot of factors such as illumination, density of edges in
the scene and noise. Huge search space is another problem with most of the existing operators.
The task for edge detection is time consuming and memory exhausting if done without
optimization. To avoid this, various evolutionary algorithms are increasingly sought for edge
detection such as bacterial foraging, particle swarm optimization and differential search
algorithms. These algorithms dont require any preprocessing and hence are much more efficient
than the previous methods for edge detection.

(iii)
CONTENTS
i. Certificate
ii. Acknowledgement
iii. Abstract
iv. List of figures
CHAPTERS

i
ii
iii
v
PAGE

1. Introduction

2. Literature

2.1 Digital Images

2.1.1 Types

2.2 Noise

2.2.1Types

2.3 Image Processing

2.4 Edge Detection

2.4.1 Approaches

10

2.4.1.1 Edge detection using gradient

10

2.4.1.2 Edge detection using second derivative

13

2.4.1.3 Ant Colony Optimization

15

2.4.1.4 Particle Swarm Optimization

16

3. Proposed methodology

18

4. Results

33

5. Conclusion

39

6. Bibliography

40
(iv)
LIST OF FIGURES

2.1 Black and white image


2.2 Grayscale Image
2.3 RGB Image
2.4 Intensity edges-(a) Step-Edges (b) Ramp-edges (c) Roof-edges
2.5 Direction of Gradient
3.1 A local configuration at the pixel position Ii,j for computing the variation Vc(Ii,j)
3.2 Permissible range for ants movement-(a) 4-connectivity (b) 8 connectivity
3.3 Eight ways of moving from one pixel to its neighborhood pixel
4.1 Test Image: Cameraman
4.2 Results obtained by incorporating equation 3.4a , 3.4b, 3.4c, 3.4d
4.3 Test Image: Lena
4.4 Results obtained by incorporating equation 3.4a, 3.4b, 3.4c, 3.4d
4.5 Test Image: Lena
4.6 Result of applying PSO based approach
4.7 Test Image: Cameraman
4.8 Result of applying PSO based approach
4.9 Test Image: Lena
4.10 Result of applying proposed optimized ACO
4.11 Test Image: Cameraman
4.12 Result of applying proposed optimized ACO

(v)

Chapter 1
INTRODUCTION
Edge detection is an important problem in image processing. Edge detection is a fundamental
technique for compressing the data content in the images to simplify the high-level image
processing tasks, as edges contain significant information about the image and edges can help to
segregate the shape of the objects. In an image, the edge gives the boundary between two regions
that is determined by sharp discontinuity in the intensity values. Edges can be determined in the
spatial domain by direct manipulations of image pixels or by transforming it to another domain
(frequency domain).. To determine the edges pixel, it is necessary to detect the position between
two pixels. The resultant image after performing edge detection is merely the outline of the input
image from which various important features like corners, lines, and curves can be extracted.
A lot of research has been done in the area of image segmentation using edge detection. The
given image is separated into object and background, by detecting an edge between them.
Most of the edge detection techniques involve computation of a local first or second order
derivative operator, following which steps are taken in order to minimize the effects of noise.
The literature comprises of many edge detection techniques like Sobel, Prewitt and Roberts who
proposed some of the earliest operators to detect edges in an image. The methods used by these
operators are gradient methods that are used to detect edges in a particular direction. Noise is the
major factor that inhibits these edge detection procedures. This problem was then overcame by
Canny which convolved the image with the derivatives of first order of Gaussian filter for
smoothening in the direction of local gradient followed by edge detection using thresholding.
Ant colony optimization (ACO) is an algorithm inspired by nature that is based on the natural
behavior of ant species. The ants while searching for food deposit pheromone on the ground.
ACO is used to deal with the edge detection problem in the images. Using this approach a
pheromone matrix is established based on the movement of a group of ants travelling on the
image. This matrix gives the information about the edges presented at each pixel location of the
image. Moreover, the ants movement is characterized by the local variation of the pixel intensity
1

values. The algorithm based on PSO uses an optimization method for detecting edges in images
corrupted with noise. The constraints are handled using a preservation method. The PSO based
algorithm effectively maximizes the interest distance (that is distances between pixel values in
the two regions separated by a continuous edge) and minimizes the intra-set distance (that is the
distance between the pixel intensities within each region). It accurately detects thin, continuous
and smooth edges in complex images. A single initialization of the algorithm is sufficient for all
the runs making the algorithm faster. For representing these curves in this search space, an
encoding scheme is used. For the evaluation of each curve, a fitness function is used to measure
how similar are the pixels within each sub-region and how different are they between two subregions
This project work is based on [1], [18]. We have implemented the earlier said work and tried to
improve the same using some modifications.

Chapter 2
LITERATURE
Digital Images
Digital images are representation of 2-dimensional images as set of pixel-intensity values.
Digitization states that an image is an approximation of a real scenario. In a mathematical view, a
monochromatic image is a 2D function f(x, y) where x and y are spatial coordinates. The
intensity or gray level of the image at any pair of coordinates(x, y) is the amplitude at that point.
There are three types of digital images based on the number bits required to store the intensity
value for each pixel position:
Black and white (1 bit per pixel): They can take only 2 values-black and white, or 0 or 1 and are
the simplest type of images and thus only 1 bit is required to represent every pixel. Moreover,
these images are usually used in applications. They are used where the information required is
only general shape or outline. Gray-scale images are converted to binary images using a
threshold operation where all the pixels above the threshold value are marked as white (1) and
those below are marked as black (0).

2.1Black and white image


Grayscale (8 bits per pixel): Gray-scale images are classified as monochrome (one-color)
images. They provide gray level information and no information about color. The gray levels
available are determined by the number of bits per pixel. The typical gray-scale image contains
8-bits/pixel allowing 256 gray-levels.

2.2 Grayscale Image


RGB (24 bits per pixel): Color images are basically three band monochromatic image data
where every band represents distinct colors. The gray-level information in each spectral band is
the true information stored in the image.
They are represented as Red, Green and Blue i.e. RGB images. The color image has 24 bits per
pixel.

2.3 RGB Image


Noise
Noise means any unwanted signal. Noise in an image is random, that is, they are not present in
an image. They are variation of the brightness levels or the color information in images, and is
usually an aspect of electronic noise. Digital images could be contaminated by noise during
image acquisition and transmission.
Corrupted images must be restored in order to extract useful information as they severely disrupt
the subsequent image processing operations.
Thus digital image processing is performed to restore the images for subsequent use.
In most cases there are two types of noises that are added to images, namely, additive Gaussian
noise and impulse noise.
In Impulse noise, there are two types of impulse noise,
1) Fixed valued impulse noise(salt-and-pepper).
2) Random valued impulse noise.
Gaussian noise affects all pixels of the image. Such noise is used during image acquisition
process. Its probability density function is equal to normal distribution.
Image features
2 types of features are there in an image. They are5

Features that are Global these depict the global features of an image, including
frequency domain descriptors, intensity histogram, high order statistics and covariance
matrix etc.

Features that are Local these depict the local regions with properties like corners, edges,
curves, lines, regions with special properties, etc.

Various features are useful, depending on the applications.


Image processing
The technique that converts an image into digital form and performs all the operations on it is
called Image processing. It is done in order to get an enhanced image and extract information
that is useful to us from it. In image processing, input is image, like video frame or photograph.
The output may be image or characteristics associated with that image. It is a type of signal
dispensation.
Usually Image Processing system applies signal processing methods to them.
The two major task of image processing are: improvement of pictorial information to make it
viable for human interpretation and processing image data for transmission, storage and
representation for autonomous machine perception.
Purpose of Image processing
The various purposes of image processing are divided into following groups. They are:
(1) Visualizing images Observe the objects that are not visible. Visualization is a method
for creating images, diagrams, or animations to send a message.
(2) Sharpening of images and its restoration Image sharpening is a very important tool
that emphasizes texture and draws viewers focus to create a better image. Digital camera
6

sensors and lenses always smoothens an image to some extent in which correction is
required. The noise removal (motion blur, sensor noise etc.) from images is called Image
Restoration. Various types of filters such as median filters or low-pass filters are the
simplest of the possible approaches for noise removal. More sophisticated methods
assume a method to differentiate them from noise.
(3) Retrieval of images Find the image of interest. For searching, browsing and retrieving
images from a large database of digital images is called image retrieval system. Most
common and traditional techniques of image retrieval utilize various methods of adding
captions, keywords, or image descriptors. It is done so that retrieval can be performed
over the annotation words.
(4) Recognition of images: It used for identifying objects present in an image. The process
begins with methods like noise removal, followed by basic level feature extraction that
helps in locating regions, lines and areas with various texture levels.
Edge Detection
The mathematical method that identifies points in a digital image at which the image
brightness has discontinuities or changes sharply is called Edge detection. The points of sharp
change are termed as edges. Edge detection is an important tool used in the areas of feature
extraction and feature detection and is used widely in image processing, machine
vision and computer vision.
Edges can be classified as follows based on intensity levels.
Step edges: The intensity in the image changes drastically from one value to a different value at
the point of discontinuity.
Ramp edges: It is a type of step edge. In this type of edge, the change in intensity is not
instantaneous. Instead, it occurs over a certain distance.

Roof edges: It is a type of ridge edge in which the change in intensity is not instantaneous.
Instead, it occurs over a certain distance.
The edges from a 2-D image of a 3-D scene that are extracted are classified as either view-point
dependent or view-point independent. An edge that depicts characteristic properties of the 3-D
objects like surface shape and surface markings is called a viewpoint independent edge. An
edge which on changing the viewpoint gets changed, and depicts the geometry of the scene, such
as occlusion of objects on one another is called a viewpoint dependent edge.

2.4 Intensity edges-(a) Step-Edges (b) Ramp-edges (c) Roof-edges


Desired characteristics of images

Accurate localization It is often desired that an edge should lie in a region that is
spatially accurate, separating the different regions in the best way possible. In many real
images, the edge position may be ambiguous. This is the case when the same pair of
dissimilar regions are separated by a collection of closely adjacent boundaries. The degree
of dissimilarity between the regions on either sides of the boundary will vary for each
boundary because each boundary in the collection has a unique spatial location. When the
edge coincides with the boundary that results in the maximum degree of dissimilarity, then
the edge is said to be accurately localized.

Thinness-It is often desired that edges (also considered as boundaries) form thin lines in
an image. Ideally, they should be only one pixel wide in the direction that is
perpendicular to the edge direction.
8

ContinuityEdges must exhibit a continuity which thus, reflects the nature of the
boundary. Usually the physical boundaries are continuous in nature. Only the correct
edges should exhibit this property. However, there should be no constraint on edges that
make closed boundaries in an image.

LengthAppearance of short and scattered edges of one or two pixels in length is caused
by noise and fine textures. We will not consider such short edges and keep our concept of
edges to those that are minimum three pixels long. The trade-off between the different
desirable characteristics of an edge is always present. Due to conflicting edge
requirements, there are many situations where it is not possible to simultaneously achieve
two or more characteristics. For instance, poor localization and the appearance of false
boundaries can be resulted as a consequence of requiring every edge to be long and
continuous. Hence, associating a measure of importance with each desirable edge
characteristic is appropriate so that situations that have conflicting edge requirements
may be solved. Importance of each characteristic is emphasized by attaching a weight to
its associated cost factor which is seen in the formulation of the comparative cost
function.

Parameters for optimal detection of edges


Optimal detection: The edge detector must potentially reduce the chances of detecting
unwanted edges caused due to noise and also should not miss real images.
Optimal localization: The edges that are detected should be extremely close to the true edges.
Response Count: Ensure that a real edge does not result in more than one already detected edge.
Applications
Some of the applications of edge detectors are:
a) Robotics, computer vision and image processing applications:
9

Contour feature extraction.


Object tracking and recognition.
b) In the area of biometrics:
Face detection
Fingerprint recognition
Iris identification etc.
c) Machine vision gauging applications:
Inspection for missing parts
Measurement of dimensions of critical parts using gauging.
d) Medical Imaging applications:
X-Ray
CT Scan
Approaches for edge detection
There are various methods for edge detection, in which most of these methods can be grouped
into two categories:
(1) Detection of local minima or maxima of the rst derivative (search-based)
(2) Detection of the zero-crossing of the second derivative (zero-crossing based).
The first class of methods that is the search-based methods can detect edges in an image by first
evaluating an edge strength measure that is a first-order derivative expression like gradient
magnitude, and then looks for the direction where the magnitude of the gradient is maximum.
The zero-crossing based methods find zero-crossings in a second-order derivative that has been
calculated from the image for finding edges.
Detecting edges using the gradient technique

10

The gradient is a vector quantity that has a magnitude and a direction. The gradient magnitude
determines the strength of an edge whereas the gradient direction is perpendicular to the
direction of the edge.

(2.1)

2.5 Direction of Gradient


Various operators are available for the calculation of gradient. Some of them are as follows:
Roberts edge detector

(2.2)

11

These following masks can be used for implementing the approximation:

(2.3)
Prewitt edge detector
Consider the arrangement of pixels about the pixel (i, j):

The partial derivatives can be computed by:

(2.4)
Setting c = 1, we get the Prewitt operator:

(2.5)
Sobel edge detector
Setting c = 2, we get the Sobel operator:

12

(2.6)
By giving higher weight to the central pixels this mask helps in providing some degree of
smoothening effect and is hence beneficial than the other 2 masks.
Scharr Operator
Scharr operator with Mx and My is as follows:

(2.7)
Sobel operator, though can reduce artifacts that are associated with the central differences
operator, but they do not have perfect rotational symmetry. Scharr operator, on the other hand,
optimized this property.
Detecting edges using the second derivative technique
Edge pixels of an image can be detected by searching the zero-crossings of the second derivative.
There exits 2 operators in two dimensional images that are associated with the second derivative:
Laplacian and Second directional derivative

13

The Laplacian Technique

(2.8)
Where,

(2.9)
The Laplacian technique can be implemented using the mask displayed below:

The steps of edge detection are as follows:

Smoothening: Blurring the image so as to reduce the noise pixels from the image.

Enhancement: Applying an appropriate lter to enhance the edge quality in the image
(sharpening).

Detection: Find the edge pixel that must be removed as noise and which should be
retained in the image (the thresholding (global/local/adaptive)) gives the criteria used for
detection).

14

Localization: Find the exact location of an edge. Edge thinning and linking are the
features to cater to during localisation.

Gaussian smoothing is always applied to minimize the effect of noise before the detection
process. This is done because both first and second order derivatives are extremely sensitive to
noise (sharp changes in intensity).
Then we compute the edge strength that is the gradient magnitude after which we apply a
threshold to check whether a pixel belongs to an edge or not. Small threshold
result in detection of more edge points since result is vulnerable to noise. On the contrary, a large
threshold can miss meek edge points and can also result in fragmented and discontinuous edges.
A basic approach to eradicate this problem utilizes multiple thresholds to detect edges. The
approach starts by making use of the upper threshold to find the commencement of an edge.
Afterwards, the path of the edge is traced in image pixel by pixel, marking an edge whenever the
pixel value is above the lower threshold. This process stops only when the value is less than
lower threshold. Still, choice of appropriate thresholding parameters, and suitable thresholding
values is a very huge challenge as it may change over the image.
Edge thinning is an important method that is used to remove the unwanted pixels on the edge of
an image. This method is used after the image filtering process and then, the edge operator is
applied to detect the edges and afterwards, the edges are smoothened using an appropriate
threshold value. This removes all the unwanted points and if applied carefully and cautiously,
results in edge pixels that are one pixel thick.
Ant Colony Optimsation
ANT colony optimization (ACO) is an optimization algorithm inspired by nature, based on the
natural phenomenon that states that ants deposit pheromone (chemical) on the ground in order to
mark the desired path that should be followed by other members of the colony. This algorithm is
used to solve many problems. ACO tackles the image edge detection problem that is to gather the
edge information presented in the image. ACO is also used for developing heuristic algorithms
for combinatorial problems. Ant Colony Optimization is a process designed to identify pixels in
an image where sharp discontinuities in intensity occur.
15

Different steps of an ACO algorithm are the following:

Problem graph representation


Initializing ants distribution
Node transition rule
Pheromone updating rule

In this method, ants travel on a 2-D image for constructing a pheromone matrix. The edge
information is extracted that is used to identify all the edges present in the image. The ants
movement is determined by the local variation of the pixel intensity values of the image.
In the model used, each pixel in the image represents an edge point in the graph. It represents an
edge because the local information of the images intensity values determines the heuristic
information and hence, is closely related with a pixel location in the image. Also, the components
of the transition and pheromone matrices are related with pixels in the image.

Particle Swarm Optimization


PSO deals with generating a set of possible solutions called population. The cognitive and social
behavior of the swarms influences this technique. Every particle moves in the multi-dimensional
space with some velocity. Every particle stores previously visited search space.
This algorithm is guided by 2 factors:
a) Movement of particle in local neighborhood.
b) Movement of particle in global neighborhood.
Best Solutions in local area (Local): - The particle searches for the best solution in the search
space.

16

Best Solution in entire area (Global): - it is the best solution considering all the particles that
participate in the local solutions. If an improved solution is found, then the best and local
positions are updated.
Parameters
i)

ith particle position:Xi = (Xi1, Xi2,.,XiN) is the ith particle of the swarm. The particle number is denoted by
the first subscript and the dimension is depicted by the second subscript.

ii)

ith particle velocity:Vi = (Vi1, Vi2,., ViN)

iii)

Xbest of the particle (Local best position):Xbest=(Pi1, Pi2, .., PiN)

iv)

Updating the velocity:-

(2.1
0)
Where:
i= (1 to m) is the number of swarms.
d= (1 to N) is objective functions dimension which needs to be optimized
The global best solution of the swarm is gbest.
Iteration number is denoted by k.

17

W is the parameter that controls the swarms previous velocity vector in the current
one. This tradeoff between local and global exploration helps in minimizing the
number of steps for searching a solution which is optimal.
The cognitive parameter is .
The social parameter is .
The random numbers 1 and 2 are between 0 and 1.
v)

Updating the position:-

(2.11)
Where:
q = correction factor that helps n speeding up the convergence process.

Chapter 3
PROPOSED METHODOLOGY
BACKGROUND WORK
The edge detection technique based on ACO utilizes a set of ants that move on a 2-dimensional
image for the construction of a pheromone matrix. Every entry of this matrix gives the edge
information of each point of the image. The movement of the ants is controlled by the local
variation of the intensity values in the image. The first step is the initialization process. Then N
iterations are run for constructing the pheromone matrix. In these iterations, the construction
process and the updation process is carried out iteratively.
18

The final step is the decision process which is carried out to determine the edge.
a) Initialization Process
The process begins with assigning A number of ants on an image I. Size of the image is M1
M2. Every pixel of this image is considered as a node. The pheromone matrix is denoted by (0)
and its initial value is set to be a constant init for every component of the matrix..
b) Construction Process
One ant is randomly chosen from the T ants at the n-th step of the construction process. This ant
will make R movement-steps on the image. The transition probability defines the ants
movement from the node (l,m) to its neighboring node (i, j) as:

(3.1)
Where,
the value of the pheromone at node (i, j) is denoted by

(n1)
i,j

, the neighborhood nodes of the

node (l,m) are denotes as (l,m) , the heuristic information at the node (i, j) is denoted as i,j . The
influence of the pheromone matrix is represented by and the influence of the heuristic matrix is
represented by .
The heuristic information is calculated as follows:

(3.2)
Here, Ii,j is the pixels intensity value located at the position (i, j) of the image I, Vc(Ii,j) is a
function of c which is a local group of pixels (referred to as the clique), the value of which
depends on the images intensity values variation on the clique c as follows:

19

3.1 A local configuration at the Ii,j pixel position .


The gray square marks the pixel Ii,j.
The variation Vc(Ii,j ) is calculated by

(3.3)
Following 4 functions are considered for f(.) :

(3.4a)

(3.4 b)

(3.4
c)

20

(3.4 d)

is a normalization factor.
The shape of the functions is adjusted using the parameter .
Either the 4 connectivity or 8 connectivity neighborhood is considered as permissible range of
ants movement ( (l,m) ) .

3.2 Permissible range for ants movement-(a) 4-connectivity (b) 8-connectivity


c) Updation Process
Two updates operations are performed to update the pheromone matrix.
1. An update operation is carried out after the movement of every ant within every constructionstep. The value of each component is updated as follows:

(3.5)

Here, denotes the evaporation rate and

21

After all ants have moved within each construction-step, the second update is carried out as
follows:
(3.6)
Here, denotes the pheromone decay coefficient.
d) Decision Process
In this final stage of the process, a threshold T is applied on the nal pheromone matrix

(N)

in

order to check at every pixel location whether it is edge or not . This threshold T is calculated
adaptively . The mean value of the pheromone matrix is chosen as the initial threshold T (0). Then
the entries of the pheromone matrix are divided into two categories by comparing them with
threshold T(0). Then the average of two mean values of each of the two categories is computed
and is set as the new threshold. This process is repeatedly carried out until there is no more
change in the threshold value (according to a user-dened tolerance ).
The above can be summarized as follows.
Step 1: T(0) is initialized as:

(3.7)
the iteration index l is set to zero .
Step 2: The entries of the pheromone matrix (N) are separated into two categories by comparing
with T(l), the rst category comprises of entries of that have values smaller than T (l), and the
second category comprises of the remaining entries of . Next, the mean of each of the above two
classes is calculated as:

(3.8)

22

(3.9)
where

(3.10)

(3.11)

(3.12)

(3.13)
Step 3: iteration index is incremented as l = l +1, and the threshold is updated as follows:

(3.14)
Step 4: If the difference |T(l)- T(n1)| is greater than , then go to 2nd step; otherwise, terminate the
iteration process and make a decision on every pixel position (i,j) to check if its an edge or not,
using the following criterion

(3.15)

The algorithm based on PSO uses an optimization method to detect edges in images corrupted
with noise. The constraints are handled using a preservation method. The PSO based algorithm
effectively maximizes the interest distance (that is distances between pixel values in the two
regions separated by a continuous edge) and minimizes the intra-set distance (that is the distance
23

between the pixel intensities within each region). It accurately detects thin, continuous and
smooth edges in complex images. A single initialization of the algorithm is sufficient for all the
runs making the algorithm faster. For representing these curves in this search space, an encoding
scheme is used. For the evaluation of each curve, a fitness function is used to measure how
similar are the pixels within each sub-region and how different are they between two subregions.
Encoding Scheme
A set of pixels are processed at a time in this method rather than one pixel for extracting the
global structure of the edge. Also to avoid noise and false detections, the approachtakes into
account a large area instead of a small one.
Fitness function
The average edge magnitude of all pixels on the edge decides the fitness value of each edge.
Edge magnitude measure
To reduce sensitivity to noise, instead of using first or second derivative another method is used
to calculate edge magnitude. The eight possible directions of movement are used to classify the
neighborhood of each pixel into two regions as follows:

3.3 Eight possible directions for moving from one pixel to its neighbor

24

Edge magnitude is modeled as a function of interest and intra-set distances: larger the inter-set
distance between these two regions is great and smaller their intra-set distances, greater would be
the edge magnitude; and the edge magnitude will be small in case of small inter-set distance and
large intra-set distances.
In movement direction m the edge magnitude at P pixel is calculated as:

(3.16)
Where,
(3.17)
Where, avgm,d(P) denotes the the average intensity of the dark regions for direction of movement
m for pixel P and is calculated as:

(3.18)
And, avgm,l(P) denotes the the average intensity of the light regions for direction of movement m
for pixel P and is calculated as:

(3.19)

IPi is the ith pixels intensity in the respective set; and w1 denotes a weight factor.
The pairwise subtractions of pixel values is calculated and added in a region to give the intra-set
distance as follows:

(3.20)

NMS Factor for Edge Thinning

25

It extracts local maximum of the edge magnitude along the direction of the gradient vector. The
non-maximal edges are suppressed. for each direction m and the EdgeMagm of a pixel on a
continuous edge is compared to the EdgeMagm of pixels P1to P6 on both sides of the edge. The
NMS factor in each direction.

(3.21)
NMS is an integer and its value lies in the range 0 to 6. When P is a local maxima in the direction
m, then NMS factor in m direction is larger.
If the estimation of the edge direction is not done correctly, it is possible that some of the real
edge pixels might be discarded by the NMS algorithm resulting in appearance of broken edges
on the edge map. Therefore, it is not necessary to remove a non-maxima edge. This method
keeps the non-maxima edge intact. By multiplication with a number less than 1 it reduces the
edge magnitude of the non-maxima edge. This is close to 1 for the edges whose NMS factor
values are high, and is nearby zero for the ones whose value is low. For scaling a NMS factor
value to fall in the range from 0 and 1 and generate this number, a sigmoid function is used.
Hence the total edge magnitude of each pixel in m direction is calculated as:

(3.22)
An edge pixel may be falsely detected as a non-edge if it has an edge magnitude that is low
compared to the threshold values. Thus, existing methods of image thresholding often result in
broken edges in the edge detection. To minimize the drawback of using these methods, another
sigmoid function is used. Estimation of the possibility score of the pixel P is done by using a
sigmoid function and is given by-

(3.23)

26

Uniformity Factor
The pixel values of immediate neighbors can be used to estimate the value of pixel for the
broken edges as the pixels that lie on an edge have similar intensity values. Thus pixel intensities
can be used for evaluating a curve. In order to guage intensity similarity of pixels lying on a
curve the uniformity factor is used:

(3.24)
Where,
IPi -- value of the pixel i on curve C.
U(C) is a real number and its value ranges from 0 to 1.
Low value of U(C) signifies a better fit on the actual edge, since pixel values are similar along
the curve.
The uniformity factor of curve along with the mean of the possibility scores of the pixels on a
continuous edge can be used to find out the total possibility score of the curve lying on a
continuous edge.
In order to maximize the probability of the pixels on the curve and minimise its uniformity factor
the possibility score is calculated as follow:

(3.25)
Curvature Cost of Continuous Edges

27

Edge orientation of pixels adjacent to each other on a smooth edge is very similar. In order to
minimise the effect of producing jagged edges a curvature cost of a continuous edge is used and
it is calculated as follows:

(3.26)
Where,
mi -- movement direction i
w3-- weight factor.
The mean of the curvature cost of all individual pixels on the curve is used to calculate the
curvature cost of curve C as follows:

(3.27)

Fitness Function with Two Constraints


In order to fit more accurately on a continuous edge the possibility score of a curve should be
maximized and to get smooth edges the curvature cost should be minimized. Incorporating these
two conditions the following fitness function is used for evaluating the curve C:
Fitness(C) = PScore(C) CCost(C)
Estimation of TH
After applying an edge operator the resultant image is binarised using a global thresholding
technique. It works efficiently to classify a group of pixels into two subsets (edge and non-edge),
28

maximizing the discriminating criteria of interset variance between the intensities of the pixels
belonging to these subsets. Pixels whose magnitude is less than t are put in the first set and those
with magnitude greater than t are put in the second set.
Let 1(t) -- average edge magnitude of the pixels in the first subset
2(t)-- average edge magnitude of the pixels in the second subset
N1(t) --number of the pixels first subset
N2(t)-- number of the pixels second subset
Then,
A(t)--The average edge magnitude of all pixels can be calculated as follows:

(3.28)
A(t) is the inter-set variance between these two subsets and is calculated as :

(3.29)
TH is the value t that corresponds to the maximum of A(t).

PROPOSED EDGE DETECTION USING OPTIMIZED ANT COLONY


ALGORITHM ON A PRE-PROCESSED IMAGE
Procedure:
1. PRE-PROCESSING STEPS:
a) Smoothening:
In order to remove noise, blurring is done. The image is first smoothed by applying
Gaussian filter with a standard deviation of 0.8 to prevent that noise is mistaken for
edges.
29

b) Finding edge strength and edge intensifier in all directions of a pixel:


Finding the edge strength in all eight directions (m) of a pixel (using the six masks
displayed in Fig. 3.3) along with the edge intensifier value (formula stated below) in
these directions that, as the name suggests, intensifies the fact whether a pixel is a part of
an edge or not.
Edge_sum[3X3](i,j,m)=sum of three middle pixels separating the black and white area.
Remaining_pixel_sum[3X3] (i,j,m)=sum of six remaining pixels.
Edge_intensifier[3X3] (i,j,m)=(1+2*Edge_sum)/Remaining_pxel_sum.

(3.30)

Where i=index of row of image,


j=index of column of image,
m=direction
c) Computing NMS for edge thinning:
The method to compute NMS is similar to what is stated in PSO algorithm mentioned
above (3.21).
d) Computing total edge strength of a pixel:
The formula to compute total edge strength of a pixel in all directions is as follows:
Total_edge_strength(i,j,m) =edgemag(i,j,m) * (2^(nms(i,j,m)-4)).(3.31)
e) Computing local edge strength of a pixel:
Local_edge_strength(i,j) = maxm=1:8(Total_edge_strength(i,j,m))

(3.32)

2. APPLYING THE ACO ALGORITHM:


The four steps of ACO algorithm stated above are applied with v matrix being the
Local_edge_strengthmatrix
a) Initialization
The process begins with assigning A number of ants on an image I. Size of the image is
M1 M2. Every pixel of this image is considered as a node. The pheromone matrix is
30

denoted by (0) and its initial value is set to be a constant init for every component of the
matrix..
b) Construction
One ant is randomly chosen from the T ants at the n-th step of the construction process.
This ant will make R movement-steps on the image. The transition probability defines the
ants movement from the node (l,m) to its neighboring node (i, j) as:

(3.33)
Where,
the value of the pheromone at node (i, j) is denoted by

(n1)
i,j

, the neighborhood nodes of

the node (l,m) are denotes as (l,m) , the heuristic information at the node (i, j) is denoted
as i,j . The influence of the pheromone matrix is represented by and the influence of the
heuristic matrix is represented by .
The heuristic information is the local edge magnitude as computed above:
i,j=Local_edge_strength(i,j)

(3.34)

The permissible range of ants movement ( (l,m) ) is either given by 4 connectivity or 8


connectivity neighborhood.
c) Updation
Two updates operations are performed to update the pheromone matrix.
1. An update operation is carried out after the movement of every ant within every
construction-step. The value of each component is updated as follows:

31

(3.5)

Here, denotes the evaporation rate and


After all ants have moved within each construction-step, the second update is carried out
as follows:
(3.6)
Here, denotes the pheromone decay coefficient.
d) Decision
Experiments show further improvement in results by applying the Otsus method for
decision making rather than the global thresholding technique.
Exhaustive searching for the threshold minimizing the intra-class variance is the main
aim of Otsus method. It is depicted as a weighted sum of variances of the two classes:
(3.37)

W1 = probabilities of the two classes


t = threshold

= variances of these classes


.
,

Variance is denoted in terms of class probabilities W1 and mean of the class .


W1 is evaluated from the histogram as t:
32

(3.38)

,
The mean of the class

(3.39)

is:

(3.40)
= value at the center of the bin of the

th

histogram.

Final Threshold (Tfinal) = maximum


The` class probabilities and class means can be computed iteratively.
The steps for the same are as follows:

Histogram and Probabilities of each intensity level are computed.

Initial

All possible thresholds

and

are setup.
maximum intensity are iterated and the

following steps are done

And

are updated.
are computed.

Final threshold is given by the maximum

33

Chapter 4
EXPERIMENTAL RESULTS
Algorithm 1

(1)

34

4.1 Test Image: Cameraman

4.2 Results obtained by incorporating equation 3.4a,3.4b,3.4c,3.4d

(2)

35

4.3 Test Image: Lena

4.4Results obtained by incorporating equation 3.4a,3.4b,3.4c,3.4d

Algorithm 2

36

(1)

4.5 Test Image: Lena

4.6 Result of applying PSO based approach

(2)
37

4.7 Test Image: Cameraman

4.8Result of applying PSO based approach

Proposed algorithm
38

[1]

4.9 Test Image: Lena

4.10Result of applying proposed optimized ACO

(2)
39

4.11. Test Image: Cameraman

4.12. Result of applying proposed optimized ACO

40

Chapter 5
CONCLUSION
Edge detection is an important part of image processing. It is beneficial for many research areas
of computer vision and image segmentation. It provides many important details for high level
processing tasks like feature detection etc. This report discusses the achievement obtained by
implementing an ACO based approach for edge detection. Experimental results show the
feasibility of the method in identifying edges in images. The report also discusses the
implementation of a PSO based approach for detection of edges in the image. Experimental
results show that our proposed algorithm used in conjunction with ACO effectively maximizes
the distances between pixel intensities in the two regions (inter-set distance) and minimizes the
distance between the pixel intensities within each region (intra-set distance), and detect thin,
smooth and continuous edges in complex as well as simple images.

41

BIBLIOGRAPHY
[1] Jing Tian, Weiyu Yu, and ShengliXie,An Ant Colony Optimization Algorithm For Image
Edge Detection2008 IEEE Congress on Evolutionary Computation (CEC 2008)
[2] H.-B. Duan, Ant Colony Algorithms: Theory and Applications. Beijing: Science Press, 2005.
[3] M. Dorigo, V. Maniezzo, and A. Colorni, Ant system: Optimization by a colony of
cooperating agents, IEEE Trans. on Systems, Man andCybernetics, Part B, vol. 26, pp. 2941,
Feb. 1996.
[4] R. C. Gonzalez and R. E. Woods, Digital Image Processing. Prentice Hall, 2007.
[5] S. E. Umbaugh, Computer Imaging: Digital Image Analysis and Process- ing. CRC Press,
2005.
[6] D.-S. Lu and C.-C.Chen, Edge detection improvement by ant colony optimization, Pattern
Recognition Letters, vol. 29, no. 4, pp. 416425, 2008.
[7] H. Pan, L.Wang, and B. Liu, Particle swarm optimization for function optimization in noisy
environment, Applied Mathematics andComputation, vol. 181, no. 2, pp. 908919, 2006.
[8] K. E. Parsopoulos and M. N. Vrahatis, Recent approaches to global optimization problems
through particle swarm optimization, Natural Computing, vol. 1, pp. 235306, 2002.
[9]M. Dorigo and L. M. Gambardella, Ant colony system: A cooperative learning approach to
the traveling salesman problem, IEEE Trans. OnEvolutionary Computation, vol. 1, pp. 5366,
Apr. 1997.
[10] M. Dorigo, G. D. Caro, and T. Stutzle, Special Issue on Ant Algorithms, Future Generation
Computer Systems, vol. 16, Jun. 2000.

42

[11] O. Cordon, F. Herrera, and T. Stutzle, Special Issue on Ant Colony Optimization: Models
and Applications, Mathware and Soft Computing,vol. 9, Dec. 2002.
[12] M. Dorigo, L. M. Gambardella, M. Middendorf, and T. Stutzle, SpecialIssue on Ant Colony
Optimization, IEEE Transactions on Evolutionary Computation, vol. 6, Jul. 2002.
[13]Kennedy, J. and Eberhart, R. C. Particle swarm optimization.Proc.IEEE int'l conf. on neural
networks

Vol.

IV,

pp.

1942-1948.IEEE

service

center,

Piscataway,

NJ,

1995.

[14]Eberhart, R. C. and Kennedy, J. A new optimizer using particle swarm theory. Proceedings of
the sixth international symposium on micro machine and human science pp. 39-43.IEEE service
center,

Piscataway,

NJ,

Nagoya,

Japan,

1995.

[15] Eberhart, R. C. and Shi, Y. Particle swarm optimization: developments, applications and
resources. Proc. congress on evolutionary computation 2001 IEEE service center, Piscataway,
NJ., Seoul, Korea., 2001.
[16] Shi, Y. and Eberhart, R. C. Parameter selection in particle swarm optimization. Evolutionary
Programming VII: Proc. EP 98 pp. 591-600. Springer-Verlag, New York, 1998.
[17] Shi, Y. and Eberhart, R. C. A modified particle swarm optimizer. Proceedings of the IEEE
International Conference on Evolutionary Computation pp. 69-73. IEEE Press, Piscataway, NJ,
1998
[18] M. Setayesh, M. Zhang, and M. Johnston, Improving edge detection using particle swarm
optimisation, in Proceedings of the 25th International Conference on Image and Vision
Computing, New Zealand.IEEE Press, 2010, pp. 18.
[19] D.-S. Lu and C.-C.Chen, Edge detection improvement by ant colony optimization,
Pattern Recognition Letters, vol. 29, pp. 416425, Mar. 2008.
[20] N. Otsu, A threshold selection method from gray level histograms,
43

IEEE Trans. Syst., Man, Cybern., vol. 9, pp. 6266, Jan. 1979.
[21] M. Randall and A. Lewis, A parallel implementation of ant colonyoptimization, Journal
of Parallel and Distributed Computing, vol. 62,pp. 14211432, Sep. 2002.
[22] H. Liu, E. Howely, and J. Duggan, Particle swarm optimization with gradually increasing
directed neighbourhoods, in Proceedingsof the 13th Annual Conference on Genetic and
Evolutionary Computation.New York, NY, USA: ACM, 2011, pp. 2936.

44

You might also like