You are on page 1of 43

Basic

Relationship
Between Pixels
PROF. JYOTSNA SINGH
DIVISION OF ELECTRONICS AND COMMUNICATION ENGINEERING
NSUT, DWARKA, NEW DELHI-110078
Basic Relationship between pixels

1. Neighbourhood
2. Adjacency
3. Connectivity
4. Paths
5. Regions and boundaries
Neighbors of a pixel p at coordinates
(x,y)
•Any pixel p(x, y) has two vertical and
two horizontal neighbours, given by
(x+1, y), (x-1, y), (x, y+1), (x, y-1)
This set of pixels are called the
4-neighbors of P and is denoted by N4(P).
Each of them are at a unit distance from
P.
•N4 - 4-neighbors
•ND - diagonal neighbors
•N8 - 8-neighbors (N4 U ND)
Neighbors of a pixel p at coordinates (x,y)

4-neighbors of p, denoted by N4(p):


(x-1, y), (x+1, y), (x,y-1), and (x, y+1).

4 diagonal neighbors of p, denoted by ND(p):


(x-1, y-1), (x+1, y+1), (x+1,y-1), and (x-1, y+1).

8 neighbors of p, denoted N8(p)


N8(p) = N4(p) U ND(p)

Weeks 1 & 2 4
Basic Relationships Between
Pixels
•The four diagonal neighbors of p(x,y) are given by,
(x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1 ,y-1)
This set is denoted by ND(P).
• Each of them are at Euclidean distance of 1.414
from P.
• The points ND(P) and N4(P) are together known as
8-neighbors of the point P, denoted by N8(P).
• Some of the points in the N4, ND and N8 may fall
outside image when P lies on the border of image.
Neighbors of a pixel p at coordinates
(x,y)
a. 4-neighbors of a pixel p
are its vertical and
horizontal neighbors
denoted by N4(p)

b. 8-neighbors of a pixel p
are its vertical horizontal and
4 diagonal neighbors
denoted by N8(p)
Adjacency
Let V be the set of intensity values used to define adjacency.
In a binary image, V ={1} if we are referring to adjacency of pixels
with value 1. In a gray-scale image, the idea is the same, but set
V typically contains more elements.
• 4-adjacency: Two pixels p and q with values from V are 4-adjacent if q
is in the set N4(p).
• 8-adjacency: Two pixels p and q with values from V are 8-adjacent if q
is in the set N8(p).
• m-adjacency: Two pixels p and q with values from V are m adjacent if,
– q is in N4(P).
– q is in ND(p) and the set [ ] is empty
(has no pixels whose values are from V).
Examples: Adjacency and Path
V = {1, 2}

0 1 1
1,1 1,2 1,3 0 1 1 0 1 1
0 2 0
2,1 2,2 2,3 0 2 0 0 2 0
0 0 1
3,1 3,2 3,3 0 0 1 0 0 1
8-adjacent m-adjacent

The 8-path from (1,3) to (3,3): The m-path from (1,3) to (3,3):
(i) (1,3), (1,2), (2,2), (3,3) (1,3), (1,2), (2,2), (3,3)
(ii) (1,3), (2,2), (3,3)

Weeks 1 & 2 8
Connectivity
It is used for establishing boundaries of objects and components
of regions in an image.
Two pixels are said to be connected:
• if they are adjacent in some sense(neighbour
pixels,4/8/m-adjacency)
• if their gray levels satisfy a specified criterion of similarity(equal
intensity level)
There are three types of connectivity on the basis of adjacency.
They are:
a) 4-connectivity: Two or more pixels are said to be 4-connected if
they are 4-adjacent with each others.
b) 8-connectivity: Two or more pixels are said to be 8-connected if
they are 8-adjacent with each others.
c) m-connectivity: Two or more pixels are said to be m-connected
if they are m-adjacent with each others.
Connectivity
Connectivity
To determine whether the pixels are adjacent in
some sense.
Let V be the set of gray-level values used to define
connectivity; then Two pixels p, q that have values
from the set V are:
a. 4-connected, if q is in the set N4(p)
b. 8-connected, if q is in the set N8(p)
c. m-connected, iff
i. q is in N4(p) or
ii. q is in ND(p) and the set is empty
Adjacency
Let V be the set of intensity values
m-adjacency: Two pixels p and q with values from V are
m-adjacent if
(i) q is in the set N4(p), or
(ii) q is in the set ND(p) and the set N4(p) ∩ N4(p) has no pixels
whose values are from V.
4-adjacency: Two pixels p and q with values from V are 4-adjacent if q
is in the set N4(p).
8-adjacency: Two pixels p and q with values from V are 8-adjacent if q
is in the set N8(p).

Weeks 1 & 2 12
Adjacency/Connectivity
• Pixel p is adjacent to pixel q if they
are connected.
• Two image subsets S1 and S2 are
adjacent if some pixel in S1 is adjacent
to some pixel in S2
Path
A (digital) path (or curve) from pixel p with coordinates (x0, y0) to pixel q
with coordinates (xn, yn) is a sequence of distinct pixels with coordinates
(x0, y0), (x1, y1), …, (xn, yn)
Where (xi, yi) and (xi-1, yi-1) are adjacent for 1 ≤ i ≤ n.
Here n is the length of the path.
If (x0, y0) = (xn, yn), the path is closed path.
We can define 4-, 8-, and m-paths based on the type of adjacency used.

Weeks 1 & 2 14
Paths & Path lengths
A path from pixel p with coordinates (x, y) to pixel q with
coordinates (s, t) is a sequence of distinct pixels with
coordinates:
(x0, y0), (x1, y1), (x2, y2) … (xn, yn),
where (x0, y0)=(x, y) and (xn, yn)=(s, t);
(xi, yi) is adjacent to (xi-1, yi-1)
• Here n is the length of the path.
• We can define 4-, 8-, and m-paths based on type of
adjacency used.
Connected Components
Let S represent a subset of pixels in an image

