september 10, 2012introduction to artificial intelligence lecture 2: perception & action 1...

Post on 25-Dec-2015

216 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

September 10, 2012 Introduction to Artificial Intelligence Lecture 2: Perception & Action

1

Boundary-following RobotRules

1

2

3

4

5

September 10, 2012 Introduction to Artificial Intelligence Lecture 2: Perception & Action

2

Boundary-following Robot (2)Rules

1

2

3

4

5

September 10, 2012 Introduction to Artificial Intelligence Lecture 2: Perception & Action

3

Thanks to Roshanak

September 10, 2012 Introduction to Artificial Intelligence Lecture 2: Perception & Action

4

Linear SeparabilityTo explain linear separability, let us consider the function f:Rn {0, 1} with

i

n

iin wxxxxf

121 if,1),...,,(

otherwise,0

where x1, x2, …, xn represent real numbers.

This will also be useful for understanding the computations of artificial neural networks later in the course.

September 10, 2012 Introduction to Artificial Intelligence Lecture 2: Perception & Action

5

Networks

x1

x2

w1 =?

w2 =? =?

Example: x1w1 + x2w2 >= ?

x1 or x2

x1

1 2 3-3 -2 -1

x2

1

2

3

-3

-2

-10

1

10

11x2

x1

0

1

0 1

x1=0.5, x2=0: 0.5w1 + 0*w2 =

x1=0, x2=0.5: 0*w1 + 0.5w2 =

w1 = w2 = 2

September 10, 2012 Introduction to Artificial Intelligence Lecture 2: Perception & Action

6

Realizing Robot Functions

s2

s30.5

s5s6s7

s4s8

s3s2s1

x1

s5s6s7

s4s8

s3s2s1

x2

s4

s5

1

x1x2

1

-2

-2

s2w2 + s3w3 + s4w4 + s5w5 >= ?

Apply weights and threshold:s2 1 + s3 1 - 2s4 - 2s5 >= 0.5?When s2=1, s3=1, s4=0, s5=0

s2w2 + s3w3 + s4w4 + s5w5=2

When s2=0, s3=1, s4=1, s5=0

s2w2 + s3w3 + s4w4 + s5w5=-1

x

September 10, 2012 Introduction to Artificial Intelligence Lecture 2: Perception & Action

7

Linear SeparabilitySo by varying the weights and the threshold, we can realize any linear separation of the input space into a region that yields output 1, and another region that yields output 0.

As we have seen, a two-dimensional input space can be divided by any straight line.

A three-dimensional input space can be divided by any two-dimensional plane.

In general, an n-dimensional input space can be divided by an (n-1)-dimensional plane or hyperplane.

Of course, for n > 3 this is hard to visualize.

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

8

let’s take a look at…

Computer Vision

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

9

Computer Vision• In grid-space world, sensory inputs are very

simple: Only the state of neighboring cells can be perceived.

• In the real world, the visual input is highly complex, noisy, and often ambiguous (3D 2D projection).

• While humans can seemingly effortless extract all relevant information from within their visual field, this is an extremely difficult task for machines.

• For example, one major problem for computers is perceptual grouping, that is, determining which parts of an image belong to the same object.

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

10

Computer Vision• In the following lectures, we will look at some

“classical” approaches to computer vision.• These approaches are not intended to replicate

vision in humans or animals.• Later in the course, we will also study artificial

neural networks for vision problems, which are supposed (to some extent) to imitate the biological example.

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

11

Computer Vision

A simple two-stage model of computer vision:

Image processing

Sceneanalysis

Bitmap image

Scene description

feedback (tuning)

Prepare image for scene analysis

Build an iconic model of the world

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

12

Image Processing• Image is represented as an mn array, I(x, y) of

numbers (image intensity array).• Each number indicates the light intensity at one of

the pixels in the image.• Many basic image processing techniques are

based on convolution.• In a convolution, a convolution filter is applied to

every pixel to create a filtered image I*(x, y):

u v

yvxuWvuIyxWyxIyxI ),(),(),(*),(),(*

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

13

x

y

Image ProcessingExample: Averaging filter:

u v

yvxuWvuIyxWyxIyxI ),(),(),(*),(),(*

0 0 0 0 0

0 1/9 1/9 1/9 0

0 1/9 1/9 1/9 0

0 1/9 1/9 1/9 0

0 0 0 0 0

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

14

Image Processing

Grayscale Image:

1 6 3 2 9

2 11 3 10 0

5 10 6 9 7

3 1 0 2 8

4 4 2 9 10

1/9 1/9 1/9

1/9 1/9 1/9

1/9 1/9 1/9

Averaging Filter:

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

15

Image Processing

Original Image:

1 6 3 2 9

2 11 3 10 0

5 10 6 9 7

3 1 0 2 8

4 4 2 9 10

Filtered Image:

0 0 0 0 0

0 0

0 0

0 0

0 0 0 0 0

1/9 1/9 1/9

1/9 1/9 1/9

1/9 1/9 1/9

value = 11/9 + 61/9 + 31/9 + 21/9 + 111/9 + 31/9 + 51/9 + 101/9 + 61/9 = 47/9 = 5.222

5

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

16

Image Processing

Original Image:

1 6 3 2 9

2 11 3 10 0

5 10 6 9 7

3 1 0 2 8

4 4 2 9 10

Filtered Image:

0 0 0 0 0

0 0

0 0

0 0

0 0 0 0 0

1/9 1/9 1/9

1/9 1/9 1/9

1/9 1/9 1/9

value = 61/9 + 31/9 + 21/9 + 111/9 + 31/9 + 101/9 + 101/9 + 61/9 + 91/9 = 60/9 = 6.667

5 7

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

17

Image Processing

Original Image:

1 6 3 2 9

2 11 3 10 0

5 10 6 9 7

3 1 0 2 8

4 4 2 9 10

Filtered Image:

0 0 0 0 0

0 0

0 0

0 0

0 0 0 0 0

5 7 5

5

5

5 6

64

Now you can see the averaging (smoothing) effect of the 33 filter that we applied.

Questions

How about the boundaries?

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

19

Image ProcessingMore common: Gaussian Filters

2

22

222

1),(),(

yx

eyxGyxW

14741

41626164

72641267

41626164

14741

Discrete version: 1/273

• implement decreasing influence by more distant pixels

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

20

Image Processing

original 33 99 1515

Effect of Gaussian smoothing:

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

21

Different Types of Filters

• Smoothing can reduce noise in the image.• This can be useful, for example, if you want to find

regions of similar color or texture in an image.• However, there are different types of noise.• For so-called “salt-and-pepper” noise, for example,

a median filter can be more effective.

http://www.mathworks.co.uk/help/images/ref/medfilt2.html

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

22

Median Filter• Use, for example, a 33 filter and move it across

the image like we did before.• For each position, compute the median of the

brightness values of the nine pixels in question.– To compute the median, sort the nine values in

ascending order.– The value in the center of the list (the fifth

value) is the median.• Use the median as the new value for the center

pixel.

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

23

Median Filter

• Is Median Filter a convolution filter?• If not, what is the difference?

– Median vs. Gaussian and Average Filters

• Size of median filter?• Advantage of the median filter: Capable of

eliminating outliers such as the extreme brightness values in salt-and-pepper noise, and preserve edges (contours).

• Disadvantage: The median filter may change the contours of objects in the image. (distorted)

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

24

Median Filter

original image 33 median 77 median

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

25

Different Types of FiltersHow can an algorithm extract relevant information from an image that enables the algorithm to recognize objects?• The most important information for the interpretation of an image (for both technical and biological systems) is the contour of objects.• Contours are indicated by abrupt changes in brightness.• We can use edge detection filters to extract contour information from an image.

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

26

Edge Detection Filters• Let us take a look at the

one-dimensional case:• A change in brightness:

• Its first derivative:

• Its second derivative:

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

27

Laplacian FiltersIdea:• Smooth the image,• compute the second derivative of the (2D) image,• Find the pixels where the brightness function “crosses” 0 and mark them.

We can actually devise convolution filters that carry out the smoothing and the computation of the second derivative.

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

28

Laplacian Filters

Continuous variant:

Discrete variants(applied after smoothing):

0 1 0

1 -4 1

0 1 0

1 1 1

1 -8 1

1 1 1

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

29

Laplacian Filters

Let us apply a Laplacian filter to the following image:

September 12, 2012 Introduction to Artificial Intelligence Lecture 3: Computer Vision I

30

Laplacian Filters

55 Laplacian

zero detection zero detection zero detection

77 Laplacian33 Laplacian

top related