dtu informatics introduction to medical image analysis rasmus r. paulsen dtu informatics...

50
DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics [email protected] http://www.imm.dtu.dk/courses/02511

Upload: keenan-paddy

Post on 14-Dec-2015

225 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

Introduction to Medical Image AnalysisRasmus R. PaulsenDTU Informatics

[email protected]

http://www.imm.dtu.dk/courses/02511

Page 2: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging2 DTU Informatics, Technical University of Denmark

Lecture 11 – Hough Transformation and Path Tracing

9.00 Lecture

Exercises

12.00 – 13.00 Lunch break

13.00- Exercises

Page 3: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging3 DTU Informatics, Technical University of Denmark

What can you do after today? Use the Hough transform for line detection Describe the slope-intercept, the general form and the normalised form

of lines Describe the connection between lines and the Hough space Use edge detection to enhance images for use with the Hough

transform Use dynamic programming to trace paths in images Describe how an image can be used as a graph Describe the fundamental properties of a cost image Compute the cost of path Compute an accumulator image for path tracing Compute a backtracing image for path tracing Describe how circular structures can be located using path tracing

Page 4: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging4 DTU Informatics, Technical University of Denmark

Line Detection Find the lines in an image

Page 5: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging5 DTU Informatics, Technical University of Denmark

What is a line?

It can be the entire object– Large scale

Can also be the border between an object and the background– Small scale

Normally only locally defined

Page 6: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging6 DTU Informatics, Technical University of Denmark

Enhancing the lines We want to locate the

borders– Enhance them

Filtering Edge detection

Original Prewitt Edge

Page 7: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging7 DTU Informatics, Technical University of Denmark

What is a line II? Result of the edge filter is a selection of

white pixels Some of them define a line

– Not a perfect straight line– “Linelike”

How do we find the collection of points that define a line?

Page 8: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging8 DTU Informatics, Technical University of Denmark

Mathematical line definition The classical definition (slope-intercept form)

-5 0 5-5

0

5

x axis

y ax

is

y=0.5 * x + 1

y = ax + bSlope Intercept

Can not represent lines that are vertical

Page 9: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging9 DTU Informatics, Technical University of Denmark

-5 0 5-5

0

5

x axis

y ax

is

Ax + By = C

Mathematical line definition General definition

With

Ax + By = C

A2 + B2 = 1

n = (A;B)

Line normal

Page 10: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging10 DTU Informatics, Technical University of Denmark

Mathematical line definition Normal parameterisation

where– is the distance from the

origin– is the angle

xcosµ+ ysinµ= ½

-5 0 5-5

0

5

x axis

y ax

is

Ax + Bx = C

µ½

µ

½

(cosµ)2 + (sinµ)2 = 1

A2 + B2 = 1

n = (cosµ;sinµ)

Page 11: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging11 DTU Informatics, Technical University of Denmark

Mathematical line definition Normal parameterisation

Therefore a line can be defined by two values– –

A line can therefore also be seen as a point in a ( , )-space

xcosµ+ ysinµ= ½

-5 0 5-5

0

5

x axis

y ax

is

Ax + Bx = C

µ½

µ½

½µ

Page 12: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging12 DTU Informatics, Technical University of Denmark

Something about angles

