Notes Dip Full
Notes Dip Full
By:
Dr. Ankush Agarwal
Outline
© ankush agarwal 3
Image
© ankush agarwal 4
Digital Image
© ankush agarwal 5
Difference
• Analog Image
– It represents the continuous range of values
– Eg: Image produced by CRT monitor
• Digital Image
– It represents the discrete values
– It is composed of picture elements called pixels
© ankush agarwal 4
Image Acquisition
C
© ankush agarwal 7
Process involved in Digital Image
© ankush agarwal 8
Process involved in Digital Image
© ankush agarwal 9
Process involved in Digital Image
• Discretization
– Process in which signals or data samples are considered at regular
intervals
• Sampling
– It is the discretization of image data in spatial coordinates or defining
finite discrete coordinate to every part of an image
• Quantization
– It is the discretization of image intensity (gray level) values or defining
finite value to every discrete interval
© ankush agarwal 10
Sampling and Quantization
© ankush agarwal 11
Sampling and Quantization
© ankush agarwal 11
Sampling and Quantization
© ankush agarwal 11
Sampling and Quantization
before after
© ankush agarwal 12
Sensor Arrangement
© ankush agarwal 13
Sensor Arrangement
© ankush agarwal 13
Sensor Arrangement
© ankush agarwal 13
Digital Image Representation
© ankush agarwal 14
Digital Image Representation
© ankush agarwal 15
Image Samples
© ankush agarwal 16
Image Size
• For an image of size m x n, if k are the number of bits for representation, then
Image size = m x n x k
© ankush agarwal 17
Image Size
• Eg:
– For an image of 512 by 512 pixels, with 8 bits per pixel
Solution
Size = 512 * 512 * 8 bits
= 29 * 29 * 23 bits
= 221/23 bytes
= 218/210 K bytes
= 256 KB
© ankush agarwal 18
Image Size
• Eg:
– For an image of 64 by 64 pixels with 3 bands, with 4 bits per pixel
Solution
Discuss in class
© ankush agarwal 19
Image Size
• Eg:
– For an image of 32 by 32 pixels with 4 bands, in which the smallest unit
of an image consists of 11 shades
Solution
Discuss in class
© ankush agarwal 19
Image Size
• Eg:
– For an image of 10x10x6, the pixels can represent 8 shades
Solution
Discuss in class
© ankush agarwal 19
Image Size
• Eg:
– For an image of 25 by 30 pixels with 5 spectral, the pixels have 17 levels
Solution
Discuss in class
© ankush agarwal 19
Motivation
• Practical applications
– Quantitative measurements
– Automatic analysis of images
© ankush agarwal 20
Perspective
© ankush agarwal 21
Applications
© ankush agarwal 22
Applications
© ankush agarwal 22
Applications
© ankush agarwal 22
Applications
© ankush agarwal 22
Applications
© ankush agarwal 22
Applications
© ankush agarwal 22
Applications
© ankush agarwal 22
Applications
© ankush agarwal 22
Image Sensing
© ankush agarwal 23
Image Resolutions
© ankush agarwal 24
Spatial Resolution
© ankush agarwal 25
Spatial Resolution
16 x 16
32 x 32
64 x 64
128 x 128
256 x 256
512 x 512
© ankush agarwal 26
Spatial Resolution
© ankush agarwal 27
Spatial Resolution
© ankush agarwal 28
Various sensors image
© ankush agarwal 29
Spectral Resolution
© ankush agarwal 30
Spectral Resolution
© ankush agarwal 32
Temporal Resolution
© ankush agarwal 33
Temporal Resolution
Sentinel-2
RGB
© ankush agarwal 35
Radiometric Resolution
© ankush agarwal 36
Radiometric Resolution
© ankush agarwal 37
Type of effects
© ankush agarwal 38
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 39
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 40
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 41
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 41
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 42
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 42
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 43
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 44
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 44
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 45
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 46
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 46
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 47
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 48
Key Stages in Digital Image Processing
Image Morphological
Segmentation
Restoration Processing
Image Object
Enhancement Recognition
Image Representation
Acquisition and Description
© ankush agarwal 48
Image types
© ankush agarwal 59
Types of Images
© ankush agarwal 60
Aspect Ratio
© ankush agarwal 61
Aspect Ratio
• Eg:
– If we want to resize a 1024x768 image to one that is 600 pixels wide with
the same aspect ratio as the original image, what should be the height of
the resized image?
Solution
Aspect Ratio = width/height
= 1024/768
= 1.33
Height = 600/1.33
= 451
© ankush agarwal 62
Aspect Ratio
• Eg:
– Suppose, we have an image that have 16 rows and have a aspect ratio of 1
or 1:1. Find the total number of pixels in the image.
Solution
in class
© ankush agarwal 63
Aspect Ratio
• Eg:
– Suppose, an image have an aspect ratio of 3:2 with a width of 36 mm.
Find the height of the image.
Solution
in class
© ankush agarwal 64
Baud Rate
© ankush agarwal 65
Baud Rate
• Eg:
– How many minutes would it take to transmit a 1024 x 1024 image with
256 gray levels using a 56K baud rate?
Solution
Total no. of bits needed to represent the image: 1024 x 1024 x 8
No. of packets required: 1024 x 1024
Total no. of bits that need to be transferred: 1024 x 1024 x [8 + 2]
Total time required: 1024 x 1024 x [8 + 2]/56000
= 187.25 sec or 3.1 min
© ankush agarwal 66
Baud Rate
• Eg:
– Compute the time required to transmit an image of 64 x 64 with 32 gray
levels using a 20 b/s.
Solution
In class
© ankush agarwal 66
Baud Rate
• Eg:
– Compute the time required to transmit an image of 200 x 200 consists of
4 bands with 9 gray levels using a 10 b/s.
Solution
In class
© ankush agarwal 66
Baud Rate
• Eg:
– Compute the time required to transmit an image of 32 x 32 consists of 7
bands with 11 levels using a 7 b/s.
Solution
In class
© ankush agarwal 66
Baud Rate
• Eg:
– Compute the time required to transmit an image having a width of 200
and a aspect of 2:5 using a 7 b/s. It consists of 4 bands with 4 bits per
pixels.
Solution
In class
© ankush agarwal 66
Basic relationship between pixels
© ankush agarwal 67
Basic relationship between pixels
• Neighborhood
• Adjacency
• Connectivity (i-1, j-1) (i-1, j) (i-1, j+1)
• Paths
• Regions and boundaries
(i, j-1) (i, j) (i, j+1)
© ankush agarwal 68
Basic relationship between pixels (Neighbours)
p
(i, j-1) (i, j+1)
(i, j)
(i+1, j)
© ankush agarwal 69
Basic relationship between pixels (Neighbours)
p
(i, j)
© ankush agarwal 70
Basic relationship between pixels (Adjacency)
• Two pixels are adjacent if they are neighbour and their intensity
level ‘V’ satisfy some specific criteria of similarity
• Let V be the set of intensity values
© ankush agarwal 71
Basic relationship between pixels (Adjacency)
• 4-adjacency: Two pixels p and q with values from set ‘V’ are 4-
adjacent if q is in the set N4(p)
• Eg:
– V = {0, 1}
1 1 0
1 1 0
1 0 1
© ankush agarwal 72
Basic relationship between pixels (Adjacency)
• 8-adjacency: Two pixels p and q with values from set ‘V’ are 8-
adjacent if q is in the set N8(p)
• Eg:
– V = {1, 2}
0 1 1
0 2 0
0 0 1
© ankush agarwal 73
Basic relationship between pixels (Adjacency)
• Eg:
0 1 1
0 1 0
0 0 1
© ankush agarwal 74
Basic relationship between pixels (Adjacency)
• Eg:
0 1 1
0 1 0
0 0 1
© ankush agarwal 74
Basic relationship between pixels (Adjacency)
• Eg:
0 1 1
0 1 0
0 0 1
© ankush agarwal 74
Basic relationship between pixels (Adjacency)
• Eg:
0 1 1
0 1 0
0 0 1
© ankush agarwal 74
Basic relationship between pixels (Adjacency)
• Eg:
– Find 4-adjacency and 8-adjacency of the center pixel
– Note: V = {1}
Solution
– 4-adjacency
0 1 1
0 1 0
0 0 1
© ankush agarwal 76
Basic relationship between pixels (Adjacency)
• Eg:
– Find 4-adjacency and 8-adjacency of the center pixel
– Note: V = {1}
Solution
– 8-adjacency
0 1 1
0 1 0
0 0 1
© ankush agarwal 76
Basic relationship between pixels (Connectivity)
© ankush agarwal 77
Basic relationship between pixels (Path)
© ankush agarwal 78
Basic relationship between pixels (Path)
• Eg:
– Compute the length of shortest-4 path between pixels p and q, where V =
{1, 2}
Solution
4 2 3 2 q
x
3 3 1 3
2 3 2 2
p 2 1 2 3
© ankush agarwal 79
Basic relationship between pixels (Path)
• Eg:
– Compute the length of shortest-8 path between pixels p and q, where V =
{1, 2}
Solution
4 2 3 2 q
3 3 1 3
2 3 2 2
p 2 1 2 3
© ankush agarwal 80
Basic relationship between pixels (Path)
• Eg:
– Compute the length of shortest-m path between pixels p and q, where V =
{1, 2}
Solution
4 2 3 2 q
3 3 1 3
2 3 2 2
p 2 1 2 3
© ankush agarwal 81
Basic relationship between pixels (Region)
© ankush agarwal 82
Distance Measure
© ankush agarwal 83
Distance Measure
© ankush agarwal 84
Distance Measure (Euclidean Distance)
© ankush agarwal 85
Distance Measure (City-block Distance)
© ankush agarwal 86
Distance Measure (Chessboard Distance)
© ankush agarwal 89
Some Mathematical Tools (Arithmetic Operations)
© ankush agarwal 92
Some Mathematical Tools (Mask Mode Radiography)
© ankush agarwal 93
Some Mathematical Tools
• Eg:
– Blood stream is injected with a dye and X-ray images are taken before
and after the injection
– f(x, y): image after injecting a dye
– h(x, y): image before injecting the dye
© ankush agarwal 94
Some Mathematical Tools (Image Averaging)
• A noisy image:
g ( x, y ) f ( x, y ) n ( x, y )
• Averaging M different noisy images:
M
1
g ( x, y )
M
g ( x, y )
i 1
i
© ankush agarwal 95
Some Mathematical Tools (Shading Correction)
© ankush agarwal 97
Some Mathematical Tools (Region of Interest)
© ankush agarwal 98
Some Mathematical Tools (Set Operations)
© ankush agarwal 99
Some Mathematical Tools (Logical Operations)
© ankush agarwal 97
Recap
• Digital Image
• Steps of Image Acquisition
– (4 steps)
• Process involved in Digital image
– (Sampling and Quantization)
• Sensor arrangement
– (Single, Line, Array)
• Levels in image
– (L = 2k)
• Image size
– (m x n x k)
• Applications of Image Processing
• Image sensing
– (EMS)
© ankush agarwal 97
Recap
• Types of resolutions
– (Spatial, Spectral, Temporal, Radiometric)
• Types of effect
– (Checkerboard, False contouring)
• Key stages of Image Processing
• Aspect ratio
– (r = w/h)
• Baud rate
• Relationship between pixels
– (Neighbour: N4, ND, N8, Adjacency: 4-, 8-, m-, Connectivity, Path: 4-, 8-, m-,
Region)
• Distance measure
– (Euclidean, City block, Chess board)
• Set operations
© ankush agarwal 97
GLA UNIVERSITY
By:
Dr. Ankush Agarwal
Outline
© ankush agarwal 3
Image Enhancement
© ankush agarwal 4
Image Enhancement
© ankush agarwal 5
Image Enhancement
• Applications of transformations
– Contrast enhancement
– Gray scale transformation
– Photometric calibration
– Display calibration
– Contour lines
© ankush agarwal 6
Image Enhancement
Image Enhancement
Frequency
Spatial Domain
Domain
Intensity Transformation
Spatial Filtering
© ankush agarwal 7
Image Enhancement
© ankush agarwal 8
Image Enhancement (Spatial domain)
© ankush agarwal 9
BASIC INTENSITY TRANSFORMATIONS
© ankush agarwal 11
Basic Intensity Transformations
• Linear transformations
– Image negative
• Non-linear transformations
– Logarithmic transformation
– Power Law (Exponential) transformation
• Piecewise-linear transformations
– Contrast stretching
– Gray-level slicing
– Bit plane slicing
• Histogram
© ankush agarwal 12
Image Enhancement (Spatial Intensity)
© ankush agarwal 13
Image Enhancement (Spatial Intensity)
© ankush agarwal 14
Image Enhancement (Spatial Intensity)
© ankush agarwal 15
Image Enhancement (Spatial Intensity)
© ankush agarwal 16
Image Enhancement (Spatial Intensity)
© ankush agarwal 17
Image Enhancement (Spatial Intensity)
© ankush agarwal 18
Image Enhancement (Spatial Intensity)
Piecewise-Linear Transformation
• A complementary approach to the previous methods
• Practical implementation of some important transformations can
be formulated only as piecewise functions
© ankush agarwal 19
Piecewise-Linear (Contrast Stretching)
© ankush agarwal 20
Piecewise-Linear (Contrast Stretching)
• (a) increase the dynamic range of the gray levels in the image
• (b) a low-contrast image
• (c) result of contrast stretching
– (r1, s1) = (rmin, 0)
– (r2, s2) = (rmax, L-1)
• (d) result of thresholding
© ankush agarwal 21
Image Enhancement (Spatial Intensity)
• The gray level below m are darkened and the levels above m are
brightened or vice-versa
• Produces a binary image from input image and the function is
known as thresholding function
g(x, y) = L if f(x, y) > m,
0 otherwise
© ankush agarwal 22
Piecewise-Linear (Gray level slicing)
© ankush agarwal 23
Piecewise-Linear (Bit-plane slicing)
© ankush agarwal 25
Piecewise-Linear (Bit-plane slicing)
© ankush agarwal 26
HISTOGRAM PROCESSING
© ankush agarwal 27
Histogram Processing
© ankush agarwal 28
Histogram Processing
2 3 3 2
4 2 4 3
3 2 3 5
2 4 2 4
© ankush agarwal 29
Normalized Histogram
© ankush agarwal 30
Histogram Processing
• Eg:
– An image with gray levels between 0 to 7 is given below. Find the
histogram of an image and normalize it
1 6 2 2
1 3 3 3
4 6 4 0
1 6 4 7
© ankush agarwal 31
Histogram Processing
© ankush agarwal 32
Histogram Processing
© ankush agarwal 32
Histogram Processing
© ankush agarwal 33
Histogram Processing
© ankush agarwal 33
Histogram Equalization
© ankush agarwal 34
Histogram Equalization
© ankush agarwal 35
Histogram Equalization
© ankush agarwal 36
Histogram Equalization
• The following equations bring back the gray levels in the range [0, L-1]
s j T (r j )
k
(L 1) p(rj )
j 0
k nj
(L 1)
j 0 MN
(L 1) k
• M – no. of rows
MN j 0
nj k 0,1,..., L 1
• N – no. of columns
• MN – total no. of pixels in the image
© ankush agarwal 37
Histogram Equalization
• Eg:
– Suppose that a 3-bit image (L = 8) of size 64 × 64 pixels (MN = 4096) has
the intensity distribution shown in following table. Get the histogram
equalization transformation function and give the p(sk) for each sk
© ankush agarwal 38
Histogram Equalization
i/p Gray Level no. of pixels p(rk) = nk/MN Σ (L-1)Σ o/p Gray
(rk) (nk) Level (s)
0 790 0.19 0.19 1.33 1
1 1023 0.25 0.44 3.08 3
2 850 0.21 0.65 4.55 5
3 656 0.16 0.81 5.67 6
4 329 0.08 0.89 6.23 6
5 245 0.06 0.95 6.65 7
6 122 0.03 0.98 6.86 7
7 81 0.02 1.00 7.00 7
© ankush agarwal 39
Histogram Equalization
© ankush agarwal 40
Histogram Equalization
© ankush agarwal 41
Histogram Matching (Specification)
© ankush agarwal 44
Histogram Matching (Specification)
• Eg:
– Suppose that a 3-bit image of size 64 × 64 pixels has the intensity
distribution shown in the table (on the left). Get the histogram
transformation function and make the output image with the specified
histogram, listed in the table on the right
© ankush agarwal 45
Histogram Matching (Specification)
© ankush agarwal 46
Histogram Matching (Specification)
© ankush agarwal 47
Histogram Matching (Specification)
© ankush agarwal 47
Histogram Matching (Specification)
© ankush agarwal 47
Histogram Matching (Specification)
© ankush agarwal 47
Histogram Matching (Specification)
© ankush agarwal 47
Histogram Matching (Specification)
© ankush agarwal 47
Histogram
• Question:
– What will be the effect on the histogram if we shuffle the pixels within the
image?
Answer:
• It’s histogram won’t change. No point processing will be affected
© ankush agarwal 48
Local Enhancement
© ankush agarwal 49
SPATIAL FILTERING
© ankush agarwal 50
Spatial Filtering
© ankush agarwal 50
Spatial Filtering
• The process consists simply of moving the filter mask from point
to point in an image
• At each point (x, y), the response of the filter at that point is
calculated using a predefined relationship
R w1 z1 w2 z 2 ... wmn z mn
mn
w z
i i
i i
© ankush agarwal 52
Mechanics of Spatial filtering
Origin x
Original Image
Pixels
Image f (x, y)
y
© ankush agarwal 53
Mechanics of Spatial filtering
Origin x
e *
Original Image Filter
Pixels
Image f (x, y)
y
© ankush agarwal 53
Mechanics of Spatial filtering
Origin x
e *
Original Image Filter
Pixels
eprocessed = r*a + s*b + t*c +
u*d + v*e + w*f +
x*g + y*h + z*i
The above is repeated for every pixel in the
Image f (x, y) original image to generate the filtered image
y
© ankush agarwal 53
Smoothing Spatial Filters
© ankush agarwal 55
Linear filters Average filter
1 1 1 1
9
1 1 1
© ankush agarwal 56
Linear filters Average filter (Results)
© ankush agarwal 58
Linear filters Weighted average filter
1 2 1
1
2 4 2
16
1 2 1
© ankush agarwal 59
Non-linear filters Order statistics filters
© ankush agarwal 60
Non-linear filters Order statistics filters Median
filter
Solution:
• 10, 15, 20, 20, 20, 20, 20, 25, 100
© ankush agarwal 61
Non-linear filters Order statistics filters Min filter
Solution:
• 10, 15, 20, 20, 20, 20, 20, 25, 100
© ankush agarwal 62
Non-linear filters Order statistics filters Max filter
Solution:
• 10, 15, 20, 20, 20, 20, 20, 25, 100
© ankush agarwal 63
Non-linear filters Order statistics filters Median
filter
• Advantages:
– Removes impulsive noise
– Preserves edges
• Disadvantages:
– performance poor when # of noise pixels in the window is greater than 1/2
# in the window
– performs poorly with Gaussian noise
© ankush agarwal 64
Non-linear filters Order statistics filters Median
filter
© ankush agarwal 66
Sharpening Spatial Filters
© ankush agarwal 67
Derivative operator
© ankush agarwal 68
Derivative operator
• Eg:
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 . . .
© ankush agarwal 69
Derivative operator
© ankush agarwal 70
Derivative operator Laplacian (Second derivative)
x y 1 -4 1
0 1 0
© ankush agarwal 71
Derivative operator Laplacian (Second derivative)
0 1 0 0 -1 0
1 -4 1 -1 4 -1 90° isotropic
0 1 0 0 -1 0
1 1 1 -1 -1 -1
45° isotropic 1 -8 1 -1 8 -1
1 1 1 -1 -1 -1
© ankush agarwal 72
Derivative operator Laplacian (Second derivative)
• As it is a derivative operator,
– it highlights gray-level discontinuities in an image
– it deemphasizes regions with slowly varying gray levels
• Tends to produce images that have
– grayish edge lines and other discontinuities, all superimposed on a dark
– featureless background
© ankush agarwal 73
Derivative operator Laplacian (Second derivative)
© ankush agarwal 74
RECAP
© ankush agarwal
Recap
Image Enhancement
Frequency
Spatial Domain
Domain
Intensity Transformation
Spatial Filtering
© ankush agarwal
Recap
• Linear transformations
– Image negative
• Non-linear transformations
– Logarithmic transformation
– Power Law (Exponential) transformation
• Piecewise-linear transformations
– Contrast stretching
– Gray-level slicing
– Bit plane slicing
• Histogram
© ankush agarwal
Recap
By:
Dr. Ankush Agarwal
Outline
© ankush agarwal 3
Fourier Transform
• Even functions that are not periodic (but whose area under the
curve is finite) can be expressed as the integral of sines and/or
cosines multiplied by a weighting function
© ankush agarwal 4
Fourier Transform
© ankush agarwal 5
Fourier Transform
f (x)[cos 2 ux jsin 2 ux] dx
© ankush agarwal 6
Fourier Transform
• Eg:
– Find its Fourier Transform
© ankush agarwal 7
Fourier Transform
Solution
© ankush agarwal 8
Fourier Transform (Discrete)
For u = 0, 1, 2, …, M-1
Where j 1
• Inverse
© ankush agarwal 9
Fourier Transform (Discrete)
• Eg:
– Find the DFT of f(x) = {0, 1, 2, 1}
Euler’s Formula:
© ankush agarwal 10
Fourier Transform (Discrete)
j 2 ux
M 1
F (u ) f ( x) e
x 0
M
Solution
F (0) 0 1 2 1
4
© ankush agarwal 11
Fourier Transform (Discrete)
Solution
j 2 ux
3
F (u 1) f ( x) e M
x 0
j 2 1.0 j 2 1.1 j 2 1.2 j 2 1.3
0.e 3
1.e 3
2.e 3
1.e 3
2
© ankush agarwal 12
Fourier Transform (Discrete)
Solution
F(0) = 4
F(1) = -2
F(2) = 0
F(3) = -2
© ankush agarwal 13
Fourier Transform (Discrete)
• Twiddle factor
– A new factor defined as
WM e j 2 / M
• Now M 1
F (u )
x 0
f ( x) WMux
• Eg:
– If M = 4, then WM will be a 4x4 matrix
© ankush agarwal 15
Fourier Transform (Discrete)
Solution j 2 .0
WM0 e 4
1
j 2 .1
WM1 e 4
cos j sin
2 2
j
© ankush agarwal 16
Fourier Transform (Discrete)
Solution
© ankush agarwal 17
Fourier Transform (Discrete)
© ankush agarwal 18
Fourier Transform (Discrete)
• Eg:
– Find the DFT of the following f(x) = {1,1,0,0}
Solution
• F(u) = {2, 1-j, 0, 1+j}
© ankush agarwal 19
Fourier Transform (Discrete)
• Eg:
– Find the IDFT of the following F(u) = {1,0, 1, 0}
Solution
• f(x) = {0.5, 0, 0.5, 0}
© ankush agarwal 20
Fourier Transform (Discrete)
• Eg:
– Find the DFT of the following image.
0 1 2 1
1 2 3 2
2 3 4 3
1 2 3 2
© ankush agarwal 21
Low pass vs high pass filters
• Low pass filter are used for image smoothing in the frequency
domain
• It removes high frequency noise from the image and preserves
low frequency components
• High pass filter are used for image sharpening in the frequency
domain
• It removes low frequency noise from the image and preserves
high frequency components
© ankush agarwal 22
Ideal filter
• Low pass
1 D(u, v) D 0
H (u, v)
0 D(u, v) D0
• High pass
0 D(u, v) D 0
H (u, v)
1 D(u, v) D 0
• ILPF passes all the frequencies within a circle of radius D0 from
the origin without attenuation and cuts off all the frequencies
outside the circle
• Where,
– D0 is a positive constant
– D(u, v) is the Euclidean Distance from any point (u, v) to the origin
© ankush agarwal 23
Butterworth filter
• It can be expressed as
1
H (u, v)
1 [ D(u, v) / D 0 ]2 n
© ankush agarwal 24
Gaussian filter
• Low pass
D 2 (u,v)/2 2
H (u, v) e
• High Pass
D 2 (u,v)/2 D0 2
H (u, v) 1 e
© ankush agarwal 25
RECAP
© ankush agarwal 26
Recap
F (u ) M
f ( x) e
x 0
• Fourier 1D, 2D
M 1
• Twiddle factor
WM e j 2 / M F (u ) f ( x) W
x 0
ux
M
© ankush agarwal 27
GLA UNIVERSITY
By:
Dr. Ankush Agarwal
Outline
© ankush agarwal 2
MORPHOLOGY
© ankush agarwal 3
Morphology
© ankush agarwal 4
Morphology
© ankush agarwal 4
Set Theory
© ankush agarwal 5
Set Theory
© ankush agarwal 6
Example sets operations
© ankush agarwal 7
Reflection and Translation
• Reflection
– The reflection of a set B, denoted by 𝐵, is defined as
𝐵 = 𝑤|𝑤 = −𝑏, 𝑓𝑜𝑟 𝑏𝐵
• Translation
– The translation of a set B by point z = (z1, z2), denoted by (B)z is defined as
𝐵 𝑧 = 𝑐|𝑐 = 𝑏 + 𝑧, 𝑓𝑜𝑟 𝑏𝐵
© ankush agarwal 8
Reflection and Translation
• Eg:
© ankush agarwal 9
Binary Image
• Binary image
– bi-valued function of x and y
• Morphological theory views
– binary image as a set of its foreground (1-valued) pixels
© ankush agarwal 10
Basic components in Morphology
© ankush agarwal 12
Structuring Elements
© ankush agarwal 13
Fundamental Operations
© ankush agarwal 14
DILATION AND EROSION
© ankush agarwal 15
Dilation
© ankush agarwal 16
Dilation
© ankush agarwal 17
Dilation
• Eg:
© ankush agarwal 18
Dilation
• Eg:
© ankush agarwal 19
Dilation
• Eg:
© ankush agarwal 19
Dilation
• Eg:
© ankush agarwal 19
Dilation
• Eg:
© ankush agarwal 19
Dilation
• Eg:
© ankush agarwal 20
Applications
© ankush agarwal 21
Properties of Dilation
• Dilation is commutative
• Dilation is associative
© ankush agarwal 22
Erosion
I S = {z |(S)z I
– The set of all points z such that, S translated by z, is contained by I
𝐼 𝑆 = 𝑧| 𝑆 𝑍 ∩ 𝐼𝑐 = ∅
• In other words, erosion of I by S is the set of all structuring
element origin locations where the translated S has no overlap
with the background of I
© ankush agarwal 23
Erosion
• Eg:
© ankush agarwal 24
Erosion
• Eg:
© ankush agarwal 24
Erosion
• Eg:
© ankush agarwal 24
Erosion
• Eg:
© ankush agarwal 25
Application
© ankush agarwal 26
Concept
• Binary image
0 1 2 3 4 5 6 7 -1 0 1
0 x Image (I)
-1
Structure Element (S)
1 0 X
2 1
3
I = {(2,2), (3,2), (3,3), (4,3), (4,4), (5,4)}
4
U = {(0,0), ..., (7,7)}
5
S = {(-1,-1), (0,-1)}
6
7
© ankush agarwal 27
Concept
x x x
© ankush agarwal 28
Dilation (by coordinate system)
• Eg:
x x
X
S = {(-1,-1), (0,-1)}
I = {(2,2), (3,2), (3,3), (4,3), (4,4), (5,4)} (1,1), (2,1), (2, 2), (3, 2), (3,3), (4,3)
I S
(2,1), (3,1), (3, 2), (4, 2), (4,3), (5,3)
I S {p | p i s,i I,s S}
(1,1), (2,1), (2, 2), (3,1), (3, 2), (3,3), (4, 2), (4,3), (5,3)
© ankush agarwal 29
Dilation (general definition)
• Eg
x x
S = {(-1,-1), (0,-1)}
I S = {(1,1), (0,1)} ˆ
I S {p | [(S) p I] }
ˆ
{p | [(S) I] I}
p
© ankush agarwal 30
Dilation (as Union of object translation)
• Eg
x x x
X
I I(-1,-1) I(0,-1)
I S sS Is
© ankush agarwal 31
Dilation (as Union of object translation)
• Eg
x x
I
I S sS Is
© ankush agarwal 31
Erosion (by coordinate system)
• Eg:
x x
X
S = {(-1,-1), (0,-1)}
I = {(2,2), (3,2), (3,3), (4,3), (4,4), (5,4)} (3,3) {(1, 1), (0, 1)} {(2, 2), (3, 2)} I
(4, 4) {(1, 1), (0, 1)} {(3,3), (4,3)} I
I S {p | p s I,s S}
(5,5) {(1, 1), (0, 1)} {(4, 4), (5, 4)} I
© ankush agarwal 32
Erosion (general definition)
• Eg
x x
S = {(-1,-1), (0,-1)}
I S {p | (S) p I c }
{p | [(S) p ] I}
I
(3,3), (4, 4), (5,5)
© ankush agarwal 33
Erosion (as Intersection of object translation)
• Eg
x x
I I(1,1)
I S sS Is
© ankush agarwal 34
Erosion (as Intersection of object translation)
• Eg
x x x
X
I I(1,1) I(0,1)
I S sS Is
© ankush agarwal 34
Erosion (as Intersection of object translation)
• Eg
x x
I
I S sS Is
© ankush agarwal 34
Eg:
• Find I S
x
X
© ankush agarwal 35
Eg:
• Find I S
x
X
© ankush agarwal 36
Eg:
• Find I S
x
X
© ankush agarwal 37
Eg:
• Find I S
x
X
© ankush agarwal 38
Eg:
• Find I S
x
X
© ankush agarwal 39
Eg:
• Find I S
x
© ankush agarwal 40
Duality
• Erosion and dilation are duals of each other with respect to set
complementation and reflection
A B z | B Z A
c c
z | B Z A
c c
z | B Z Ac
Ac B
© ankush agarwal 41
Combining Dilation and Erosion
© ankush agarwal 42
OPENING AND CLOSING
© ankush agarwal 43
Opening and Closing
© ankush agarwal 44
Opening and Closing
• Opening
– smooth the contours of an object
– breaks narrow strips
– eliminates thin edges
– it is less destructive than the Erosion
• Closing
– smooth sections of the contours
– fuses narrow breaks & long thin gulfs
– eliminates small holes & fills gaps in the contour
© ankush agarwal 45
Closing
I
© ankush agarwal 46
Closing
I S
© ankush agarwal 46
Closing
I S (I S )S
© ankush agarwal 46
Opening
I
© ankush agarwal 47
Opening
I S
© ankush agarwal 47
Opening
I S (I S ) S
© ankush agarwal 47
HIT OR MISS TRANSFORM
© ankush agarwal 48
Hit or Miss Transform
• Concept:
– Hit object
– Miss background
© ankush agarwal 49
Hit or Miss Transform
• It is given as
I ⊛ S ( I S ) ( I c (W S ))
• It can be written as
I ⊛ S ( I S1 ) ( I c S 2 )
– where,
• S1 is the set formed from elements of S associated with an object (S in this case)
• S2 is the set of elements of S associated with the corresponding background (W –
S)
• The set contains all the points at which, S1 found a match (hit) in
I and S2 found a match in Ic
© ankush agarwal 50
Hit or Miss Transform
© ankush agarwal 51
Hit or Miss Transform
© ankush agarwal 52
Hit or Miss Transform
I S
© ankush agarwal 52
Hit or Miss Transform
Ic x
W-S
© ankush agarwal 53
Hit or Miss Transform
I c (W S) x
W-S
© ankush agarwal 53
Hit or Miss Transform
I ⊛ S ( I S ) ( I c (W S ))
© ankush agarwal 54
Eg
• Find I ⊛ S
0 0 0 0 0 0 0 0 0 0 I x 1 x
0 1 1 1 1 1 1 1 0 0 S 0 1 1
0 1 1 1 1 1 1 1 0 0 0 0 x
0 1 1 1 1 1 1 1 0 0
0 1 1 1 1 1 1 0 0 0
0 1 1 1 1 1 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
© ankush agarwal 55
Eg:
0 0 0 0 0 0 0 0 0 0 x 1 x
0 0 0 0 0 0 0 0 0 0 0 1 1
0 1 1 1 1 1 1 0 0 0 0 0 x
0 1 1 1 1 1 1 0 0 0 S
0 1 1 1 1 1 0 0 0 0
0 1 1 1 1 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
0 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
I S
© ankush agarwal 56
Eg:
1 1 1 1 1 1 1 1 1 1 x 1 x x 0 x
1 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0
1 0 0 0 0 0 0 0 1 1 0 0 x 1 1 x
1 0 0 0 0 0 0 0 1 1 S W-S
1 0 0 0 0 0 0 1 1 1
1 0 0 0 0 0 1 1 1 1
1 0 0 0 0 1 1 1 1 1
1 0 0 0 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
Ic
© ankush agarwal 57
Eg:
0 0 0 0 0 0 0 0 0 1 x 1 x x 0 x
0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0
0 0 0 0 0 0 0 0 0 1 0 0 x 1 1 x
0 0 0 0 0 0 0 0 0 1 S W-S
0 0 0 0 0 0 0 0 1 1
0 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 1 1 1 1
0 1 0 0 0 1 1 1 1 1
0 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0
I c (W S)
© ankush agarwal 57
Eg:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1
0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1
0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1
0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
© ankush agarwal 58
Eg:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
© ankush agarwal 58
Eg
• Find I ⊛ S
0 0 0 0 0 0 0 0 0 0 0 0 I 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0 0 0 S 0 1 1 1 0
0 1 1 1 0 0 0 0 1 1 1 0 0 1 1 1 0
0 1 1 1 0 0 0 0 1 1 1 0 0 1 1 1 0
0 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
© ankush agarwal 59
Eg
• Find I ⊛ S
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I S I c (W S)
© ankush agarwal 60
BOUNDARY EXTRACTION
© ankush agarwal
Boundary Extraction
© ankush agarwal 62
Boundary Extraction
• Eg:
– Find ( I ) (internal boundary)
1 1 1 0 1 1 1 1 1 0 I 1 1 1
1 1 1 0 1 1 1 1 1 0 S 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
© ankush agarwal 63
Boundary Extraction
1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 1 1 1 1 1 0 0 1 0 0 0 1 1 1 0 0
1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 0 0
1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
I S
© ankush agarwal 64
Boundary Extraction
1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0
1 0 1 1 1 0 0 0 1 1 0 1 0 0 0 1 1 1 0 0
1 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
I ( I S ) I S
© ankush agarwal 64
Boundary Extraction
• Eg:
– Find ( I ) (internal and external boundary)
I
x
x
S
© ankush agarwal 65
Boundary Extraction
x x
I S
© ankush agarwal 66
Boundary Extraction
x x
I ( I S ) I S
© ankush agarwal 66
Boundary Extraction
x x
I S
© ankush agarwal 67
Boundary Extraction
x x
(I S ) I I S
© ankush agarwal 67
REGION FILLING
© ankush agarwal 68
Region Filling
© ankush agarwal 69
Region Filling
x
I
S x
© ankush agarwal 70
Region Filling
654 3
43 2 3
2 1 2
1 0 1
2 1 2
© ankush agarwal 71
Region Filling
• Eg:
x
I
S x
© ankush agarwal 72
Region Filling
• Eg: x
I
S x
© ankush agarwal 73
EXTRACTION OF CONNECTED COMPONENTS
© ankush agarwal 74
Extraction of Connected Components
© ankush agarwal 75
Extraction of Connected Components
x
I
S x
© ankush agarwal 76
Extraction of Connected Components
© ankush agarwal 77
Extraction of Connected Components
• Eg: x
I
S x
© ankush agarwal 78
CONVEX HULL
© ankush agarwal 79
Convex Hull
© ankush agarwal 80
Convex Hull
• Steps include
– Choose a seed point X0
– do i = 0 to 3
• Iterate X k ( X k 1 ⊛ Si ) I until convergence
– Minimize convex set using bounding box of I
© ankush agarwal 81
Convex Hull
I
x 1 x x 1 1 1
S 1 0 x x 0 x
1 x x x x x
S0 S1
x x 1 x x x
x 0 1 x 0 x
x x 1 1 1 1
S2 S3
© ankush agarwal 82
Convex Hull
x 1 x x
1 0 x
1 x x
0 1
0 1 2 S0
1 2
0
© ankush agarwal 83
Convex Hull
x 1 1 1
x 0 x
x x x
0 1
0 1 2 S1
1 2
0
3
3 4
4 5
6
© ankush agarwal 83
Convex Hull
0 1
0 1 2
1 2
x x 1
7 0
x 0 1
8 3
7 3 4 x x 1
4
6
5
S2
© ankush agarwal 83
Convex Hull
0 1
0 1 2
1 2
x x x
7 0
x 0 x
8 3
7 3 4 1 1 1
S3
4 5
6
© ankush agarwal 83
Convex Hull
0 1
0 1 2
1 2
7 0
8 3
7 3 4
4 5
6
© ankush agarwal 84
Convex Hull
x x
0 1
0 1 2
1 2
7 0
8 3
7 3 4
4 5
6
© ankush agarwal 84
Convex Hull
x x
0 1
0 1 2
1 2
7 0
8 3
7 3 4
4 5
6
© ankush agarwal 84
Convex Hull
x x
0 1
0 1
1
0
3
7 3 4
4 5
© ankush agarwal 84
Convex Hull
x x
© ankush agarwal 84
Convex Hull
x x
H
0 1 I
0 1
1
0
3
7 3 4
4 5
© ankush agarwal 85
Convex Hull
x x
0 1
0 1
1
0 D
3
7 3 4
4 5
© ankush agarwal 85
MORPHOLOGICAL THINNING AND THICKENING
© ankush agarwal 86
Thinning
© ankush agarwal 87
Thinning
• Critical pixel
– Its deletion changes the connectivity of its neighbourhood locally
• End pixel
– Its deletion reduces the length of an already thinned curve
© ankush agarwal 88
Thinning
0 0 0 X 0 0 1 X 0
X 1 X 1 1 0 1 1 0
1 1 1 1 1 X 1 X 0
S0 S1 S2
1 1 X 1 1 1 X 1 1
1 1 0 X 1 X 0 1 1
X 0 0 0 0 0 0 0 X
S3 S4 S5
0 X 1 0 0 X
I 0 1 1 0 1 1
0 X 1 X 1 1
S6 S7
© ankush agarwal 89
Thinning
0 0 0
X 1 X
1 1 1
0 0 0 0 0 0 0
S0
© ankush agarwal 90
Thinning
X 0 0
1 1 0
1 1 X
0 0 0 0 0 0 0
S1
© ankush agarwal 90
Thinning
1 X 0
1 1 0
1 X 0
0 0 0 0 0 0 0
S2
0
0
© ankush agarwal 90
Thinning
0 0 0 0 0 0 0
1 1 X
1 1 0
0 X 0 0
0
S3
0
© ankush agarwal 90
Thinning
0 0 0 0 0 0 0
1 1 1
X 1 X
0 0 0 0
0 0
S4
0 0 0 0
© ankush agarwal 90
Thinning
0 0 0 0 0 0 0
X 1 1
0 1 1
0 0 0 X
0 0 0
S5
0 0 0 0
© ankush agarwal 90
Thinning
0 0 0 0 0 0 0
0 0
0 0 0
0 0 0 0 0 X 1
0 1 1
0 X 1
S6
© ankush agarwal 90
Thinning
0 0 0 0 0 0 0
0 0
0 0 0
0 0 0 0 0 0 X
0 1 1
X 1 1
S7
© ankush agarwal 90
Thinning
© ankush agarwal 91
Thinning
0 0 0
X 1 X
1 1 1
S0
0 0 0 0 0
© ankush agarwal 91
Thinning
X 0 0
1 1 0
1 1 X
S1
0 0 0 0 0
© ankush agarwal 91
Thinning
1 X 0
1 1 0
1 X 0
S2
0 0 0 0 0
© ankush agarwal 91
Thinning
1 1 X
0 0 0 0 0
1 1 0
X 0 0
S3
© ankush agarwal 91
Thinning
1 1 1
0 0 0 0 0
X 1 X
0 0 0
0 0
S4
© ankush agarwal 91
Thinning
X 1 1
0 0 0 0 0
0 1 1
0 0 X
0 0 0
S5
© ankush agarwal 91
Thinning
0 0 0 0 0
0 0 0
0 X 1
0 1 1
0 X 1
S6
© ankush agarwal 91
Thinning
0 0 0 0 0
0 0 0
0 0 X
0 1 1
X 1 1
S7
© ankush agarwal 91
Thinning
© ankush agarwal 92
Thinning
© ankush agarwal 92
Thinning
• Eg:
© ankush agarwal 93
Thickening
I {S } (((( I ⊛ S0 ) ⊛ S1 ) ⊛S
2 ) ...⊛S 7 )
• Approach
– Take Ic
– res = Apply thinning on Ic
– Take resc
I {S } | ( I c S ) followed by (isolated pixel removal) |c
© ankush agarwal 94
RECAP
• Dilation I S {z | ( Sˆ ) z I }
• Erosion I S {z | ( S ) z I c }
• Opening I S ( I S ) S
• Closing I S ( I S )S
• Boundary (Internal) ( I ) I ( I S )
• Boundary (External) (I ) (I S ) I
© ankush agarwal 95
RECAP
• Region Filling X k ( X k 1 S ) Ic
• Connected Components X k ( X k 1 S ) I
• Convex Hull X k ( X k 1 ⊛ Si ) I
© ankush agarwal 96
GLA UNIVERSITY
By:
Dr. Ankush Agarwal
Outline
© ankush agarwal 2
SEGMENTATION
© ankush agarwal 3
Segmentation
© ankush agarwal 4
Segmentation
© ankush agarwal 5
Segmentation
© ankush agarwal 6
Segmentation
Discontinuity Similarity
© ankush agarwal 7
Segmentation
© ankush agarwal 8
Segmentation (Basic Idea)
© ankush agarwal 9
Thresholding
© ankush agarwal 10
Thresholding (Types)
• Global Thresholding
– If T is the only function of f(x, y), then the threshold is called global
threshold
– Apply the same threshold to the whole image
• Local Thresholding
– If T is a function of both f(x, y) & p(x, y), then the threshold is called local
– The threshold depends on local property
© ankush agarwal 11
Thresholding
© ankush agarwal 12
Thresholding
• Eg:
– Disk = 255 and background = 127
– Segment the image into two regions: disk and background
– What will be the threshold values?
© ankush agarwal 13
Global Thresholding
© ankush agarwal 14
Global Thresholding (Algorithm)
© ankush agarwal 15
Global Thresholding (Problem)
© ankush agarwal 16
Global Thresholding (Problem)
© ankush agarwal 17
Global Thresholding (Problem)
© ankush agarwal 18
Adaptive Thresholding
© ankush agarwal 19
SEGMENTATION (SIMILARITY)
© ankush agarwal 20
Region
© ankush agarwal 21
Region based approach
© ankush agarwal 22
Region based approach
© ankush agarwal 23
Region growing
© ankush agarwal 24
Region splitting
© ankush agarwal 26
Region splitting
R
I1 I2
I41 I42 I1 I2 I3 I4
I3
I43 I44
I41 I41 I41 I41
© ankush agarwal 27
Region splitting
• Advantage
– Created regions are adjacent and homogenous
• Disadvantage
– Over splitting, since no merge is performed
– More clusters
• Improvement
– Split and Merge
© ankush agarwal 28
Region splitting and merging
• After splitting
• Merging phase
– If 2 adjacent regions are homogenous, they are merged
• Repeat merging step, until no further merging is possible
© ankush agarwal 29
SEGMENTATION (DISCONTINUITY)
© ankush agarwal 30
Segmentation (Discontinuity)
© ankush agarwal 31
Segmentation (Discontinuity)
© ankush agarwal 32
Segmentation (Discontinuity)
0 1 0 0 -1 0
1 -4 1 -1 4 -1 90° isotropic
0 1 0 0 -1 0
1 1 1 -1 -1 -1
45° isotropic 1 -8 1 -1 8 -1
1 1 1 -1 -1 -1
© ankush agarwal 33
Segmentation (DiscontinuityPoint)
© ankush agarwal 34
Segmentation (Discontinuity Point)
7 7 7 7 7 7 7 -1 -1 -1
7 10 7 7 7 7 7 -1 8 -1 24 -3
3 0 0 0
7 7 7 7 7 7 7 -1 -1 -1 -3
3 -3
3 0 0 0
7 7 7 7 7 7 7 P 0 0 3 3 3
7 7 7 7 4 7 7 0 0 3 24
-24 3
7 7 7 7 7 7 7 0 0 3 3 3
7 7 7 7 7 7 7
I Rp =I º|IPº P|
© ankush agarwal 35
Segmentation (Discontinuity Line)
-1 -1 -1 -1 -1 2 -1 2 -1 2 -1 -1
2 2 2 -1 2 -1 -1 2 -1 -1 2 -1
-1 -1 -1 2 -1 -1 -1 2 -1 -1 -1 2
© ankush agarwal 36
Segmentation (Discontinuity Line)
1 1 1 1 1 1 1 1 -1 -1 -1
1 1 1 1 1 1 1 3 2 2 2 0 0 0 0 2 2
1 1 1 1 1 1 3 1 -1 -1 -1 0 0 0 2 2 0
1 1 1 1 1 3 1 1 H 6 6 6 0 0 2
3 3 3 3 3 1 1 1 12 12 12 6 2 2
1 1 1 1 1 1 1 1 6 6 6 4 2 0
1 1 1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 1 1
I |I º H|
© ankush agarwal 37
Segmentation (Discontinuity Line)
1 1 1 1 1 1 1 1 -1 -1 2
1 1 1 1 1 1 1 3 -1 2 -1 0 0 0 0 2 4
1 1 1 1 1 1 3 1 2 -1 -1 0 0 0 2 4 12
1 1 1 1 1 3 1 1 D45º 0 0 0 0 12 4
3 3 3 3 3 1 1 1 0 0 0 6 4 2
1 1 1 1 1 1 1 1 0 0 0 4 2 0
1 1 1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 1 1
I |I º D45º|
© ankush agarwal 38
Segmentation (Discontinuity Line)
1 1 1 1 1 1 1 1 -1 2 -1
1 1 1 1 1 1 1 3 -1 2 -1 0 0 0 0 2 2
1 1 1 1 1 1 3 1 -1 2 -1 0 0 0 2 2 0
1 1 1 1 1 3 1 1 V 0 0 0 0 0 2
3 3 3 3 3 1 1 1 0 0 0 0 2 2
1 1 1 1 1 1 1 1 0 0 0 2 2 0
1 1 1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 1 1
I |I º V|
© ankush agarwal 39
Segmentation (Discontinuity Line)
1 1 1 1 1 1 1 1 2 -1 -1
1 1 1 1 1 1 1 3 -1 2 -1 0 0 0 0 4 4
1 1 1 1 1 1 3 1 -1 -1 2 0 0 0 4 4 0
1 1 1 1 1 3 1 1 D-45º 0 0 0 6 0 4
3 3 3 3 3 1 1 1 0 0 0 0 4 4
1 1 1 1 1 1 1 1 0 0 0 2 4 0
1 1 1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 1 1
I |I º D-45º|
© ankush agarwal 40
Segmentation (Discontinuity Line)
1 1 1 1 1 1 1 1
1 10 10 10 10 14 14 3
1 10 10 10 14 14 12
3 1
1 16 16 16 16 12
3 14 1
3 12
3 12
3 12
3 36 14 14 1
1 16 16 16 14 14 10 1
1 10 10 10 10 10 10 1
1 1 1 1 1 1 1 1
© ankush agarwal 41
Segmentation (Discontinuity Edge)
© ankush agarwal 42
Segmentation (Discontinuity Edge)
• Edge linking
– process takes an unordered set of edge pixels produced by an edge
detector as i/p to form an ordered list of edgels
• Edge following
– process takes the entire edge strength or gradient image as i/p &
produces geometric primitives such as lines or curves
© ankush agarwal 45
Segmentation (Discontinuity Edge Derivative)
© ankush agarwal 46
Segmentation (Discontinuity Edge Derivative)
1 1 1 1 2 2 2
Robert -1 -2 -1 -1 -1 -1
1 1 1 1 2 2 2
1 1 1 1 2 2 2 1 0 0 0 0 0 0 0
2 2 2 2 1 1 1 0 -1 1 2 1 1 1 1
2 2 2 2 1 1 1 G45º SH PH
2 2 2 2 1 1 1 -1 0 1 -1 0 1
0 1
2 2 2 2 1 1 1 -2 0 2 -1 0 1
-1 0
I -1 0 1 -1 0 1
G-45º
SV PV
Sobel Prewitt
© ankush agarwal 47
Segmentation (Discontinuity Edge Derivative)
• Motivation
– Detect sudden changes in image intensity
– Gradient: sensitive to intensity changes
• Gradient T
f f
f
x y
© ankush agarwal 48
Segmentation (Discontinuity Edge Derivative)
© ankush agarwal 49
Segmentation (Discontinuity Edge Derivative)
• Eg:
– Find the strength & the direction of the edge at the highlighted pixel
– Pixels in gray are 0 and white are 1
Solution
• Derivative is computed by using a 3x3 neighbourhood
– subtract the pixels in the top row from bottom row (x direction)
– similarly obtain the derivative in the y direction
-1 -1 -1 -1 0 1
0 0 0 -1 0 1
1 1 1 -1 0 1
© ankush agarwal 50
Segmentation (Discontinuity Edge Derivative)
• Eg:
– Find the strength & the direction of the edge at the highlighted pixel
– Pixels in gray are 0 and white are 1
I (x, y)
Gx x 2
I
G y I (x, y) 2
y
| I | Gx2 G y2 2 2
Gy
(x, y) tan
1
1 45
x
G
© ankush agarwal 51
Simple edge detection using gradient
© ankush agarwal 52
CANNY EDGE DETECTOR
© ankush agarwal 53
Canny (Characteristics)
© ankush agarwal 54
Canny (Steps)
© ankush agarwal 55
Canny (Steps – Gaussian filter)
© ankush agarwal 56
Canny (Steps - Derivative)
© ankush agarwal 57
Canny (Steps - Magnitude and Orientation)
© ankush agarwal 58
Canny (Steps - Apply Non Maxima Suppression)
© ankush agarwal 59
Canny (Steps - Apply Non Maxima Suppression)
© ankush agarwal 61
Canny (Steps – Apply Hysteresis Thresholding)
© ankush agarwal 62
Canny
• Eg:
– Compute derivative
© ankush agarwal 63
Canny
• Eg:
– Compute magnitude and orientation
-4 -3 -1 0 0 2 1 1 0 0
-3 -4 -3 -1 0 1 2 3 1 0
0 -1 -3 -4 -3 0 1 3 2 1
0 0 -1 -3 -4 0 0 1 1 2
0 0 0 0 -1 0 0 0 0 1
© ankush agarwal 64
Canny
• Eg:
– Apply Non-maxima suppression
© ankush agarwal 65
Canny
• Eg:
– Apply Hysteresis Threshold
© ankush agarwal 66
HOUGH TRANSFORM
© ankush agarwal 67
Hough Transform
y = mx+c c = -mx+y
variable: x, y variable: m, c
parameter: m, c parameter: x, y
© ankush agarwal 68
Hough Transform
• Eg:
© ankush agarwal 69
Hough Transform
• Step 1:
– Known
• -1.2<=m<=-0.8
• step_m = 0.1
© ankush agarwal 70
Hough Transform
• Step 2:
– Compute c
© ankush agarwal 71
Hough Transform
• Step 3:
– Find min and max of c
(x,y) = (4,1) (x,y) = (3,2) (x,y) = (2,3) (x,y) = (1,4)
• Range: 4.2 to 5.8 c = -4m+1 c = -3m+2 c = -2m+3 c = -m+4
• Interval: 0.1 m c m c m c m c
-0.8 4.2 -0.8 4.4 -0.8 4.6 -0.8 4.8
-0.9 4.6 -0.9 4.7 -0.9 4.8 -0.9 4.9
-1.0 5.0 -1.0 5.0 -1.0 5.0 -1.0 5.0
-1.1 5.4 -1.1 5.3 -1.1 5.2 -1.1 5.1
-1.2 5.8 -1.2 5.6 -1.2 5.4 -1.2 5.2
© ankush agarwal 72
Hough Transform
• Step 4:
– Voting
© ankush agarwal 73
Hough Transform
• Step 5:
– Find equation
• m =-1.0
• c = 5.0
• y = -x+5
© ankush agarwal 74
Hough Transform
• Problem
– The slope of line parallel to y – axis is infinity, the computer can not
handle it.
– So, we follow another parameterization of a line
– p = x cos θ + y sin θ
© ankush agarwal 75
Hough Transform
y
6
5
4
3
p = x cos θ + y sinθ
2
Edgels: (0,5), (1,4), (3,2), (3,3), (5,0)
1
0
0 1 2 3 4 5 6 x
© ankush agarwal 76
Hough Transform
p = x cos θ + y sinθ
© ankush agarwal 77
Hough Transform
0 cos θ + 5 sin θ 1 cos θ + 4 sin θ 3 cos θ + 2 sin θ 3 cos θ + 3 sin θ 5 cos θ + 0 sin θ
0 0 1 3 3 5
90 5 4 2 3 0
© ankush agarwal 78
Hough Transform
© ankush agarwal 79
GLA UNIVERSITY
By:
Dr. Ankush Agarwal
Outline
© ankush agarwal 2
IMAGE REPRESENTATION AND DESCRIPTION
© ankush agarwal 3
Image Representation and Description
• Benefits
– Easier to understand
– Require fewer memory
– faster to be processed
© ankush agarwal 5
Border
© ankush agarwal 6
Border (Algo)
• Step 1: Start scanning row-wise from top left corner of the image
• Step 2: Mark the first object pixel obtained as the start pixel
• Step 3: Based on the previous pixel (p) and the current pixel (c),
find the next pixel (n)
– n is found by searching in the neighbourhood of c, clockwise starting from
previous pixel p
• Step 4: Mark the current pixel as previous pixel & the next pixel
as the current pixel
• Step 5: Go to step 3
© ankush agarwal 7
Border (Eg)
1 1 1
p c
1 1
1 1
1 1
1 1 1 1
© ankush agarwal 8
Border (Eg)
1 1 1
p c
1 1
1 1
1 1
1 1 1 1
© ankush agarwal 8
Border (Eg)
1 1 1
p c
1 1
1 1
1 1
1 1 1 1
© ankush agarwal 8
Border (Eg)
1 1 1
p c
1 1
1 1
1 1
1 1 1 1
© ankush agarwal 8
Border (Eg)
1 1 1
p c
1 1
1 1
1 1
1 1 1 1
© ankush agarwal 8
Border (Eg)
1 1 1
p c
1 1
1 1
1 1
1 1 1 1
© ankush agarwal 8
Chain Code
© ankush agarwal 9
Chain Code
• Eg:
– Find the 4 directional Chain Code
Solution
• 1101101030332330322212
© ankush agarwal 10
Chain Code
• Eg:
– Find the 8 directional Chain Code
Solution
• 22120207656764443
© ankush agarwal 11
Chain Code (Problem)
© ankush agarwal 12
Chain Code
© ankush agarwal 13
Chain Code Normalization
Sort
33001122 00112233
30011223 01122330
00112233 11223300
01122330 12233001
33001122
11223300 22330011
12233001 23300112
22330011 33001122
First row gives the normalized chain code: 00112233 23300112 30011223
© ankush agarwal 14
Chain Code Differential
© ankush agarwal 15
Chain Code Differential
© ankush agarwal 16
Chain Code Differential
• Eg:
– Find the shape number & order of the given boundary
Solution
• 4-direction chain code: 0 3 0 3 2 2 1 1
• First difference: 3 1 3 3 0 3 0
• Circular first difference: 3 1 3 3 0 3 0 3
• Shape number: 0 3 0 3 3 1 3 3
• Order: 8
© ankush agarwal 17