institutionen fÖr systemteknik/file/e0005e... · •dip section 10.2.6 •dip 3ed page 717 ”to...

45
INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET 2012-09-17 E0005E, Lecture 3 1

Upload: others

Post on 12-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

INSTITUTIONEN FÖR SYSTEMTEKNIK

LULEÅ TEKNISKA UNIVERSITET

2012-09-17 E0005E, Lecture 3 1

Page 2: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Lecture 3 Preliminary Notes

• Attendance – Make sure you are registered

• Course Guide – Any questions?

• MATLAB Tips – Anything missing that you need?

• Plagarism - ”copying another persons work and presenting it as your own”

- http://www.youtube.com/watch?v=Mwbw9KF-ACY&feature=related

- Ephorus compares your submission against millions of documents from the internet and against past submissions in this course

• More on Thresholding, DIP Textbook 10.3

2012-09-17 E0005E, Lecture 3 2

Page 3: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

INSTITUTIONEN FÖR SYSTEMTEKNIK

LULEÅ TEKNISKA UNIVERSITET

2012-09-17 E0005E, Lecture 3 3

Edges, Lines, Points Neighbourhood operations (spatial filters)

Matthew Thurley

Industrial Image Processing

Page 4: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Last Lecture

• Histogram Equalisation (you used this in Lab 1)

• Geometric Transformations

• Point Operations

• Neighbourhood Operations

• Noise Filtering

- Linear filtering

- Median Filtering

- Edge Preserving Filtering

2012-09-17 E0005E, Lecture 3 4

Note to the lecturer -

review how to do this

Page 5: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

This Lecture

• Edge Detection

- Textbook: DIP 10.2 Point, Line & Edge Detection, 3.4, 3.5, 3.6

- First Order Derivative Operators (Sobel)

- Second Order (Laplacian)

- First Order Diagonal (Compass) Operators

- Laplace of Gaussian Operator

• Image Sharpening

• Scale Space : Pyramid Scheme

• Binary Edges 2012-09-17 E0005E, Lecture 3 5

Page 6: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

2012-09-17 6

Edges

• Edges are one of the most important features in an image as they are strong indicators of object boundaries.

• Sharp edges help us observe features and objects

E0005E, Lecture 3

Image with blurred edges Image with sharp edges

Page 7: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Edges

• Edge shape and position can be seen as an effective representation of an object.

• One could extract a polygonal representation of the boudary of both objects.

• In practise this requires a very controlled environment like the one shown with few objects and good contrast between the objects and the background.

2012-09-17 E0005E, Lecture 3 7

Page 8: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

2012-09-17 E0005E, Lecture 3 8

What sort of features are of interest?

Different types of filters will be suited to different kinds of feaures

Page 9: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Gradient neighbourhood operation

• Numerical difference (first order derivative)

• Centre difference

• First difference approximation

in an image

• Differentiation as a sliding window operation

2012-09-17 E0005E, Lecture 3 9

1 -1

Page 10: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Gradient

• For computational reasons we may approximate this by |Di| + |Dj|

• In both cases the magnitude of the gradient is no longer restricted to the interval [0..255]

• Histogram of the gradient image will look somewhat like a negative exponential curve.

2012-09-17 E0005E, Lecture 3 10

Page 11: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Gradient

• Roberts cross gradient operators

• Sobel Operators using centre difference gradient

- The two simple differentiators Di and Dj are expanded to two square 3x3 image operators

• The components sum to 0 which is a property of a gradient operator. This ensures that in an area of constant intensity the result of the operator will be 0

2012-09-17 E0005E, Lecture 3 11

Textbook: DIP 10.2.1-10.2.5, 3.6.1, 3.6.4 Gradient

Page 12: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Sobel Edge Detector

2012-09-17 E0005E, Lecture 3 12

Page 13: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

2012-09-17 E0005E, Lecture 3 13

Page 14: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

2nd Order Derivative

2012-09-17 E0005E, Lecture 3 14

Textbook: DIP 10.2.1-10.2.5, 3.6.2

Page 15: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

2012-09-17 E0005E, Lecture 3 15

Page 16: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Laplacian Edge Detector

• The laplace will give a double response to an edge often the zero crossings are used to detect the edge

