0% found this document useful (0 votes)
2 views

Module 5

This document presents a lecture on Digital Image Processing by Dr. Justin Varghese, covering various topics including image segmentation, edge detection, and morphological operations. Key concepts such as region-based segmentation, watershed segmentation, and the mathematical foundations of image processing are discussed. The document also explores practical applications of dilation, erosion, and their effects on image contours.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Module 5

This document presents a lecture on Digital Image Processing by Dr. Justin Varghese, covering various topics including image segmentation, edge detection, and morphological operations. Key concepts such as region-based segmentation, watershed segmentation, and the mathematical foundations of image processing are discussed. The document also explores practical applications of dilation, erosion, and their effects on image contours.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

19ECS352 - Image Processing. Dr.

Justin Varghese Slide 1

Digital Image Processing

Justin Varghese, Ph.D. (Eng.), SM IEEE


Professor,
Department of Computer Science & Engineering,
Gitam (Deemed to be University)
GST, Bangalore Campus
Mobile: +91-9940955156
Email: [email protected], [email protected]

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 2

Image Segmentation

• Segmentation subdivides an image into its constituent


regions or objects.
• Level of division depends on the problem being
solved.
• Image segmentation algorithms generally are based
on one of two basic properties of intensity values:
discontinuity (e.g. edges) and similarity (e.g.,
thresholding, region growing, region splitting and
merging)
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 3

Detection of Discontinuities

• Define9 the response of the mask:


R =  wi zi
i =1
• Point detection: R T

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 4

Point Detection Example

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 5

Line Detection

• Masks that extract lines of different directions.

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 6

Illustration

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 7

Edge Detection

• An ideal edge has the properties of the model


shown to the right:
• A set of connected pixels, each
of which is located at an
orthogonal step transition in
gray level.
• Edge: local concept
• Region Boundary: global idea

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 8

Ramp Digital Edge

• In practice, optics, sampling and


other image acquisition
imperfections yield edges that area
blurred.
• Slope of the ramp determined by
the degree of blurring.

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 9

Zero-Crossings of 2nd Derivative

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 10

Noisy Edges: Illustration

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 11

Edge Point

• We define a point in an image as being an edge


point if its 2-D 1st order derivative is greater
than a specified threshold.
• A set of such points that are connected
according to a predefined criterion of
connectedness is by definition an edge.

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 12

Gradient Operators

• Gradient:  f 
Gx   x 
f =   =  f 
Gy   
 y 

f = [Gx2 + Gy2 ]1/ 2


• Magnitude:
• Direction:  Gy 
 ( x, y) = tan  
−1

 Gx 

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 13

Gradient Masks

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 14

Diagonal Edge Masks

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 15

Illustration

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 16

Illustration (cont’d)

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 17

Illustration (cont’d)

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 18

Thresholding

• Foundation: background point vs. object point


• The role of illumination: f(x,y)=i(x,y)*r(x,y)
• Basic global thresholding
• Adaptive thresholding
• Optimal global and adaptive thresholding
• Use of boundary characteristics for histogram
improvement and local thresholding
• Thresholds based on several variables

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 19

Foundation

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 20

The Role of Illumination

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 21

Basic Global Thresholding

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 22

Region-Based Segmentation

• Let R represent the entire image region. We may


view segmentation as a process that partitions R into
n sub-regions
n R1, R2, …, Rn such that:
– (a)  Ri = R
i =1
– (b) Ri is a connected region
– (c) Ri  R j = 
– (d) P(Ri)= TRUE for i=1,2,…n
– (e) P(Ri U Rj)= FALSE for i != j

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 23

Region Growing

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 24

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 25

Region-Splitting and Merging


Region Splitting
•Initially take the image as a whole to be the area of interest.

•Look at the area of interest and decide if all pixels contained in the region satisfy
some similarity constraint.

•If TRUE then the area of interest corresponds to a region in the image.

•If FALSE split the area of interest (usually into four equal sub-areas) and consider
each of the sub-areas as the area of interest in turn.
•This process continues until no further splitting occurs. In the worst case this
happens when the areas are just one pixel in size.

•This is a divide and conquer or top down method.


If only a splitting schedule is used then the final segmentation would probably
contain many neighbouring regions that have identical or similar properties.
Thus, a merging process is used after each split which compares adjacent regions
and merges them if necessary. Algorithms of this nature are called split and
merge algorithms.
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 26

