CS654: Digital Image Analysis Lecture 26: Image segmentation.

45
CS654: Digital Image Analysis Lecture 26: Image segmentation

Transcript of CS654: Digital Image Analysis Lecture 26: Image segmentation.

Page 1: CS654: Digital Image Analysis Lecture 26: Image segmentation.

CS654: Digital Image Analysis

Lecture 26: Image segmentation

Page 2: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Recap of Lecture 25

• Line detection

• Least square, RANSAC

• Hough space/ parametric space

• Voting

• Circle detection

• GHT

Page 3: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Outline of Lecture 26

• Thresholding

• Otsu’s method

• Region based segmentation

• Region growing

• Split and Merge

Page 4: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Introduction

• Detected boundaries between regions

• Pixel distribution was not exploited

• Can the regions be segmented directly?

• How to exploit the top-down/ bottom-up cues?

• Threshold

• Region-based segmentation

Page 5: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Thresholding

𝑔 (𝑥 , 𝑦 )={1 𝐼𝑓 𝑓 (𝑥 , 𝑦 )>𝑇0 𝐼𝑓 𝑓 (𝑥 , 𝑦 )≤𝑇 𝑔 (𝑥 , 𝑦 )={ 𝒂 ; 𝐼𝑓 𝑓 (𝑥 , 𝑦 )>𝑇2

𝒃 ; 𝐼𝑓 𝑇1< 𝑓 (𝑥 , 𝑦 )≤𝑇 2

𝒄 ; 𝐼𝑓 𝑓 (𝑥 , 𝑦 )≤𝑇 1

Global thresholding, local thresholding, adaptive thresholding

Multiple thresholding

Page 6: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Key factors

• Separation between peaks

• The noise content in the

image

• The relative size of the object

and the background

• Uniformity of the illumination

source

• Uniformity of the reflectance

property of the imageAutomatic threshold selection

Page 7: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Iterative threshold selection

1. Select an initial estimate of the threshold . A good initial value is the average intensity of the image

2. Calculate the mean grey values and of the partitions,

3. Partition the image into two groups, , using the threshold

4. Select a new threshold:

5. Repeat steps 2-4 until the mean values and in successive iterations do not change.

𝑇=12

(𝜇1+𝜇2 )

Page 8: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Optimal thresholding

Definition: Methods based on approximation of the histogram of an image using a weighted sum of two or more probability densities with normal distribution.

Page 9: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Example

Input image Histogram Segmented image

Page 10: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Otsu’s Image Segmentation Algorithm

• Find the threshold that minimizes the weighted within-class variance.

• Equivalent to: maximizing the between-class variance.

• Operates directly on the gray level histogram [e.g. 256 numbers, P(i)]

• It is fast (once the histogram is computed).

Page 11: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Otsu: Assumptions

• Histogram (and the image) are bimodal.

• No use of spatial coherence, nor any other notion of object structure.

• Assumes stationary statistics, but can be modified to be locally adaptive

• Assumes uniform illumination (implicitly), so the bimodal brightness behavior arises from object appearance differences only.

Page 12: CS654: Digital Image Analysis Lecture 26: Image segmentation.

The weighted within-class variance is:

w2 (t) q1(t)1

2 (t) q2 (t) 22(t)

Where the class probabilities are estimated as:

q1(t) P(i)i1

t

L

ti

iPtq1

2 )()(

t

i

iiPtq

t11

1 )()(

1)(

L

ti

iiPtq

t12

2 )()(

1)(

And the class means are given by:

Otsu’s method: Formulation

Page 13: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Finally, the individual class variances are:

12(t) [i 1(t)]

2 P(i)

q1(t)i1

t

L

ti tq

iPtit

1 2

22

22 )(

)()]([)(

Run through the full range of t values and pick the value that minimizes

Is this algorithm first enough?

w2 (t)

Otsu’s method: Formulation

w2 (t) q1(t)1

2 (t) q2 (t) 22(t)

Page 14: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Between/ Within/ Total Variance

• The total variance does not depend on threshold (obviously).

• For any given threshold, the total variance is the weighted sum of the within-class variances

• The between class variance, which is the sum of weighted squared distances between the class means and the global mean.

Page 15: CS654: Digital Image Analysis Lecture 26: Image segmentation.

The total variance can be expressed as

2 w2 (t) q1(t)[1 q1 (t)][1(t) 2 (t)]

2

Within-class, from before Between-class,

Minimizing the within-class variance is the same as maximizing the between-class variance.

compute the quantities in recursively as we run through the range of t values.

Total variance

B2 (t)

B2 (t)

Page 16: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Recursive algorithm

q1(t 1)q1(t) P(t 1)

1(t 1) q1(t)1 (t) (t 1)P(t 1)

q1(t 1)

q1(1) P(1) 1(0) 0;

2(t 1) q1(t 1)1(t 1)

1 q1(t 1)

Initialization...

Recursion...

Page 17: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Example

Input image Histogram

Global thresholding

Otsu’s method

Page 18: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Example (in presence of noise)

Input image Histogram Global threshold

Smoothened image Histogram Otsu’s method

Page 19: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Image partitioningInput image Histogram Global threshold

Global Otsu’s Method Image partitioning Local Otsu’s method

Page 20: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Thresholding (non-uniform background)

Input image Global thresholding using Otsu’s method

Local thresholding with moving average

Page 21: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Region based segmentation

• Goal: find coherent (homogeneous) regions in the image

• Coherent regions contain pixel which share some similar property

• Advantages: Better for noisy images

• Disadvantages: Oversegmented (too many regions), Undersegmented (too few regions)

• Can’t find objects that span multiple disconnected regions

Page 22: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Types of segmentations

Oversegmentation Undersegmentation

Multiple Segmentations

Input

Page 23: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Region Segmentation: Criteria

A segmentation is a partition of an imageinto a set of regions satisfying:

1. Si = S Partition covers the whole image.

2. Si Sj = , i j No regions intersect.

3. Si, P(Si) = true

4. P(Si Sj) = false, i j, Si adjacent SjHomogeneity predicate is satisfied by each region.

Union of adjacent regions does not satisfy it.

Define and implement the similarity predicate.

Page 24: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Methods of Region Segmentation

• Region growing

• Split and merge

• Clustering

Page 25: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Region Growing

• It start with one pixel of a potential region

• Try to grow it by adding adjacent pixels till the pixels being compared are too dissimilar

• The first pixel selected can be • The first unlabelled pixel in the image • A set of seed pixels can be chosen from the image.

• Usually a statistical test is used to decide which pixels can be added to a region

Page 26: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Example

Input image

Outputimage

Histogram Initial Seed image

Final seeds

Threshold 1 Threshold 2 Region growing

Page 27: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Split and Merge

• Split into four disjoint coordinates any region for which =false

• When no further splitting is possible, merge adjacent region for which = true

• Stop when no further merging is possible

Page 28: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Example

R1 R2

R4R3

R21 R22

R23 R24

R31 R32

R33 R34

R1

R4

Input image

Split Split Merge

Page 29: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Quadtree representation

R

R1 R2 R3 R4

R21 R22 R23 R24 R31 R32 R33 R34

R21 R22

R23 R24

R31 R32

R33 R34

R1

R4

Page 30: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Clustering

• Task of grouping a set of objects

• Objects in the same group (called a cluster) are more similar (in some sense or another) to each other

• Object of one cluster is different from an object of the another cluster

• Connectivity model, centroid model, distribution model, density model, graph based model, hard clustering, soft-clustering, …

Page 31: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Feature Space

Source: K. Grauman

Page 32: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Centroid model

• Computational time is short

• User have to decide the number of clusters before starting classifying data

• The concept of centroid

• One of the famous method: K-means Method

Page 33: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Decide the number of the final classified result with N.

Numbers of cluster: N

we now assume N=3

Page 34: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Randomly choose N point for the centroids of cluster.

(N=3)

Numbers of cluster: N

Page 35: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Find the nearest point for every centroid of cluster. Classify the point into the cluster.

Notice the definition of th nearest!

Page 36: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Calculate the new centroid of every cluster.

Notice the definition of the centroid!

Page 37: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Repeat step1~ step4 until all the point are classified.

Page 38: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Repeat step1~ step4 until all the point are classified.

Page 39: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Repeat step1~ step4 until all the point are classified.

Page 40: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Repeat step1~ step4 until all the point are classified.

Page 41: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Repeat step1~ step4 until all the point are classified.

Page 42: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Partitional Clustering

• K-mean algorithm :

Data clustering completed

For N=3

Page 43: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Example

Image Clusters on intensity Clusters on color

Slides by D.A. Forsyth

Page 44: CS654: Digital Image Analysis Lecture 26: Image segmentation.

ExampleInput image Segmentation using K-means

Page 45: CS654: Digital Image Analysis Lecture 26: Image segmentation.

Thank youNext Lecture: Image segmentation