DIPMOD1111111111111
DIPMOD1111111111111
GLA
Module 1
• Introduction and Fundamentals:
– Motivation and Perspective,
Applications, Components of
Image Processing System,
– Element of Visual Perception, A Simple
Image Model,
– Sampling and Quantization, Some Basic
Relationships between Pixels
Type of image:
Analog image and Digital image:
The key differences between analog images and digital images are given in the table below:
Analog images are continuous and physical, while digital images are discrete and numerical.
Digital images are more practical for modern applications due to their ease of processing,
storage, and transmission.
How it works?
Applications:
1. Medical field
3. Remote Sensing
DIP: Module1, Bondita Paul, Asst. Prof. GLA
4. Object Tracking
5. Classification
6. Change Detection
DIP: Module1, Bondita Paul, Asst. Prof. GLA
7. Disaster Monitoring
What is a pixel?
Where,
M: number of rows and
N: number of columns
i.e.
where,
• k: number of bits used for representation
• Assume that the discrete levels are equally spaced and that they
are integers in the interval [0, L-1].
• The total number of bits ‘b’ required to represent an image is
given by
• b=M × N × k
• For M=N
• b=M^2×k
DIP: Module1, Bondita Paul, Asst. Prof. GLA
• When an image can have 2^k intensity levels, then the image is
called as k-bit image. For example, an image with 256 possible
discrete intensity values is called an 8-bit image.
• The range of values spanned by the grayscale is referred to as the
dynamic range.
Detailed Conversion List:
Q. For an image of 512 by 512 pixels, with 8 bits per pixel. What will
be the total bits required to store the image?
Ans:
Size = 512 * 512 * 8 bits
= 29 * 29 * 23 bits
= 221/23 bytes
= 218/210 K bytes
= 256 KB
Q. For an image of 64 by 64 pixels with 3 bands, with 4 bits per
pixel. Calculate the total bits present in the image.
Ans: Given:
1. Image Dimensions: 64×64 pixels
2. Number of Bands (Channels): 3 bands
3. Bits per Pixel: 4 bits
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Formula:
Total Bits=Width×Height×Bands×Bits per Pixel
Total Bits=64×64×3×4 =49152 bits
= 6144 bytes (6 KB)
Q. For an image of 32 by 32 pixels with 4 bands/channels, in
which the smallest unit of an image consists of 11 shades.
Determine the total number of bits required to store this image.
Ans: Given:
Image Dimensions: 32×32 pixels
Number of Bands: 4
Shades (Levels): 11
The number of bits required to represent N shades is:
Bits per Pixel (bpp), k=log2(N)
For N=11
bpp=log2(11)=3.459=4 bits per pixel.
Total Bits=Width×Height×Bands×bpp
=32×32×4×4=16384 bits=2,048 bytes = 2 KB
Since we know there are 256 levels and 8 bits per pixel present in
Grayscale image. Find out how many bits per pixel are present in
the binary image and how many levels are present in the color
image.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Black and
Feature Binary Image Grayscale Image Color Image
White Image
A subset of Contains color
Simplest form Contains multiple
grayscale, information using
with two intensity shades of gray
Definition typically only combinations of
levels: black (0) between black and
black and white Red, Green, and
and white (1). white.
(high contrast). Blue (RGB).
256 levels (Only Millions of colors
256 levels
Intensity 2 levels (black black (0) and (e.g., 24-bit color
(typically 8 bits per
Levels and white). white (255) are supports 16.7
pixel).
highlighted. million colors).
8 bits or higher per 8-bit (pure black 24 bits (8 bits per
Bit Depth 1 bit per pixel.
pixel. and white). channel: RGB).
Used for Used for detailed High-contrast
Used for
segmentation, intensity applications,
representing real-
Purpose thresholding, or representation (e.g., such as printing
world images with
document medical imaging, or artistic
natural colors.
scanning. photography). purposes.
OCR, edge X-rays, Photography,
Printing, logos,
Applications detection, mask photographs, video, gaming, and
line art.
creation. intensity analysis. digital displays.
A scanned text A black and A colorful
A grayscale portrait
document or a white logo with landscape
Example image with various
thresholded object no intermediate photograph or
shades of gray.
mask. shades. painting.
Image Resolutions:
There are four types of resolution
• Spatial resolution
• Spectral resolution
• Temporal resolution
• Radiometric resolution
Spatial resolution:
The smallest possible feature that can be detected in an image.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Measurement:
1. Remote Sensing:
o High spatial resolution is used for mapping urban areas,
while low spatial resolution is used for large-scale
environmental monitoring.
2. Medical Imaging:
o Important in modalities like X-rays, CT scans, and MRIs
to detect small abnormalities.
3. Digital Photography:
o Determines the sharpness and quality of captured images.
4. Microscopy:
o Used in biology and materials science to observe fine
details at micro or nanoscales.
Example:
Electromagnetic Spectrum:
Wavelength
Region Frequency Range Examples/Applications
Range
Communication (radio, TV, mobile
Radio Waves > 1 mm < 3×10^9 Hz
phones)
Microwave ovens, radar, satellite
Microwaves 1 mm – 1 m 10^9 - 10^12 Hz
communication
10^{12} - 10^14 Heat sensors, remote controls,
Infrared (IR) 700 nm – 1 mm
Hz thermal imaging
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Wavelength
Region Frequency Range Examples/Applications
Range
4.3 ×10^14 -
Visible Light 400 – 700 nm Human vision, photography
7.5×10^14 Hz
Ultraviolet Sterilization, fluorescent lights,
10 – 400 nm 10^15 - 10^17 Hz
(UV) tanning
X-rays 0.01 – 10 nm 10^17 - 10^19 Hz Medical imaging, material analysis
Gamma Rays < 0.01 nm > 10^19 Hz Cancer treatment, nuclear processes
Spectral Resolution:
For example:
Example Application:
DIP: Module1, Bondita Paul, Asst. Prof. GLA
• Landsat Satellite:
o Temporal resolution: 16 days
o The satellite revisits the same area once every 16 days.
o Useful for monitoring changes like deforestation, crop growth, or
urban expansion over time.
• Landsat Sensor:
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Solution:
Checkerboard Effect:
This occurs when the number of pixels in an image is reduced while
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Example of sampling:
Example of quantization:
Comparison Table
Mid-Term 2024:
Image Acquisition:
• The image is captured by a sensor (eg. Camera) and digitized if
the output of the camera or sensor is not already in digital form,
using an analog-to-digital converter.
• Involves image preprocessing viz. scaling, resizing etc.
Image Enhancement:
• Process of image manipulation to make it more suitable for
specific use
• Different images require different enhancement methods
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Image Restoration:
• Process of reconstructing or recovering the original image from
the degraded image.
• Degradation is caused by factors like motion blur, noise, or poor
lighting.
• Mathematical and probabilistic models are used to reverse the
damage.
Compression:
• Technique for reducing the storage space required to save the
image, or bandwidth required to transmit it.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Morphological Processing:
•
Segmentation:
•
Representation & Description:
Object recognition:
Knowledge Base:
Aspect Ratio:
The aspect ratio of an image is the proportional
relationship between its width (column) and height
(row), expressed as a ratio. It defines the shape of the
image or frame and is written as:
Significance:
• Determines the overall shape of the image.
to prevent distortion.
Some Common Aspect Ratios:
• 1:1: Square images (e.g., profile pictures).
Width/Height=3/2
Let the new dimensions be w (width) and h (height). These
must satisfy: w/h=3/2
The cropped dimensions must fit within the original image
dimensions: w≤3000, h≤4000
To maximize the usable area, we need to take the largest
possible w and h that fit the aspect ratio of 3:2 while staying
within the original dimensions.
Case 1: If w=3000, Then
h=2/3w=2/3×3000=2000
Since h must be an integer, round down: h=2000
Thus, the cropped dimensions are 2000×3000 pixels.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Baud Rate:
Baud rate refers to the number of signal changes or symbols
transmitted per second in a communication channel. It is a
measure of how quickly information is transmitted.
• Generally, transmission is accomplished in packets
consisting of a start bit, a byte of information & a stop bit
• It is measured in baud (1 baud = 1 symbol per second).
• Relation to Bit Rate:
– The bit rate is the number of bits transmitted per
second, while the baud rate is the number of symbols
transmitted per second.
• If each symbol represents 1 bit, then:
Bit Rate=Baud Rate
• If each symbol represents multiple bits (e.g., in advanced
modulation schemes like QAM), then:
• Bit Rate=Baud Rate×Bits per Symbol
DIP: Module1, Bondita Paul, Asst. Prof. GLA
• Example:
– A communication system with a baud rate of 1000
baud transmits 1000 symbols per second.
• If each symbol carries 2 bits, the bit rate would be:
• Bit Rate=1000 baud×2 bits per symbol=2000 bps
(bits per second)
1. Applications:
o Used in data communication systems like modems,
Ans: Given:
1. Image I1:
o Dimensions: 10×20
2. Image I2:
o Dimensions: 100×X, maintaining the same aspect
ratio as I1
o X=100×2= 200
3. Pixel Information:
o Maximum value among pixels: 16 (requires 4 bits to
per packet)
Each pixel requires 4 bits, so:
Total Bits to Represent the Image I2
=20,000×4=80,000 bits
5. Packets Required for Transmission:
Each packet can carry 10−5 = 5 data bits (as 5 bits are used
for flags).
Number of Packets=Total Bits/Bits per Packet=80,000/5
=16000 packets
6. Total Bits to be Transferred (Including Flags):
Each packet has 10 bits (i.e., 5 data + 5 flag bits), so:
Total Bits Transferred=16000×10=4,00,000 bits
7. Transfer Time:
Transfer speed = 20 bits/sec (Given)
Transfer Time = 4,00,000/20=20,000 sec.
Image Sensors:
Image sensors sense the intensity, amplitude, coordinates, and
other features of the images and pass the result to the image
processing hardware. It includes the problem domain.
➢ Neighbourhood
➢ Adjacency
➢ Connectivity
➢ Paths
➢ Regions and Boundaries
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Neighborhood of a pixel:
• Some of the points in the N4 ND and N8 may fall outside the image
when P lies on the border of image.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Adjacency:
1 1 0
1 1 0
1 0 1
b) 8-adjacency: Two pixels p and q with values from V are
8-adjacent if q is in the set N8(p).
Eg: V = {1, 2}
0 1 1
0 2 0
0 0 1
DIP: Module1, Bondita Paul, Asst. Prof. GLA
0 1 1 0 1 1
0 1 0 0 1 0
0 0 1 0 0 1
0 1 1 0 1 1
0 1 0 0 1 0
0 0 1 0 0 1
0 1 1
0 1 0 Final image
0 0 1
• 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:
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Connectivity:
❖ q is in N4(p) or
❖ q is in ND(p) and the set [N4(p) ∩ N4(q)] is empty.
• Eg:
– Compute the length of shortest-4, 8, m path between pixels
p (3, 0) and q (0, 3), where V ={1, 2}
4 2 3 2
q
3 3 1 3
2 3 2 2
2 3
Ans: Shortest 4 path
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Since there is no 4-
connected path between 1
and 2, the shortest 4-
connected path between
points p and q does not exist
The shortest 8 path exists
V = {1}
Ri Rj
1 1 0 0 1 1
1 0 1 0 1 1
1 1 0 1 1 1
When discussing a particular region, the type of adjacency must
be specified. In the above example, the two regions are adjacent
only if 8-adjacency is considered.
Boundary
• The boundary (also referred to as the border or contour)
of a region R is defined as the set of points in R that are
adjacent to points in the complement of R.
• It consists of pixels within the region that have at least one
neighbouring pixel belonging to the background.
• In other words, the boundary of a region R includes all
pixels within R that have one or more neighbours not
included in R.
Types of Boundaries:
• Inner Border: The border of the foreground.
• Outer Border: The border of the background.
0 0 0 0 0
0 1 1 0 0
0 1 1 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
DIP: Module1, Bondita Paul, Asst. Prof. GLA
0 0 0
0 1 0
0 1 0
0 1 0
0 1 0
0 0 0
1. Inner Border:
Since R encompasses the entire image, there are no background
pixels within the image. Therefore, the inner border does not
exist because all pixels in R are surrounded only by other pixels
in R.
2. Outer Border:
Similarly, the outer border does not exist within the image
because there are no background pixels surrounding R from
outside.
Example:
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
• Outer Border: Does not exist within the image, but conceptually
would lie along the edges of the image, adjacent to the
hypothetical background outside.
2
2 1 2
2 1 0 1 2
2 1 2
2
2 2 2 2 2
2 1 1 1 2
2 1 0 1 2
2 1 1 1 2
2 2 2 2 2
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Ans:
3 1 2 1
2 2 0 2
1 2 1 1
1 0 1 2
Fig: (a) Two sets of coordinates, A and B, in 2-D space, (b) The union
of A and B, (c) The intersection of A and B, (d) The complement of
A, (e) The difference between A and B.
Logical operation:
1. AND/NAND
2. OR/NOR
3. EXOR/EXNOR
DIP: Module1, Bondita Paul, Asst. Prof. GLA
4. INVERT/LOGICAL NOT
Image Enhancement
Image enhancement involves improving the quality of
images to make them more useful and visually appealing.
The main objectives of image enhancement include:
• Enhancing the visual appeal of images.
Ans:
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Log Transformations
•
• Used to expand the values of dark pixels
in an image while compressing the higher-level
values.
• Often used to process X-ray images to improve the
visibility of details in darker regions.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Power-law transformations
• Power-law transformation, also known as gamma
correction, is a type of intensity transformation used in
image processing. It enhances or adjusts the pixel intensity
levels in an image according to the power-law equation:
s = c r^γ
Where,
• s: Output intensity (transformed pixel value).
• r: Input intensity (original pixel value).
• c: A scaling constant, used to adjust the overall
brightness.
• γ (gamma): A positive real number called the gamma
value controls the degree of transformation.
• For various
values of γ
different
levels of
enhancements
can be
obtained.
(c=1 for all
cases)
• Principle Advantage:
intensity ranges.
Contrast Stretching
Gray-level Slicing
Bit-plane slicing
Contrast Stretching:
• It is particularly
useful for improving
low-contrast images
caused by poor
illumination, limited
dynamic range of the
imaging sensor, or
improper camera
settings.
• In this plot (r1, s1) and (r2, s2) control the shape of the
DIP: Module1, Bondita Paul, Asst. Prof. GLA
s1=0; if r<=r1
s1=L-1; if r>r2
◦ Intermediate values of (r1, s1) and (r2, s2) produces
various degree of spread in the intensity.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Example:
1. Input Image:
o Consider an image with pixel intensities ranging
from 50 to 150 (low contrast).
2. Contrast Stretching:
o Let (r1, s1) = (50,0) and (r2, s2) = (150, 255)
o The transformation function stretches the input
range (50–150) to the full output range (0–255).
3. Result:
o The darker areas (close to 50) become even darker
(near 0).
o The brighter areas (close to 150) become even
brighter (near 255), enhancing contrast in the image.
This process is commonly used to improve the visual quality
of an image by making features more distinguishable.
The formula for contrast stretching is defined as a piecewise
linear function:
Where:
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Ans:
Where:
• Minimum and maximum intensity values in the input
image (rmin=10, rmax=60).
• Minimum and maximum intensity values for the output
image (smin=120, smax=180).
Given Input Intensities:
Input values: 10, 15, 20, 50
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Thresholding
• It is a limited case of contrast stretching, it produces a two-
level (binary) image.
• Thresholding is required to extract a part of an image that
contains all the information.
• Thresholding is a part of a more general segmentation
problem.
• In thresholding, pixels with an intensity lower than the
threshold are set to zero (dark area), and those with an
DIP: Module1, Bondita Paul, Asst. Prof. GLA
intensity greater than the threshold are set to 255 (i.e. L-1,
bright area). This produces a binary image.
• S=T(r) = 0 ; r<m
=L-1; r>m
Where m is a threshold
value. r is the input, defined
by the pixels of input image
f(x, y).
Transformation Function:
Example:
• Input image: An 8-bit grayscale image with pixel values
ranging from 0 to 255.
• Desired range: r1=100, r2=150.
For a pixel with:
• Intensity f(x,y)=120: It falls within the range, so s=255.
• Intensity f(x,y)=80: It falls outside the range, so s=0.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Example:
• Input image: Same as before, with intensity values from
0 to 255.
• Desired range: r1=100, r2 = 150.
For a pixel with:
• Intensity f(x,y)=120: It falls within the range, so s=255.
• Intensity f(x,y)=80: It falls outside the range, so s=80.
Result: The output image will have the desired range (100–
150) brightened, while other areas retain their original
intensity values.
An 8-bit
fractal image
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Binary Representation
Each pixel is represented in binary:
Extracting Bit-Planes
• Bit-plane 0 (LSB):
DIP: Module1, Bondita Paul, Asst. Prof. GLA
• Bit-plane 7 (MSB):
Final result:
Observation
• Higher-order bit planes (e.g., Bit-plane 7, 6): Contain
most of the visually significant information of the image.
• Lower-order bit planes (e.g., Bit-plane 0, 1): Contain
finer details and noise, contributing less to the overall
image appearance.
Applications
1. Compression: Analyzing bit-plane significance can help
in data compression by discarding less important planes.
2. Encryption: Selective encryption of specific bit planes
enhances security.
3. Image Analysis: Highlighting specific planes aids in
identifying features and patterns.
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Ans:
DIP: Module1, Bondita Paul, Asst. Prof. GLA
Histogram Processing
• A histogram in digital image processing is a graphical
representation of the distribution of pixel intensity
values (gray levels) in an image. It helps in visualizing
the frequency of occurrence of different intensity
levels across the entire image.
• Gray Levels:
o The gray levels represent the different intensities
of light in an image. In an 8-bit image, gray levels
DIP: Module1, Bondita Paul, Asst. Prof. GLA
o h(rk)=nk
o where:
▪ rk: The kth gray level or intensity in the range
[0, L-1].
▪ nk is the number of pixels in the image with
the gray level rk.
▪ h(rk): The histogram of a digital image for the
gray level rk
h(2)=6 h(5)=1
h(3)=5 h(6)=0
h(4)=4 h(7)=0
This histogram is normalized by dividing each
component by the total number of pixels (n) in the
image. Thus, the normalized histogram is given by,
DIP: Module1, Bondita Paul, Asst. Prof. GLA
p(rk) = nk/n
– k=0, 1, 2, 3,-----L-1
– p(rk) gives an estimate of the probability of
occurrence of gray level rk
– The sum of all components of a normalized
n
rk nk P(rk)=nk/n
0 1 1/16
1 3 3/16
2 2 2/16
3 3 3/16
4 3 3/16
5 0 0
6 3 3/16
7 1 1/16
n
P(r ) = 1
k =0
k
DIP: Module1, Bondita Paul, Asst. Prof. GLA
• Histogram-based Operations:
o Histogram Equalization: The process of
adjusting the image histogram to enhance its
contrast by spreading out the intensity values
more uniformly across the available range.
DIP: Module1, Bondita Paul, Asst. Prof. GLA