You are on page 1of 30

Digital Image Processing

Part 2

Assist. Prof. Dr. Rasper Dh. Rashid


E-mail : rasber.dhahir@ukh.edu.krd
Master Students / Computer Science
2022-2023
A simple Mathematical model of an image

 A monochromatic image is a 2D function f(x, y) representing the detected


energy level at each point (x,y) of its “Spatial” region.
 The amplitude of f at the spatial coordinates (x, y) is a positive scalar
quantity whose physical meaning is determined by the source of the
image and the source of energy.
 When an image is generated from a physical process, its values are
proportional to energy radiated by the source, i.e.
0< f(x, y)< ∞.
 f(x, y) is the product of two components: the amount of source illumination
incident on the scene i(x, y) and the amount of illumination reflected by
the objects in the scene r(x, y):
f(x, y)=i(x, y)r(x, y)
where 0<i(x, y)<∞ and 0<r(x, y)<1.
 The nature of i(x, y) is determined by the illumination source, and r(x, y)
depends on the characteristics of the imaged object.
Digitising an image

 To convert the continuous function f(x,y) to digital form we need to


sample the continuous sensed data in both coordinates and in amplitude
using finite and discrete sets of values.
 Digitizing the coordinate values is called sampling.
 Digitizing the amplitude values is called quantisation.
 The number of selected values in the sampling process is known as the
image spatial resolution. This is simply the number of pixels relative to
the given image area
 The number of selected values in the quantisation process is called the
grey-level (colour level) resolution. This is expressed in terms of the
number of bits allocated to the colour levels.
 The quality of a digitised image depends the resolution parameters on
both processes.
Digital image Representaion – Revised

 A monochrome digital image is a 2-dimensional light intensity function f


(x,y) whose independent variables (x,y) are digitised through spatial
sampling, and whose intensity values are quantised by a finite uniformly
spread grey-levels.
f(1,1) f(1,2) f(1,3) … f(1,n)
f(2,1) f(2,2) f(2,3) … f(2,n)
f= f(3,1) f(3,2) f(3,3) … f(3,n)
: : : : :
: : : : :
f(m,1) f(m,2) f(m,3) … f(m,n)

 Usually, m=n and the number of graylevels are g=2k for some k. The
spatial resolution is mn and g is the greylevel resolution.
 RGB based colour images are represented similarly except that f(i,j) is a
3D vector representing intensity of the three primary colors at the (i,j) pixel
posiotion,
Spatial and Intensity Resolution

Spatial resolution
— A measure of the smallest discernible detail in an image
— stated with line pairs per unit distance, dots (pixels) per
unit distance, dots per inch (dpi)

Intensity resolution
— The smallest discernible change in intensity level
— stated with 8 bits, 12 bits, 16 bits, etc.
Spatial Resolution

 The spatial resolution of a digital image reflects the amount


of details that one can see in the image (i.e. the ratio of pixel
“area” to the area of the image display).
 If an image is spatially sampled at mxn pixels, then the
larger mn the finer the observed details.
 For a fixed image area, the noticeable image quality is
directly proportional to the value of mn results.
 Reduced spatial resolution, within the same area, may result
in what is known as Checkerboard pattern.
 However beyond a certain fine spatial resolution, the human
eye may not be able to notice improved quality.
Spatial Resolution Vs Image Quality

 Decreasing spatial resolution reduces image quality proportionally -


Checkerboard pattern.
Spatial Resolution Vs Image Quality - continued

 The checkerboard effect is not visible if a lower–resolution


image is displayed in a proportionately small window.
Effect of grey level resolution

123 162 200 147 93 61 80 100 73 46


137 157 165 232 189 68 78 82 116 94
f(i,j) int(f(i,j)/2)
Image f = 151 155 152 141 130 75 77 76 70 65
205 101 100 193 115 102 50 50 96 57
250 50 75 88 100 125 25 37 43 50
8 bits 7 bits

30 40 50 36 23 15 20 25 18 11 7 10 12 9 5
34 39 41 58 47 17 19 20 29 23 8 9 10 14 11
37 38 38 35 32 18 19 19 17 16 9 9 9 8 8
51 25 25 48 28 25 12 12 24 14 12 6 6 12 7
62 12 18 21 25 31 6 9 10 12 15 3 4 5 6
6 bits 5 bits 4 bits

3 5 6 4 2 1 2 3 2 1 0 1 1 1 0
4 4 5 7 5 2 2 2 3 2 1 1 1 1 1
4 4 4 4 4 2 2 2 2 2 1 1 1 1 1
6 3 3 6 3 3 1 1 3 1 1 0 0 1 0
7 1 2 2 3 3 0 1 1 1 1 0 0 0 0
3 bits 2 bits 1 bits

Original image f is reasonably bright, but gradually the pixels get


darker as the Grey-level resolution decreases.
Effect of grey level resolution

8 bits 7 bits 6 bits

4 bits 3 bits
5 bits

2 bits 1 bit 0 bits !!!


Image Interpolation
Interpolation : Process of using known data to estimate
unknown values. For example (zooming, shrinking, and rotating).

