Dr Mai Kamal DIP 2022 1
By
Lecturer, Computer Science Department,
Faculty of Computers and Artificial Intelligence,
Benha University
Dr Mai Kamal DIP 2022 2
Digital Iamge Processing Course
Dr Mai Kamal DIP 2022 3
Digital Iamge Processing
Course
Teams Link
[Link]
mGOukoYKvZIwPVey1-
EUiL4Y1%40thread.tacv2/conversations?groupId=47e1fe88-6e6b-
433e-b771-94c21eeb96c6&tenantId=ff4a48d6-4b5e-4fd3-8266-
7eafc3e6e23e
Dr Mai Kamal DIP 2022 4
Grading Formula
Weights of the Assessments
Final Term Examination 50
Midterm Exam 15
Practical Exam 15
Quiz 1 5
Quiz 2 5
Semester Work 10
Dr Mai Kamal DIP 2022 5
Text Book
R. Gonzalez, R. Woods.
Digital Ιmage Processing,
Prentice Hall, 2008.
Third Edition .
Dr Mai Kamal DIP 2022 6
Main Definitions and Fundamentals
Dr Mai Kamal DIP 2022 7
Types of Sensations of Color
Dr Mai Kamal DIP 2022 8
Types of Sensations of Color
Luminance describes the amount of
light that passes through, is emitted from,
or is reflected from a particular area, and
falls within a given solid angle.
Dr Mai Kamal DIP 2022 9
What is Hue?
Hue is the main indication of color.
It is the value actually telling you which color it is
or the value that lets you go "red" when you see a
red object.
White light occurs when all wavelengths are
reflected back to the human eye.
Black light occurs when no light reflected to the
human eye.
Each different hue is
different reflected wavelength
of the light.
Dr Mai Kamal DIP 2022 10
What is Saturation?
In the upper part, the RGB value of the
leftmost part of the image, it would be (255, 0,
0). A color in the middle will be (255, 128, 128),
and the rightmost part is (255, 255, 255), which
is white.
For the lower gradient, it starts from red
(255,0,0). by moving toward into the right, it
gets to (128, 0, 0) in the middle, and finally (0,
0, 0) at the end, which is black.
Dr Mai Kamal DIP 2022 14
Types of Sensations of Color
Hue: the human sensation according to which an area
appears to be similar to one, or to proportions of two, of the
perceived colours red, yellow, green and blue.
Colorfulness: the human sensation according to which an
area appears to exhibit more or less of its hue.
Brightness: the human sensation by which an area exhibits
more or less light.
Lightness: the sensation of an area’s brightness relative to a
reference white in the scene.
Lightness is intensity or value is the brightness of the color.
Chroma: the colourfulness of an area relative to the
brightness of a reference white.
Saturation: the colourfulness of an area relative to its
brightness.
Dr Mai Kamal DIP 2022 16
Simultaneous Contrast
simultaneous contrast is related to the fact that a
region’s perceived brightness does not depend simply
on its intensity.
All the center squares have exactly the same intensity,
but they appear darker as the background become
lighter.
Dr Mai Kamal DIP 2022 19
Optical Illusion
It is a visual stimuli that is perceived by the eyes
and then comprehended by the brain in a way that is
different from reality.
Ex: in which the eye fills in no existing information
or wrongly perceive geometrical properties of
objects.
Dr Mai Kamal DIP 2022 20
Digital Image Processing (DIP)
Digital image processing is a technology of
applying a number of computer algorithms
to process a digital image.
It includes:
– Image acquisition – Image processing
Dr Mai Kamal DIP 2022 21
Types of Digital Images
Black and white image
– single color plane with 2 bits.
Grey scale image
– single color plane with 8 bits.
Color image
– three color planes each with 8 bits.
– RGB, CMY, YIQ, etc.
Indexed color image
– single plane that indexes a color table.
Compressed images
– TIFF, JPEG, BMP, etc.
22
Colored Image Example
24 bit RGB Representation (uncompressed)
128 135 166 138 190 132
129 255 105 189 167 190
229 213 134 111 138 187
128 138 135 190 166 132
129 189 255 167 105 190
229 111 213 138 134 187
Color Planes
23
Gray and Binary Image
The grey level or grey value indicates
the brightness of a pixel.
The minimum grey level is 0. The
maximum grey level depends on the
digitization depth of the image. For an 8-
bit-deep image it is 255.
In a binary image a pixel can only take
on either the value 0 or the value 255.
Dr Mai Kamal DIP 2022 24
Bit Planes
Grayscale images can be transformed into a
sequence of binary images breaking them up
into their bit-planes.
Ex: if we have an 8-bit image will break into
eight binary images 0th bit to 7th bit.
0th bit has the least effect in terms of the
magnitude of the value called the least
significant bit.
7th bit has the greatest effect in terms of the
magnitude of the value called the most
significant bit.
Dr Mai Kamal DIP 2022 27
Bit Planes
Dr Mai Kamal DIP 2022 28
DIGITIZING THE IMAGE
Dr Mai Kamal DIP 2022 30
Image Acquisition
Dr Mai Kamal DIP 2022 31
Methods of Image Processing
Methods of Digital
Image Image
Processing
Analog
Image
Dr Mai Kamal DIP 2022 32
Methods of Image Processing
What is the difference between analog and
digital system?
Digital system uses binary format as 0 and 1 whereas
analog system uses electronic pulses with varying
magnitude to send data.
Digital System uses discrete signals as on/off
representing binary format. Off is 0, On is 1.
Analog System uses continuous signals with varying
magnitude.
Dr Mai Kamal DIP 2022 33
Methods of Image Processing
A digital image is a representation of a real image as a set
of numbers that can be stored and handled by a digital
computer.
For example, a black and white image records only the
intensity of the light falling on the pixels.
Dr Mai Kamal DIP 2022 34
Analog Image
The analog image processing is applied on analog
signals and it processes only two-dimensional
signals. The images are manipulated by electrical
signals. In analog image processing, analog signals
can be periodic or non-periodic
Dr Mai Kamal DIP 2022 35
Analog Image
The television signal is a voltage level which varies in
amplitude to represent brightness through the image. By
electrically varying the signal, the displayed image
appearance is altered.
The brightness and contrast controls on a TV set serve to
adjust the amplitude and reference of the video signal,
resulting in the brightening, darkening and alteration of
the brightness range of the displayed image.
Dr Mai Kamal DIP 2022 36
Digital Image
A digital image processing is applied to digital images
(a matrix of small pixels and elements).
For manipulating the images, there is a number of
software and algorithms that are applied to perform
changes.
Digital image processing is one of the fastest growing
industry which affects everyone's life.
Dr Mai Kamal DIP 2022 37
Digital Image
When, digital computers are used to process the image.
The image will be converted to digital form using a
scanner – digitizer and then process it .
Dr Mai Kamal DIP 2022 38
Analog VS Digital Image
Dr Mai Kamal DIP 2022 39
Image Digitization
When we capture the image of an object, we use image
sensors to sense the incoming light and form the image.
Image sensors convert the incoming light from an object
into electrical signals that can be stored and viewed later.
These analog signals are continuous.
We cannot process analog images by a computer. Analog
signals contain infinite points, and we need infinite memory
to store them.
We need to convert the analog images into digital images to
store and process by a computer.
Dr Mai Kamal DIP 2022 40
Image Digitization
An analog image is converted to a digital image by
digitizing the analog signals. We apply sampling and
quantization to the analog signals to convert them into
digital form.
A digital image is formed by arranging pixels in rows
and columns.
Dr Mai Kamal DIP 2022 41
Image Digitization
covert continuous data into digital form.
There are two process to make that:
1. Sampling
2. Quantization
Dr Mai Kamal DIP 2022 42
Image Sampling
Sampling is the process of converting an analog signal
into discrete values.
We get a finite number of samples of an analog signal.
The number of samples gives us the number of pixels.
More samples will result in higher image quality of the
digital image because of more pixels.
The sampled signal is then quantized to get the value of
each pixel.
Dr Mai Kamal DIP 2022 43
Image quantization
After sampling the analog signal, we will apply
quantization. Quantization digitizes the amplitude of the
sampled signal.
Quantization is done by rounding off the amplitude of
each sample and then assigning a different value
according to its amplitude. Each value will represent a
different color tone.
Dr Mai Kamal DIP 2022 44
Sampling vs Quantization
Example
Dr Mai Kamal DIP 2022 46
Sampling vs Quantization
Dr Mai Kamal DIP 2022 48
Representing Digital Image
Image processing is a method to convert an
image into digital form and perform some
operations on it.
Image representation: to convert the input data
to form suitable for computer process.
Dr Mai Kamal DIP 2022 49
Representing Digital Image
M- rows , N-columns, x=[0:M-1] and y=[0:N-
1].
[0,0.5,1]
Dr Mai Kamal DIP 2022 50
Representing Digital Image
M and N are positive integers.
Number of intensity levels L= 2𝑘 .
• Where, k is positive integer.
Dr Mai Kamal DIP 2022 51
Dynamic Range
DYNAMIC RANGE is the range of tonal
difference between the lightest light and darkest
dark of an image.
Dynamic Range of the imaging system is defined
as ratio of maximum measurable intensity to the
minimum detectable intensity level in the system.
Upper limit is determined
by the saturation, and
lower limit is Noise.
maximum measurable intensity
Dynamic Intensity Range =
minimum detectable intensity level
Dr Mai Kamal DIP 2022 52
Image Contrast
Contrast is defined as difference in intensity
between highest and lowest intensity level in
the image.
When the dynamic range is very high, then the
image is said to have high contrast.
Dr Mai Kamal DIP 2022 54
Image Contrast
Contrast is defined as the ratio (max-
min)/(max+min).
– Where, max and min are the maximum and
minimum of the grating intensity, respectively
Dr Mai Kamal DIP 2022 55
Representing Digital Image
Number of bits (b) = MxNxk
If M=N , b=𝑁 2 k
Dr Mai Kamal DIP 2022 56
Spatial Resolution
Spatial resolution is the density of pixels over
the image.
Spatial resolution
• A measure of the smallest discernible detail in
an image. 1250 dpi 300 dpi
• stated with
– line pairs per unit distance,
– pixels per unit distance,
– dots per unit distance,(dpi) . 150 dpi
72 dpi
Dr Mai Kamal DIP 2022 57
Spatial Resolution
The effect of reducing Spatial resolution .
1024x1024 512x512 256x256
128x128 64x64 32x32
Dr Mai Kamal DIP 2022 58
Intensity Resolution
Is the smallest discernible change in the
intensity level.
The most intensity level used the finer the level
of detail discernable in an image.
Intensity level resolution is usually given terms
of the number of bits used to store each
intensity level.
The number of intensity level assuming by
powers of 2.
Dr Mai Kamal DIP 2022 59
Intensity Resolution
The number of intensity level assuming by
powers of 2.
Dr Mai Kamal DIP 2022 60
Effects of Varying Gray-Level
Resolution
256 gray level 8 bit per 128 gray level (7 bpp) 64 gray level (6 bpp) 32 gray level (5 bpp)
pixel (bpp)
16 gray level (4 bpp) 8 gray level (3 bpp) 4 gray level (2 bpp) 2 gray level (1 bpp)
Dr Mai Kamal DIP 2022 61
Effects of Varying Gray-Level
Resolution
Dr Mai Kamal DIP 2022 62
Effects of Varying Gray-Level
Resolution
Dr Mai Kamal DIP 2022 63
RELATIONSHIPS BETWEEN
PIXELS
Dr Mai Kamal DIP 2022 65
Neighbour of the Pixel
An image is denoted by f(x,y) and p,q are used to
represent individual pixels of the image.
Neighbours of a pixel
– A pixel p at (x,y) has 4 horizontal/vertical
neighbors at (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
– A pixel p at (x,y) has 4
diagonal neighbours at
(x+1,y+1), (x+1,y-1), (x-1,y+1)
and (x-1,y-1). These are called
the diagonal-neighbours of p :
𝑵𝑫 𝒑 .
Dr Mai Kamal DIP 2022 66
Neighbour of the Pixel
The 4-neighbours and the diagonal
neighbours of p are called 8-neighbours of
p : 𝑵𝟖 𝒑 .
Neighbors of a pixel
a. 4-neighbors of a pixel p are
its vertical and horizontal
neighbors denoted by 𝑵𝟒 𝒑 .
a. 8-neighbors of a pixel p are
its vertical horizontal and 4
diagonal neighbors denoted
by 𝑵𝟖 𝒑 .
Dr Mai Kamal DIP 2022 67
Neighbour of the Pixel
𝑵𝟒 - 4-neighbors.
𝑵𝑫 - diagonal neighbors.
𝑵𝟖 - 8-neighbors (𝑁4 U 𝑁8 ).
Dr Mai Kamal DIP 2022 68
Adjacency
Two pixels are connected if they are neighbors and
their gray levels satisfy 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).
Dr Mai Kamal DIP 2022 69
Adjacency
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 to 255, v set could be
any subset of these 256 values.
Dr Mai Kamal DIP 2022 70
Adjacency
Let V be set of gray levels 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 𝑁4 𝑝 .
8-adjacency: Two pixels p and q with values from V
are 8-adjacent if q is in the set 𝑁8 𝑝 .
m-adjacency: Two pixels p and q with values from V
are madjacent if:
q is in 𝑁4 𝑝
q is in 𝑁𝐷 𝑝 and the set [𝑵𝟒 𝒑 ∩𝑵𝟒 𝒒 ] is
empty (has no pixels whose values are from V).
Dr Mai Kamal DIP 2022 71
Connectivity
Pixel p is adjacent to pixel q if they are
connected.
Connectivity : To determine whether the
pixels are adjacent in some sense.
Mixed adjacency is a modification of 8-
adjacency and is used to eliminate the multiple
path connections that often arise when 8-
adjacency is used.
Dr Mai Kamal DIP 2022 72
Example
Adjacency / Connectivity
Consider the pixel arrangement shown in
the blow figure for V={1}.
Dr Mai Kamal DIP 2022 73
Example
Adjacency / Connectivity
Dr Mai Kamal DIP 2022 74
Paths & Path lengths
A digital path (or curve) from pixel p with
coordinate (x,y) to pixel q with coordinate (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).
(xi, yi) is adjacent pixel (xi-1, yi-1) for 1≤j≤n ,
• n- The length of the path.
• If (x0, y0)= (xn, yn):the path is closed path.
Dr Mai Kamal DIP 2022 75
Distance Measures
For pixels p, q and z, with coordinates (x,y),
(s,t) and (u,v), respectively. D is a distance
function or metric if:
• D(p,q) ≥ 0,
• D(p,q) = 0 if p=q,
• D(p,q) = D(q,p), and
• D(p,z) ≤
D(p,q) + D(q,z) .
Dr Mai Kamal DIP 2022 76
Distance Measures
Dr Mai Kamal DIP 2022 77
Distance Measures
1. Euclidean Distance (𝐷𝑒 )
The points contained in a disk of radius r
centered at (x,y).
Dr Mai Kamal DIP 2022 78
Distance Measures
2. 𝐷4 distance (city-block distance)
Pixels having a 𝐷4 distance from (x,y)
less than or equal to some value r from a
diamond centered (x,y).
Dr Mai Kamal DIP 2022 79
Distance Measures
Example :
the pixels with 𝐷4 =1 are the 4-nighbors
of (x, y).
Dr Mai Kamal DIP 2022 80
Distance Measures
3. 𝐷8 distance (chess board distance)
square – centered at (x, y)
𝐷8 = 1 are 8-neighbors of (x,y)
Dr Mai Kamal DIP 2022 81
Distance Measures
Example :
𝐷8 distance 2
Dr Mai Kamal DIP 2022 82
Distance Measures
4. 𝐷𝑚 distance:
– Is defined as the shortest m-path between
the points.
– The distance between pixels depends only
on the values of pixels.
Dr Mai Kamal DIP 2022 83
Distance Measures
Dr Mai Kamal DIP 2022 84
Relationship between Pixels
Arithmetic/Logic Operations:
Addition : p + q
Subtraction: p – q
Multiplication: p*q
Division: p/q
AND: p AND q
OR : p OR q
Complement: NOT(q)
Dr Mai Kamal DIP 2022 86
Mathematical Tools used in
DIP
Dr Mai Kamal DIP 2022 87
Mathematical Tools used in
DIP
Dr Mai Kamal DIP 2022 88
Logical Operations
Dr Mai Kamal DIP 2022 89
Next Lecture
LEC.4: IMAGE ENHANCEMENT
IN THE SPATIAL DOMAIN
Dr Mai Kamal DIP 2022 90
Dr Mai Kamal DIP 2022 91