Nothing Special   »   [go: up one dir, main page]

Project Description: 1. Edge Detection - Canny Edge Detector

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Project Description:

Eye Detection has many Applications; it can be used for Face Tracking, Recognition,
Personal Identication ,

The Main Goal was to find An Easy Way To detect Eyes In Images , Using the Following
Simple Methods:
1. Edge Detection
2. Hough Circle
3. Label Eyes Circles.

Explanation about the Methods I used:

1. Edge Detection – Canny Edge Detector


Edges characterize boundaries and are therefore a problem of fundamental importance in image
processing. Edges in images are areas with strong intensity contrasts – a jump in intensity from
one pixel to the next. Edge detecting an image significantly reduces the amount of data and
filters out useless information, while preserving the important structural properties in an
image.

The Canny edge detection algorithm is known to many as the optimal edge detector. Canny's
intentions were to enhance the many edge detectors already out at the time he started his work.
He was very successful in achieving his goal and his ideas and methods can be found in his
paper, "A Computational Approach to Edge Detection". In his paper, he followed a list of criteria
to improve current methods of edge detection. The first and most obvious is low error rate. It is
important that edges occuring in images should not be missed and that there be NO responses to
non-edges. The second criterion is that the edge points be well localized. In other words, the
distance between the edge pixels as found by the detector and the actual edge is to be at a
minimum. A third criterion is to have only one response to a single edge. This was implemented
because the first 2 were not substantial enough to completely eliminate the possibility of multiple
responses to an edge.

Based on these criteria, the canny edge detector first smoothes the image to eliminate and noise.
It then finds the image gradient to highlight regions with high spatial derivatives. The algorithm
then tracks along these regions and suppresses any pixel that is not at the maximum
(nonmaximum suppression). The gradient array is now further reduced by hysteresis. Hysteresis
is used to track along the remaining pixels that have not been suppressed. Hysteresis uses two
thresholds and if the magnitude is below the first threshold, it is set to zero (made a nonedge). If
the magnitude is above the high threshold, it is made an edge. And if the magnitude is between
the 2 thresholds, then it is set to zero unless there is a path from this pixel to a pixel with a
gradient above T2.

2. The Hough Transform

The Hough transform is a method that, in theory, can be used to find features of any shape in an
image. In practice it is only generally used for finding straight lines or circles. The computational
complexity of the method grows rapidly with more complex shapes.

Assume we have some data points in an image which are perhaps the result of an edge detection
process, or boundary points of a binary blob. We wish to recognise the points that form a straight
line.

Consider a point (xi, yi) in the image. The general equation of a line is

y = ax + b.

There are infinitely many lines that pass through this point, but they all satisfy the condition

yi = axi + b

for varying a and b.

We can rewrite this equation as

b = -xia + yi,

and plot the variation of a and b.