► For every pixel p in S, the set of pixels in S that are connected to p is


called a connected component of S.

► If S has only one connected component, then S is called Connected


Set.

► We call R a region of the image if R is a connected set

► Two regions, Ri and Rj are said to be adjacent if their union forms a


connected set.

► Regions that are not to be adjacent are said to be disjoint.

Weeks 1 & 2 16
Basic Relationships Between Pixels

► Boundary (or border)

The boundary of the region R is the set of pixels in the region that
have one or more neighbors that are not in R.
If R happens to be an entire image, then its boundary is defined as the
set of pixels in the first and last rows and columns of the image.

► Foreground and background

An image contains K disjoint regions, Rk , k = 1, 2, …, K. Let Ru denote


the union of all the K regions, and let (Ru)c denote its complement.
All the points in Ru is called foreground;
All the points in (Ru)c is called background.

Weeks 1 & 2 17
Question 1

► In the following arrangement of pixels, are the two


regions (of 1s) adjacent? (if 8-adjacency is used)

1 1 1
Region 1
1 0 1
0 1 0
0 0 1 Region 2

1 1 1
1 1 1

Weeks 1 & 2 18
Question 2

► In the following arrangement of pixels, are the two


parts (of 1s) adjacent? (if 4-adjacency is used)

1 1 1
Part 1
1 0 1
0 1 0
0 0 1 Part 2

1 1 1
1 1 1

Weeks 1 & 2 19
► In the following arrangement of pixels, the two
regions (of 1s) are disjoint (if 4-adjacency is used)

1 1 1
Region 1
1 0 1
0 1 0
0 0 1 Region 2

1 1 1
1 1 1

Weeks 1 & 2 20
► In the following arrangement of pixels, the two
regions (of 1s) are disjoint (if 4-adjacency is used)

1 1 1
foreground
1 0 1
0 1 0
0 0 1 background

1 1 1
1 1 1

Weeks 1 & 2 21
Distance measures
Distance measures Given pixels p, q and z with
coordinates (x, y), (s, t), (u, v) respectively, the
distance function D has following properties:
a. D(p, q) ≥ [D(p, q) = 0, iff p = q]
b. D(p, q) = D(q, p)
c. D(p, z) ≤ D(p, q) + D(q, z)
Different Distance measures:
• Euclidean Distance :
De(p, q) = [(x-s)2 + (y-t)2]

City Block Distance: !


D4(p, q) = |x-s| + |y-t|

Chess Board Distance: !


D8(p, q) = max(|x-s|, |y-t|)
Example: Addition of Noisy Images for Noise Reduction
Noiseless image: f(x,y)
Noise: n(x,y) (at every pair of coordinates (x,y), the noise is uncorrelated
and has zero average value)

Corrupted image: g(x,y)


g(x,y) = f(x,y) + n(x,y)

Reducing the noise by adding a set of noisy images, {gi(x,y)}

Weeks 1 & 2 24
Example: Addition of Noisy Images for Noise Reduction

Weeks 1 & 2 25
Example: Addition of Noisy Images for Noise Reduction

► In astronomy, imaging under very low light levels frequently


causes sensor noise to render single images virtually useless
for analysis.

► In astronomical observations, similar sensors for noise


reduction by observing the same scene over long periods of
time. Image averaging is then used to reduce the noise.

Weeks 1 & 2 26
Weeks 1 & 2 27
An Example of Image Subtraction: Mask Mode Radiography
Mask h(x,y): an X-ray image of a region of a patient’s body

Live images f(x,y): X-ray images captured at TV rates after injection of the
contrast medium

Enhanced detail g(x,y)

g(x,y) = f(x,y) - h(x,y)

The procedure gives a movie showing how the contrast medium propagates
through the various arteries in the area being observed.

Weeks 1 & 2 28
Weeks 1 & 2 29
An Example of Image Multiplication

Weeks 1 & 2 30
Set and Logical Operations

Weeks 1 & 2 31
Set and Logical Operations
Let A be the elements of a gray-scale image
The elements of A are triplets of the form (x, y, z), where x and y
are spatial coordinates and z denotes the intensity at the point (x,
y).

The complement of A is denoted Ac

Weeks 1 & 2 32
Set and Logical Operations
The union of two gray-scale images (sets) A and B is defined as the
set

Weeks 1 & 2 33
Set and Logical Operations

Weeks 1 & 2 34
Set and Logical Operations

Weeks 1 & 2 35
Neighborhood based arithmetic/Logic :
Value assigned to a pixel at position ‘e’ is a function of its neighbors
and a set of window functions.
Arithmetic/Logic Operations
• Tasksdone using neighbourhood processing:
◦– Smoothing / averaging
◦– Noise removal / filtering
◦– Edge detection
◦– Contrast enhancement
Set and Logical Operations

Weeks 1 & 2 38
Spatial Operations
Single-pixel operations
Alter the values of an image’s pixels based on the intensity.

e.g.,

Weeks 1 & 2 39
Spatial Operations
Neighborhood operations

The value of this pixel is determined


by a specified operation involving the
pixels in the input image with
coordinates in Sxy

Weeks 1 & 2 40
Spatial Operations
Neighborhood operations

Weeks 1 & 2 41
Geometric Spatial Transformations
Geometric transformation (rubber-sheet transformation)
— A spatial transformation of coordinates

— intensity interpolation that assigns intensity values to the spatially transformed


pixels.

Affine transform

Weeks 1 & 2 42
Weeks 1 & 2 43

You might also like