- Interpolation (sometimes called resampling), an imaging


method to increase (or decrease) the number of pixels in a digital
image.

- Some digital cameras use interpolation to produce a larger


image than the sensor captured or to create digital zoom.
Zooming and Resizing

 It is the scaling of an image area A of wxh pixels by a factor s while


maintaing spatial resolution (i.e. output has swsh pixels).
 First we need a linear scaling function S to map the coordinates of
new pixels onto the original pixel grid of A.
 For each (x,y) in the resized area, we need to interpolate the gray
value sf(x,y) in terms of the pixels values in A that neighbour the
point S(x,y). Different models of approximations are used.

A
S(A)
Example: Scaling A by a factor s=1.5
Zooming and Shrinking Digital Images

This topic is related to image sampling and quantization because


zooming may be viewed as oversampling, while shrinking may
be viewed as under sampling. The key difference between these
two operations is that zooming and shrinking are applied to a
digital image. Zooming requires two steps: the creation of new
pixel locations, and the assignment of gray levels to those new
locations.
Methods of Zooming
Nearest neighbour Image Scaling (Pixel replication)
is the simplest and fastest implementation of image scaling
technique. It is very useful when speed is the main concern, for
example when zooming image for editing .

- The principle in image scaling is to have a reference image and


using this image as the base to construct a new scaled image. The
constructed image will be smaller, larger, or equal in size depending
on the scaling ratio.
Methods of Zooming
- When enlarging an image, we are actually introducing empty
spaces in the original base picture. From the image below, an image
with dimension (w1 = 4, h1 = 4) is to be enlarged to (w2 = 8, h2 =
8). The black pixels represent empty spaces where interpolation is
needed, and the complete picture is the result of nearest neighbor
interpolation.
example
If you have an image of 2 rows and 2 columns and you want to
zoom it twice or 2 times using pixel replication, here how it can be
done. For a better understanding, the image has been taken in the
form of matrix with the pixel values of the image

The above image has two rows and two columns, we will first
zoom it row wise.
example
Row wise zooming:
When we zoom it row wise, we will just simple copy the rows pixels
to its adjacent new cell. Here how it would be done
1 2
1 2
3 4
3 4

Column size zooming: The next step is to replicate each of the pixel
column wise, that we will simply copy the column pixel to its adjacent
new column or simply below it. Here how it would be done
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
Advantage and disadvantage:
One of the advantage of this zooming technique is, it is very
simple. You just have to copy the pixels and nothing else.

The disadvantage of this technique is that image got zoomed but


the output is very blurry. And as the zooming factor increased, the
image got more and more blurred. That would eventually result in
fully blurred image.
Methods of Zooming
Zero Order Hold Method:

is another method of zooming. It is also known as zoom twice.


Because it can only zoom twice.

Working In zero order hold method:

we pick two adjacent elements from the rows respectively and then
we add them and divide the result by two and place their result in
between those two elements. We first do this row wise and then we
do this column wise.
New image size:
As you can see that the dimensions of the new image are 3 x 3
where the original image dimensions are 2 x 2. So it means that
the dimensions of the new image are based on the following
formula
New image size = (2(no. rows)-1)X(2(no. columns) -1)
Basic Relationships Between Pixels

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


neighbors whose coordinates are given by: (x+1, y), (x-1, y),
(x, y+1), (x, y-1) This set of pixels, called the 4-neighbors of
p, is denoted by N4(p).

(x, y-1)

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

(x, y+1)
4-diagonal neighbors of p

Each pixel is a unit distance from (x, y), and some of the
neighbors of p lie outside the digital image if (x, y) is on the
border of the image.
(x-1, y-1) (x+1, y-1)

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

The 4-diagonal neighbors of p have coordinates (x+1, y+1),


(x+1, y-1), (x-1, y+1), (x-1, y-1)and are denoted by ND(p).
8 neighbors of p

N4(p), together with the ND(p), are called the 8-neighbors of


p, denoted by N8(p). As before, some of the points in ND(p)
and N8(p) fall outside the image if (x, y) is on the border of
the image.

8 neighbors of p, denoted N8(p)


N8(p) = N4(p) U ND(p)
Mathematical Operations in DIP

Array vs. Matrix Operation

 a11 a12   b11 b12 


A  B
 a21 a22  
Array
product  21 22 
b b
operator
 a11b11 a12b12 
A .* B   Array product
 a21b21 a22b22 
Matrix
product
operator
 a11b11  a12b21 a11b12  a12b22  Matrix product
A*B 
a b 
 21 11 22 21
a b a b
21 12  a 22 22 
b
Arithmetic Operations

Arithmetic operations between images are array operations.


The four arithmetic operations are denoted as

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


d(x,y) = f(x,y) – g(x,y)
p(x,y) = f(x,y) × g(x,y)
v(x,y) = f(x,y) ÷ g(x,y)
Addition

Image: I Image: I+50


Subtraction

Image: I Image: I-80


Multiplication

Image: I Image: I*3


Division

Image: I Image: I/2


Complement

Image: I Image: 255-I

You might also like