medical image analysis · 2020. 4. 11. · in matlab and in this presentation in the course notes....
TRANSCRIPT
-
DTU Compute
Medical Image Analysis
Rasmus R. PaulsenDTU Compute
http://www.compute.dtu.dk/courses/02512
mailto:[email protected]://www.compute.dtu.dk/courses/02512
-
DTU Compute
2020Image Analysis2 DTU Compute, Technical University of Denmark
Lecture 10 – Hough Transformation and Path Tracing
Hough transform
θ
ρ
-50 0 50
-400
-200
0
200
400
-
DTU Compute
2020Image Analysis3 DTU Compute, 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 Choose appropriate pre-processing steps for path tracing Describe how circular structures can be located using path tracing
-
DTU Compute
2020Image Analysis4 DTU Compute, Technical University of Denmark
Line Detection Find the lines in an image
-
DTU Compute
2020Image Analysis5 DTU Compute, 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
-
DTU Compute
2020Image Analysis6 DTU Compute, Technical University of Denmark
Enhancing the lines We want to locate the
borders– Enhance them
Filtering Edge detection
Original Prewitt Edge
-
DTU Compute
2020Image Analysis7 DTU Compute, 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?
-
DTU Compute
2020Image Analysis8 DTU Compute, 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
-
DTU Compute
2020Image Analysis9 DTU Compute, 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 + B y = C
A2 + B 2 = 1
Line normal
-
DTU Compute
2020Image Analysis10 DTU Compute, Technical University of Denmark
Mathematical line definition Normal parameterisation
where– is the distance from the
origin– is the angle
-5 0 5-5
0
5
x axis
y ax
is
Ax + Bx = C
A2 + B 2 = 1
-
DTU Compute
2020Image Analysis11 DTU Compute, 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
-5 0 5-5
0
5
x axis
y ax
is
Ax + Bx = C
½µ
-
DTU Compute
2020Image Analysis12 DTU Compute, Technical University of Denmark
Something about angles
In Matlab and in this presentation
In the course notes
-
DTU Compute
2020Image Analysis13 DTU Compute, 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
θ
ρ
-
DTU Compute
2020Image Analysis14 DTU Compute, Technical University of Denmark
More about angles
-5 0 5-5
0
5
x axis
y ax
is
ρ = x cos θ + y sin θWhy?
but Matlab only allows
look at the mirror-projection of the normal
is used to determine if it is the “upper” or “lower line”
-
DTU Compute
2020Image Analysis15 DTU Compute, Technical University of Denmark
How do we use the Hough space?
-50 0 50-5
0
5
θ
ρ
?
-
DTU Compute
2020Image Analysis16 DTU Compute, 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
θ
ρ
-
DTU Compute
2020Image Analysis17 DTU Compute, 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
-
DTU Compute
2020Image Analysis18 DTU Compute, 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
-
DTU Compute
2020Image Analysis19 DTU Compute, 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
θ
ρ
-
DTU Compute
2020Image Analysis20 DTU Compute, 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
θ
ρ
-
DTU Compute
2020Image Analysis21 DTU Compute, Technical University of Denmark
Hough transform per pixel
-50 0 50-5
0
5
θ
ρ
Go through all and calculate (x, y) are fixed
Sinusoid!
-
DTU Compute
2020Image Analysis22 DTU Compute, Technical University of Denmark
Real Hough Transform
Hough space
θ
ρ
-50 0 50
-60
-40
-20
0
20
40
60
-
DTU Compute
2020Image Analysis23 DTU Compute, Technical University of Denmark
Real Hough Transform IIHough space
θ
ρ
-50 0 50
-60
-40
-20
0
20
40
60
-
DTU Compute
2020Image Analysis24 DTU Compute, 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
-
DTU Compute
2020Image Analysis25 DTU Compute, 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
-
DTU Compute
2020Image Analysis26 DTU Compute, Technical University of Denmark
The practical guide to the Hough Transform Start with an input image
-
DTU Compute
2020Image Analysis27 DTU Compute, Technical University of Denmark
The practical guide to the Hough Transform Detect edges and create a
binary image
-
DTU Compute
2020Image Analysis28 DTU Compute, Technical University of Denmark
The practical guide to the Hough Transform Compute Hough transform
and locate the maxima
θ
ρ
-50 0 50
-300-200-100
0100200300
-
DTU Compute
2020Image Analysis29 DTU Compute, 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
-
DTU Compute
2020Image Analysis30 DTU Compute, 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
-
DTU Compute
2020Image Analysis31 DTU Compute, 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.
-
DTU Compute
2020Image Analysis32 DTU Compute, Technical University of Denmark
Dynamic Programming Break up large problem into
many small sub-problems A classic algorithm:
– Dijkstra’s algorithm– One source to all nodes shortest path
We will look at a simplifiedvariant
Dijkstra, E. W. (1959). "A note on two problems in connexion with graphs". Numerische Mathematik. 1: 269–271.
-
DTU Compute
2020Image Analysis33 DTU Compute, 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
-
DTU Compute
2020Image Analysis34 DTU Compute, 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
-
DTU Compute
2020Image Analysis35 DTU Compute, 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
-
DTU Compute
2020Image Analysis36 DTU Compute, 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
𝐶𝐶(𝑟𝑟, 𝑐𝑐)
-
DTU Compute
2020Image Analysis37 DTU Compute, Technical University of Denmark
Path cost A path is defined as (r,c)
coordinates
P = [(1,3), (2,3), (3, 2), (4,3), (5,4)]
-
DTU Compute
2020Image Analysis38 DTU Compute, Technical University of Denmark
Total cost – what is 𝐶𝐶𝑡𝑡𝑡𝑡𝑡𝑡?A) 167B) 350C) 403D) 270E) 345
0
31
0 1 0
A B C D E
P = [(1,3), (2,3), (3, 2), (4,3), (5,4)]
Chart1
A
B
C
D
E
0
31
0
1
0
Sheet1
A0
B31
C0
D1
E0
-
DTU Compute
2020Image Analysis39 DTU Compute, Technical University of Denmark
Path cost This is NOT the optimal path How do we compute the path
P that has minimum 𝐶𝐶𝑡𝑡𝑡𝑡𝑡𝑡?
Test all possible paths?– No! Impossible amount of
posibilities
P = [(1,3), (2,3), (3, 2), (4,3), (5,4)]
-
DTU Compute
2020Image Analysis40 DTU Compute, Technical University of Denmark
Path Cost
A) 1B) 2C) 3D) 4E) 5
20
0 0 0 0
A B C D E
A path has been found in the image P=[(1,4),(2,4),(3,5),(4,5),(5,5),(6,4)]. A Matlab matrix coordinate system is used. What is the total cost of the path?
Chart1
A
B
C
D
E
20
0
0
0
0
Sheet1
A20
B0
C0
D0
E0
-
DTU Compute
2020Image Analysis41 DTU Compute, Technical University of Denmark
Path restriction Path is only allowed to
– Go down– Move one pixel left or
right Longer jumps not
allowed
-
DTU Compute
2020Image Analysis42 DTU Compute, Technical University of Denmark
Accumulator image Keeps track of the
accumulated cost for possible paths
Path ending here has cost 296
-
DTU Compute
2020Image Analysis43 DTU Compute, Technical University of Denmark
Computing the accumulator image
Step 1: Copy first row of input image
-
DTU Compute
2020Image Analysis44 DTU Compute, Technical University of Denmark
Computing the accumulator image
Step 2: Fill second row
-
DTU Compute
2020Image Analysis45 DTU Compute, Technical University of Denmark
Computing the accumulator image
Step 3: Fill all rows by looking at the previous row
-
DTU Compute
2020Image Analysis46 DTU Compute, Technical University of Denmark
Accumulator ImageA) 57B) 167C) 301D) 241E) 145
02 3
18
2
A B C D E
An optimal path has been found in the image. What is the value of the accumulator image in the marked pixel?
Chart1
A
B
C
D
E
0
2
3
18
2
Sheet1
A0
B2
C3
D18
E2
-
DTU Compute
2020Image Analysis47 DTU Compute, Technical University of Denmark
Using the accumulator image
Step 4: The end of the optimal path can now be found
-
DTU Compute
2020Image Analysis48 DTU Compute, Technical University of Denmark
The backtracing image
• Keeps track of where the path came from
• Each pixel stores the column number
-
DTU Compute
2020Image Analysis49 DTU Compute, Technical University of Denmark
Using the backtracing image
Step 5: Trace the path in the backtracing image
-
DTU Compute
2020Image Analysis50 DTU Compute, Technical University of Denmark
Using the backtracing image
-
DTU Compute
2020Image Analysis51 DTU Compute, Technical University of Denmark
BacktracingA) 1B) 2C) 3D) 4E) 5
19
2 13 2
A B C D E
An optimal path has been found in an image. The backtracing image is seen below and the optimal pathends in the marked pixel. A Matlab coordinate system is used. What is the optimal path?
Chart1
A
B
C
D
E
19
2
1
3
2
Sheet1
A19
B2
C1
D3
E2
-
DTU Compute
2020Image Analysis53 DTU Compute, Technical University of Denmark
Pre-processing We would like to track
paths that are not dark curves
-
DTU Compute
2020Image Analysis54 DTU Compute, Technical University of Denmark
X-ray preprocessingA) Gaussian smoothingB) 255-IC) Gradient filterD) RegistrationE) Morphological operation
1
10 10
0
3
A B C D E
Chart1
A
B
C
D
E
1
10
10
0
3
Sheet1
A1
B10
C10
D0
E3
-
DTU Compute
2020Image Analysis55 DTU Compute, Technical University of Denmark
Pre-processing
Edge filtered image(Gaussian smoothing followed by Prewitt)
-
DTU Compute
2020Image Analysis56 DTU Compute, Technical University of Denmark
Path tracing on pre-processed image
Paths found on pre-processed image
-
DTU Compute
2020Image Analysis57 DTU Compute, Technical University of Denmark
OptimalPath 2
A) 1B) 2C) 3D) 4E) 5
1
19
1 0 0
A B C D E
A 5 x 5 image is filled with values given the gray level run length encoding: 2, 180, 1, 15, 3, 112, 1, 8, 4, 177, 1, 20, 4, 195, 1, 12, 3, 242, 2, 25, 3, 9. After that the optimal path is found. What is the total cost?
Chart1
A
B
C
D
E
1
19
1
0
0
Sheet1
A1
B19
C1
D0
E0
-
DTU Compute
2020Image Analysis58 DTU Compute, Technical University of Denmark
Next week
Statistical shape analysis
Medical Image AnalysisLecture 10 – Hough Transformation and Path TracingWhat can you do after today?Line DetectionWhat is a line?Enhancing the linesWhat is a line II?Mathematical line definitionMathematical line definitionMathematical line definitionMathematical line definitionSomething about anglesHough SpaceMore about anglesHow do we use the Hough space?How do we use the Hough space?Filled Hough-SpaceHough transform in practiseHough transform as a voting schemeHough transform per pixelHough transform per pixelReal Hough TransformReal Hough Transform IIReal Hough Transform and linesFinding the lines in Hough spaceThe practical guide to the Hough TransformThe practical guide to the Hough TransformThe practical guide to the Hough TransformThe practical guide to the Hough TransformPath TracingPath tracingDynamic ProgrammingPath tracingImages as graphsSimplified problemSimplified problemPath costTotal cost – what is 𝐶 𝑡𝑜𝑡 ?Path costPath CostPath restrictionAccumulator imageComputing the accumulator imageComputing the accumulator imageComputing the accumulator imageAccumulator ImageUsing the accumulator imageThe backtracing imageUsing the backtracing imageUsing the backtracing imageBacktracingPre-processingX-ray preprocessingPre-processingPath tracing on pre-processed imageOptimal� Path 2Next week