Introduction to
Digital Image Processing
(Part 2)
By
Dr. Pradyut Kumar Biswal
IIIT, Bhubaneswar
Image formation
➢ The image is denoted by 2D functions of the form f(x,y).
➢ The value of f at spatial coordinates (x,y ) is a scalar quantity
whose values are proportional to energy radiated by a physical
source (e.g., electromagnetic waves).
➢ f(x,y ) must be nonnegative and finite i.e.
9/5/2024 Digital Image Processing 2
Image
➢ Function f(x,y) is characterized by two components:
▪ the amount of source illumination incident on the
scene being viewed, i.e. illumination components
denoted by i(x,y)
▪ the amount of illumination reflected by the objects
in the scene i.e. reflectance components denoted by
r(x,y).
➢ f(x,y)= i(x,y) * r(x,y) where
➢ Thus, reflectance is bounded by 0 (total absorption) and
1 (total reflectance).
9/5/2024 Digital Image Processing 3
Image Sampling and Quantization
➢ To create a digital image, the continuous
sensed data need to be converted into a digital
format using two processes: sampling and
quantization.
➢ An image may be continuous with respect to
the x- and y-coordinates, and also in
amplitude.
➢ To digitize it, we have to sample the function
in both coordinates and also in amplitude.
➢ Digitizing the coordinate values is called
sampling.
➢ Digitizing the amplitude values is called
quantization.
9/5/2024 Digital Image Processing 4
Image Sampling and Quantization
Continuous Image Amplitude variation along AB
9/5/2024 Digital Image Processing 5
Image Sampling and Quantization
9/5/2024 Digital Image Processing
6
Digital Image Representation
➢ Let f(s,t) represent a continuous image function of two
continuous variables, s and t.
➢ Let digital image is represented by f(x,y) containing M
rows and N columns, where (x,y) are discrete
coordinates
x= 0, 1, 2, ……M−1 and y= 0, 1, 2, …… N−1
9/5/2024 Digital Image Processing 7
Digital Image Representation
Surface Plot Intensity Image Array Representation
Coordinate convention used
to represent digital
9/5/2024 Digital Image Processing 8
Image contrast
➢ The range of values spanned by the gray scale is
referred to as the dynamic range.
➢ Image contrast is defined as the difference in
intensity between the highest and lowest intensity
levels in an image
➢ The contrast ratio is the ratio of the two quantities
i.e. highest and lowest intensity levels in an image.
➢ When an appreciable number of pixels in an image
have a high dynamic range, the image is to have
high contrast.
➢ An image with low dynamic range typically has a
dull, washed-out gray look.
9/5/2024 Digital Image Processing 9
Image Resolution
➢ Two types i.e. Spatial resolution and Intensity
resolution.
➢ Spatial resolution is a measure of the smallest
discernible detail in an image. Quantitatively,
spatial resolution can be stated in several ways,
with line pairs per unit distance, and dots (pixels)
per unit distance.
➢ Intensity resolution similarly refers to the smallest
discernible change in intensity level.
➢ Based on hardware considerations, the number of
intensity levels usually is an integer power of two.
➢ The number of bits used to quantize intensity is
called as intensity resolution.
9/5/2024 Digital Image Processing 10
Spatial Resolution
930 dpi 300 dpi
150 dpi 72 dpi
9/5/2024 Digital Image Processing 11
Intensity Resolution
9/5/2024 Digital Image Processing 12
Neighbors of a pixel
➢ some of the points in ND (p) and N8 (p) fall outside the image if
(x,y) is on the border of the image.
9/5/2024 Digital Image Processing 13
Connectivity
➢ Two pixels are connected if:
▪ They are neighbors (i.e. adjacent in some sense
-- e.g. N4(p), N8(p), …)
▪ Their gray levels satisfy a specified criterion of
similarity (e.g. equality, …)
9/5/2024 Digital Image Processing 14
Adjacency and Connectivity
➢ Let V: a set of intensity values used to define
adjacency and connectivity.
➢ 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
V typically contains more elements, for example,
V = {180, 181, 182, …, 200}
➢ If the possible intensity values 0 – 255, V set
can be any subset of these 256 values
9/5/2024 Digital Image Processing 15
Adjacency
V: set of gray level values (L), (V is a subset of L.)
3 types of adjacency
➢ 4- adjacency: 2 pixels p and q with values from V
are 4- adjacent if q is in the set N4(p)
➢ 8- adjacency: 2 pixels p and q with values from V
are 8- adjacent if q is in the set N8(p)
➢ m- adjacency (mixed adjacency): 2 pixels p and
q with values from V are m-adjacent if
1. q is in N4(p), or
2. q is in ND(p) and the set N4(p) ∩ N4(q) has
no pixels whose values are from V.
9/5/2024 Digital Image Processing 16
Example of Adjacency
9/5/2024 Digital Image Processing 17
Example of Adjacency
➢ In this example, to connect between two pixels
(i.e. finding a path between two pixels):
▪ In 8-adjacency way, multiple paths can be found
between two pixels
▪ While, in m-adjacency, one path can be found only
between two pixels
➢ So, m-adjacency has eliminated the multiple
path connection that has been generated by
the 8-adjacency.
9/5/2024 Digital Image Processing 18
A digital path
➢ A digital 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), …,
(xn,yn),
➢ where (x0,y0)= (x,y) and (xn,yn)=(s,t), and pixels
(xi,yi) and (xi-1,yi-1) are adjacent for 1 ≤ i ≤ n.
➢ Here, n is the length of the path.
9/5/2024 Digital Image Processing 19
A digital path
➢ If (x0,y0) = (xn, yn), the path is closed.
➢ We can specify 4-, 8- or m-paths depending on
the type of adjacency specified.
9/5/2024 Digital Image Processing 20
Connectivity
➢ S: a subset of pixels in an image.
➢ Two pixels p and q are said to be
connected in S if there 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.
9/5/2024 Digital Image Processing 21
Region
➢ Let R represent a subset of
pixels in an image.
➢ R can be called 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. Considering
8-adjacency
➢ Regions that are not adjacent
are said to be disjoint.
9/5/2024 Digital Image Processing 22
Foreground and background
➢ Suppose that the image contains K disjoint
regions Rk where k = 1,2, ….K, none of which
touches the image border.
➢ Let Ru : the union of all the K regions and
(Ru)c : is the complement .
➢ Then, Ru is called foreground , and (Ru)c : is the
background .
9/5/2024 Digital Image Processing 23
Boundaries
➢ The boundary (also called the border or contour) of
a region R is the set of pixels in R that are adjacent
to pixels in the complement of R.
➢ In another way, the border of a region is the set of
pixels in the region that have at least one
background neighbor.
➢ 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 in the image.
9/5/2024 Digital Image Processing 24
Distance measures
If we have 3 pixels: p,q,z respectively
p with coordinate (x,y)
q with coordinate (s,t)
z with coordinate (v,w)
Then: D is a distance function or metric if
• D (p,q) ≥ 0 , (D(p,q) = 0 iff p = q)
• D(p,q) = D(q,p)
• D(p,z) ≤ D(p,q) + D(q,z)
9/5/2024 Digital Image Processing 25
Distance measures
➢ Euclidean distance between p and q:
De(p,q) = [(x-s)2 + (y-t)2]1/2
➢ For this distance measure, the pixels having
a distance less than or equal to some value r
from (x,y) are the points contained in a disk
of radius r centered at (x,y).
9/5/2024 Digital Image Processing 26
Distance measures
➢ D4 distance (also called city-block distance):
D4(p,q) = |x-s| + |y-t|
➢ Pixels having a D4 distance from (x,y) that
is less than or equal to some value d form a
diamond centered at (x,y).
9/5/2024 Digital Image Processing 27
Distance Measures
Example:
The pixels with distance D4 ≤ 2 from (x,y) form
the following contours of constant distance.
The pixels with D4 = 1 are
the 4-neighbors of (x,y)
9/5/2024 Digital Image Processing 28
Distance measures
➢ D8 distance (also called chessboard
distance) :
D8(p,q) = max (|x-s| , |y-t|)
➢ In this case, the pixels with D8 distance
from (x,y) less than or equal to some
value d form a square centered at (x,y).
9/5/2024 Digital Image Processing 29
Distance Measures
Example:
D8 distance ≤ 2 from (x,y) form the following
contours of constant distance.
D8 = 1 are the 8-neighbors of (x,y)
9/5/2024 Digital Image Processing 30
Distance measures
9/5/2024 Digital Image Processing 31
Example:
Compute the distance between the two pixels
using the three distances :
q: (1,1)
P: (2,2) 1 2 3
Euclidian distance : ((1-2)2+(1-2)2)1/2 =sqrt(2). 1 q
2
D4(City Block distance): |1-2| +|1-2| =2 p
D8(chessboard distance ) : max(|1-2|,|1-2|)=1 3
(because it is one of the 8-neighbors )
9/5/2024 Digital Image Processing 32
Distance Measures
➢ Dm distance: is defined as the shortest m-path
between the points.
➢ In this case, the distance between two pixels will
depend on the values of the pixels along the
path, as well as the values of their neighbors.
9/5/2024 Digital Image Processing 33
Distance Measures
➢ Example:
Consider the following arrangement of pixels and
assume that p, p2, and p4 have value 1 and that
p1 and p3 can have a value of 0 or 1
Suppose that we consider
the adjacency of pixels
values 1 (i.e. V = {1})
9/5/2024 Digital Image Processing 34
Distance Measures
➢ Cont. Example:
Now, to compute the Dm between points p and
p4
Here we have 4 cases:
Case1: If p1 =0 and p3 = 0
The length of the shortest m-path
(the Dm distance) is 2 (p, p2, p4)
9/5/2024 Digital Image Processing 35
Distance Measures
➢ Cont. Example:
Case2: If p1 =1 and p3 = 0
then, the length of the shortest
path will be 3 (p, p1, p2, p4)
9/5/2024 Digital Image Processing 36
Distance Measures
➢ Cont. Example:
Case3: If p1 =0 and p3 = 1
The same applies here, and the shortest –m-
path will be 3 (p, p2, p3, p4)
9/5/2024 Digital Image Processing 37
Distance Measures
➢ Cont. Example:
Case4: If p1 =1 and p3 = 1
The length of the shortest m-path will be 4 (p,
p1 , p2, p3, p4 )
9/5/2024 Digital Image Processing 38
Arithmetic Operations
➢ Arithmetic operations between two images f(x,y)
and g(x,y) are denoted as
➢ These are elementwise operations i.e. they are
performed between corresponding pixel pairs in f
and g for x =0, 1, …(M-1) and y=0,1,…..(N-1)
9/5/2024 Digital Image Processing 39
Geometric Transformations
➢ geometric transformations modify the
spatial arrangement of pixels in an
image.
➢ It consists of two basic operations:
▪ Spatial transformation of
coordinates.
▪ Intensity interpolation that assigns
intensity values to the spatially
transformed pixels.
9/5/2024 Digital Image Processing 40
Geometric Transformations
➢ Let (x,y) are pixel coordinates in the
original image and (x’,y′) are the
corresponding pixel coordinates of the
transformed image.
➢ The transformation of coordinates may
be expressed as,
9/5/2024 Digital Image Processing 41
Affine Transformations
➢ Affine transformations include 4 operations
i.e. scaling, translation, rotation, and
shearing.
➢ In generalized form,
➢ This transformation can scale, rotate,
translate, or sheer an image, depending on
the values chosen for the elements of
matrix A
9/5/2024 Digital Image Processing 42
Affine Transformations
➢ Affine transformations can be performed in 2
ways.
➢ Forward mapping: Scanning the pixels of the
input image and, at each location (x,y)
computing the spatial location (x’,y’) of the
corresponding pixel in the output image.
➢ Disadvantage: two or more pixels in the input
image can be transformed to the same location
in the output image. How to combine multiple
output values into a single output pixel value?
➢ Some output locations may not be assigned a
pixel at all.
9/5/2024 Digital Image Processing 43
Affine Transformations
➢ Inverse mapping: Scans the output pixel
locations and, at each location (x’,y’),
computes the corresponding location in the
input image using (x,y), where,
(x,y) = A−1 (x’,y’).
➢ It then interpolates among the nearest input
pixels to determine the intensity of the output
pixel value.
9/5/2024 Digital Image Processing 44
Affine Transformations
9/5/2024 Digital Image Processing 45
Affine Transformations
9/5/2024 Digital Image Processing 46
Query?
Thanks
9/5/2024 Digital Image Processing 47