µ2 [¡ 90o;90o[ In Matlab and in this presentation

µ2 [0o;180o[ In the course notes

Page 13: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging13 DTU Informatics, Technical University of Denmark

Hough Space

-5 0 5-5

0

5

x axis

y ax

is

= x cos + y sin

-50 0 50-5

0

5

¡ 90o < µ< 90o

µ½

µ= ¡ 80;½= 1

Page 14: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging14 DTU Informatics, Technical University of Denmark

More about angles

-5 0 5-5

0

5

x axis

y ax

is

= x cos + y sin µ= ¡ 80o

µ½

Why?

µ= 100o

¡ 90o < µ< 90o

but Matlab only allows

look at the mirror-projection of the normal

µ= ¡ 80

½is used to determine if it is the “upper” or “lower line”

Page 15: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging15 DTU Informatics, Technical University of Denmark

How do we use the Hough space?

-50 0 50-5

0

5

?

Page 16: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging16 DTU Informatics, Technical University of Denmark

How do we use the Hough space? What if every little “line-segment” was plotted in the Hough-

space?

-50 0 50-5

0

5

Page 17: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging17 DTU Informatics, Technical University of Denmark

Filled Hough-Space All “line segments” in the image examined A “global line” can now be found as a cluster of points

-50 0 50-5

0

5

In practice it is difficult to identify clusters

Page 18: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging18 DTU Informatics, Technical University of Denmark

Hough transform in practise Hough Space is represented as an image It is quantisized – made into finite boxes

-50 0 50-5

0

5

Pixel

A line segment here

Belongs to this pixel

Page 19: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging19 DTU Informatics, Technical University of Denmark

Hough transform as a voting scheme The pixels in the Hough space are used to vote for lines. Each line segment votes by putting one vote in a pixel The pixels are also called accumulator cells

-50 0 50-5

0

5

Page 20: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging20 DTU Informatics, Technical University of Denmark

Hough transform per pixel In practise we do not use line segments Each pixel in the input image votes for all potential lines going

through it.

-50 0 50-5

0

5

Page 21: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging21 DTU Informatics, Technical University of Denmark

Hough transform per pixel

-50 0 50-5

0

5

xcosµ+ ysinµ= ½Go through all and calculate µ ½ (x, y) are fixed

Sinusoid!

Page 22: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging22 DTU Informatics, Technical University of Denmark

Real Hough Transform

Hough space

-50 0 50

-60

-40

-20

0

20

40

60

Page 23: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging23 DTU Informatics, Technical University of Denmark

Real Hough Transform II

Hough space

-50 0 50

-60

-40

-20

0

20

40

60

Page 24: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging24 DTU Informatics, Technical University of Denmark

Real Hough Transform and lines

Hough space

-50 0 50

-60

-40

-20

0

20

40

60

Spot the line!

A maximum where Hough pixel has value 3

Page 25: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging25 DTU Informatics, Technical University of Denmark

Finding the lines in Hough space The lines are found in Hough space where most

pixels have voted for there being a line Can be found by searching for maxima in Hough

Space Hough transform

-50 0 50

-400

-200

0

200

400

Page 26: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging26 DTU Informatics, Technical University of Denmark

The practical guide to the Hough Transform Start with an input image

Page 27: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging27 DTU Informatics, Technical University of Denmark

The practical guide to the Hough Transform Detect edges and create a

binary image

Page 28: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging28 DTU Informatics, Technical University of Denmark

The practical guide to the Hough Transform Compute Hough transform

and locate the maxima

-50 0 50

-300

-200

-100

0

100

200

300

Page 29: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging29 DTU Informatics, Technical University of Denmark

The practical guide to the Hough Transform Draw the lines corresponding

to the found maxima Here the cyan line is the

longest

Page 30: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging30 DTU Informatics, Technical University of Denmark

Exam question 09.24

Page 31: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging31 DTU Informatics, Technical University of Denmark

Path Tracing The diameter as

function of the distance to the optic cup tells something about the patients health

We need to find the arteries and veins

Path tracing is one solution

Fundus imageArteries and veins

Page 32: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging32 DTU Informatics, Technical University of Denmark

Path tracing A path is defined as a

curve in an image defined as something that is different from the background’

In this case it is a dark line

Pre-processing can for example turn edges into dark lines.

Page 33: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging33 DTU Informatics, Technical University of Denmark

Path tracing A GPS device uses path

tracing Based on graph

algorithms– A city is a node– A road is an edge. The

weight of the edge is the fuel cost

How do we come from Copenhagen to Aalborg using the least fuel?

Dijkstra’s algorithm

Copenhagen

Aalborg

2.3 l

2.1 l

1.3 l

Page 34: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging34 DTU Informatics, Technical University of Denmark

Images as graphs Each pixel is a node Pixel neighbours are

connected by edges The edge cost is the

pixel value Directed graph Imagine a car driving on

the image Called a cost image

C(2;3) = 14

Page 35: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging35 DTU Informatics, Technical University of Denmark

Simplified problem Track dark lines Path going from top to

bottom No sharp turns – smooth Problem:

– from the top to the bottom

– Sum of pixel values should be minimal

Page 36: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging36 DTU Informatics, Technical University of Denmark

Simplified problem Pixel value at (r,c)

equals the cost

The path P consist of pixels

The sum of pixel values in the path

C(r;c)

Ctot =X

(r;c)2P

C(r;c)

Page 37: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging37 DTU Informatics, Technical University of Denmark

Path cost A path is defined as (r,c)

coordinates What is ?

How do we compute the path P that has minimum

Test all possible paths?P = [(1,3), (2,3), (3, 2), (4,3), (5,4)]

Ctot

Ctot

Page 38: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging38 DTU Informatics, Technical University of Denmark

Path restriction Path is only allowed to

– Go down– Move one pixel left or

right Longer jumps not

allowed

Page 39: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging39 DTU Informatics, Technical University of Denmark

Accumulator image Keeps track of the

accumulated cost for possible paths

Optimal path ending here has cost 296

Page 40: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging40 DTU Informatics, Technical University of Denmark

Computing the accumulator image

Step 1: Copy first row of input image

Page 41: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging41 DTU Informatics, Technical University of Denmark

Computing the accumulator image

Step 2: Fill second row

A (r;c) = I (r;c) + min(A (r ¡ 1;c¡ 1);A (r ¡ 1;c);A (r ¡ 1;c+ 1))

Page 42: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging42 DTU Informatics, Technical University of Denmark

Computing the accumulator image

Step 3: Fill all rows by looking at the previous row

A (r;c) = I (r;c) + min(A (r ¡ 1;c¡ 1);A (r ¡ 1;c);A (r ¡ 1;c+ 1))

Page 43: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging43 DTU Informatics, Technical University of Denmark

Using the accumulator image

Step 4: The end of the optimal path can now be found

Page 44: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging44 DTU Informatics, Technical University of Denmark

The backtracing image

• Keeps track of where the path came from

• Each pixel stores the column number

Page 45: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging45 DTU Informatics, Technical University of Denmark

Using the backtracing image

Step 5: Trace the path in the backtracing image

Page 46: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging46 DTU Informatics, Technical University of Denmark

Using the backtracing image

Page 47: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging47 DTU Informatics, Technical University of Denmark

Pre-processing We would like to track

paths that are not dark curves

Pre-processing– Turn edges into dark

curves Any ideas?

Page 48: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging48 DTU Informatics, Technical University of Denmark

Pre-processing

Edge filtered image(Gaussian smoothing followed by Prewitt)

Page 49: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging49 DTU Informatics, Technical University of Denmark

Path tracing on pre-processed image

Paths found on pre-processed image

Page 50: DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics rrp@imm.dtu.dk  TexPoint fonts

DTU Informatics

29/4/2009Introduction to Medical Imaging50 DTU Informatics, Technical University of Denmark

Exercises

?