Advanced Digital Image Processing
• Interpolation
• Image Segmentation
Spring 2019
Adil Masood Siddiqui
[email protected]
Scaling
Rotation
Desirable properties for Interpolation
Normalized B Spline
Constant Interpolation
Constant Interpolation
Linear Interpolation
B Spline Interpolation Function
B Spline Interpolation Functions
B Spline Interpolation Functions
B Spline Interpolation Functions
Modified B Spline Functions
Cubic Interpolation
Cubic B Spline Interpolation
Example
Bilinear Interpolation
Nearest Neighbor Interpolation
Image Scaling
Image Scaling
Image Rotation
Image Segmentation
• The process of subdividing and image into its
constituent parts or objects, for further
analysis of objects.
• But there is a limit to which we should stop
dividing the image, which should be
application dependent.
Image Segmentation Techniques
• Discontinuity Based
– Isolated Points
– Lines
– Edges
• Similarity Based
– Thresholding
– Region Growing
– Region Splitting and Merging
Discontinuity Based Techniques
• Mask is used.
• Point Detection
– If the result is greater than some non-negative
threshold then we say that an isolated point exists
-1 -1 -1
-1 8 -1
-1 -1 -1
Line Detection
Calculate the absolute value of each mask and higher value will give us
the direction of the line corresponding to the direction of line.
-1 -1 -1 -1 -1 2
2 2 -2 -1 2 -1
-1 -1 -1 2 -1 -1
45
Horizontal
-1 2 -1 2 -1 -1
-1 2 -1 -1 2 -1
-1 2 -1 -1 -1 2
vertical -45
Second order derivatives are sensitive to noise but it can be used for further anlysis of
images e,g zero crossings gives the exact local of edges.
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators
Operators
• First-order derivatives:
– The gradient of an image f(x,y) at location (x,y) is defined
as the vector:
G x f
x
f f
G
y y
x
– The magnitude of this vector: f mag (f ) G 2 G 2
y
1
2
– The direction of this vector: Gx
( x, y ) tan
1
Gy
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators
Operators
Roberts cross-gradient operators
Prewitt operators
Sobel operators
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators
Operators
Prewitt masks for
detecting diagonal edges
Sobel masks for
detecting diagonal edges
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators:
Operators: Example
Example
f G x G y
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators:
Operators: Example
Example
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators:
Operators: Example
Example
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators
Operators
• Second-order derivatives: (The Laplacian)
– The Laplacian of an 2D function f(x,y) is defined as
2 f 2 f
f 2 2
2
x y
– Two forms in practice:
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators
Operators
• Consider the function: A Gaussian function
r2
2
h( r ) e 2
where r 2 x 2 y 2
and : the standard deviation
• The Laplacian of h is
r2 The Laplacian of a Gaussian
r 2 2 2
(LoG)
h( r )
2
e
2
4
• The Laplacian of a Gaussian sometimes is called the Mexican
hat function. It also can be computed by smoothing the image
with the Gaussian smoothing mask, followed by application of
the Laplacian mask.
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators
Operators
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators:
Operators: Example
Example
Sobel gradient
Gaussian smooth function Laplacian mask
Detection
Detection of
of Discontinuities
Discontinuities
Gradient
Gradient Operators:
Operators: Example
Example
Edge Linking Approaches
• Local processing
• Global Processing
Local Processing
• Image is already operator by Sobel Edge
Detector
Edge Linking and Boundary Detection
Edge
Edge Linking
Linking and
and Boundary
Boundary Detection
Detection
Local
Local Processing
Processing
• Two properties of edge points are useful for edge linking:
– the strength (or magnitude) of the detected edge points
– their directions (determined from gradient directions)
• This is usually done in local neighborhoods.
• Adjacent edge points with similar magnitude and direction are
linked.
• For example, an edge pixel with coordinates (x0,y0) in a
predefined neighborhood of (x,y) is similar to the pixel at (x,y)
if
f ( x, y ) ( x0 , y0 ) E , E : a nonnegativ e threshold
( x, y ) ( x0 , y0 ) A, A : a nonegative angle threshold
Edge
Edge Linking
Linking and
and Boundary
Boundary Detection
Detection
Local
Local Processing:
Processing: Example
Example
In this example,
we can find the
license plate
candidate after
edge linking
process.
Hough Transform
Edge
Edge Linking
Linking and
and Boundary
Boundary Detection
Detection
Global
Global Processing
Processing via
via the
the Hough
Hough Transform
Transform
• Hough transform: a way of finding edge points in an image
that lie along a straight line.
• Example: xy-plane v.s. ab-plane (parameter space)
yi axi b
Edge
Edge Linking
Linking and
and Boundary
Boundary Detection
Detection
Global
Global Processing
Processing via
via the
the Hough
Hough Transform
Transform
• The Hough transform consists of
finding all pairs of values of and
which satisfy the equations
that pass through (x,y).
• These are accumulated in what is
basically a 2-dimensional
histogram.
• When plotted these pairs of
and will look like a sine wave.
The process is repeated for all
x cos y sin
appropriate (x,y) locations.
Edge
Edge Linking
Linking and
and Boundary
Boundary Detection
Detection
Hough
Hough Transform
Transform Example
Example
The intersection of the curves
corresponding to points 1,3,5
2,3,4
1,4
Edge
Edge Linking
Linking and
and Boundary
Boundary Detection
Detection
Hough
Hough Transform
Transform Example
Example
Thresholding
Thresholding
• Assumption: the range of intensity levels covered by objects
of interest is different from the background.
1 if f ( x, y ) T
g ( x, y )
0 if f ( x, y ) T
Single threshold Multiple threshold
Thresholding
Thresholding
The
The Role
Role of
of Illumination
Illumination
Thresholding
Thresholding
The
The Role
Role of
of Illumination
Illumination
r ( x, y ) (a) (c) i ( x, y )
(d) (e)
f ( x, y ) i ( x, y ) r ( x, y )
Thresholding
Thresholding
Basic
Basic Global
Global Thresholding
Thresholding
Thresholding
Thresholding
Basic
Basic Global
Global Thresholding
Thresholding
Thresholding
Thresholding
Basic
Basic Adaptive
Adaptive Thresholding
Thresholding
Thresholding
Thresholding
Basic
Basic Adaptive
Adaptive Thresholding
Thresholding
How to solve this problem?
Thresholding
Thresholding
Basic
Basic Adaptive
Adaptive Thresholding
Thresholding
Answer: subdivision
Thresholding
Thresholding
Optimal
Optimal Global
Global and
and Adaptive
Adaptive Thresholding
Thresholding
• This method treats pixel values as probability density functions.
• The goal of this method is to minimize the probability of
misclassifying pixels as either object or background.
• There are two kinds of error:
– mislabeling an object pixel as background, and
– mislabeling a background pixel as object.
Thresholding
Thresholding
Use
Use of
of Boundary
Boundary Characteristics
Characteristics
Thresholding
Thresholding
Thresholds
Thresholds Based
Based on
on Several
Several Variables
Variables
Color image
Region-Based
Region-Based Segmentation
Segmentation
• Edges and thresholds sometimes do not give good
results for segmentation.
• Region-based segmentation is based on the
connectivity of similar pixels in a region.
– Each region must be uniform.
– Connectivity of the pixels within the region is very
important.
• There are two main approaches to region-based
segmentation: region growing and region splitting.
Region-Based
Region-Based Segmentation
Segmentation
Basic
Basic Formulation
Formulation
• Let R represent the entire image region.
• Segmentation is a process that partitions R into subregions,
R1,R2,…,Rn, such that
n
(a) Ri R
i 1
(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 any adjacent regions Ri and R j
where P(Rk): a logical predicate defined over the points in set Rk
For example: P(Rk)=TRUE if all pixels in Rk have the same gray
level.
Region-Based
Region-Based Segmentation
Segmentation
Region
Region Growing
Growing
Region-Based
Region-Based Segmentation
Segmentation
Region
Region Growing
Growing
• Fig. 10.41 shows the histogram of Fig. 10.40 (a). It is difficult to
segment the defects by thresholding methods. (Applying region
growing methods are better in this case.)
Figure 10.40(a) Figure 10.41
Region-Based
Region-Based Segmentation
Segmentation
Region
Region Splitting
Splitting and
and Merging
Merging
• Region splitting is the opposite of region growing.
– First there is a large region (possible the entire image).
– Then a predicate (measurement) is used to determine if
the region is uniform.
– If not, then the method requires that the region be split
into two regions.
– Then each of these two regions is independently tested by
the predicate (measurement).
– This procedure continues until all resulting regions are
uniform.
Region-Based
Region-Based Segmentation
Segmentation
Region
Region Splitting
Splitting
• The main problem with region splitting is determining where to
split a region.
• One method to divide a region is to use a quadtree structure.
• Quadtree: a tree in which nodes have exactly four descendants.
Image Segmentation