DIP - Lecture 2 Updated
DIP - Lecture 2 Updated
2
Department of Computing & Communication Technology
Sampling and Quantization
Basic Concepts in Sampling & Quantization
Sampling and quantization are crucial steps in image processing, where they
play a significant role in digitizing and representing visual information
Sampling
q Sampling refers to the process of converting a continuous 2D image
into a discrete representation by selection of its pixel values at specific
locations
q Each sample represents the intensity or color value of the image at a
particular point
q In digital imaging, an image is composed of a grid of pixels, where each
pixel represents a tiny element of the image
3
Department of Computing & Communication Technology
Sampling and Quantization
Sampling
Quantization
q Quantization is a process of transforming a real-valued sampled image
to one taking only a finite number of distinct values
q Under the quantization process, the amplitude values of the image are
digitized (In simple words, when you are quantizing an image, you are
dividing a signal into quanta(partitions))
4
Department of Computing & Communication Technology
Sampling and Quantization
q An image 𝑓 may be continuous with respect to the 𝑥 − and 𝑦 −
coordinates, and also in amplitude
q To convert the continuous image to digital form, the image function 𝑓
has to be sampled in both coordinates in amplitude
5
Department of Computing & Communication Technology
Sampling and Quantization
6
Department of Computing & Communication Technology
Sampling and Quantization
q To sample the image function, we
take equally spaced samples along
line AB
q The spatial location of each sample
is indicated by a vertical tick mark in
the bottom part of the figure
q The samples are shown as small
white squares superimposed on the
function
q The set of these discrete locations
gives the sampled function
§ The right side of the Figure shows the
q To form a digital function, the
intensity scale divided into eight
intensity values also must be discrete intervals, ranging from black to
converted (quantized) into discrete white
quantities § The vertical tick marks indicate the
specific value assigned to each of the
eight intensity intervals
7
Department of Computing & Communication Technology
Sampling and Quantization
q The continuous intensity levels are
quantized by assigning one of the
eight values to each sample
q The assignment is made depending
on the vertical proximity of a sample
to a vertical tick mark
q The digital samples resulting from
both sampling and quantization are
shown in the figure
q Starting at the top of the image and
carrying out this procedure line by
line produces a two-dimensional
Digital samples from the
digital image Sampling and Quantization
process
8
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
q Let represent a continuous image function of two continuous
variables, s and t
q Converting this continuous function into a digital image, the process of
sampling and quantization is applied
q Suppose that we sample the continuous image into a 2-D array,
containing M-rows and N-columns, where are discrete
coordinates
q For notational clarity and convenience, integer values are used for
these discrete coordinates:
9
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
q Thus, for example, the value of the digital image at the origin is ,
and the next coordinate value along the first row is
q Here, the notation (0, 1) is used to signify the second sample along the
first row
q In general, the value of the image at any coordinates (x, y) is denoted
as , where x and y are integers
q The section of the real plane covered by the coordinates of an image is
called the spatial domain, with x and y being referred to as spatial
variables or spatial coordinates
q There are three basic ways to represent
10
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
§ The first representation is a plot of the function, with
two axes determining the spatial location and the third
axis being the values of “f” (intensities) as a function of
the two spatial variables x and y
12
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
13
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
14
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
q Note that the origin of a digital image is at the top left, with the positive
x-axis extending downward and the positive y-axis extending to the
right
q This is a conventional representation based on the fact that many
image displays (e.g., TV monitors) sweep an image starting at the top
left and moving to the right one row at a time
q More important is the fact that the first element of a matrix is by
convention at the top left of the array, so choosing the origin of f(x, y)
at that point makes sense mathematically
q This representation is the standard right-handed Cartesian coordinate
system
q The axes are simply shown pointing downward and to the right, instead
of to the right and up
15
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
§ Expressing sampling and quantization in more formal mathematical terms can
be useful
§ Let Z and R denote the set of integers and the set of real numbers,
respectively
§ 𝑓(𝑥, 𝑦) is a digital image if (𝑥, 𝑦) are integers from 𝑍 ! and 𝑓 is a function that
assigns an intensity value (that is, a real number from the set of real numbers,
𝑅) to each distinct pair of coordinates (𝑥, 𝑦)
§ This functional assignment is the quantization process. If the intensity levels are
integers, then Z replaces R, and a digital image then becomes a 2-D function
whose coordinates and amplitude values are integers 16
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
§ The digitization process requires that decisions be made regarding the values
for M, N, and for the number, L, of discrete intensity levels
§ The assumption is made that the discrete levels are equally spaced and that
they are integers in the interval [0, L - 1]
17
Department of Computing & Communication Technology
Sampling and Quantization
Representing Digital Image
When an image can have 2$ intensity levels, it is common practice to refer to
the image as a “k-bit image.” For example, an image with 256 possible
discrete intensity values is called an 8-bit image
18
Department of Computing & Communication Technology
Sampling and Quantization
Spatial and Intensity Resolution
Spatial resolution and intensity resolution are two concepts that
characterize the quality and detail of an image. A balance between these
two factors needs to be considered based on the specific requirements of
the image-processing task
Spatial Resolution
Ø Spatial resolution refers to the level of detail or the ability to distinguish
features in an image
Ø It relates to the number of pixels used to represent the image and the physical
size of each pixel
Ø A higher spatial resolution means more pixels are used, resulting in finer
details and a clearer representation of the image
19
Department of Computing & Communication Technology
Sampling and Quantization
Spatial Resolution
Ø Spatial resolution is expressed in terms of the number of dots (pixels) per unit
length, such as dots (pixels) per inch (PPI) or pixels per centimeter (PPCM)
20
Department of Computing & Communication Technology
Sampling and Quantization
Intensity Resolution
Ø Intensity resolution (gray level resolution or bit depth) is the number of distinct
intensity levels that can be assigned to each pixel in an image
Ø For grayscale images, the intensity resolution determines the number of shades
of gray that can be distinguished, For example, an 8-bit image has 256 distinct
intensity levels (𝐿 = 2$ = 2% ), allowing for fine shifts between black and white
Ø The most common number is 8 bits, with 16 bits being used in some applications
in which enhancement of specific intensity ranges is necessary
21
Department of Computing & Communication Technology
Sampling and Quantization
Intensity Resolution
Ø In color images, intensity resolution is applied to each color channel (e.g., red,
green, and blue), and the overall color resolution is influenced by the intensity
resolutions of those channels
Ø Increasing the intensity resolution can enhance the visual quality of an image,
especially in applications that require accurate representation of color or shading,
such as digital photography or professional graphics
Ø However, it's important to note that the available intensity resolution is limited by
the capabilities of the image sensor or the color space being used
22
Department of Computing & Communication Technology
Sampling and Quantization
Illustration of effect of Reducing Spatial Resolution
The figures show the effects of reducing spatial resolution in an image. The images in
Figs (a) through (d) are shown in 1250, 300, 150, and 72 dpi, respectively. The lower -
resolution images are smaller than the original. For example, the original image is of
size 3692 * 2812 pixels, but the 72 dpi image is an array of size 213 * 162. To facilitate
comparisons, all the smaller images were zoomed back to the original size.
(a) (b)
There are some small visual differences
between Figs (a) and (b), the most notable
being a slight distortion in the large black
needle. For the most part, however, Fig (b) is
acceptable, Figure (c) begins to show visible (c) (d)
degradation (see, for example, the small
needle pointing to 60 on the right side).
Figure (d) shows degradation that is visible in
most features of the image.
23
Department of Computing & Communication Technology
Sampling and Quantization
Image Interpolation
Ø Image interpolation is a technique used to estimate the values of pixels in
a digital image at locations where they are not explicitly defined
(interpolation is the process of using known data to estimate values at
unknown locations)
25
Department of Computing & Communication Technology
Sampling and Quantization
Image Interpolation
Nearest Neighbour Interpolation
q If an image of size 500 x 500 pixels has to be enlarged 1.5 times to 750 x
750 pixels. A simple way to visualize zooming is to create an imaginary 750
x 750 grid with the same pixel spacing as the original, and then shrink it so
that it fits exactly over the original image
27
Department of Computing & Communication Technology
Sampling and Quantization
Bilinear Interpolation
Ø From the equation above, the four coefficients (a, b, c, and d) are
determined from the four equations in four unknowns that can be written
using the four nearest neighbors of point (x, y)
Ø bilinear interpolation gives much better results than nearest neighbor
interpolation, with a modest increase in computational burden
Bicubic Interpolation
Bicubic interpolation is a more sophisticated method that takes into account
the values and positions of 16 neighboring pixels (forming a 4x4 square)
around the new pixel
28
Department of Computing & Communication Technology
Sampling and Quantization
Bicubic Interpolation
It uses a weighted average based on the distances to these pixels, resulting
in smoother and more detailed output
Neighbours of a Pixel
A pixel p at coordinates (x, y) has four horizontal and vertical neighbors
whose coordinates are given by
30
Department of Computing & Communication Technology
Pixel Relationship
Neighbours of a Pixel
31
Department of Computing & Communication Technology
Pixel Relationship
Adjacents, Connectivity, Regions, and Boundaries
Adjacency
32
Department of Computing & Communication Technology
Pixel Relationship
Adjacents, Connectivity, Regions, and Boundaries
Adjacency
33
Department of Computing & Communication Technology
Pixel Relationship
Adjacents, Connectivity, Regions, and Boundaries
Three Types of Adjacency
2:
34
Department of Computing & Communication Technology
Pixel Relationship
Adjacents, Connectivity, Regions, and Boundaries
Three Types of Adjacency
3:
i) q is in 𝑁#(𝑝), or
ii) q is in 𝑁! (𝑝) and the set 𝑁# 𝑝 ∩ 𝑁#(𝑞)N4(p) has no pixels
whose values are from V
35
Department of Computing & Communication Technology