You are on page 1of 41

University of Baghdad

Al-Khwarizmi College of Engineering


Biomedical Engineering Department

Image processing for BME 2


5th Stage

Lecture 4
Basic Relationship of Pixels

By:
Dr. Noor Kamal
PhD in Biomedical Engineering
Image processing for BME 2_Lec 4_ 2020 1
Basic Relationship of Pixels

• Neighbors
• Adjacency and Connectivity
• Path
• Region and Boundary
• Distance

Image processing for BME 2_Lec 4_ 2020 2


Basic Relationship of Pixels

Image processing for BME 2_Lec 4_ 2020 3


Some Basic Relationship Between Pixels

Image processing for BME 2_Lec 4_ 2020 4


Neighbors of a Pixel

• A pixel p at coordinates (x,y) has four horizontal and vertical neighbors:


N4(P)={(x+1,y), (x-1,y),(x,y+1),(x,y-1)}

Image processing for BME 2_Lec 4_ 2020 5


Neighbors of a Pixel

Diagonal -neighborhood relation considers only diagonal neighbor pixels.

• The four diagonal neighbors of P


ND(P)={(x+1 y+1) (x-1 y-1) (x-1 y+1) (x+1 y-1)}

Image processing for BME 2_Lec 4_ 2020 6


Neighbors of a Pixel

8-neighborhood relation considers all neighbor pixels


• The eight point neighbors of P
N8(P)=N4(P)U ND(P)
Image processing for BME 2_Lec 4_ 2020 7
Adjacency

Image processing for BME 2_Lec 4_ 2020 8


Adjacency

Image processing for BME 2_Lec 4_ 2020 9


Adjacency

Image processing for BME 2_Lec 4_ 2020 10


Adjacency, Connectivity
• Two pixels are adjacent if they are neighbors and their intensity
level ‘V’ satisfy some specific criteria of similarity (gray levels are
similar).
• Similar gray level means that the gray levels of both pixels belong to
set V
Ex:
V = {1}
V = { 0, 2}
• Binary image V = { 0, 1}
In binary images, 2 pixels are adjacent if they are neighbors & have
some intensity values either 0 or 1.
• Gray scale image V = { 0, 1, 2, ------, 255}
In gray scale, image contains more gray level values in range 0 to 255.

Image processing for BME 2_Lec 4_ 2020 11


Adjacency, Connectivity

• 4-adjacency:Two pixels p and q with the values


from set ‘V’ are 4adjacent if q is in the set of N4(p).
• EX: V = { 0, 1}

• p in RED color q can be any value in GREEN color.

Image processing for BME 2_Lec 4_ 2020 12


Adjacency, Connectivity

• 8-adjacency:Two pixels p and q with the values


from set ‘V’ are 8 adjacent if q is in the set of N8(p).
• Ex: V = { 1, 2}

• p in RED color q can be any value in GREEN color

Image processing for BME 2_Lec 4_ 2020 13


Adjacency, Connectivity

• m-adjacency: Two pixels p and q with the values


from set ‘V’ are m-adjacent if
• (i) q is in N4(p) OR
• (ii) q is in ND(p) & the set N4(p) n N4(q) have no
pixels whose values are from ‘V’.
• Ex. V = { 1 }

Image processing for BME 2_Lec 4_ 2020 14


Adjacency, Connectivity

• m-adjacency: Two pixels p and q with the values from set ‘V’ are m-
adjacent if
• (i) q is in N4(p)
• (ii) q is in ND(p) & the set N4(p) intersection N4(q) have no pixels
whose values are from ‘V’.
Ex. V = { 1 }

- b & c are m-adjacent.


- b & e are m-adjacent.
- e & I are m-adjacent.
- e & c are not m-adjacent.

Image processing for BME 2_Lec 4_ 2020 15


Connectivity

• 2 pixels are said to be connected if their exists a


path between them.
• Let ‘S’ represent subset of pixels in an image.
• Two pixels p & q are said to be connected in ‘S’ if
their exists a path between them consisting entirely
of pixels in ‘S’.
• For any pixel p in S, the set of pixels that are
connected to it in S is called a connected
component of S.

Image processing for BME 2_Lec 4_ 2020 16


Path

Image processing for BME 2_Lec 4_ 2020 17


Path

Image processing for BME 2_Lec 4_ 2020 18


Path

Image processing for BME 2_Lec 4_ 2020 19


Regions & Boundaries
• Region: Let R be a subset of pixels in an image. Two regions
Ri and Rj are said to be adjacent if their union form a
connected set.
• Regions that are not adjacent are said to be disjoint.
• We consider 4- and 8- adjacency when referring to regions.
• Below regions are adjacent only if 8-adjacency is used.

Image processing for BME 2_Lec 4_ 2020 20


Boundary (border or contour)
The boundary of a region R is the set of pixels that are adjacent
i.e have one or more neighbors that are not in R.

RED colored 1 is NOT a member of border if 4-connectivity is


used between region and background. It is if 8-connectivity is
used.

Image processing for BME 2_Lec 4_ 2020 21


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 22


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 23


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 24


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 25


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 26


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 27


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 28


Connected Components Labeling (CCL)
Example # 1 (4-connectivity based)

Image processing for BME 2_Lec 4_ 2020 29


Connected Components Labeling (CCL)
Example # 2 (8-connectivity based)

Image processing for BME 2_Lec 4_ 2020 30


Connected Components Labeling (CCL)
Example # 2 (8-connectivity based)

Image processing for BME 2_Lec 4_ 2020 31


Connected Components Labeling (CCL)
Example # 2 (8-connectivity based)

Image processing for BME 2_Lec 4_ 2020 32


Connected Components Labeling (CCL)
Example # 3

33
Image processing for BME 2_Lec 4_ 2020
Distance Measures

Distance between pixels p, q & z with coordinates ( x,


y), ( s, t) & ( v, w) resp. is given by:
1. D( p, q) ≥ 0 [ D( p, q) = 0 if p = q] called reflexivity
2. D( p, q) = D( q, p) called symmetry
3. D( p, z) ≤ D( p, q) + D( q, z) called transmitivity
• Euclidean distance between p & q is defined as
De( p, q) = [( x-s)2 + (y -t)2]1/2

Image processing for BME 2_Lec 4_ 2020 34


Distance Measure (City block)

Image processing for BME 2_Lec 4_ 2020 35


Distance Measure (Chessboard)

Image processing for BME 2_Lec 4_ 2020 36


Distance Measure of Path

Image processing for BME 2_Lec 4_ 2020 37


Example # 1
Consider the image segment shown in figure.
Compute length of the shortest-4, shortest-8 &
shortest-m paths between pixels p & q where,
V = {1, 2}.

Image processing for BME 2_Lec 4_ 2020 38


Example # 1

• Shortest-4 path:
V = {1, 2}.

So, Path does not exist.

Image processing for BME 2_Lec 4_ 2020 39


Example # 2

• Shortest-8 path:
V = {1, 2}.

So, shortest-8 path = 4

Image processing for BME 2_Lec 4_ 2020 40


Example # 3

• Shortest-m path:
V = {1, 2}.

So, shortest-m path = 5

Image processing for BME 2_Lec 4_ 2020 41

You might also like