• Histogram of a laplacian edge image will look like a very narrow bell curve centered about 0.

2012-09-17 E0005E, Lecture 3 16

Page 17: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Compare First & Second Order Derivatives

2012-09-17 E0005E, Lecture 3 17

Page 18: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Edge Detection

2012-09-17 E0005E, Lecture 3 18

Page 19: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Edge Detection

2012-09-17 E0005E, Lecture 3 19

Page 20: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Detection of Isolated Points

2012-09-17 E0005E, Lecture 3 20

• This laplacian filter is isotropic – meaning its reponse is independent of direction (in the four directions, vertical, horizontal, two diagonal)

Page 21: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Detection of Lines

• The sobel first order derivative filters, detect step edges and lines

• Second order laplacian filters can be used to detect lines, such as these masks that provide maximum response for one pixel wide lines

2012-09-17 E0005E, Lecture 3 21

Page 22: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Edge Detection Summary

• First order derivatites produce thicker edges

• Second order have a stronger response to fine detail; thin lines, isolated points, noise

• Second order produce a double-edge response

• Second order zero-crossing (transition from positive to negative or vice-versa) can be a good edge location feature

2012-09-17 E0005E, Lecture 3 22

Page 23: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Group Quiz

• Design a filter that detects 1 pixel wide breaks in horizontal lines that are 1 pixel wide. Explain how your filter will work with some examples.

• Start by thinking about what sort of filter finds a 1 pixel wide horizontal line

• In General a spatial filter / neighbourhood operator can be understood by looking for what feature it returns a maximal response (both positive and negative) and when it returns 0

2012-09-17 E0005E, Lecture 3 23

Page 24: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Image Sharpening using the Laplacian

2012-09-17 E0005E, Lecture 3 24

Blurred Image Laplacian Edges (postive values shown only) 0)

Blurred + Laplacian Blurred + Laplacian

Speaking Notes: Adding the blurred image to the laplacian restored overall intensity variations, increasing contrast at locations of intensity dicontinuities (edges), which are locations of high visibility for humans.

Page 25: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Image Enhancement Example

2012-09-17 E0005E, Lecture 3 25

Textbook: DIP 3.6.7

Page 26: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Diagonal Edge Operators

Compass Operators

• A compass operator set is one that detects vertical, horizontal and diagonal edges.

• The Sobel edge detection masks are shown on the left.

2012-09-17 E0005E, Lecture 3 26

Textbook: DIP page 708-710

Page 27: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

2012-09-17 E0005E, Lecture 3 27

Derivatives and Noise

Page 28: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Edges and Noise

• Gradient based edge detections are very susceptable to noise

2012-09-17 E0005E, Lecture 3 28

Page 29: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Linear White Noise Filtering (Smoothing)

2012-09-17 E0005E, Lecture 3 29

Negative side effect in that

prominent edges become

blurred

Page 30: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

LoG Edge Detector

2012-09-17 E0005E, Lecture 3 30

More on Gaussian filters

in lecture 6.

The Gaussian filter

performs smoothing with

a mask where the values

in the mask create a 3D

bell curve, and the size of

the mask is defined by

the standard deviation.

G

Page 31: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

LoG Edge Detector

2012-09-17 E0005E, Lecture 3 31

Textbook DIP pg. 715

Page 32: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

LoG Edge Detector

2012-09-17 E0005E, Lecture 3 32

The key thing to remember is that edge detectors are susceptable to noise, and if necessary

how you will smooth the data without overly degrading the desired edge information.

Page 33: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

LoG Edge Detector

• DIP section 10.2.6

• DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D gaussian surface lies between +- 3 standard deviations. … the size of an n x n LoG filter should be such that n is the smallest odd integer greater than or equal to 6 standard deviations. Choosing a filter mask smaller than this will tend to ’truncate’ the LoG function..”

2012-09-17 E0005E, Lecture 3 33

Page 34: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

More Info About Spatial Filters

• We have seen many neighbourhood operations (spatial filters)

• If you want to know what a filter does, look for what will give it maximum and minumum response, and look how it combines information

2012-09-17 E0005E, Lecture 3 34

Page 35: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Quiz

