Computer Vision - PowerPoint PPT Presentation

1 / 72
About This Presentation
Title:

Computer Vision

Description:

... Nagarajan et al. 'A real time marking inspection scheme. for semiconductor industries' ... i.) If only one of its neighbors (top or left) is 1, copy its label. ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 73
Provided by: bast151
Category:

less

Transcript and Presenter's Notes

Title: Computer Vision


1
Computer Vision Lecture 2
Binary Image Analysis 22.10.2009
Bastian Leibe RWTH Aachen http//www.umic.rwth-aa
chen.de/multimedia leibe_at_umic.rwth-aachen.de
TexPoint fonts used in EMF. Read the TexPoint
manual before you delete this box. AAAAAA
2
Announcements
  • Tuesday lecture slot (1315 1445)
  • Currently relatively small room (UMIC 024)
  • Overlaps with several other lectures.
  • Possible solution
  • We can get a bigger room (and reduce overlaps) by
    shifting the lecture to start 45 minutes earlier.
  • Quick poll
  • Who would have conflicting lectures on
  • Tue 1230 1400 ?

3
Binary Images
  • Just two pixel values
  • Foreground and background
  • Regions of interest

Slide credit Kristen Grauman
4
Uses Industrial Inspection
R. Nagarajan et al. A real time marking
inspection scheme for semiconductor industries,
2006
5
Uses Document Analysis, Text Recognition
6
Uses Medical/Bio Data
7
Uses Blob Tracking Motion Analysis
8
Uses Shape Analysis, Free-Viewpoint Video
Visual Hull Reconstruction
Blue-c project, ETH Zurich
Medial axis
9
Uses Intensity Based Detection
  • Looking for dark pixels

fg_pix find(im lt 65)
Slide Credit Kristen Grauman
10
Uses Color Based Detection
  • Looking for pixels within a certain color range

fg_pix find(hue gt t1 hue lt t2)
Slide Credit Kristen Grauman
11
Issues
  • How to demarcate multiple regions of interest?
  • Count objects
  • Compute further features per object
  • What to do with noisy binary outputs?
  • Holes
  • Extra small fragments

Slide Credit Kristen Grauman
12
Outline of Todays Lecture
  • Convert the image into binary form
  • Thresholding
  • Clean up the thresholded image
  • Morphological operators
  • Extract individual objects
  • Connected Components Labeling
  • Describe the objects
  • Region properties

Image Source D. Kim et al., Cytometry 35(1), 1999
13
Thresholding
  • Grayscale image ? Binary mask
  • Different variants
  • One-sided
  • Two-sided
  • Set membership

Image Source http//homepages.inf.ed.ac.uk/rbf/HI
PR2/
14
Selecting Thresholds
  • Typical scenario
  • Separate an object from a distinct background
  • Try to separate the different grayvalue
    distributions
  • Partition a bimodal histogram
  • Fit a parametric distribution (e.g. Mixture of
    Gaussians)
  • Dynamic or local thresholds
  • In the following, I will present some simple
    methods.
  • We will see some more general methods in Lecture
    6

15
A Nice Case Bimodal Intensity Histograms
Ideal histogram,light object on dark background
Actual observedhistogram with noise
Source Robyn Owens
16
Not so Nice Cases
  • How to separate those?
  • Threshold selection is difficult in the general
    case
  • Domain knowledge often helps
  • E.g. Fraction of text on a document page (?
    histogram quantile)
  • E.g. Size of objects/structure elements

Source Shapiro Stockman
17
Global Binarization Otsu79
  • Search for the threshold T that minimizes the
    within-class variance ?within of the two classes
    separated by T
  • where
  • This is the same as maximizing the between-class
    variance ?between

18
Algorithm
  • Precompute a cumulative grayvalue histogram h.
  • For each potential threshold T
  • 1.) Separate the pixels into two clusters
    according to T
  • 2.) Look up n1, n2 in h and compute both cluster
    means
  • 3.) Compute
  • Choose

19
Local Binarization Niblack86
  • Estimate a local threshold within a small
    neighborhood window W
  • where k ?-1,0 is a user-defined parameter.

W
20
Local Binarization Niblack86
  • Estimate a local threshold within a small
    neighborhood window W
  • where k ?-1,0 is a user-defined parameter.
  • Improved version to suppress background noise for
    document binarization Sauvola00
  • where R is the dynamic range of?? and k gt 0.
  • Typical values R128 for 8-bit images and k? 0.5.

Useful for text,but not for larger objects
21
Effects
22
Additional Improvements
  • Document images often contain a smooth gradient
  • Try to fit that gradient with a polynomial
    function

Source S. Lu C. Tan, ICDAR07
23
Surface Fitting
  • Polynomial surface of degree d
  • Least-squares estimation, e.g. for d3 (m10)

24
Surface Fitting
  • Iterative Algorithm
  • 1.) Fit parametric surface to all points in
    region.
  • 2.) Subtract estimated surface.
  • 3.) Apply global threshold (e.g. with Ohta
    method)
  • 4.) Fit surface to all background pixels in
    original region.
  • 5.) Subtract estimated surface.
  • 5.) Apply global threshold (Ohta)
  • 6.) Iterate further if needed
  • The first pass also takes foreground pixels into
    account.
  • This is corrected in the following passes.
  • Basic assumption here most pixels belong to the
    background.

