Image Analysis The topics of this lecture are Segmentation - - PowerPoint PPT Presentation

image analysis
SMART_READER_LITE
LIVE PREVIEW

Image Analysis The topics of this lecture are Segmentation - - PowerPoint PPT Presentation

Image Analysis The topics of this lecture are Segmentation Thresholding Region based segmentation Christina Olsn colsen@cs.umu.se The Watershed-algorithm Department of Computing Science Ume University February 17, 2009 Christina Olsn


slide-1
SLIDE 1

Image Analysis

Segmentation Christina Olsén colsen@cs.umu.se

Department of Computing Science Umeå University

February 17, 2009

Christina Olsén (CS, UmU) Segmentation February 17, 2009 1 / 46

The topics of this lecture are Thresholding Region based segmentation The Watershed-algorithm

Christina Olsén (CS, UmU) Segmentation February 17, 2009 2 / 46

Thresholding

50 100 150 200 250 300 50 100 150

T = 120 T = 150 T = 170

Christina Olsén (CS, UmU) Segmentation February 17, 2009 3 / 46

Original Low-pass filtered Histogram

50 100 150 200 250 300 50 100 150 50 100 150 200 250 300 50 100 150 200 250 300 350

Christina Olsén (CS, UmU) Segmentation February 17, 2009 4 / 46

slide-2
SLIDE 2

Suppose that there is one object present in the image and that it has a specific intensity µ1 Suppose that this intensity is different from the intensity µ2 of the background In a perfect world it is sufficient to say that: Pixels with intensity value µ1 constitute the object and pixels with intensity µ2 constitute the background

Christina Olsén (CS, UmU) Segmentation February 17, 2009 5 / 46

We do not live in a perfect world Due to noise, uneven lightning and uneven intensity of the object and the background we can not assume that all pixels are of two different intensity Suppose that there is one object and the background present in the image We say that the intensity of the object is given by the probability density function p1(z) and the intensity of the background is given by p2(z) The a-priori probability for a pixel to belong to the object is P1 and to the background P2 Since we only have one object it must hold that P1 + P2 = 1

Christina Olsén (CS, UmU) Segmentation February 17, 2009 6 / 46

We say that we have a mixture model p(z) = P1p1(z) + P2p2(z) The histogram of the image is an estimate of this model Suppose that we establish a single threshold T and say that pixels with intensity higher than T belongs to the object and pixels with intensity lower than T belongs to the background The error of using this threshold is E(T) = P2E1(T) + P1E2(T) where E1(T) = T

−∞

p2(z)dz and E2(T) = ∞

T

p1(z)dz

Christina Olsén (CS, UmU) Segmentation February 17, 2009 7 / 46

Obviously we want to find the T that yields the lowest error That is the T that minimizes E(T) = P2E1(T) + P1E2(T) To find this T we solve dE

dT = 0 and obtains:

P1p1(T) = P2p2(T) The observable error against the histogram h(z) is e = 1 n

n

  • i=1

(p(zi) − h(zi))2 Without doing any assumptions, it is very hard to minimize e This can be handled in two ways

◮ By assuming that we know the form of the distributions p1(z) and

p2(z) and solve for T analytically

◮ Or we can solve for T by iterative numerical methods Christina Olsén (CS, UmU) Segmentation February 17, 2009 8 / 46

slide-3
SLIDE 3

Analytical

We assume that p1 and p2 are normal distributed we obtain (for p1(z)) p1(z) = 1 √ 2πσ1 e−(z−µ1)2/2σ2

1

where µ1 and σ2

1 are the expected value and variance for the

distribution. We can now find the optimal T by solving p1(T)P1 = p2(T)P2 analytically.

Christina Olsén (CS, UmU) Segmentation February 17, 2009 9 / 46

Analytical

The optimal T is the solution to AT 2 + BT + C = 0 where A = σ2

1 − σ2 2

B = 2(µ1σ2

2 − µ2σ2 1)

C = σ2

1µ2 2 − σ2 2µ2 1 + 2σ2 1σ2 2 ln(σ2P1/σ1P2)

Christina Olsén (CS, UmU) Segmentation February 17, 2009 10 / 46

50 100 150 200 250 300 0.5 1 1.5 2 2.5 3 3.5 x 10

−3

background: µ2: 70, σ2: 40 P2:0.7

  • bject: µ1:160, σ1: 10 P1:0.3