Region-Splitting and Merging

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 27

Watershed Segmentation Algorithm


◼ Visualize an image in 3D: spatial coordinates and gray levels.
◼ In such a topographic interpretation, there are 3 types of points:
❑ Points belonging to a regional minimum

❑ Points at which a drop of water would fall to a single minimum.

(→The catchment basin or watershed of that minimum.)


❑ Points at which a drop of water would be equally likely to fall to more

than one minimum. (→The divide lines or watershed lines.)

Watershed lines

Bahadir K. Gunturk EE 7730 - Image Analysis I 27


Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 28

Watershed Segmentation Algorithm


◼ The objective is to find watershed lines.
◼ The idea is simple:
❑ Suppose that a hole is punched in each regional minimum and that the entire
topography is flooded from below by letting water rise through the holes at a
uniform rate.
❑ When rising water in distinct catchment basins is about the merge, a dam is
built to prevent merging. These dam boundaries correspond to the watershed
lines.

EE 7730 - Image Analysis I 28


Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 29

Watershed Segmentation Algorithm

Bahadir K. Gunturk EE 7730 - Image Analysis I 29


Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 30

Watershed Segmentation Algorithm


• Start with all pixels with the lowest possible value.
– These form the basis for initial watersheds
• For each intensity level k:
– For each group of pixels of intensity k
• If adjacent to exactly one existing region, add these pixels to
that region
• Else if adjacent to more than one existing regions, mark as
boundary
• Else start a new region

Bahadir K. Gunturk EE 7730 - Image Analysis I 30


Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 31

Watershed Segmentation Algorithm


Watershed algorithm might be used on the gradient image instead of the original
image.

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 32

Morphological Operations
Morphology: a branch of biology that deals with the form and
structure of animals and plants
An approach for processing digital image based on its shape
A mathematical tool for investigating geometric structure in image
Morphological image processing is used to extract image components
for representation and description of region shape, such as
boundaries, skeletons, and the convex hull
The language of mathematical morphology is – Set theory.
Unified and powerful approach to numerous image processing
problems.
Simplify image data, preserve essential shape characteristics and
eliminate noise
Permits the underlying shape to be identified and optimally
reconstructed from their distorted, noisy forms
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 33

Basic Concepts in Set Theory


 Subset

 Union

 Intersection

disjoint / mutually exclusive


 Complement
 Difference
 Reflection
 Translation

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 34

Dilation
• Dilation is used for expanding an element A by using structuring
element B
• Dilation of A by B and is defined by the following equation:

• This equation is based 0n obtaining the reflection 0f B


about its origin and shifting this reflection by z.
• The dilation of A by B is the set of all displacements z,
such that and A overlap by at least one element. Based
On this interpretation the equation of (9.2-1) can be
rewritten as:

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 35

Dilation – Example 1

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 36

Dilation – Example 2

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 37

Dilation –Example

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 38

Erosion

• Erosion is used for shrinking of element A by


using element B
• Erosion for Sets A and B in Z2, is defined by
the following equation:

• This equation indicates that the erosion of A


by B is the set of all points z such that B,
translated by z, is combined in A.
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 39

Erosion – Example 1

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 40

Erosion – Example 2

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 41

Erosion and Dilation summary

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 42

Opening And Closing


 Opening – smoothes contours , eliminates protrusions

 Closing – smoothes sections of contours, fuses narrow


breaks and long thin gulfs, eliminates small holes and fills
gaps in contours

 These operations are dual to each other

 These operations are can be applied few times, but has


effect only once

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 43

Opening And Closing

 Opening –
First – erode A by B, and then dilate the result by B
In other words, opening is the unification of all B objects
Entirely Contained in A

eliminates protrusions
breaks necks
smoothes contour

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 44

Opening And Closing

opening with a disk structure element:


•breaks thin connections within an object
•eliminates small islands and sharp
protrusions

closing with a disk structure element:


•fills thin connections within an object
•eliminates small holes and fills dents in
contours
•fills small gaps in parts of an object

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 45

Properties

Opening
(i) AB is a subset (subimage) of A
(ii) If C is a subset of D, then C B is a subset of D B
(iii) (A B) B = A B
Closing
(i) A is a subset (subimage) of A•B
(ii) If C is a subset of D, then C •B is a subset of D •B
(iii) (A •B) •B = A •B

