Date post: | 04-Jan-2016 |
Category: |
Documents |
Upload: | cecilia-gilbert |
View: | 219 times |
Download: | 0 times |
1
Regions and Binary Images
Hao Jiang
Computer Science Department
Sept. 25, 2014
Figure Ground Separation
2
Brightness Thresholding
3
=-
Thresholding Given a grayscale image or an intermediate matrix
threshold to create a binary output.
Example: background subtraction
Looking for pixels that differ significantly from the “empty” background.
fg_pix = find(diff > t);Slides from Kristen Grauman
Thresholding Given a grayscale image or an intermediate matrix
threshold to create a binary output.
Example: color-based detection
Looking for pixels within a certain hue range.
fg_pix = find(hue > t1 & hue < t2);
Slides from Kristen Grauman
More Binary Images
6
Slide from Kristen Grauman
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 from Kristen Grauman
Find Connected Regions
8
Find Connected Regions
9
Our target in this image is the largest blob.
Connected Components
Identify distinct regions of “connected pixels”
Shapiro and Stockman
Pixel Neighbors
11
4 neighboring pixels of the blue pixel
Pixel Neighbors
12
8 neighboring pixels of the blue pixel
Recursive Method
13
label = 2for i = 1 to rows for j = 1 to cols if I(i, j) == 1 labelConnectedRegion(i, j, label) label ++; endend
Recursive Method
14
function labelConnectedRegion(int i, int j, int label) if (i,j) is labeled or background or out of boundary return
I(i,j)=label for (m,n) belongs to neighbors of (i,j) labelConnectedRegion(m,n,label) end
Sequential connected components
Slide from J. Neira
Sequential connected components
Example
17
1 1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
18
2 1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
19
2 2 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
20
2 2 3 1 1
1 1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
21
2 2 3 3 1
1 1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
22
2 2 3 3 3
1 1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
23
2 2 3 3 3
2 1 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
24
2 2 3 3 3
2 2 1 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
25
2 2 3 3 3
2 2 2 1
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
26
2 2 3 3 3
2 2 2 2
1 1 1 1
1 1 1 1 1
1 1 1 1 1
2 3
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
(2,3)
Example
27
2 2 3 3 3
2 2 2 2
2 1 1 1
1 1 1 1 1
1 1 1 1 1
2 3
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
28
2 2 3 3 3
2 2 2 2
2 2 1 1
1 1 1 1 1
1 1 1 1 1
2 3
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
29
2 2 3 3 3
2 2 2 2
2 2 4 1
1 1 1 1 1
1 1 1 1 1
2 3
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
30
2 2 3 3 3
2 2 2 2
2 2 4 4
1 1 1 1 1
1 1 1 1 1
2 3
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
31
2 2 3 3 3
2 2 2 2
2 2 4 4
5 1 1 1 1
1 1 1 1 1
2 3
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
32
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 1 1 1
1 1 1 1 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
(5,2)
Example
33
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 1 1
1 1 1 1 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
34
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 4 1
1 1 1 1 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
35
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 4 4
1 1 1 1 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
36
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 4 4
5 1 1 1 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
37
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 4 4
5 5 1 1 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
38
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 4 4
5 5 5 1 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
39
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 4 4
5 5 5 5 1
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
(5,2)
Example
40
2 2 3 3 3
2 2 2 2
2 2 4 4
5 5 2 4 4
5 5 5 5 4
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Example
41
3 3 3 3 3
3 3 3 3
3 3 4 4
3 3 3 4 4
3 3 3 3 4
2 3
3 3
4 4
5 3
6 6
7 7
8 8
9 9
Image Label equivalence table
Region properties
Given connected components, can compute simple features per blob, such as: Area (num pixels in the region) Centroid (average x and y position of pixels in the region) Bounding box (min and max coordinates)
How could such features be useful?
A1=200
A2=170
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
Morphological operators
Change the shape of the foreground regions/ objects.
Useful to clean up result from thresholding
Basic operators are: Dilation Erosion
Dilation
Expands connected components Grow features Fill holes
Before dilation After dilation
Erosion
Erode connected components Shrink features Remove bridges, branches, noise
Before erosion After erosion
Structuring elements
Masks of varying shapes and sizes used to perform morphology, for example:
Scan mask across foreground pixels to transform the binary image
>> help strel
Dilation
At each position: Dilation: OR (MAX) of everything inside the
structuring element mask.
Example for Dilation (1D)
SExfxg )()(
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1Output Image
111
Adapted from T. Moeslund
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1Output Image
111
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0Output Image
111
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0 1Output Image
111
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0 1 1Output Image
111
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0 1 1 1Output Image
111
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0 1 1 1 1Output Image
111
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0 1 1 1 1 1Output Image
111
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0 1 1 1 1 1 1Output Image
111
Note that the object gets bigger and holes are filled.>> help imdilate
Example for Dilation
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
1 1 0 1 1 1 1 1 1 1Output Image
111
Note that the object gets bigger and holes are filled.>> help imdilate
Erosion
At each position: Erosion: AND (MIN) of everything inside the
structuring element mask.
Example for Erosion (1D)
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0Output Image
111
SExfxg O)()( _
Example for Erosion (1D)
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0Output Image
111
SExfxg O)()( _
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0Output Image
111
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0Output Image
111
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0 0Output Image
111
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0 0 1Output Image
111
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0 0 1 0Output Image
111
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0 0 1 0 0Output Image
111
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0 0 1 0 0 0Output Image
111
Example for Erosion
1 0 0 0 1 1 1 0 1 1Input image
Structuring Element
0 0 0 0 0 1 0 0 0 0Output Image
111
Note that the object gets smaller>> help imerode
Opening
Erode, then dilate Remove small objects, keep original shape
Before opening After opening
Slide from Kristen Grauman
Closing
Dilate, then erode Fill holes, but keep original shape
Before closing After closing
Slide from Kristen Grauman
Morphology Operators on Grayscale Images
Dilation and erosion typically performed on binary images. If image is grayscale: for dilation take the neighborhood max, for erosion
take the min.
original dilated eroded
Slide from Kristen Grauman
Matlab
Create structure element
se = strel(‘disk’, radius); Erosion
imerode(image, se); Dilation
imdilate(image, se); Opening
imopen(image, se); Closing
imclose(image, se); More possibilities
bwmorph(image, ‘skel’);
73
Figure Ground Separation
74
Brightness Thresholding
75
Opening
76
Find the Largest Connected Region
77
Example Using Binary Image Analysis: segmentation of a liver
Slide credit: Li Shen Slide from Kristen Grauman
Example Using Binary Image Analysis:Bg subtraction + blob detection
…
Slide from Kristen Grauman
University of Southern Californiahttp://iris.usc.edu/~icohen/projects/vace/detection.htm
Example Using Binary Image Analysis:Bg subtraction + blob detection
Slide from Kristen Grauman