Lecture 3: Binary image analysis Thursday, Sept 6 Sudheendras - - PDF document

lecture 3 binary image analysis
SMART_READER_LITE
LIVE PREVIEW

Lecture 3: Binary image analysis Thursday, Sept 6 Sudheendras - - PDF document

Lecture 3: Binary image analysis Thursday, Sept 6 Sudheendras office hours Mon, Wed 1-2 pm ENS 31NR Forsyth and Ponce book Binary images Two pixel values Foreground and background Regions of interest


slide-1
SLIDE 1

Lecture 3: Binary image analysis

Thursday, Sept 6

slide-2
SLIDE 2
  • Sudheendra’s office hours

– Mon, Wed 1-2 pm – ENS 31NR

  • Forsyth and Ponce book
slide-3
SLIDE 3

Binary images

  • Two pixel values
  • Foreground and background
  • Regions of interest
slide-4
SLIDE 4

Constrained image capture setting

  • R. Nagarajan et al. A real time marking inspection scheme

for semiconductor industries, 2006

slide-5
SLIDE 5

Documents, text

slide-6
SLIDE 6

Medical, bio data

slide-7
SLIDE 7

Intermediate low-level cues

  • =

Edges Motion Orientation

NASA robonaut http://robonaut.jsc.nasa.gov/status/October_prime.htm

slide-8
SLIDE 8

Shape

Silhouette visual hulls Medial axis

slide-9
SLIDE 9

Outline

  • Thresholding
  • Connected components
  • Morphological operators
  • Region properties

– Spatial moments – Shape

  • Distance transforms

– Chamfer distance

slide-10
SLIDE 10

Thresholding

  • Grayscale -> binary mask
  • Useful if object of interest’s intensity

distribution is distinct from background

  • Examplehttp://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/FITZ

GIBBON/simplebinary.html

slide-11
SLIDE 11

Selecting thresholds

  • Partition a bimodal histogram
  • Fit Gaussians
  • Dynamic or local thresholds
slide-12
SLIDE 12

A nice case: bimodal intensity histograms

Ideal histogram, light object on dark background Actual observed histogram with noise

Images: http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT2/node3.html

slide-13
SLIDE 13
  • Example
  • Thresholding a bimodal histogram
  • Otsu method (1979) : automatically select

threshold by minimizing the weighted within-group variance of the two groups of pixels separated by the threshold.

A nice case: bimodal intensity histograms

slide-14
SLIDE 14

Not so nice cases

  • Threshold selection is an art, not a science

Shapiro and Stockman

slide-15
SLIDE 15

Connected components

  • Identify distinct regions

Shapiro and Stockman

slide-16
SLIDE 16

Connected components

  • P. Duygulu
slide-17
SLIDE 17

Connectedness

  • Which pixels are considered neighbors

Image from http://www-ee.uta.edu/Online/Devarajan/ee6358/BIP.pdf

4-connected 8-connected

slide-18
SLIDE 18

Connected components

  • Various algorithms to compute

– Recursive (in memory) – Two rows at a time (image not necessarily in memory) – Parallel propagation strategy

slide-19
SLIDE 19

Recursive connected components

  • Demo http://www.cosc.canterbury.ac.nz/mukundan/covn/Label.html
  • Find an unlabeled pixel, assign it a new

label

  • Search to find its neighbors, and

recursively repeat to find their neighbors til there are no more

  • Repeat
slide-20
SLIDE 20

Sequential connected components

Slide from J. Neira

slide-21
SLIDE 21
slide-22
SLIDE 22

Morphological operators

  • Dilation
  • Erosion
  • Open, close
slide-23
SLIDE 23

Dilation

  • Expands connected components
  • Grow features
  • Fill holes

Before dilation After dilation

slide-24
SLIDE 24

Structuring elements

  • Masks of varying shapes used to perform

morphology

  • Scan mask across foreground pixels to

transform the binary image

