You are on page 1of 31

CS409: Selected Topics

Digital Image Processing


LN02: Digital Image Fundamentals

Prof. Dr. Mostafa Gadal-Haqq M. Mostafa


Computer Science Department
College of Information Technology
Misr University for Science and Technology

Agenda
 Human Visual System (The Eye)
 What’s a Digital Image?
 Digital Image Acquisition.
 Digital Image Representation.
 Pixel Neighborhood and Connectivity.
 Distance Measure
 Adjacency, Connectivity, Regions, and Boundaries

 Image Operations

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 2

1
Human Visual System (Eye)
 Structure of the Eye
 The eye is nearly a sphere, with an
average diameter of ~ 20 mm.
Three membranes enclose the
eye: the cornea and sclera outer
cover; the choroid; and the retina.
 The light receptors are the Rods
(~75 – 150M), which are sensitive
to light intensity, and Cones (~ 6 -
7M), which are sensitive to colors
and concentrated in the fovea, a
1.5 mm spot). These receptors do
not exist in blind spot.
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 3

Human Visual System (Eye)


 Structure of the Eye
Distribution of the rods and the cones in the retina

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 4

2
Human Visual System (Eye)
 Image formation in the Eye
 The focal lengths of the lens of the eye has a range of
14mm to 17mm.
 The size of the image, h, can be obtained from the
geometry as: h/17 = 15/100  h = 2.55 mm.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 5

Human Visual System (Eye)


 Brightness Adaptation and Discrimination
 The perceived brightness is not a simple function of
intensity.
 the visual system tends
to undershoot or
overshoot around the
boundary of regions of
different intensities, as
illustrated by the
perceived intensity of the
Mach Bands.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 6

3
Human Visual System (Eye)
 Brightness Adaptation and Discrimination
 The phenomenon Simultaneous Contrast is
related to the fact that a region’s perceived
brightness does not depend simply on its
intensity.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 7

Human Visual System (Eye)


 Adaptation and Discrimination (Optical illusions)

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 8

4
Human Visual System (Eye)
 Adaptation and Discrimination (The optical illusions)

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 9

Light and the Electromagnetic Spectrum

 The electromagnetic wave can be expressed in


terms of wavelength (), frequency (), or
energy (E). Where:

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 10

5
Light and the Electromagnetic Spectrum

 The electromagnetic spectrum

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 11

Digital Image Acquisition


 A digital imaging system (digital camera).

Line Sensor

A CDD, Single Sensor

Array Sensor
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 12

6
Digital Image Acquisition
 Digital imaging systems (line and circular)

A CDD, Single Sensor


CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 13

Digital Image Acquisition


 A digital imaging system (Array Sensor)

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 14

7
Digital Image Acquisition
 Sampling & Quantization

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 15

Digital Image Acquisition


 Sampling & Quantization

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 16

8
Digital Image Acquisition
 Real Images formation
 A real image can be represented as a y
two-dimensional continuous light
intensity function f(x,y); where x and y
denote the spatial coordinates any point
in the image, where
0 < f(x,y) < 
g(x,y)
f (x,y) = i (x,y) * r (x,y)
Where:
 i(x,y) is the intensity (illumination) of the
source, and r(x,y) is the reflectance of
the object (both are continuous). Where,
0 < i (x,y) < 
x
& 0< r (x,y)< 1
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 17

Digital Image Acquisition


 Digital Images
n
 A digital image is the
sampling and quantization
of a two-dimensional real
image both in spatial
coordinates and brightness.
I(m,n)
 A digital image I(m,n) =
samples of f(x,y); where m
and n are integers, and I is
the intensity at m and n .
m

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 18

9
Digital Image Acquisition
 What is the best quantization level ?
 Digital images are typically quantized to 256
levels (0 for black and 255 for white).

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 19

Digital Image Representation


 A digital image can be
represented as a two-dimensional n
matrix.

i(0,0) i(0,1) ……. i(0, n-1)


i(1,0) i(1,1) ……. i(1, n-1)
. .
I(mn) = . . . . . . . . . . ..
. . I(m,n)
i(m-1,0) i(m-1,0) … i(m-1, n-1)

• Each element is called a pixel (picture


element).
• A color (RGB) image is represented m
by a 3-dimensional matrix I(mxnx3)
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 20

10
Digital Image Size
 The digital image size (i.e. the number of bits
required to store the digital image) is determines by
its dimensions ( M x N ) and the number of bits k
required to store the intensity levels ( L = 2k )