25
Result Comparison
Original image
Global (Ohta)
Polynomial Global
Local (Niblack)
Source S. Lu C. Tan, ICDAR07
26
Result Comparison
Original image
Global (Ohta)
Polynomial Global
Local (Niblack)
Source S. Lu C. Tan, ICDAR07
27
Outline of Todays Lecture
  • Convert the image into binary form
  • Thresholding
  • Clean up the thresholded image
  • Morphological operators
  • Extract individual objects
  • Connected Components Labeling
  • Describe the objects
  • Region properties

Image Source D. Kim et al., Cytometry 35(1), 1999
28
Cleaning the Binarized Results
  • Results of thresholding often still contain noise
  • Necessary cleaning operations
  • Remove isolated points and small structures
  • Fill holes
  • ? Morphological Operators

Image Source D. Kim et al., Cytometry 35(1), 1999
29
Morphological Operators
  • Basic idea
  • Scan the image with a structuring element
  • Perform set operations (intersection, union)of
    image content with structuring element
  • Two basic operations
  • Dilation (Matlab imdilate)
  • Erosion (Matlab imerode)
  • Several important combinations
  • Opening (Matlab imopen)
  • Closing (Matlab imclose)
  • Boundary extraction

Matlabgtgt help strel
Image Source R.C. Gonzales R.E. Woods
30
Dilation
  • Definition
  • The dilation of A by B is the setof all
    displacements z, such that and A overlap
    by at least one element.
  • ( is the mirrored version of B, shifted by
    z)
  • Effects
  • If current pixel z is foreground, set allpixels
    under (B)z to foreground.
  • ? Expand connected components
  • ? Grow features
  • ? Fill holes

Image Source R.C. Gonzales R.E. Woods
31
Erosion
  • Definition
  • The erosion of A by B is the setof all
    displacements z, such that is entirely
    contained in A.
  • Effects
  • If not every pixel under (B)z is foreground, set
    the current pixel zto background.
  • ? Erode connected components
  • ? Shrink features
  • ? Remove bridges, branches, noise

Image Source R.C. Gonzales R.E. Woods
32
Effects
Image Source http//homepages.inf.ed.ac.uk/rbf/HI
PR2/
33
Effects
Image Source http//homepages.inf.ed.ac.uk/rbf/HI
PR2/
34
Opening
  • Definition
  • Sequence of Erosion and Dilation
  • Effect
  • is defined by the points thatare
    reached if B is rolled around inside A.
  • ? Remove small objects,keep original shape.

Image Source R.C. Gonzales R.E. Woods
35
Effect of Opening
  • Feature selection through sizeof structuring
    element

Image Source http//homepages.inf.ed.ac.uk/rbf/HI
PR2/
36
Effect of Opening
  • Feature selection through shapeof structuring
    element

Image Source http//homepages.inf.ed.ac.uk/rbf/HI
PR2/
37
Closing
  • Definition
  • Sequence of Dilation and Erosion
  • Effect
  • is defined by the points thatare
    reached if B is rolled around on the outside of
    A.
  • ? Fill holes,keep original shape.

Image Source R.C. Gonzales R.E. Woods
38
Effect of Closing
  • Fill holes in thresholded image(e.g. due to
    specularities)

Size of structuringelement determineswhich
structures areselectively filled.
Image Source http//homepages.inf.ed.ac.uk/rbf/HI
PR2/
39
Example Application Opening Closing
Source R.C. Gonzales R.E. Woods
40
Morphological Boundary Extraction
  • Definition
  • First erode A by B, then subtractthe result from
    the original A.
  • Effects
  • If a 3?3 structuring element is used,this
    results in a boundary that isexactly 1 pixel
    thick.

Source R.C. Gonzales R.E. Woods
41
Morphology Operators on Grayscale Images
  • Dilation and erosion are typically performed on
    binary images.
  • If image is grayscale for dilation take the
    neighborhood max, for erosion take the min.

Slide credit Kristen Grauman
42
Outline of Todays Lecture
  • Convert the image into binary form
  • Thresholding
  • Clean up the thresholded image
  • Morphological operators
  • Extract individual objects
  • Connected Components Labeling
  • Describe the objects
  • Region properties

Image Source D. Kim et al., Cytometry 35(1), 1999
43
Connected Components Labeling
  • Goal Identify distinct regions

Binary image
Connected componentslabeling
Sources Shapiro Stockman, Chandra
44
Connected Components Examples
Source Pinar Duygulu
45
Connectedness
  • Which pixels are considered neighbors?

Source Chaitanya Chandra
46
Sequential Connected Components
Slide credit J. Neira
47
Sequential Connected Components (2)
  • Process the image from left toright, top to
    bottom
  • 1.) If the next pixel to process is 1
  • i.) If only one of its neighbors
    (top or left) is 1, copy its label.
  • ii.) If both are 1 and have the
    same label, copy it.
  • iii.) If they have different labels
  • ? Copy the label from the left.
  • ? Update the equivalence table.
  • iv.) Otherwise, assign a new label.
  • Re-label with the smallest of equivalentlabels