etc

slide-25
SLIDE 25

Dilation / Erosion

  • Dilation: if current pixel is

foreground, set all pixels under S to foreground in

  • utput (OR)
  • Erosion: if every pixel

under S is foreground, leave as is; otherwise, set current pixel to background in output

slide-26
SLIDE 26

Example for Dilation (1D)

SE x f x g ⊕ = ) ( ) (

1 1 1 1 1 1

Input image Structuring Element

1 1

Output Image

1 1 1

Adapted from T. Moeslund

slide-27
SLIDE 27

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1

Output Image

1 1 1

slide-28
SLIDE 28

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1

Output Image

1 1 1

slide-29
SLIDE 29

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1

Output Image

1 1 1

slide-30
SLIDE 30

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1 1 1 1

Output Image

1 1 1

slide-31
SLIDE 31

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1 1 1 1 1

Output Image

1 1 1

slide-32
SLIDE 32

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1 1 1 1 1 1

Output Image

1 1 1

slide-33
SLIDE 33

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1 1 1 1 1 1

Output Image

1 1 1

slide-34
SLIDE 34

Example for Dilation

1 1 1 1 1 1

Input image Structuring Element

1 1 1 1 1 1 1 1 1

Output Image

1 1 1

The object gets bigger and holes are filled!

slide-35
SLIDE 35

Erosion

  • Erode connected components
  • Shrink features
  • Remove bridges, branches, noise

Before erosion After erosion

slide-36
SLIDE 36

Example for Erosion (1D)

1 1 1 1 1 1

Input image Structuring Element Output Image

1 1 1

SE x f x g O ) ( ) ( =

_

slide-37
SLIDE 37

Example for Erosion (1D)

1 1 1 1 1 1

Input image Structuring Element Output Image

1 1 1

SE x f x g O ) ( ) ( =

_

slide-38
SLIDE 38

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element Output Image

1 1 1

slide-39
SLIDE 39

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element Output Image

1 1 1

slide-40
SLIDE 40

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element Output Image

1 1 1

slide-41
SLIDE 41

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element

1

Output Image

1 1 1

slide-42
SLIDE 42

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element

1

Output Image

1 1 1

slide-43
SLIDE 43

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element

1

Output Image

1 1 1

slide-44
SLIDE 44

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element

1

Output Image

1 1 1

slide-45
SLIDE 45

Example for Erosion

1 1 1 1 1 1

Input image Structuring Element

1 1

Output Image

1 1 1

The object gets smaller

slide-46
SLIDE 46

Dilation / Erosion

  • Dilation: if current pixel is

foreground, set all pixels under S to foreground in

  • utput (OR)
  • Erosion: if every pixel

under S is foreground, leave as is; otherwise, set current pixel to background in output

Images by P. Duygulu

slide-47
SLIDE 47

Opening

  • Erode, then dilate
  • Remove small objects, keep original shape

Before opening After opening

slide-48
SLIDE 48

Closing

  • Dilate, then erode
  • Fill holes, but keep original shape

Before closing After closing

slide-49
SLIDE 49

Application: blob tracking

Absolute differences from frame to frame

slide-50
SLIDE 50

Threshold

slide-51
SLIDE 51

Erode

slide-52
SLIDE 52

Application: blob tracking

  • Background subtraction + blob tracking
slide-53
SLIDE 53

Application: segmentation of a liver

Slide credit: Li Shen

slide-54
SLIDE 54

Region properties

Some useful features can be extracted once we have connected components, including

  • Area
  • Centroid
  • Extremal points, bounding box
  • Circularity
  • Spatial moments
slide-55
SLIDE 55

Area and centroid

Shapiro & Stockman

slide-56
SLIDE 56

Circularity

Shapiro & Stockman [Haralick]

slide-57
SLIDE 57

Invariant descriptors

[a1, a2, a3,…] [b1, b2, b3,…] Feature space distance

Often want features independent of position, orientation, scale.

slide-58
SLIDE 58

Central moments

S is a subset of pixels (region). Central (j,k)th moment defined as:

  • Invariant to translation of S.
slide-59
SLIDE 59

Central moments

  • 2nd central moment: variance
  • 3rd central moment: skewness
  • 4th central moment: kurtosis
slide-60
SLIDE 60

Axis of least second moment

  • Invariance to orientation?

Need a common alignment Axis for which the squared distance to 2d object points is minimized.

slide-61
SLIDE 61

Distance transform

  • Image reflecting distance to nearest point

in point set (e.g., foreground pixels).

4-connected adjacency 8-connected adjacency

slide-62
SLIDE 62

Distance transform

Edge image Distance transform image

slide-63
SLIDE 63

Distance transform (1D)

Adapted from D. Huttenlocher

slide-64
SLIDE 64

Distance Transform (2D)

Adapted from D. Huttenlocher

slide-65
SLIDE 65

Chamfer distance

  • Average distance to nearest feature

Edge image Distance transform image

  • D. Gavrila, DAGM 1999
slide-66
SLIDE 66

Chamfer distance

  • D. Gavrila, DAGM 1999

Edge image Distance transform image More on this and

  • ther distances

later

slide-67
SLIDE 67

Generalized distance transforms

  • Same forward/backward algorithm

applicable with different initialization

  • Initialize with function values F(x,y):
slide-68
SLIDE 68

The University of Ontario The University of Ontario

Distance Transform vs. Generalized Distance Transform

Assuming

then is standard Distance Transform (of image features)

⎭ ⎬ ⎫ ⎩ ⎨ ⎧ ∞ = . . ) ( W O feature image is p pixel if p F

) ( p F ) ( p D

∞ + ∞ + ∞ +

Locations of binary image features

p

|| || min )} ( || {|| min ) (

) ( :

q p q F q p p D

q F q q

− = + − =

=

Slide credit Y. Boykov

slide-69
SLIDE 69

The University of Ontario The University of Ontario

Distance Transform vs. Generalized Distance Transform

For general

is Generalized Distance Transform of

)} ( || {|| min ) ( q F q p p D

q

+ − =

) ( p F

F(p) may represent non-binary image features (e.g. image intensity gradient)

) ( p F

) ( p F ) ( p D

Slide credit Y. Boykov

Location of q is close to p, and F(q) is small there

slide-70
SLIDE 70

Binary images

  • Pros

– Can be fast to compute, easy to store – Simple processing techniques available – Lead to some useful compact shape descriptors

  • Cons

– Hard to get “clean” silhouettes, noise common in realistic scenarios – Can be too coarse of a representation – Not 3d

slide-71
SLIDE 71

Matlab

  • N = HIST(Y,M)
  • L = BWLABEL(BW,N);
  • STATS = REGIONPROPS(L,PROPERTIES) ;

– 'Area' – 'Centroid' – 'BoundingBox' – 'Orientation‘, …

  • IM2 = imerode(IM,SE);
  • IM2 = imdilate(IM,SE);
  • IM2 = imclose(IM, SE);
  • IM2 = imopen(IM, SE);
  • [D,L] = bwdist(BW,METHOD);
slide-72
SLIDE 72
  • Everything is matrix

Tutorial adapted from W. Freeman, MIT 6.896

slide-73
SLIDE 73
  • Matrix index
slide-74
SLIDE 74
  • Manipulate matrices
slide-75
SLIDE 75
  • Manipulate matrices
slide-76
SLIDE 76
  • Scripts and functions

– Scripts are m-files containing MATLAB statements – Functions are like any other m-file, but they accept arguments – Name the function file the same as the function name

slide-77
SLIDE 77
  • Try to code in matrix ways
slide-78
SLIDE 78
  • whos
  • help
  • lookfor
  • clear / clear x
  • save
  • load