T2:192 T1:140 Lowest error if object are pixelvalues 140 < I < 192: 3.58 %

Christina Olsén (CS, UmU) Segmentation February 17, 2009 11 / 46

50 100 150 200 250 300 0.5 1 1.5 2 2.5 3 3.5 4 x 10

−3

background: µ2: 90, σ2: 40 P2:0.7

  • bject: µ1:150, σ1: 10 P1:0.3

T2:173 T1:135 Lowest error if object are pixelvalues 135 < I < 173: 10.3 %

Christina Olsén (CS, UmU) Segmentation February 17, 2009 12 / 46

slide-4
SLIDE 4

The success of our analytical approach is dependent on

◮ How well we can estimate the types of distributions ◮ How well we can estimate the parameters that control the

distributions

◮ How hard it is to solve the equations involved

Most of the times we must use iterative solutions

Christina Olsén (CS, UmU) Segmentation February 17, 2009 13 / 46

Iterative

1

Let i = 0

2

Calculate the center of mass of the histogram Ti =

  • z h(z) · z
  • z h(z)

3

Calculate µ0(Ti) = µ[h(z) | z < Ti] and µ1(Ti) = µ[h(z) | z ≥ Ti]

4

Let Ti+1 = µ0(Ti) + µ1(Ti) 2

5

If |Ti − Ti+1| < ǫ then end, otherwise let i = i + 1 and go to 3.

Christina Olsén (CS, UmU) Segmentation February 17, 2009 14 / 46

Histogram

50 100 150 200 250 300 50 100 150

Christina Olsén (CS, UmU) Segmentation February 17, 2009 15 / 46

Threshold T = 128

Christina Olsén (CS, UmU) Segmentation February 17, 2009 16 / 46

slide-5
SLIDE 5

Histogram

50 100 150 200 250 300 20 40 60 80 100 120 140

Christina Olsén (CS, UmU) Segmentation February 17, 2009 17 / 46

Threshold T = 120

Christina Olsén (CS, UmU) Segmentation February 17, 2009 18 / 46 1

Let i = 0

2

Let Ti be some suitable value.

3

Define pi

0(z) = [h(z)|z < Ti]

and pi

1(z) = [h(z)|z ≥ Ti]

4

Calculate Pi

0, µi 0 and σi 0 for pi 0(z) and pi 1

5

Calculate a Ti+1 ∈ (0, Lmax) from AT 2

i+1 + BTi+1 + C = 0

where A = σ2

0 − σ2 1, B = 2(µ0σ2 1 − µ1σ2 0)

and C = σ2

0µ2 1 − σ2 1µ2 0 + 2σ2 0σ2 1 ln(σ2P1/σ1P2)

6

If |Ti − Ti+1| < ǫ then end, otherwise let i = i + 1 and go to 3.

Christina Olsén (CS, UmU) Segmentation February 17, 2009 19 / 46

Histogram

50 100 150 200 250 300 20 40 60 80 100 120 140

Christina Olsén (CS, UmU) Segmentation February 17, 2009 20 / 46

slide-6
SLIDE 6

Threshold T = 148

Christina Olsén (CS, UmU) Segmentation February 17, 2009 21 / 46

Histogram

50 100 150 200 250 300 20 40 60 80 100 120 140

Christina Olsén (CS, UmU) Segmentation February 17, 2009 22 / 46

Threshold T = 138

Christina Olsén (CS, UmU) Segmentation February 17, 2009 23 / 46

Otsu

The aim with thresholding is to divide the histogram (i.e. the intensity values in the image) into two parts. If we choose the approach to minimize the variance of the object and background pixels respectively it has been noticed that we

  • ften obtain thresholds that are close to optimal.

Christina Olsén (CS, UmU) Segmentation February 17, 2009 24 / 46

slide-7
SLIDE 7

The total variance within objects for a given threshold T is defined as σ2

within(T) = nB(T)σ2 B(T) + nO(T)σ2 O(T)

nB = T−1

i=0 p(i), nO = L−1 i=T p(i)

σ2

B and σ2 O is the variance for background and object respectively.

The aim is to choose the T that minimizes σ2

within

Christina Olsén (CS, UmU) Segmentation February 17, 2009 25 / 46

To calculate σ2

within for each T can be rather costly

By using the relationship σ2

between = σ2 − σ2 within

