Digital Image Processing Lecture Notes: M.Sc. Cs - (Iv Sem) (2020-2021)
Digital Image Processing Lecture Notes: M.Sc. Cs - (Iv Sem) (2020-2021)
Digital Image Processing Lecture Notes: M.Sc. Cs - (Iv Sem) (2020-2021)
LECTURE NOTES
Prepared by
Dr.M.Umadevi
Assistant Professor
Department of Computer Science
UNIT-1
DIGITAL IMAGE FUNDAMENTALS & IMAGE TRANSFORMS
The term gray level is used often to refer to the intensity of monochrome images.
Color images are formed by a combination of individual 2-D images.
For example: The RGB color system, a color image consists of three (red, green and
blue) individual component images. For this reason many of the techniques developed for
monochrome images can be extended to color images by processing the three component
images individually.
An image may be continuous with respect to the x- and y- coordinates and also in
amplitude. Converting such an image to digital form requires that the coordinates, as well as
the amplitude, be digitized.
APPLICATIONS OF DIGITAL IMAGE PROCESSING
Since digital image processing has very wide applications and almost all of the technical
fields are impacted by DIP, we will just discuss some of the major applications of DIP.
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
i) Short term storage for use during processing
ii) On line storage for relatively fast retrieval
iii) Archival storage such as magnetic tapes and disks
Image display: Image displays in use today are mainly color TV monitors. These monitors
are driven by the outputs of image and graphics displays cards that are an integral part of
computer system.
Hardcopy devices: The devices for recording image includes laser printers, film cameras,
heat sensitive devices inkjet units and digital units such as optical and CD ROM disk. Films
provide the highest possible resolution, but paper is the obvious medium of choice for written
applications.
Networking: It is almost a default function in any computer system in use today because of
the large amount of data inherent in image processing applications. The key consideration in
image transmission bandwidth.
Fundamental Steps in Digital Image Processing:
There are two categories of the steps involved in the image processing –
1. Methods whose outputs are input are images.
2. Methods whose outputs are attributes extracted from those images.
Image acquisition: It could be as simple as being given an image that is already in digital
form. Generally the image acquisition stage involves processing such scaling.
Image Enhancement: It is among the simplest and most appealing areas of digital image
processing. The idea behind this is to bring out details that are obscured or simply to
highlight certain features of interest in image. Image enhancement is a very subjective area of
image processing.
Color image processing: It is an area that is been gaining importance because of the use of
digital images over the internet. Color image processing deals with basically color models
and their implementation in image processing applications.
Wavelets and Multiresolution Processing: These are the foundation for representing image
in various degrees of resolution.
Compression: It deals with techniques reducing the storage required to save an image, or the
bandwidth required to transmit it over the network. It has to major approaches a) Lossless
Compression b) Lossy Compression
Morphological processing: It deals with tools for extracting image components that are
useful in the representation and description of shape and boundary of objects. It is majorly
used in automated inspection applications.
Representation and Description: It always follows the output of segmentation step that is,
raw pixel data, constituting either the boundary of an image or points in the region itself. In
either case converting the data to a form suitable for computer processing is necessary.
Recognition: It is the process that assigns label to an object based on its descriptors. It is the
last step of image processing which use artificial intelligence of software.
Knowledge base:
Knowledge about a problem domain is coded into an image processing system in the form of
a knowledge base. This knowledge may be as simple as detailing regions of an image where
the information of the interest in known to be located. Thus limiting search that has to be
conducted in seeking the information. The knowledge base also can be quite complex such
interrelated list of all major possible defects in a materials inspection problems or an image
database containing high resolution satellite images of a region in connection with change
detection application.
A Simple Image Model:
An image is denoted by a two dimensional function of the form f{x, y}. The value or
amplitude of f at spatial coordinates {x,y} is a positive scalar quantity whose physical
meaning is determined by the source of the image. When an image is generated by a physical
process, its values are proportional to energy radiated by a physical source. As a
consequence, f(x,y) must be nonzero and finite; that is o<f(x,y) <co The function f(x,y) may
be characterized by two components- The amount of the source illumination incident on the
scene being viewed.
(a) The amount of the source illumination reflected back by the objects in the scene
These are called illumination and reflectance components and are denoted by i(x,y) an r (x,y)
respectively.
The functions combine as a product to form f(x,y). We call the intensity of a monochrome
image at any coordinates (x,y) the gray level (l) of the image at that point l= f (x, y.)
L min ≤ l ≤ Lmax
white on the gray scale. All intermediate values are shades of gray of gray varying from
black to white.
SAMPLING AND QUANTIZATION:
To create a digital image, we need to convert the continuous sensed data into digital from.
This involves two processes – sampling and quantization. An image may be continuous with
respect to the x and y coordinates and also in amplitude. To convert it into digital form we
have to sample the function in both coordinates and in amplitudes.
Digitalizing the coordinate values is called sampling. Digitalizing the amplitude values is
called quantization. There is a continuous the image along the line segment AB. To simple
this function, we take equally spaced samples along line AB. The location of each samples is
given by a vertical tick back (mark) in the bottom part. The samples are shown as block
squares superimposed on function the set of these discrete locations gives the sampled
function.
In order to form a digital, the gray level values must also be converted (quantized) into
discrete quantities. So we divide the gray level scale into eight discrete levels ranging from
eight level values. The continuous gray levels are quantized simply by assigning one of the
eight discrete gray levels to each sample. The assignment it made depending on the vertical
proximity of a simple to a vertical tick mark.
Starting at the top of the image and covering out this procedure line by line produces a two
dimensional digital image.
Digital Image definition:
A digital image f(m,n) described in a 2D discrete space is derived from an analog
image f(x,y) in a 2D continuous space through a sampling process that is frequently referred
to as digitization. The mathematics of that sampling process will be described in subsequent
Chapters. For now we will look at some basic definitions associated with the digital image.
The effect of digitization is shown in figure.
The 2D continuous image f(x,y) is divided into N rows and M columns. The
intersection of a row and a column is termed a pixel. The value assigned to the integer
coordinates (m,n) with m=0,1,2..N-1 and n=0,1,2…N-1 is f(m,n). In fact, in most cases, is
actually a function of many variables including depth, color and time (t).
Thus the right side of the matrix represents a digital element, pixel or pel. The matrix can be
represented in the following form as well. The sampling process may be viewed as
partitioning the xy plane into a grid with the coordinates of the center of each grid being a
pair of elements from the Cartesian products Z2 which is the set of all ordered pair of
elements (Zi, Zj) with Zi and Zj being integers from Z. Hence f(x,y) is a digital image if gray
level (that is, a real number from the set of real number R) to each distinct pair of coordinates
(x,y). This functional assignment is the quantization process. If the gray levels are also
integers, Z replaces R, the and a digital image become a 2D function whose coordinates and
she amplitude value are integers. Due to processing storage and hardware consideration, the
number gray levels typically is an integer power of 2.
k
L=2
Then, the number, b, of bites required to store a digital image is B=M *N* k When M=N, the
2
equation become b=N *k
When an image can have 2k gray levels, it is referred to as “k- bit”. An image with 256
8
possible gray levels is called an “8- bit image” (256=2 ).
of the sun. Depending on the nature of the source, illumination energy is reflected from, or
transmitted through, objects. An example in the first category is light reflected from a planar
surface. An example in the second category is when X-rays pass through a patient‟s body for
the purpose of generating a diagnostic X-ray film. In some applications, the reflected or
transmitted energy is focused onto a photo converter (e.g., a phosphor screen), which
converts the energy into visible light. Electron microscopy and some applications of gamma
imaging use this approach. The idea is simple: Incoming energy is transformed into a voltage
by the combination of input electrical power and sensor material that is responsive to the
particular type of energy being detected. The output voltage waveform is the response of the
sensor(s), and a digital quantity is obtained from each sensor by digitizing its response. In
this section, we look at the principal modalities for image sensing and generation.
example, a green (pass) filter in front of a light sensor favors light in the green band of the
color spectrum. As a consequence, the sensor output will be stronger for green light than for
other components in the visible spectrum.
In order to generate a 2-D image using a single sensor, there has to be relative displacements
in both the x- and y-directions between the sensor and the area to be imaged. Figure shows an
arrangement used in high-precision scanning, where a film negative is mounted onto a drum
whose mechanical rotation provides displacement in one dimension. The single sensor is
mounted on a lead screw that provides motion in the perpendicular direction. Since
mechanical motion can be controlled with high precision, this method is an inexpensive (but
slow) way to obtain high-resolution images. Other similar mechanical arrangements use a flat
bed, with the sensor moving in two linear directions. These types of mechanical digitizers
sometimes are referred to as microdensitometers.
Image Acquisition using a Sensor strips:
A geometry that is used much more frequently than single sensors consists of an in-line
arrangement of sensors in the form of a sensor strip, shows. The strip provides imaging
elements in one direction. Motion perpendicular to the strip provides imaging in the other
direction. This is the type of arrangement used in most flat bed scanners. Sensing devices
with 4000 or more in-line sensors are possible. In-line sensors are used routinely in airborne
imaging applications, in which the imaging system is mounted on an aircraft that flies at a
constant altitude and speed over the geographical area to be imaged. One dimensional
imaging sensor strips that respond to various bands of the electromagnetic spectrum are
mounted perpendicular to the direction of flight. The imaging strip gives one line of an image
at a time, and the motion of the strip completes the other dimension of a two-dimensional
image. Lenses or other focusing schemes are used to project area to be scanned onto the
sensors. Sensor strips mounted in a ring configuration are used in medical and industrial
imaging to obtain cross-sectional (“slice”) images of 3-D objects.
analog circuitry sweep these outputs and convert them to a video signal, which is then
digitized by another section of the imaging system.
This set of pixels, called the 4-neighbors or p, is denoted by N4(p). Each pixel is one
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. The four diagonal neighbors of p have coordinates and are
denoted by ND (p).
(x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1, y-1)
These points, together with the 4-neighbors, 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.
ADJACENCY AND CONNECTIVITY
Let v be the set of gray –level values used to define adjacency, in a binary image, v={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 – 255, V set can be any subset of these 256 values.
if we are reference to adjacency of pixel with value.
Three types of adjacency
4- Adjacency – two pixel P and Q with value from V are 4 –adjacency if A is in the
set N4(P)
8- Adjacency – two pixel P and Q with value from V are 8 –adjacency if A is in the
set N8(P)
M-adjacency –two pixel P and Q with value from V are m – adjacency if (i) Q is in
N4(p) or (ii) Q is in ND(q) and the set N4(p) ∩ N4(q) has no pixel whose values are
from V.
• Mixed adjacency is a modification of 8-adjacency. It is introduced to eliminate the
ambiguities that often arise when 8-adjacency is used.
• For example:
Fig:1.8(a) Arrangement of pixels; (b) pixels that are 8-adjacent (shown dashed) to the
center pixel; (c) m-adjacency.
Types of Adjacency:
• In this example, we can note that to connect between two pixels (finding a path
between two pixels):
– In 8-adjacency way, you can find multiple paths between two pixels
– While, in m-adjacency, you can find only one path between two pixels
• So, m-adjacency has eliminated the multiple path connection that has been generated
by the 8-adjacency.
• Two subsets S1 and S2 are adjacent, if some pixel in S1 is adjacent to some pixel in S2.
Adjacent means, either 4-, 8- or m-adjacency.
A Digital Path:
• 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) and (xn, yn) = (s,t) and pixels (xi, yi) and (xi-1, yi-1) are adjacent for 1 ≤ i ≤ n
• n is the length of the path
• If (x0,y0) = (xn, yn), the path is closed.
We can specify 4-, 8- or m-paths depending on the type of adjacency specified.
• Return to the previous example:
Fig:1.8 (a) Arrangement of pixels; (b) pixels that are 8-adjacent(shown dashed) to the
center pixel; (c) m-adjacency.
In figure (b) the paths between the top right and bottom right pixels are 8-paths. And
the path between the same 2 pixels in figure (c) is m-path
Connectivity:
• Let S represent a subset of pixels in an image, 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.
• For any pixel p in S, the set of pixels that are connected to it in S is called a connected
component of S. If it only has one connected component, then set S is called a
connected set.
Region and Boundary:
• REGION: Let 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.
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 in the image. This extra definition is required because an image
has no neighbors beyond its borders. Normally, when we refer to a region, we are referring to
subset of an image, and any pixels in the boundary of the region that happen to coincide with
the border of the image are included implicitly as part of the region boundary.
DISTANCE MEASURES:
For pixel p,q and z with coordinate (x.y) ,(s,t) and (v,w) respectively D is a distance function
or metric if
D [p.q] ≥ O {D[p.q] = O iff p=q}
D [p.q] = D [p.q] and
D [p.q] ≥ O {D[p.q]+D(q,z)
• The Euclidean Distance between p and q is defined as:
Pixels having a distance less than or equal to some value r from (x,y) are the points
contained in a disk of radius „ r „centered at (x,y)
• The D4 distance (also called city-block distance) between p and q is defined as:
D4 (p,q) = | x – s | + | y – t |
Pixels having a D4 distance from (x,y), less than or equal to some value r form a
Diamond centered at (x,y)
Example:
The pixels with distance D4 ≤ 2 from (x,y) form the following contours of
constant distance.
The pixels with D4 = 1 are the 4-neighbors of (x,y)
• The D8 distance (also called chessboard distance) between p and q is defined as:
D8 (p,q) = max(| x – s |,| y – t |)
Pixels having a D8 distance from (x,y), less than or equal to some value r form a
square Centered at (x,y).
Example:
D8 distance ≤ 2 from (x,y) form the following contours of constant distance.
• Dm distance:
It is defined as the shortest m-path between the points.
In this case, the distance between two pixels will depend on the values of the
pixels along the path, as well as the values of their neighbors.
• Example:
Consider the following arrangement of pixels and assume that p, p2, and p4
have value 1 and that p1 and p3 can have can have a value of 0 or 1 Suppose
that we consider the adjacency of pixels values 1 (i.e. V = {1})
Case2: If p1 =1 and p3 = 0
now, p1 and p will no longer be adjacent (see m-adjacency definition)
then, the length of the shortest
path will be 3 (p, p1, p2, p4)
Case3: If p1 =0 and p3 = 1
The same applies here, and the shortest –m-path will be 3 (p, p2, p3, p4)
Case4: If p1 =1 and p3 = 1
The length of the shortest m-path will be 4 (p, p1 , p2, p3, p4)
IMAGE TRANSFORMS:
2-D FFT:
WALSH TRANSFORM:
We define now the 1-D Walsh transform as follows:
The array formed by the inverse Walsh matrix is identical to the one formed by the forward
Walsh matrix apart from a multiplicative factor N.
2-D Walsh Transform
We define now the 2-D Walsh transform as a straightforward extension of the 1-D transform:
HADAMARD TRANSFORM:
We define now the 2-D Hadamard transform. It is similar to the 2-D Walsh transform.
We define now the Inverse 2-D Hadamard transform. It is identical to the forward 2-D
Hadamard transform.
The general equation for a 2D (N by M image) DCT is defined by the following equation:
Each step in the one dimensional Haar wavelet transform calculates a set of wavelet
coefficients (Hi-D) and a set of averages (Lo-D). If a data set s0, s1,…, sN-1 contains N
elements, there will be N/2 averages and N/2 coefficient values. The averages are stored in
the lower half of the N element array and the coefficients are stored in the upper half.
The Haar equations to calculate an average ( ai ) and a wavelet coefficient ( ci ) from
the data set are shown below Eq
si si 1 si si 1
ai ci
2 2
In wavelet terminology the Haar average is calculated by the scaling function. The
coefficient is calculated by the wavelet function.
Two-Dimensional Wavelets
The two-dimensional wavelet transform is separable, which means we can apply a
one-dimensional wavelet transform to an image. We apply one-dimensional DWT to all rows
and then one-dimensional DWTs to all columns of the result. This is called the standard
decomposition and it is illustrated in figure 4.8.
Step 2 : Convolve the columns of the result of step 1 with the low-pass filter and rescale this
to half its size by sub-sampling.
Step 3 : Convolve the result of step 1 with high-pass filter and again sub-sample to obtain an
image of half the size.
Step 4 : Convolve the original image rows with the high-pass filter.
Step 5: Convolve the columns of the result of step 4 with the low-pass filter and recycle this
to half its size by sub-sampling.
Step 6 :Convolve the result of step 4 with the high-pass filter and again sub-sample to obtain
an image of half the size.
At the end of these steps there are four images, each half the size of original. They are
1. The low-pass / low-pass image (LL), the result of step 2,
2. The low-pass / high-pass image (LH), the result of step 3,
3. The high-pass / low-pass image (HL), the result of step 5, and
4. The high-pass / high-pass image (HH), the result of step 6
These images can be placed into a single image grid as shown in the figure 4.10.