image size = M x N x L (bits)


 Typical values of b are:
 k=1,L=2 black and white (binary) images.
 k = 8 , L = 256 grayscale, or indexed color images
 k = 24, L = 16777216 RGB color image.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 21

Digital Image Size


 Image size (bits) for various values of N (image
resolution = N x N) with k = bit depth, and L is the
number of intensity levels.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 22

11
Digital Image Resolution
 Digital image resolution is determined by the
number of pixels (samples) in the image.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 23

Image Resolution & Spatial Resolution

 To say an Image has a resolution 1024 x 1024 is not a


meaningful statement unless you state the spatial
dimensions encompassed by the image.
 Spatial resolution is a measure of the smallest
discernible detail in an image. It can be stated in as
the line pairs per unit distance, or the dots (pixels) per
unit distance. For example, if the width of a line is 0.1
mm, there are 5 line pairs per unit distance (mm).
 Spatial resolution (dots per inch - dpi) is important
when printing an image. For example: newspapers
are printed with a resolution of 75 dpi, magazines at
133 dpi, and books at 2400 dpi.
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 24

12
Digital Image Resolution
 Image resolution vs spatial resolution.

1024x1024x8 512x512x8 256x256x8

128x128x8 64x64x8 32x32x8

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 25

Digital Image Resolution


 Effects of reducing spatial resolution.

1250 dpi 300 dpi 150 dpi 72 dpi

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 26

13
Intensity Resolution/Levels
 Intensity resolution is the number of bits used to
quantize intensity. For example, an image whose
intensity is quantized into 256 levels has 8 bits of
intensity resolution.
 False contouring is the effect caused when using
insufficient number of intensity levels in smooth areas
of a digital image (quite visible in images displayed
using 16 or less intensity levels).
 A rule of thumb for the lowest spatial and intensity
resolution to print an image in 5cm x 5cm with
reasonably free of sampling checkerboards and false
contouring is 256 x 256 with 64 intensity levels .
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 27

Effect of Quantization Levels


 Effect of Quantization (intensity resolution/levels)

Image size:
452 x 374.
Displayed
256 128 16 8
at different
intensity
levels

64 32 4 2

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 28

14
Image Quality (isopreference curve)

 Effect of resolution on the quality of images with different details

How to determine
N and k for each
image with
Low details Medium details
different details
to have
High
reasonable
details
quality?
Isopreference curve
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 29

Image Interpolation
 Image interpolation is the process of using known data to
estimate values at unknown locations (used to obtain high-
resolution image from its low-resolution form).
 Interpolation is a basic tool used extensively in tasks such
as image resizing (shrinking and zooming in/out), rotating,
and geometric corrections.
 Methods for image interpolation:
 Nearest Neighbor interpolation: assigns the neighbor intensity
level to the new location.
 Bilinear interpolation approximate the value at the new location
using bilinear interpolation of the 4-neighbor pixels.
 Bicubic interpolation approximate the value at the new location
using bicubic interpolation of the (4x4) 16-neighbor pixels
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 30

15
Image Interpolation
 Bilinear interpolation

Where the coefficients a, b, c, and d are



obtained using the values of the 4-neighbor
pixels.
 Bicubic interpolation

 Where the coefficients aij are obtained using


the values of the (4x4) 16-neighbor pixels.
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 31

Image Interpolation

Source: Bicubic interpolation - Wikipedia


CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 32

16
Image Interpolation

72 dpi resized to 72 dpi resized to 72 dpi resized to


3692 x 2812 using 3692 x 2812 using 3692 x 2812 using
Neighbor interpolation bilinear interpolation bicubic interpolation

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 33

Image Interpolation

150 dpi resized to 150 dpi resized to 150 dpi resized to


3692 x 2812 using 3692 x 2812 using 3692 x 2812 using
Neighbor interpolation bilinear interpolation bicubic interpolation

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 34

17
Image Interpolation

Rotated 21o Rotated 21o Rotated 21o


300 dpi image Using Using
Using
Nearest bilinear bicubic
neighbor interpolation interpolation
interpolation

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 35

Digital image Types


 Black and white (Binary) Images
• Each pixel has one of two levels either 0 (black) or 1
(white).
• For B/W image, k = 1 bits and L = 2.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 36

18
Digital image Types
 Grayscale (Intensity) Images

Each pixel is given


a gray level value
between 0 – 255 or
between 0 – 1.

We need 8 bits to
store a grayscale
value.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 37

Digital image Types


 Indexed (Color) Images