= nB(T)(µB(T) − µ)2 + nO(T)(µO(T) − µ)2 = nB(T)nO(T)(µB(T) − µO(T))2 We can find the T that maximizes σ2

between

It can also be shown that the values can be updated iteratively This method is called Otsu’s method and is implemented in MatLabs greythresh command

Christina Olsén (CS, UmU) Segmentation February 17, 2009 26 / 46 Christina Olsén (CS, UmU) Segmentation February 17, 2009 27 / 46

Otsus Method Thresholding T = 125

Christina Olsén (CS, UmU) Segmentation February 17, 2009 28 / 46

slide-8
SLIDE 8

Region based methods

The segmentation of an image involves dividing it into regions R1, R2, . . . , Rn for which holds:

1

  • i Ri = R

2

Ri is a connected component, ∀i

3

Ri ∩ Rj = ∅ ∀i = j

4

P(Ri) = TRUE, ∀i

5

P(Ri ∪ Rj) = FALSE, ∀i = j P is a logical predicate defined on all points that belong to a region

Christina Olsén (CS, UmU) Segmentation February 17, 2009 29 / 46

Region growing

1

Let i = 0

2

choose a start region ri

3

Define ri+1 = pi

  • ri. Where pi are the neighbors ri that full fills

the predicate P(pi)

4

If pi = ∅ then end otherwise let i = i + 1 and goto 3.

Christina Olsén (CS, UmU) Segmentation February 17, 2009 30 / 46 Original Region−växning ΔT=10% Region−växning ΔT=5% Christina Olsén (CS, UmU) Segmentation February 17, 2009 31 / 46

Quad-tree

The previous methods is based on choice of start region One way round this is to start from the top-region R (i.e. the entire image) and divide it The division is carried out repeatedly for all regions not meeting a criteria P. The division is carried on recursively until all regions have size 1

  • r they all meet the criteria P.

The sub-division is made easier if the image has side length of the form N = 2n When the division is carried out all regions that fulfill P is merged to one

Christina Olsén (CS, UmU) Segmentation February 17, 2009 32 / 46

slide-9
SLIDE 9

Original Quadtree uppdelning

In this case the following criteria has been used: Do the average intensity deviate more than 10% from a specific gray value (taken inside the star)

Christina Olsén (CS, UmU) Segmentation February 17, 2009 33 / 46

Watershed

The Watershed algorithm is base on morphological operators The basic idea is to let object grow from starting points with dilation The trick is now to let objects merge by building barriers (or dams) The image is a landscape that we fill with water. The water will accumulate at the lowest and form ponds. As the water rises ponds will tend to merge, but we prevent that by building dams between ponds that are about to merge. The dams will define the border between ponds (i.e. objects). Each dam will form a closed contour.

Christina Olsén (CS, UmU) Segmentation February 17, 2009 34 / 46 bw Christina Olsén (CS, UmU) Segmentation February 17, 2009 35 / 46

Distance transform of ~bw

10 20 30 40 50 60 70 10 20 30 40 50 60 70 −20 −15 −10 −5

Christina Olsén (CS, UmU) Segmentation February 17, 2009 36 / 46

slide-10
SLIDE 10

10 20 30 40 50 60 70 10 20 30 40 50 60 70 −20 −10 10 20 30 40 50 60 70 10 20 30 40 50 60 70 −20 −10 10 20 30 40 50 60 70 10 20 30 40 50 60 70 −20 −10

Christina Olsén (CS, UmU) Segmentation February 17, 2009 37 / 46 Christina Olsén (CS, UmU) Segmentation February 17, 2009 38 / 46

bw Distance transform of ~bw

Christina Olsén (CS, UmU) Segmentation February 17, 2009 39 / 46 Christina Olsén (CS, UmU) Segmentation February 17, 2009 40 / 46

slide-11
SLIDE 11

Christina Olsén (CS, UmU) Segmentation February 17, 2009 41 / 46 Christina Olsén (CS, UmU) Segmentation February 17, 2009 42 / 46 Christina Olsén (CS, UmU) Segmentation February 17, 2009 43 / 46

extended minima image

Christina Olsén (CS, UmU) Segmentation February 17, 2009 44 / 46

slide-12
SLIDE 12

imposed minima image

Christina Olsén (CS, UmU) Segmentation February 17, 2009 45 / 46 Christina Olsén (CS, UmU) Segmentation February 17, 2009 46 / 46