Note: repeated openings/closings has no effect!


45
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 48

Department of Computer Science & Engineering-Bangalore Campus 48


19ECS352 - Image Processing. Dr. Justin Varghese Slide 49

Useful: open & close

49
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 50

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 51

Morphological Operations
►Boundary Extraction
The boundary of a set A, can be obtained by first eroding A by B
and then performing the set difference between A and its erosion.

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 52
The Hit-or-Miss
Transformation
if B denotes the set composed of
D and its background,the match
(or set of matches) of B in A,
denoted A  B,
A * B = ( A − D )   Ac − (W − D )

B = ( B1 , B2 )
B1 : object
B2 : background
A  B = ( A − B1 )  ( Ac − B2 )

4/8/2025 52
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 53

Boundary Extraction

 ( A) = A − ( A − B)
Department of Computer Science & Engineering-Bangalore Campus 53
19ECS352 - Image Processing. Dr. Justin Varghese Slide 54
Region Filling
X k = ( X k −1  B)  A k = 1,2,3,...c

Department of Computer Science & Engineering-Bangalore Campus 54


19ECS352 - Image Processing. Dr. Justin Varghese Slide 55

Region Filling Algorithm

Department of Computer Science & Engineering-Bangalore Campus 55


19ECS352 - Image Processing. Dr. Justin Varghese Slide 56

Extraction of Connected Components

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 57

Example

Department of Computer Science & Engineering-Bangalore Campus 57


19ECS352 - Image Processing. Dr. Justin Varghese Slide 58

Gray-Scale Morphology

f ( x, y) : gray-scale image
b( x, y): structuring element

4/8/2025 58
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 59

Gray-Scale Morphology: Erosion and Dilation


by Flat Structuring

 f − b ( x, y) = (min
s ,t )b
 f ( x + s, y + t )

 f  b ( x, y) = max
( s ,t )b
 f ( x − s, y − t )

4/8/2025 59
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 60

4/8/2025 60
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 61

Gray-Scale Morphology: Erosion and Dilation


by Nonflat Structuring

 f − bN  ( x, y) = (min
s ,t )b
 f ( x + s, y + t ) − bN (s, t )

 f  bN  ( x, y) = max
( s ,t )b
 f ( x − s, y − t ) + bN (s, t )

4/8/2025 61
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 62

Duality: Erosion and Dilation

 

 f −b c
( x, y) =  f  b  ( x, y)
c

 

where f c = − f ( x, y) and b = b(− x, − y)
 

 f −b c
=  f b
c

 

( f  b ) =
c
( f c
− b)

4/8/2025 62
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 63

Opening and Closing

f b = ( f − b)  b
f • b = ( f  b) − b

 
( f b) c
=f c
b=−f b
 
(f b) = f b = − f b
c c

4/8/2025 63
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 64

4/8/2025 64
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 65

Properties of Gray-scale Opening

(a) f bf
(b) if f1f 2 , then ( f1 b )  ( f 2 b )
(c) (f b) b = f b

where er denotes e is a subset of r and also


e( x, y)  r ( x, y).

4/8/2025 65
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 66

4/8/2025 66
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 67

Morphological Smoothing

• Opening suppresses bright details smaller than the specified


SE, and closing suppresses dark details.

• Opening and closing are used often in combination as


morphological filters for image smoothing and noise removal.

4/8/2025 67
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 68

Morphological Smoothing

4/8/2025 68
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 69

Morphological Gradient

• Dilation and erosion can be used in combination with image


subtraction to obtain the morphological gradient of an image,
denoted by g,
g = ( f  b) − ( f − b)

• The edges are enhanced and the contribution of the


homogeneous areas are suppressed, thus producing a
“derivative-like” (gradient) effect.

4/8/2025 69
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 70

Morphological Gradient

4/8/2025 70
Department of Computer Science & Engineering-Bangalore Campus
19ECS352 - Image Processing. Dr. Justin Varghese Slide 71

Questions?

Department of Computer Science & Engineering-Bangalore Campus


19ECS352 - Image Processing. Dr. Justin Varghese Slide 72

Thank You

Department of Computer Science & Engineering-Bangalore Campus

You might also like