If we divide parameter space into a number of discrete accumulator cells we can collect `votes' in
a b space from each data point in x y space. Peaks in a b space will mark the equations of lines of
co-linear points in x y space.

However, we have a problem with using y = ax + b to represent lines when the line is vertical. In
that case and our parameter space is unbounded (we would need a very large computer
to store our parameter accumulator array!)

An alternative representation of a line is given by


where r is the distance of the line from the origin and theta is the angle between this

perpendicular and the x-axis. Our parameter space is now in and r, where and r
is limited by the size of the image.

As before, peaks in the accumulator array mark the equations of significant lines.

In theory any kind of curve can be detected if you can express it as a function of the form

For example a circle can be represented as

(x - a)2 + (y - b)2 - r2 = 0.

One then has to work in n dimensional parameter space (three dimensional space for a circle).

This model has three parameters: two parameters for the centre of the circle and one parameter
for the radius of the circle. If the gradient angle for the edges is available, then this provides a
constraint that reduces the number of degrees of freedom and hence the required size of the
parameter space. The direction of the vector from the centre of the circle to each edge point is
determined by the gradient angle, leaving the value of the radius as the only unknown parameter.

Thus, the parametric equations for a circle in polar coordinates are

x = a + r cos
and
y = b + r sin.
Solving for the parameters of the circle we obtain the equations
a = x - r cos
and
b = y - r sin.
Now given the gradient angle  at an edge point (x,y), we can compute cos and sin. Note that
these quantities may already be available as a by-product of edge detection. We can eliminate the
radius from the pair of equations above to yield
b = a tan- x tan+ y.
Then the Hough Transform algorithm for circle fitting can be described as follows.

Circle Fitting Algorithm


1. Quantise the parameter space for the parameters a and b.
2. Zero the accumulator array M(a,b).
3. Compute the gradient magnitude G(x,y) and angle (x,y).
4. For each edge point in G(x,y), increment all points in the accumulator array
M(a,b) along the line

b = a tan- x tan+ y.

5. Local maxima in the accumulator array correspond to centres of circles in the


image.

3. Label Eyes Circles.


This Labeling System is designed for specific Portrait images, it work best with a plain
background.
This Method is trying To label The eyes Using a Simple Parameters and Correlations
between the Circles ,It Try To find The best Match , Two Circles That Suits The Eyes .
I used the methods to give points to circles and to filter circles.
I'll explain the methods and the idea behind each Method:

1. The Slope between the Circles.

Because I'm using a portrait images I'm Assuming the Head (and Though the eyes) are
having a slope of less than 45 degrees. I check For Each Circle If he got a Friend Circle with
that slope , if no I'm filtering him.

Lower Slope will Credit the Circles in More Points.

2. The Distance Between Two Circles.

I check That Distance is not Two Close Or not Too Far in Each 2 Circles, if I found a
isolated circle that have friend too far ( width /2 ) , because I'm assuming all the Face Is
inside The image , I'll Filter him, Good distance will give points to the Circles.

3. Number of Circles in the area of the Circle .

I notice in my testing with the hough circle that the area of the eyes gives a lot of circles in
the same place or very close, So I give Points To circles that are congruent Depending on the
number of circles.

4. The Radius compatibility Between the Circles

The Last Method is checking the Circle Radius ,if The Radius size is closer or even
compatible You get more points . the reason is obvious the eyes are in the same size and
probably the circles of the eyes are pretty much the same size.
The Code :
Since I used the Java Programming language I had a lot of work, because as you know it's
much easier to do it on matlab.

I build An User Friendly Interface ,That allow you to load, and save image results, and also
in the options bar u can see all the 3 stages I talked about earlier in the project description,
Edge detection , hough circle and label eyes circles.

So it's very simple.

Here is a screenshot:

The Classes are divided to :

EyeDetection.java – Just The main.

Eye_d_gui.java – the Gui Of the Program .

Edge_detector.java – that I took the code from the internet ,The canny Edge Detector.

Hough_Circle.java – written by me ,make the hough circle transform and the label eye .

ImageFilter.java – filter the load and save images.


Picture.java – an Enhancement features To Image class like grayscale.

Results:
I have tested 20 Images that attached to the Project file.
Note : The Program is not complete ,it need a hard work and more Time To make it work
realy good , but I think it is in the right direction.

Face1.jpg , Resulotion : 235x180

Bad result , Reason : Hough Circle doesn't detect eyes circles.

Face2.jpg , Resulotion : 235x180

Bad result , Reason : Hough Circle doesn't detect eyes circles.

Face3.jpg , Resulotion : 147x213

Bad result , Reason : Hough Circle doesn't detect eyes circles.

Face4.jpg , Resulotion : 200x178

Bad result , Reason : Hough Circle doesn't detect eyes circles.

Face5.jpg , Resulotion : 246x243

Bad result , Reason : Hough Circle doesn't detect eyes circles

Face6.jpg , Resulotion : 175x231

Bad result , Reason : Label eyes Circles doesn't detect eyes.

Face7.jpg , Resulotion : 198x252

Bad result , Reason : Label eyes Circles doesn't detect eyes

Face8.jpg , Resulotion : 194x201


Quite good result , Reason : Hough Circle detect eyes , but not so good.

Face9.jpg , Resulotion : 260x284

Bad result , Reason : Hough Circle doesn't detect eyes.

Face10.jpg , Resulotion : 206x264

Good result .

Face11.jpg , Resulotion : 163x221

Good result .

Face12.jpg , Resulotion : 263x294

Bad result , Reason : Hough Circle doesn't detect eyes.

Face13.jpg , Resulotion : 198x216

Good result .

Face14.jpg , Resulotion : 187x209

Good result .

Face15.jpg , Resulotion : 263x342

Bad result , Reason : Hough Circle doesn't detect eyes.

Face16.jpg , Resulotion : 161x176

Quite good result , Reason : Hough Circle detect eyes , but not so good.
.
Face17.jpg , Resulotion : 224x274

Quite good , Reason : The Circle are very close to the eyes.

Face18.jpg , Resulotion : 211x225

Bad result , Reason : Hough Circle doesn't detect eyes so good , and the label also don't work
very good.

Face19.jpg , Resulotion : 263x342

Bad result , Reason : Hough Circle doesn't detect eyes.


Face20.jpg , Resulotion : 263x342

Bad result , Reason : Hough Circle doesn't detect eyes.

Conclusions :

From 20 images : 4 gives good results , 13 gives a bad result , and 3 are quite good .
That's mean that approximately the success is 30%.
Therefore The Program is not good enough to detect eyes, and need to be improve :
The Following Methods need to be taken in order to make it work better:
1. using An eye Templates and check the correlation of The pixels to the template.
This could solve the Cases that Label Eyes Circles was unable To detect the eyes.

Template example:

2 . As you all know there is an effect of red eyes in images , this effect can be used in order
to improve the detection of the circles of the eyes in images using the hough circle method .
But this improvement have to be Hardware improvement.

You might also like