Professional Documents
Culture Documents
Points, lines, regions, etc. Discontinuities and similarities Point and line detection
Approaches considered:
Thresholding methods
Detection of Discontinuities
Line Detection
Image Processing Image Segmentation Prof. Barner, ECE Department, University of Delaware
Edge Detection
Wire-bond mask for electronic circuit Application of 45 edge mask Result of thresholding
Concepts:
Edge local Boundary global Step Ramp Ideal edges are smoothed by optics, sampling, illumination conditions Inch thickness determined by transition region
Prof. Barner, ECE Department, University of Delaware 6
Ideal edge:
Practical edge:
Image Processing Image Segmentation Prof. Barner, ECE Department, University of Delaware
Second derivative:
Even modest levels of noise severely degraded gradient-based edge detection Possible solution: noise smoothing prior to edge detection
Prof. Barner, ECE Department, University of Delaware 8
Gradient Operators
Two-dimensional gradient:
f Gx x f = = G y f y
1/ 2
Magnitude:
2 2 Gx f = mag ( f ) = + Gy
Direction (angle)
( x, y ) = tan 1
Gy Gx
Perpendicular to edge
f Gx + G y
Approximation:
Preprocess image
11
12
LoG Example
Angiogram example
Recall Laplacian:
2 f = 2 f 2 f + x 2 y 2
Sobel output shown for reference Threshold LoG Mark zero crossings
To obtain edges:
Edge detection limitations: Produces double edges, insensitive to edge direction, sensitive to noise Pre-smooth with Gaussian filter
h( r ) = e
r2 2 2
r2 2 2
h(r ) = 4
13
14
Edge Linking
Example criteria:
Goal: license plate localization Shown: horizontal and vertical gradient images Linking criteria:
Strength of gradients
f ( x, y ) f ( x0 , y0 ) E
Gradient 25 Angle differences 15 Linked edges Search for license plate based on rectangle side ratios
Prof. Barner, ECE Department, University of Delaware 16
Direction of gradients
( x, y ) ( x0 , y0 ) < A
Final result:
15
General approach:
Project feature into a parameter space Examples: lines, circles, etc. Defining parameters: slope and intercept Map lines into the single (slope, intercept) 2-tuple
Line case:
Map to all (slope, intercept) 2-tuples corresponding to the infinite number of lines passing through the point Result: a curve in the (slope, intercept)
Prof. Barner, ECE Department, University of Delaware
Fix xi and yi Line in parameter space: b=-xia+yi All lines (in parameter space) for points on a line in image space cross at a single point
17
18
Image space:
Parameter space:
x cos + y sin =
Subdivide , plane Map each point in the image plane to a curve in the , plane
20
Edge detection Hough transform Peak detection Map (lines) back to image space
Problem: identify region of exposure Problem: x-ray scattering smoothes edges Solution:
22
Radon transform:
xy
Examples:
Sample border
Thresholding Approaches
Objects and background have different intensities Multimodal distribution Globally Locally Adaptively
Illumination Effects
K-Means Algorithm
Clustering algorithm
Apply to spatial or multidimensional samples Apply to intensities (one-dimensional) to cluster histogram
Procedure:
1. 2. 3. 4.
If components independent:
Assign all points (pixel values) to the cluster defined by the closest centroid
Utilized appropriate distance metric (Euclidian, city block, etc.)
Density is a delta
No longer separable
Prof. Barner, ECE Department, University of Delaware 29
Repeat Steps 2 and 3 until centroid movements areto below a fixed threshold
Prof. Barner, ECE Department, University of Delaware 30
Fingerprint Example
10 9 8 7 6 5
3 2 1 0 0 1 2 3 4 5 6 7 8 9 10
4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10
reassign
10 9 8
10 9 8 7 6
reassign
Input image: grayscale Histogram shows two modes Set threshold with Kmeans algorithm
K=2
7 6 5 4 3 2 1
Java Demo
Image Processing Image Segmentation
0 0 1 2 3 4 5 6 7 8 9 10
5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10
31
32
Statistical modeling
Relaxation of K-means
Objective: given N observed samples, determined all parameters = (,1,2) = (,1,21,2,22) Estimation technique: Maximum Likelihood
Log-likelihood function:
L ( ; Z) = log[(1 i ) p ( yi ) + i p 2 ( yi )]
i =1
1
34
Given L ( ; Z, ) = log[(1 i ) p ( yi ) + i p 2 ( yi )]
Case 1:
i =1
ML estimates of 1 and 21 are the sample mean and variance for all samples with i = 0 ML estimates of 2 and 22 are the sample mean and variance for all samples with i = 1
3.
Case 2:
Solution: proceed in an iterative fashion utilizing a the expected values of is ( ) = E ( i | , Z) = Pr( i = 1| , Z) These are hidden terms, referred to as responsibilities
(1 ) y (1 ) y =
N i =1 N i i =1 i
2 1 =
N i =1
1 ) 2 (1 i )( yi
N i =1
(1 i )
i =1 i N i =1
2 2
2 )2 ( yi i =1 i
N N i =1
Determined using soft assignments of all samples and the probability of a sample being from distribution #2
Prof. Barner, ECE Department, University of Delaware 35
4.
Model samples as three Gaussian mixtures Initialize with guess Colors indicate probability of belonging to each parent distribution Shown:
Samples with probabilities Initial guess distributions Distribution variance contour Iterations 1-6 and final result (iteration 20)
Prof. Barner, ECE Department, University of Delaware
Shown:
Java Demo
37
38
Simple approach:
1 =
i =1 N
(1 i ) yi (1 i )
2 =
i =1
i =1 i N
yi
i =1 i
Generalizations
Fuzzy C-Means
Example: K-means
Samples assigned to more than one cluster membership function Assignments are functions of distance More robust
Prof. Barner, ECE Department, University of Delaware 39
Shown:
10
Enlargements of:
Bimodal histogram
Solution:
Finer partitioning
Prof. Barner, ECE Department, University of Delaware
41
42
Objective:
= P2 p2 (T ) P 1 p1 (T )
P2 p2 (T ) = P 1 p1 (T )
P 1 2 1
( z 1 ) 2 212
P2 2 2
( z 2 )2
2 2 2
Automatically outline heart ventricle boundaries Utilizes contrast medium Intensity log mapping to counter exponential radioactive absorption effects Subtraction of base (noncontrast) image Image (frame) averaging to reduce noise Subdivide image Generate local histograms
Prof. Barner, ECE Department, University of Delaware 44
Preprocessing:
Results may yield two thresholds If both distributions have a common variance, 2:
T=
Procedure:
1 + 2
2
P 1 ln 2 + 1 2 P 1
43
11
Region-Based Segmentation
Procedure (contd):
Fit (uni/bi-modal) Gaussian distributions to histograms For blocks with bimodal distributions:
Previous approaches utilized continuities and/or pixel value attributes (gray value)
They do not operate on or directly consider regions Let R be the entire image region Segment R into n subregions, R1, R2,, Rn, such that:
(a) Ri = R.
i =1 n
Region-based formulation:
(b) Ri is a connected region, i = 1, 2,..., n. (c) Ri R j = for all i and j , i j. (d) P ( Ri )=TRUE for i=1,2,...,n. (e) P ( Ri R j )=FALSE for i j.
45
46
Region Growing
Approach:
Objective:
Segment x-ray image to identify weld failures All pixels having maximum (255) value Absolute gray value difference 65
Criteria examples: gray level, texture, color, size, shape Multiple criteria: gray value and size, etc.
Iterative procedure
How to set the seed regions, number of regions? How to set criteria? When to stop?
47
48
12
Shown results:
Merge and/or split the set of regions to satisfy region segmentation conditions
Observations:
Quadtree method:
Histogram is not suited to strict thresholding Connectivity criteria critical to satisfactory result
Prof. Barner, ECE Department, University of Delaware
Split into four disjoint quadrants any region Ri for which P(Ri)=FALSE Merged in the adjacent regions Ri and Rk for which P(RiRk)=TRUE Stop when no further merging or splitting is possible
Prof. Barner, ECE Department, University of Delaware 50
49
Morphology
Homogeneity criteria:
Useful in the representation and description of region shapes Examples: boundaries, skeletons and convex hulls Typically applied to binary images Multilevel extensions exist
Prof. Barner, ECE Department, University of Delaware 52
Set operations
51
13
Dilation
The set of all displacements, z, such that the reflection of B and A overlap by at least one element
z
= { | = b, for b B} B
for a A}
Prof. Barner, ECE Department, University of Delaware 53
Rewrite dilation: A B = {z | ( B) A A}
Translation ( A) z = {c | c = a + z ,
Dilation Example
Erosion
Dilation application:
Filling in gaps
Example:
Scanned text
The erosion of A by B : AB={z|(B)z A} Result: The set of all displacements, z, such that B, translated by z, is contained in A Note dilation and erosion are duels of each other with the respective complementation and reflection: (AB)c=Ac B
Prof. Barner, ECE Department, University of Delaware 56
55
14
Erosion Example
Opening
A function of detail (structuring element) size Erosion removes (and shrinks) details Postprocess through dilation: expands remaining details
Opening smooths the contour of an object, breaks narrow isthmuses, and eliminates in protrusions
57
58
Closing
Closing smooths the contour of an object, fuses narrow breaks and long thin gulfs, eliminate small holes, and fills gaps in the contour
Ai B = ( A B ) B
Opening and closing our duels of each other with respect to complementation and reflection
59
60
15
Points belonging to a regional minimum Points that drain to a common minimum point
A drop of water released at all such points flows downhill, reaching a common minimum Points referred to as catchment basin or watershed points Points referred to as divide or watershed lines
Operations:
Closing
Interpretation:
Punch a hole in each regional minimum Flood entire topography from below with rising water Build dams to prevent catchment basins from merging Once fully flooded, only dams remain
Let M1 and M2 denote the set of points and two regional minima Catchment basins associated with the two regional minima:
Defines a set of points (pixel locations) that drain to each of the minima Flooding stage denoted by: n-1
C[n-1] has two connected components At step n there is a single, one connected component, q
Prof. Barner, ECE Department, University of Delaware 64
63
16
Dam construction:
The dilation is constrained to q Dilation is not performed on points that cause the sets to merge
Example:
The watershed algorithm is typically applied to a gradient image Regional minima (coordinates) in image g(x,y): M1, M2,, MR Set containing the coordinates of the samples in the catchment basin associated with Mi: C (Mi) Set of image points less than threshold n:
T [ n ] = {( s, t ) | g ( s, t ) < n}
Flood the image, and mark all pixels < the flood plane g(x,y)=n Set containing (coordinates) of points in catchment basin C (Mi) that are < n
Cn ( M i ) = C ( M i ) T [ n ]
Condition 1 violations: some dilations outside q (not shown) Point satisfying both conditions constitute dams Marked with xs
Prof. Barner, ECE Department, University of Delaware
Binary image (set) indicating if catchment basin points are > n (1) < n (0)
65
66
Set of connected components in T[n]: Q[n] Three possibilities for each qQ[n]:
1.
q C[n-1] is empty
C [ max + 1] = C ( M i )
i =1
A new minimum is encountered Incorporate q into C[n-1] to form C[n]: C[n]=q C[n-1] Connected component q lies within the catchment basin of the some regional minimum (q Cn-1(Mi)) Incorporate q into C[n-1] to form C[n]: C[n]=q C[n-1] A ridge separating two (or more) catchment basins is encountered A damn is built to prevent flooding across basins Dilate qC[n-1] with a 3x3 structuring element, restricting the dilation to q See previous description
Prof. Barner, ECE Department, University of Delaware
Maximum image value: max Minimum image value: min Each connected component in C[n-1] is contained in exactly one connected component of T[n]
Prof. Barner, ECE Department, University of Delaware 67
2.
Note: C[n-1]C[n]T[n]
3.
68
17
Over Segmentation
Watershed advantages:
Watershed disadvantages:
Excessive number of minima Preprocessing filtering Restrict minima by using markers Merged generated regions
69
70
Region that is surrounded by greater magnitude points Points in region form a connected component Points in the connected component have the same gray level value Light gray denotes markers Markers are the only allowable minima Each region contains a single marker and background Partition each region into foreground and background
Apply watershed
Each region is considered in independent image Final results consist of boundaries around the foreground in each marker defined region
71
72
18