2 - DIP-Basic Calculations On Pixel Level
2 - DIP-Basic Calculations On Pixel Level
ب ِْس ِم ِ
اللهُم عن ِل ْمننا نما ي ن ْن نفعننا نوانْ نف ْعننا ِب نما عنل ْم نَتننا نو ِِ ْْ نَ ِعلْ ِما
Digital Image Processing
BME 430
2- Basic calculations on pixel level
By
Prof. Nahed H. Solouma
2
Objectives
By the end of this topic, the student should be able to:
• Understand the pixel neighborhood.
• Understand the pixel adjacency.
• Understand and apply the different types of distance
measurements.
• Understand the meaning of digital path, connected
component, boundary and a region.
• Understand the distance transform.
3
Pixel Neighborhood
Neighbors of a pixel 𝑝(𝑥, 𝑦) (notice the colors)
Four neighbors 𝑁4 (𝑝): Eight neighbors 𝑁8 (𝑝):
(vertical + horizontal) 𝑁4 (𝑝) + 𝑁𝐷 (𝑝)
Diagonal neighbors 𝑁𝐷 (𝑝)
𝑁4 𝑝 = {𝑝 𝑥 + 1, 𝑦 , 𝑝 𝑥 − 1, 𝑦 , 𝑁𝐷 𝑝
𝑝 𝑥, 𝑦 + 1 , 𝑝(𝑥, 𝑦 − 1)} = {𝑝 𝑥 + 1, 𝑦 + 1 , 𝑝 𝑥 + 1, 𝑦 − 1 ,
𝑝(𝑥 − 1, 𝑦 + 1), 𝑝(𝑥 − 1, 𝑦 − 1)} 4
Pixel Adjacency
The set of pixels 𝑆 that is adjacent to a pixel 𝑝 𝑥, 𝑦 is composed of its neighbors that have
graylevels in a specified range 𝑉.
There are 3 types of adjacency:
• 4-adjacency: a pixel 𝑞 is 4-adjacent to pixel 𝑝 if 𝑞 is in the set 𝑁4 (𝑝) and graylevels, of
both, are in a specified range 𝑉
• 8-adjacency: a pixel 𝑞 is 8-adjacent to pixel 𝑝 if 𝑞 is in the set 𝑁8 (𝑝) and graylevels, of
both, are in a specified range 𝑉
(a) (b) (c)
Types of distances:
1. Euclidean distance
2. City block distance
3. Chessboard distance
11
Distance Measurements
The Euclidean distance between 𝑝(𝑎, 𝑏) and 𝑞(𝑠, 𝑡) is defined as:
1
𝐷𝑒 (𝑝, 𝑞) = (𝑎 − 𝑠)2 +(𝑏 − 2
𝑡) 2
• The pixels have 𝐷𝑒 ≤ 𝑟 from a central pixel at 𝑝(𝑎, 𝑏) form a disc of radius 𝑟
Diamond-shaped
or city block
distance
13
Distance Measurements
The distance 𝐷8 (also called chessboard distance) between 𝑝(𝑎, 𝑏) and
𝑞(𝑠, 𝑡) is defined as:
𝐷8 𝑝, 𝑞 = max( 𝑎 − 𝑠 , 𝑏 − 𝑡 )
Chessboard distance
14
Distance Transform
It transforms the pixels values (in an object) to their distances to
the closest boundary point.
Usually applied to binary images and results in a graylevel image
that looks like the input image,
Example:
Input images
Distance Transform
Reference: https://homepages.inf.ed.ac.uk/rbf/HIPR2/distance.htm 15
Distance Transform
17
Thank you
18