M4 CST304 Ktunotes - in
M4 CST304 Ktunotes - in
CST 304
Computer Graphics and Image Processing
Module - 4 (Fundamentals of Digital Image Processing)
Introduction to Image processing and applications. Image
as 2D data. Image representation in Gray scale, Binary
and Colour images. Fundamental steps in image
processing. Components of image processing system.
Coordinate conventions. Sampling and quantization.
Spatial and Gray Level Resolution. Basic relationship
between pixels– neighbourhood, adjacency, connectivity.
Fundamentals of spatial domain-convolution operation.
Text Books:
1. Rafael C. Gonzalez, Richard E. Woods, Digital Image
Processing (English)
Introduction
• What is Digital Image Processing?
Digital Image
— a two-dimensional function
f ( x, y)
x and y are spatial coordinates
The amplitude of f is called intensity or gray level at the point (x, y)
Pixel
— the elements of a digital image
5
Origins of Digital Image
Processing
7
Sources for Images
• Electromagnetic (EM) energy spectrum –
Gamma rays to Radio Waves
• Acoustic / Ultrasonic – Ultrasound scan
• Electronic – Electronic Microscope images
• Synthetic images produced by computer –
Fractals etc.
8
Electromagnetic (EM) energy
spectrum
Major uses
Gamma-ray imaging: nuclear medicine and astronomical observations
X-rays: medical diagnostics, industry, and astronomy, etc.
Ultraviolet: lithography, industrial inspection, microscopy, lasers, biological imaging,
and astronomical observations
Visible and infrared bands: light microscopy, astronomy, remote sensing, industry,
and law enforcement
Microwave band: radar
Radio band: medicine (such as MRI) and astronomy
9
Examples: Gama-Ray Imaging
10
Examples: X-Ray Imaging
11
Examples: Ultraviolet Imaging
12
Examples: Light Microscopy Imaging
13
Examples: Visual and Infrared Imaging
14
Examples: Visual and Infrared Imaging
15
Examples: Infrared Satellite Imaging
2003
USA 1993
Weeks 1 & 2 16
Examples: Infrared Satellite Imaging
Weeks 1 & 2 17
Examples: Automated Visual Inspection
18
Examples: Automated Visual Inspection
Results of
automated
reading of the
plate content by
the system
19
Example of Radar Image
Weeks 1 & 2 20
Examples: MRI (Radio Band)
Weeks 1 & 2 21
Examples: Ultrasound Imaging
Weeks 1 & 2 22
23
Types of Images
• Binary, Grayscale, Color
• Binary
• It is the simplest type of image. It takes only two values i.e., Black and White or
0 and 1. The binary image consists of a 1-bit image and it takes only 1 binary
digit to represent a pixel. Binary images are mostly used for general shape or
outline.
• Binary images are generated using threshold operation. When a pixel is above
the threshold value, then it is turned white('1') and which are below the
threshold value then they are turned black('0')
24
Types of Images
Grayscale Images
• Grayscale images are referred to as monochrome
(one color) images. They contain gray level
information – no color information.
• The number of bits used for each pixel determines
the number of different gray levels available.
Types of Images
Color Images
• Color images are three channel monochrome images in
which, each channel contains a different color and the actual
information is stored in the digital image. The color images
contain gray level information in each Red, Blue, Green
channels.
• The images are represented as Red, Green and Blue (RGB
images). And each color image has 24 bits/pixel means 8 bits
for each of the three color channels (RGB).
26
• Image Sensors:
With reference to sensing, two elements are required
to acquire digital image. The first is a physical device
that is sensitive to the energy radiated by the object
we wish to image and second is specialized image
processing hardware.
• Specialize Image Processing Hardware:
It consists of the digitizer just mentioned, plus
hardware that performs other primitive operations
such as an arithmetic logic unit, which performs
arithmetic such addition and subtraction and logical
operations in parallel on images.
35
Components of an Image Processing System
• Computer:
It is a general-purpose computer and can range
from a PC to a supercomputer depending on the
application. In dedicated applications, sometimes
specially designed computer is used to achieve a
required level of performance
• Software:
It consists of specialized modules that perform
specific tasks a well-designed package also
includes capability for the user to write code, as a
minimum, utilizes the specialized module. More
sophisticated software packages allow the
integration of these modules.
36
• Mass Storage:
This capability is a must in image processing
applications. An image of size 1024 x1024 pixels, in
which the intensity of each pixel is an 8- bit quantity
requires one Megabytes of storage space if the
image is not compressed. Image processing
applications falls into three principal categories of
storage.
• Short term storage for use during processing
• On line storage for relatively fast retrieval
• Archival storage such as magnetic tapes and
disks
37
• Neighborhood
• Adjacency
• Connectivity
• Paths
• Adjacency
Let V be the set of intensity values
• Adjacency
Let V be the set of intensity values
(ii) q is in the set ND(p) and the set N4(p) ∩ N4(q) has no pixels
whose values are from V.
53
54
55
56
57
• Path
A (digital) path (or curve) from pixel p with coordinates (x0, y0) to pixel q
with coordinates (xn, yn) is a sequence of distinct pixels with
coordinates
We can define 4-, 8-, and m-paths based on the type of adjacency
used.
Examples: Adjacency and Path
V = {1, 2}
0 1 1 0 1 1 0 1 1
0 2 0 0 2 0 0 2 0
0 0 1 0 0 1 0 0 1
Weeks 1 & 2 58
Examples: Adjacency and Path
V = {1, 2}
0 1 1 0 1 1 0 1 1
0 2 0 0 2 0 0 2 0
0 0 1 0 0 1 0 0 1
8-adjacent
Weeks 1 & 2 59
Examples: Adjacency and Path
V = {1, 2}
0 1 1 0 1 1 0 1 1
0 2 0 0 2 0 0 2 0
0 0 1 0 0 1 0 0 1
8-adjacent m-adjacent
Weeks 1 & 2 60
Examples: Adjacency and Path
V = {1, 2}
0 1 1
1,1 1,2 1,3 0 1 1 0 1 1
0 2 0
2,1 2,2 2,3 0 2 0 0 2 0
0 0 1
3,1 3,2 3,3 0 0 1 0 0 1
Two pixels p and q with
values from V are 8-adjacent if 8-adjacent m-adjacent
q is in the set N8(p).
The 8-path from (1,3) to (3,3): The m-path from (1,3) to (3,3):
(i) (1,3), (1,2), (2,2), (3,3) (1,3), (1,2), (2,2), (3,3)
(ii) (1,3), (2,2), (3,3)
Two pixels p and q with values from V are m-
adjacent if
(i) q is in the set N4(p), or
(ii) q is in the set ND(p) and the set N4(p) ∩ N4(q) has
Weeks 1 & 2 no pixels whose values are from V. 61
62
3 1 2 1q
2 2 0 2
1 2 1 1
1 0 1 1
p
Basic Relationships Between Pixels
• Connected in S
Let S represent a subset of pixels in an image. Two pixels
p with coordinates (x0, y0) and q with coordinates (xn, yn) are
said to be connected in S if there exists a path
Weeks 1 & 2 63
Basic Relationships Between Pixels
Let S represent a subset of pixels in an image
Weeks 1 & 2 64
Basic Relationships Between Pixels
• Boundary (or border)
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.
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 of the image.
Weeks 1 & 2 65
Question 1
1 1 1
Region 1
1 0 1
0 1 0
0 0 1 Region 2
1 1 1
1 1 1
Weeks 1 & 2 66
Question 2
1 1 1
Part 1
1 0 1
0 1 0
0 0 1 Part 2
1 1 1
1 1 1
Weeks 1 & 2 67
• In the following arrangement of pixels, the two regions
(of 1s) are disjoint (if 4-adjacency is used)
1 1 1
Region 1
1 0 1 Regions that are not adjacent are
0 1 0 said to be disjoint.
0 0 1 Region 2
1 1 1
1 1 1
Weeks 1 & 2 68
• In the following arrangement of pixels, the two regions
(of 1s) are disjoint (if 4-adjacency is used)
Weeks 1 & 2 69
Distance Measures
• Given pixels p, q and z with coordinates (x, y), (s, t),
(u, v) respectively, the distance function D has
following properties:
a. D(p, q) ≥ 0 [D(p, q) = 0, if p = q]
b. D(p, q) = D(q, p)
Weeks 1 & 2 70
Distance Measures
The following are the different Distance measures:
a. Euclidean Distance :
De(p, q) = [(x-s)2 + (y-t)2]1/2
Weeks 1 & 2 71
Question 3 Chess Board Distance:
D8(p, q) = max(|x-s|, |y-t|)
0 0 0 0 0
0 0 1 1 0
max(|1-4|, |4-2|) = 3
0 1 1 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
Weeks 1 & 2 72
City Block Distance:
Question 4 D4(p, q) = |x-s| + |y-t|
Convolution operation
• In image processing, convolution is the process of
transforming an image by applying a kernel over each
pixel and its local neighbors across the entire image. The
kernel is a matrix of values whose size and values
determine the transformation effect of the convolution
process.
Spatial Domain Processing – 81
Convolution operation
The Convolution Process involves these steps:
1 -1 -1
1 0 0 0 0 1 -1 1 -1 Filter 1
0 1 0 0 1 0 -1 -1 1
0 0 1 1 0 0
1 0 0 0 1 0 -1 1 -1
0 1 0 0 1 0 -1 1 -1 Filter 2
0 0 1 0 1 0 -1 1 -1
…
…
6 x 6 image
Each filter detects a
small pattern (3 x 3).
83
1 -1 -1
Convolution -1 1 -1 Filter 1
-1 -1 1
stride=1
1 0 0 0 0 1 Dot
product -
0 1 0 0 1 0 3
1
0 0 1 1 0 0
1 0 0 0 1 0
0 1 0 0 1 0
0 0 1 0 1 0
6 x 6 image
84
1 -1 -1
Convolution -1 1 -1 Filter 1
-1 -1 1
If stride=2
1 0 0 0 0 1
0 1 0 0 1 0 -
3
3
0 0 1 1 0 0
1 0 0 0 1 0
0 1 0 0 1 0
0 0 1 0 1 0
6 x 6 image
85
1 -1 -1
Convolution -1 1 -1 Filter 1
-1 -1 1
stride=1
1 0 0 0 0 1
0 1 0 0 1 0 - - -
3
1 3 1
0 0 1 1 0 0
- -
1 0 0 0 1 0 1 0
3 3
0 1 0 0 1 0
- -
0 0 1 0 1 0 0 1
3 3
- - -
6 x 6 image 3
2 2 1
86
-1 1 -1
Convolution -1
-1
1
1
-1
-1
Filter 2
stride=1
Repeat this for each filter
1 0 0 0 0 1
0 1 0 0 1 0 - - -
3- - - -
1 3 1
0 0 1 1 0 0 1 1 1 1
- -
1 0 0 0 1 0 - 1- 0-
3 31
0 1 0 0 1 0 1 Feature
1 2
- - Map
0 0 1 0 1 0 - - 0- 1
3 3 1
1 1 2
- - -
6 x 6 image 3- -
20 2 13
1 4
Two 4 x 4 images
Forming 2 x 4 x 4 matrix
87
Convolution
or feature map
88
With image convolutions, you can easily detect lines. Here are four
convolutions to detect horizontal, vertical and lines at 45 degrees:
Convolution - examples
Earlier, we had to use separate components for horizontal and vertical lines. A
way to "combine" the results is to merge the convolution kernels. The new
image convolution kernel looks like this: