You are on page 1of 49

DIGITAL IMAGE PROCESSING AND

APPLICATIONS

Digital Image Fundaments


(Chapter 2)
Functions needed in image acquisition stage
Dr. Hetal N. Patel
SIMPLE IMAGE FORMATION MODEL
 F(x,y) must be nonzero and finite
0 < f(x,y) < ∞

 If i(x,y) and r(x,y) are illumination and reflectance


components of an image resp. then
f(x,y) = i(x,y) * r(x,y)
0 < i(x,y) < ∞
and 0 < r(x,y) < 1

2
WHAT IS A GRAY SCALE?

 The intensity of a monochrome image at any


coordinates(x0 , y0 ) is the gray level ‘L’ of the
L

image at that point.


 L = f(x0 , y0)
and l lies in the range
Lmin <= L <= Lmax
Lmin = imin *rmin & Lmax = imax*rmax
 The interval [Lmin , Lmax] is called the gray
scale. Commonly used gray scale is [0,L-1].
3
IMAGE SAMPLING AND QUANTIZATION

4
5
6
REPRESENTING DIGITAL IMAGE

 f(x,y)= [ f(0,0) f(0,1) … f(0,N-1)


f(1,0) f(1,1) … f(1,N-1)
. . … .
. . … .
f(M-1,0) f(M-1,1)…f(M-1,N-1)]
The right side of this equation is defined as an image.
The no. of gray levels is an integer power of 2:
L = 2k
 The number ,b, of bits required to store a digitized image
is
b=M*N*k

7
REPRESENTATION OF DIGITAL IMAGE

8
STORAGE BITS FOR VARIOUS VALUES OF N AND K

9
SPATIAL AND INTENSITY RESOLUTION

 Spatial resolution is a measure of the smallest


discernible details in an image.

10
ZOOMING AN IMAGE
 Requires two steps:
1) The creation of new pixel location and
2) The assignment of gray levels to those new locations.
 Two methods for gray-level assignment to a pixel:
1) The nearest neighbor interpolation and
2) The bilinear interpolation
3) The bicubic interpolation

11
ZOOMING OF AN IMAGE

12
HOW TO ZOOM THE INPUT IMAGE USING
MATLAB?
>>i=imread('circuit.tif');
>> [r,c]=size(i);
>> j=imresize(i,[10*r , 10*c],’nearest’);
>>k=imresize(i, [10*r , 10*c], ‘bilinear’);
>>figure(1),imshow(i);
>> figure(2),imshow(j);
>>Figure(3),imshow(k);
Figure(1) is shown here , which is an input image.
Figure(2) is the zoom of an input image using nearest neighbor
interpolation.
Figure(3) is the zoom of an input image using bilinear interpolation

13
HOW TO ZOOM THE INPUT IMAGE USING
MATLAB? CONT..

Input image Nearest Neighbor Bilinear Interpolation

14
PIXEL REPLICATION: SPECIAL CASE OF
NEAREST NEIGHBOR INTERPOLATION
BILINEAR AND BICUBIC INTERPOLATION
 Let (x,y) denote the coordinates of the location to
which we want to assign an intensity value and let
v(x,y) denote that intensity value. For bilinear
interpolation, the assigned value is obtained using
the equation ,
 V(x,y)= ax + by + cxy + d
 Bicubic interpolation involves the sixteen nearest
neighbors of a point. The intensity value assigned to
point (x,y) is obtained using equation,
3 3
 V(x,y) = Ʃ Ʃ aij x i y j
i=0 j=0 16
COMPARISON BETWEEN NEAREST
NEIGHBOR AND BILINEAR INTERPOLATION

17
BILINEAR INTERPOLATION
 Consider enlarging a M x M image to size N x N where M = 500
and N = 750. Imagine scaling the 750 x 750 grid to fit over our
500 x 500 image. Assume our original image is represented by
matrix A and the enlarged image by matrix B. We need to step
over every grid point in the 750 x 750 image (every element in B).
Consider a single element in matrix B, say element B(332, 615).
T he corresponding scaled coordinates of the grid point are:

 x=332(M – 1)/(N – 1)=332(500 – 1)/(750 –1)=221.185


 y=615(M – 1)/( N –1)=615(500 – 1)/(750 –1)=409.726

 Note that these coordinate values will always lie between 0 and 499.
The four nearest neighbors of this grid point are: A(221, 409),
A(221, 410), A(222, 409), and A(222, 410). (These coordinate
values can be found by using the floor and ceil functions.)
 The bilinear interpolation equation is:
 v ( x , y)=a x+b y +c x y+d
BILINEAR INTERPOLATION

 We obtain four equations by evaluating this


equation at the four nearest neighbors. In
matrix form we would have:
BILINEAR INTERPOLATION
 Assume the four nearest neighbors have intensity
values:
 A(221, 409) = 121, A(221, 410) = 124,
 A(222, 409) = 118, and A(222, 410) = 110.
 Solving the matrix equation above with these
values yields: [a b c d ]=[4496 2434 −11
−994720] .
 Using these four coordinates in the bilinear
interpolation equation above gives v(221.185,
409.726) = 121.15 We would then assign this
value to B(332, 615) (after appropriate
rounding). This procedure would need to be
repeated for each element of B.
BICUBIC INTERPOLATION
 In mathematics, bicubic interpolation is an
extension of cubic interpolation for
interpolating data points on a two dimensional
regular grid. The interpolated surface
is smoother than corresponding surfaces
obtained by bilinear interpolation or nearest-
neighbor interpolation. Bicubic interpolation
can be accomplished using either Lagrange
polynomials, cubic splines or cubic
convolution algorithm.
BICUBIC INTERPOLATION(CONT..)

 In contrast to bilinear interpolation, which only


takes 4 pixels (2×2) into account, bicubic
interpolation considers 16 pixels (4×4).
 Images resampled with bicubic interpolation
are smoother and have fewer interpolation
artifacts.
BICUBIC INTERPOLATION
BICUBIC INTERPOLATION
BICUBIC INTERPOLATION
SHRINKING AN IMAGE

 Done in similar manner as described for


zooming
 The deletion of row - column pixels.

26
SHRINKING OF AN INPUT IMAGE

27
SAME SIZE, DIFFERENT PIXEL SIZES
VARYING GRAY LEVEL RESOLUTION
SIZE, QUANTIZATION LEVELS AND DETAILS

Isopreference curves
BASIC RELATIONSHIP BETWEEN PIXELS

 Neighborhood
 Adjacency

 Connectivity

 Paths

 Regions and boundaries


NEIGHBORHOOD OF A PIXEL

 Any pixel p(x,y) has two vertical and two


horizontal neighbors, given by
(x+1,y),(x-1,y),(x,y+1) and(x,y-1)
 This set of pixels are called the 4-neighbors of
pixel p , is denoted by N4(p).
 Each pixel is a unit distance from pixel p (x,y),
and some of the neighbors of p lie outside the
digital image if (x,y) is on the border of the
image.
NEIGHBORS OF A PIXEL (CONT..)

 The four diagonal neighbors of p(x,y) are given


by
(x+1,y+1),(x+1,y-1),(x-1,y+1) and(x-1,y-1)
 This set is denoted by ND(p).

 These points, together with the 4-neighbors are


called the 8-neighbors of p, denoted by N8(p).
NEIGHBORS OF A PIXEL(CONT..)

 4-neighbors of a pixel p
are its vertical and
horizontal neighbors
denoted by N4(p).

 8-neighbors of a pixel p
are its vertical,
horizontal and 4
diagonal neighbors
denoted by ND(p).
NEIGHBORS OF A PIXEL( CONT..)

 N4 :- 4-neighbors.
 ND :- diagonal neighbors.
 N8- 8- neighbors (N4UND)
ADJACENCY

 Two pixels are connected if they are neighbors


and their gray levels satisfied some specified
criterion of similarity.
 For example, in a binary image two pixels are
connected if they are 4-neighbors and have
same value(0/1).
ADJACENCY (CONT..)
 Let V be set of gray level values used to define
adjacency.
 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 [N4(p) ∩ N4(q)] is empty.
CONNECTIVITY
 To determine whether the pixels
are adjacent in some sense.
 Two pixels p and q 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 :
➢ if q is in N4(p) or
➢ q is in ND(p) and the set
[N4(p) ∩ N4(q)] is empty.
ADJACENCY/ CONNECTIVITY
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.
PATHS AND PATH LENGTHS

 A path from pixel p with co-ordinates (x,y) to


pixel q with co-ordinates (s,t) is a sequence of
distinct pixels with co-ordinates
(x 0,y 0), (x 1,y 1), (x 2,y 2),……….(x n,y n)
Where (x 0,y 0) = (x,y) and (x n,y n)=(s,t).
(x i,y i) is adjacent to (x i-1,y i-1), 1<i<n
 Here n is the length of the path.

 We can define 4-,8- and m- paths based on


type of adjacency used.
CONNECTED COMPONENTS

 If p and q are pixels of an image subset S then


p is connected to q in S if there is a path from p
to q consisting entirely of pixels in S.
 For every pixel p in S , the set of pixels in S that
are connected to p is called as connected
components of S.
 If S has only one connected component then S
is called connected set.
REGIONS AND BOUNDARIES

 A subset R of pixels in an image is called a


Region of the image if R is the connected set.
 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.
DISTANCE MEASUREMENT
 For pixels p , q and z ,with co-ordinates
(x,y),(s,t) and (v,w),resp. D is a distance
function if
1. D(p,q) >=0 : (D(p,q) = 0 if p=q),
2. D(p,q) = D(q,p) and
3. D(p,z) <=D(p,q) + D(q,z)
 The Euclidean distance between p and q is
defined as
De(p,q) = [ (x-s)2 +(y-t)2 ]1/2
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|)
DISTANCE MEASUREMENT EXAMPLE

Consider the example shown above , to find the distance


between the pixels P and P4 with the values of P , P3 and P4
is solved in three different cases:
(i) p1 = p2 = 0 (ii) p1 = 1 ,p2 = 0 and (iii) p1 = p2 =1
If p1 and p2 are 0 then the m-distance between the pixels P
and P4 is two ; assume each pixels are placed at unit
distance from the neighbor.

If p1 is 1 and p2 is 0 than the


m-distance between the pixels
P and P4 is three.
If p1 and p2 are 1 then the m-distance between the pixels
P and P4 is 4 ; assume each pixels are placed at unit
distance from the neighbor.
THANK YOU

MATHEMATICAL
TOOLS USED IN
DIGITAL IMAGE
PROCESSING

You might also like