Slide credit J. Neira
48
Application Blob Tracking
Slide credit K. Grauman
49
Slide credit K. Grauman
50
Eroding
Slide credit K. Grauman
51
Application Segmentation of a Liver
Slide credit Li Shen
52
Outline of Todays Lecture
  • Convert the image into binary form
  • Thresholding
  • Clean up the thresholded image
  • Morphological operators
  • Extract individual objects
  • Connected Components Labeling
  • Describe the objects
  • Region properties

Image Source D. Kim et al., Cytometry 35(1), 1999
53
Region Properties
  • From the previous steps, we can obtain separated
    objects.
  • Some useful features can be extracted once we
    have connected components, including
  • Area
  • Centroid
  • Extremal points, bounding box
  • Circularity
  • Spatial moments

54
Area and Centroid
  • We denote the set of pixels in a region by R
  • Assuming square pixels, we obtain
  • Area
  • Centroid

Source Shapiro Stockman
55
Circularity
  • Measure the deviation from a perfect circle
  • Circularity
  • where and are the mean and vari-ance
    of the distance from the centroid of the shape
    to the boundary pixels (xk,yk).
  • Mean radial distance
  • Variance of radial distance

Source Shapiro Stockman
56
Invariant Descriptors
  • Often, we want features independent of location,
    orientation, scale.

Feature spacedistance
Slide credit Kristen Grauman
57
Central Moments
  • S is a subset of pixels (region).
  • Central (j,k)th moment defined as
  • Invariant to translation of S.
  • Interpretation
  • 0th central moment area
  • 2nd central moment variance
  • 3rd central moment skewness
  • 4th central moment kurtosis

Slide credit Kristen Grauman
58
Moment Invariants
  • Normalized central moments
  • From those, a set of invariant moments can be
    defined for object description.
  • Robust to translation, rotation scaling, but
    dont expect wonders (still summary statistics).

(Additional invariantmoments ?5, ?6, ?7 can be
found in the literature).
59
Moment Invariants
60
Axis of Least Second Moment
  • Invariance to orientation?
  • Need a common alignment
  • Compute Eigenvectors of 2nd moment matrix
    (Matlab eig(A))

Axis for which the squared distance to 2D
object points is minimized(maximized).
61
Summary Binary Image Processing
  • Pros
  • Fast to compute, easy to store
  • Simple processing techniques
  • Can be very useful for constrained scenarios
  • Cons
  • Hard to get clean silhouettes
  • Noise is common in realistic scenarios
  • Can be too coarse a representation
  • Cannot deal with 3D changes

Slide credit Kristen Grauman
62
References and Further Reading
  • More on morphological operators can be found in
  • R.C. Gonzales, R.E. Woods,Digital Image
    Processing.Prentice Hall, 2001
  • Online tutorial and Java demos available on
  • http//homepages.inf.ed.ac.uk/rbf/HIPR2/

63
  • Questions ?

64
Demo Haribo Classification
65
You Can Do It At Home
  • Accessing a webcam in Matlab
  • function out webcam
  • uses "Image Acquisition Toolbox
  • adaptorName 'winvideo'
  • vidFormat 'I420_320x240'
  • vidObj1 videoinput(adaptorName, 1, vidFormat)
  • set(vidObj1, 'ReturnedColorSpace', 'rgb')
  • set(vidObj1, 'FramesPerTrigger', 1)
  • out vidObj1
  • cam webcam()
  • imggetsnapshot(cam)

66
Matlab Intro Everything is a matrix
Tutorial adapted from W. Freeman, MIT
67
Matlab Intro Matrix Index
Tutorial adapted from W. Freeman, MIT
68
Matlab Intro Manipulating Matrices
Tutorial adapted from W. Freeman, MIT
69
Matlab Intro Manipulating Matrices
Tutorial adapted from W. Freeman, MIT
70
Matlab Intro 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

Tutorial adapted from W. Freeman, MIT
71
Matlab Intro Try to Code in Matrix Ways
72
Matlab Intro Important Commands
  • whos ? List variables in workspace
  • help ? Get help for any command
  • lookfor ? Search for keywords
  • clear/clear x ? Erase a variable/all variables
  • save ? Save the workspace
  • load ? Load a saved workspace
  • keyboard ? Enter debugging mode (until dbquit)

73
Morphology in Matlab
  • N hist(Y,M)
  • IM2 imerode(IM,SE)
  • IM2 imdilate(IM,SE)
  • IM2 imclose(IM, SE)
  • IM2 imopen(IM, SE)
  • L bwlabel(BW,N)
  • STATS regionprops(L,PROPERTIES)
  • 'Area'
  • 'Centroid'
  • 'BoundingBox'
  • 'Orientation,

Slide credit Kristen Grauman
74
  • Questions ?
Write a Comment
User Comments (0)
About PowerShow.com