• Consider two black and white images of the same size with the same number of black pixels, and white pixels in both images. The left side of the first image is white, and the right side black, whereas the second image is layed out like a chess board in a 8 by 8 grid of black and white squares.

• Suppose that each image is blurred with a 3x3 averaging mask

a) Would the histograms of the blurred images be equal? Explain. If your answer is no, sketch the two histograms

2012-09-17 E0005E, Lecture 3 35

Page 36: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Multiresolution Imaging

• Here we consider down-sampling an image to get less spatial resolution but still include the prominent edges.

• Down-sampling an image in a simple way, eg. discarding every second row and column , can create a more pixelated (aliased) image with more abrupt changes in grey level which can result in erroneous ”edges”.

• Consider this image and its downsampled version from http://en.wikipedia.org/wiki/Shannon_sampling_theorem

2012-09-17 E0005E, Lecture 3 36

Images can exhibit aliasing if the sampling resolution is inadequate. Consider this digital photograph of a wall with high frequency variation in color (color changes often and in a repetitive pattern). Aliasing can occur when it is down sampled. The aliasing appears as a moiré pattern. We can overcome this by blurring (smoothing such as an averaging filter) the image before sampling it.

Page 37: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Multiresolution Imaging

• Sub-sampling the image will create a more pixelated (aliased) image with more abrupt changes in grey level

2012-09-17 E0005E, Lecture 3 37

Original Aliasing with Pre-Smoothing

100x100 25x25 25x25

Page 38: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Multiresolution Imaging

2012-09-17 E0005E, Lecture 3 38

Smoothing & Downsampling

Textbook DIP Ch 7.1.1 Image Pyramids

Upsampling & Interpolating

Lowest resolution

Original (highest) resolution

Page 39: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Multiresolution Imaging

• Development Phase 3: 1. Create a pyramid of down-sampled images of a door using average filtering as the

smoothing filter.

a) Smoothing / Average filter (Gaussian filter is ideal)

b) Down-sample

2. Perform edge detection on the lowest resolution image & threshold to get a binary edge image

3. Successively process higher resolution images in the pyramid, performing edge detection on only the pixels in the higher resolution versions that corresponded to binary edges in the lower resolution images

a) Identify the pixels in the next higher resolution image corresponding to the binary edges in the lower resolution image

b) Perform edge detection on only these pixels

c) Threshold

d) Repeat for the next higher resolution image

2012-09-17 E0005E, Lecture 3 39

Group Work: Pyramid algorithm. Assume a 32x32 image

More detail in Development Phase 3

Page 40: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Binary Edges

2012-09-17 E0005E, Lecture 3 40

Page 41: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Thinning Binary Edges (lecture 4)

2012-09-17 E0005E, Lecture 3 41

Page 42: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Line Detection in Binary Edges (lecture 5)

2012-09-17 E0005E, Lecture 3 42

Page 43: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Summing Up

• Consider the following three questions;

- What do I need to work on?

- What have I learnt today?

- What was the main point left unanswered today?

• Write your answers in the provided journal. Write the lecture number 2 on top of the page. Write your name and student number on the front of the book

2012-09-17 E0005E Industrial Image Analysis 43

Page 44: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

End of Lecture

2012-09-17 E0005E, Lecture 3 44

Page 45: INSTITUTIONEN FÖR SYSTEMTEKNIK/file/E0005E... · •DIP section 10.2.6 •DIP 3ed page 717 ”To specify the size of a Gaussian filter, recall that 99.7% of the volume under a 2D

Multiresolution Imaging

• Down-sampling an image in a simple way, eg. discarding every second row and column , can create a more pixelated (aliased) image with more abrupt changes in grey level which can result in erroneous ”edges”.

• We can overcome this by averaging/smoothing as we down-sample.

• The fundamental principle at work here is described by the Nyquist-Shannon sampling theorem [wikipedia, 1], which we can rephrase for images as; if an image contains frequencies (repeating variations in intensity), one every 2C pixels, then it can be completely represented by a series of intensity values every C pixels.

• For an image and a value of C=2, we would need to remove frequencies (repeating changes in color) that happen every 4 pixels or less.

2012-09-17 E0005E, Lecture 3 45

[Wikipedia, 1] http://en.wikipedia.org/wiki/Shannon_sampling_theorem

This slide is too much information