Evolving Edge detection Final project by Rubshtein Andrey (303468490)

35
Evolving Edge detection Evolving Edge detection Final project by Final project by Rubshtein Andrey (303468490) Rubshtein Andrey (303468490)

Transcript of Evolving Edge detection Final project by Rubshtein Andrey (303468490)

Evolving Edge detectionEvolving Edge detection

Final project by Final project by

Rubshtein Andrey (303468490)Rubshtein Andrey (303468490)

IntroductionIntroduction

Is it possible for a living creature to evolve Is it possible for a living creature to evolve vision?vision?

Is it possible for a living creature to evolve at Is it possible for a living creature to evolve at least an edge detector?least an edge detector?

A bit about Genetic AlgorithmsA bit about Genetic Algorithms

Simulates an Simulates an environment in which environment in which there are “living there are “living creatures”creatures”

They are called They are called Genomes.Genomes.

Each Genome has Each Genome has some parameterssome parameters

There exists a global There exists a global fitness function which fitness function which tells how successful a tells how successful a Genome is.Genome is.

There exists a There exists a Population of some Population of some GenomesGenomes

There are many There are many GenerationsGenerations

More about Genetic AlgorithmsMore about Genetic Algorithms

Each generation consist of 3 stages:Each generation consist of 3 stages:Selection – The more fit are chosen.Selection – The more fit are chosen.Crossover – Some genomes are crossed, Crossover – Some genomes are crossed,

while inheriting their parents properties.while inheriting their parents properties.Mutation – Some Genomes are randomly Mutation – Some Genomes are randomly

changed, with a slight variation.changed, with a slight variation.We hope that after some generations, we We hope that after some generations, we

get more fitted Genomes.get more fitted Genomes.

The GoalThe Goal

Assumptions:Assumptions:Each living creature can perform a Each living creature can perform a

convolution, with a constant mask, which convolution, with a constant mask, which is coded into his Genome.is coded into his Genome.

The creatures that detect edges better, The creatures that detect edges better, survive better.survive better.

There exists an ideal edge detector.There exists an ideal edge detector.

More about the GoalsMore about the Goals

Is it possible to develop, by means of Is it possible to develop, by means of natural selection, a good edge detector?natural selection, a good edge detector?

Is it possible to achieve that using only Is it possible to achieve that using only convolution type edge detectors, while the convolution type edge detectors, while the perfect edge picture is not?perfect edge picture is not?

Ideal edge detectorIdeal edge detector

Canny’s edge detector was Canny’s edge detector was chosen as an ideal edge chosen as an ideal edge detector.detector.

Why Canny? Has an Why Canny? Has an impressive results, and uses impressive results, and uses much more advanced much more advanced techniques than convolutionstechniques than convolutions

So it’s challenging to try to So it’s challenging to try to evolve to it.evolve to it.

About the simulationAbout the simulation

The genome structureThe genome structure A 3x3 MatrixA 3x3 Matrix Each of the cells is in Each of the cells is in

the range [-255,255]the range [-255,255] A threshold value in A threshold value in

the range [0,255]the range [0,255]

-1-1 225225 -5-5

-230-230 -100-100 00

5050 6767 -1-1

Threshold = 50Threshold = 50

FitnessFitness

About similarity MeasureAbout similarity Measure

Both images are binary after thresholdBoth images are binary after threshold The measure is :The measure is :

Similarity[x,y]=Sum[x OR y] / Sum[ x AND y]Similarity[x,y]=Sum[x OR y] / Sum[ x AND y]

Why this measure is good?Why this measure is good?

It is symmetric : Sim[x,y]=Sim[y,x]It is symmetric : Sim[x,y]=Sim[y,x] It has the range of [0,1]It has the range of [0,1] It is simple to implementIt is simple to implement It is “reflexive” – Sim[x,x]=1It is “reflexive” – Sim[x,x]=1 It doesn’t give extra points for pictures It doesn’t give extra points for pictures

which have a common non-edge (0 ) pixel.which have a common non-edge (0 ) pixel. It reduces points for false positive edges, It reduces points for false positive edges,

and false negative edges.and false negative edges.

Why this measure isn’t goodWhy this measure isn’t good

A small movement in the picture results in a low A small movement in the picture results in a low similarity ratesimilarity rate

The measure takes into account single pixels, The measure takes into account single pixels, which isn’t the goal in edge detectionwhich isn’t the goal in edge detection

A better measure would have been perhaps one A better measure would have been perhaps one that takes into account the shape of the edges that takes into account the shape of the edges (Geshtalt)(Geshtalt)

The Test SubjectsThe Test Subjects

The numbers (The simplest)The numbers (The simplest)

The Guitar (Medium)The Guitar (Medium)

The dog (Hardest)The dog (Hardest)

The resultsThe results

After a few generations, the Genomes After a few generations, the Genomes learn to somehow detect edges. learn to somehow detect edges.

Yet even in the easy pictures, the Yet even in the easy pictures, the evolution fails to get a good ratio of evolution fails to get a good ratio of similarity ( Usually less than 0.3)similarity ( Usually less than 0.3)

But, we see an impressive results, when But, we see an impressive results, when looking with our eyes.looking with our eyes.

Evolution of numbers (The ideal)Evolution of numbers (The ideal)

Generation 5Generation 5Sim=0.11Sim=0.11

Generation 10Generation 10Sim=0.13Sim=0.13

Generation 20Generation 20Sim=0.23Sim=0.23

Generation 30Generation 30Sim=0.25Sim=0.25

Generation 40Generation 40Sim=0.27Sim=0.27

Generation 80Generation 80Sim=0.28Sim=0.28

Generation 100Generation 100Sim=0.29Sim=0.29

Generation 110Generation 110Sim=0.32Sim=0.32

Results for easy picturesResults for easy pictures

It is amazing that It is amazing that we’ve managed to we’ve managed to evolve something evolve something close to the idealclose to the ideal

Then again, the Then again, the similarity rate is lowsimilarity rate is low

Evolution of Dog (The ideal)Evolution of Dog (The ideal)

Generation 10 Sim=0.05Generation 10 Sim=0.05

Generation 100 Sim=0.10Generation 100 Sim=0.10

Generation 300 Sim=0.16Generation 300 Sim=0.16

Results for hard picturesResults for hard pictures

The evolution finds The evolution finds some solution, yet it some solution, yet it isn’t as good as isn’t as good as wantedwanted

The similarity rate is The similarity rate is very lowvery low

ConclusionsConclusions

It is easy to evolve some kind of edge It is easy to evolve some kind of edge detectordetector

It is hard to evolve a good edge detector, It is hard to evolve a good edge detector, in terms of similarityin terms of similarity

It seems that an edge detector evolved It seems that an edge detector evolved from one picture isn’t good for another from one picture isn’t good for another picture.picture.

Why the results are bad:Why the results are bad:

Canny is a very sophisticated edge Canny is a very sophisticated edge detector. Perhaps it’s impossible to imitate detector. Perhaps it’s impossible to imitate it using only convolutions?it using only convolutions?

Perhaps the similarity measure isn’t Perhaps the similarity measure isn’t suitable for this problem. Perhaps using suitable for this problem. Perhaps using another similarity it’s possible to get better another similarity it’s possible to get better results.results.

The endThe end

Thank you for listening :-)Thank you for listening :-)