In order to reduce the color image Indices
size,each pixel is given the index
of a color In a color table (color
map).

Index R G B
1
2
3
4
5
6
7
8
.
. Color Map
CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 38

19
Digital image Types
 RGB (Color) Images

Each pixel is a mixture of


three values of Red, Geen,
and Blue.

R,G,B = {0-255, 0-255, 0-255}


0 = Black
255 = White

In normalized values:
R,G,B = {0-1, 0-1, 0-1}
0 = Black
1 = White

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 39

Types of Pixel Neighborhoods

• Image sampling:
• Rectangular sampling - In most cases, images are sampled by laying
a rectangular grid over an image.
• Hexagonal sampling - An alternative sampling scheme is shown.

• Pixel Neighborhoods:
• 4-connected and 8-connected neighborhood (Rectangular sampling)
• 6-connected neighborhood (Hexagonal sampling)

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 40

20
Types of Pixel Neighborhoods
 Basic Relationships Between Pixels

4-connected 8-connected 6-connected

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 41

Distance Measures
 If pixels p and q have coordinates (x, y) and (s, t),
respectively.
 The Euclidean distance between p and q

 De(p, q) = [(x – s)2 + (y – t) 2] ½

 The D4 (City-block ) distance between p and q

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

 The D8 (Chessboard ) distance between p and q

 D8(p, q) = max( |x – s| , |y – t| )

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 42

21
Distance Measures
 Results of D4 and D8 distances

 The pixels with D4=1 are the 4-neighbors


 The pixels with D8=1 are the 8-neighbors

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 43

Adjacency, Connectivity, Regions, and Boundaries

 Adjacency:
 4-adjacency : Two pixels p and q are 4-adjacent if
q is in the set N4(p).
 8-adjacency. Two pixels p and q are 8-adjacent if
q is in the set N8(p).
 Connectivity: Let S represent a subset of pixels:
 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.
 the set of pixels that are connected to each other
in S is called a connected component of S.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 44

22
Adjacency, Connectivity, Regions, and Boundaries

 Path:
 A (digital) path (or curve) 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); (xn , yn)= (s, t); and
pixels (xi , yi) and (xi-1 , yi-1) are adjacent for 1<= i <= n.

 In this case, n is the length of the path. If (x0 , y0)= (s, t) the
path is a closed path.
 We can define 4- or 8-paths depending on the type of
adjacency specified.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 45

Adjacency, Connectivity, Regions, and Boundaries

 Region:
 If R be a subset of pixels in an image, we call R a
region of the image if R is a connected set.

 Boundary:
 The boundary (also called border or contour) of a
region R is the set of pixels in the region that have
one or more neighbors that are not in R.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 46

23
Adjacency, Connectivity, Regions, and Boundaries

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 47

Types of image Operations


 Operation Domain

Operation Characterization Complexity/Pixel

the output value at a specific coordinate is


Point dependent only on the input value at constant
that same coordinate.

the output value at a specific coordinate is


Local dependent on the input values in the P2
neighborhood of that same coordinate.

the output value at a specific coordinate is


Global dependent on all the values in the input N2
image.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 48

24
Types of image Operations

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 49

Types of image Operations


 Pixel Operations

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 50

25
Types of image Operations
 Local Operations

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 51

Types of image Operations


 Local Operations?

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 52

26
Types of image Operations
 Arithmetic Operations?

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 53

Types of image Operations


 Arithmetic Operations?

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 54

27
Types of image Operations
 Logical Operations?

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 55

Types of image Operations


 Sets Operations

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 56

28
Types of image Operations
 Geometric Operation
(Transformation)

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 57

Types of image Operations


 Space Transformations

 Forward Transformations

 Inverse Transformations

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 58

29
Types of image Operations
 Space Transformation (Fourier Transformation)

 Forward Kernel

 Inverse Kernel

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 59

Categories of Image Operations

 Linear and Nonlinear Operations

 H is said to be a linear operator if, for any two


images f and g and any two scalars a and b,

H( a f + b g ) = a H( f ) + b H( g )

 Operations that do not satisfy this condition is


called nonlinear operations

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 60

30
Homework 1

 Solve the following problems (page 100-101):

 2.1, 2.2, 2.3, 2.4, 2.5, 2.6,


2.9, and 2.10.

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 61

Next time

Chapter 3:
Intensity Transformations
and Spatial Filtering

CS409: Digital Image Processing Prof. Dr. Mostafa GadalHaqq. 62

31

You might also like