Module1 All Slides
Module1 All Slides
Lect. Week
6th Jan to 10th Jan 2025 2
Motivation
• Three Major Motivation for Processing of Images.
3
Application of Image Processing
1. Remote sensing.
2. Medical Domain.
4. Industrial automation.
5. Film and entertainment industry. To add the special effects and create artificial
environment.
4
Application of Image Processing
5
Application of Image Processing
6
Application of Image Processing
Medical Domain
7
Application of Image Processing
Remote Sensing
8
CSET344 - Syllabus
9
Course Overview : Module 1
1. Analog-to-Digital Image Conversion:
Sampling and Quantization
Histogram Equalization: A specific histogram processing method that aims to redistribute pixel
intensities to achieve a uniform distribution.
3. Convolution:
A fundamental operation in image processing where a kernel (filter) is slide over the image, and an
output pixel is computed as a weighted sum of the input pixels within the kernel's region.
4. Image Smoothing:
Mean Filter, Median Filter, Gaussian Filter
5. Edge Detection:
Prewitt Operator, Sobel Operator, Laplacian Operator, Laplacian of Gaussian (LoG) Operator
And Canny Edge Detector: 10
Course Overview: Module 2
1.Line and Circle Detection using the Hough Transform:
Corner Detection: A technique for identifying image locations where two edges intersect,
forming a sharp corner.
Color Models: Mathematical representations of color, defining how colors are represented
numerically. Common examples include RGB, HSV, and CIELAB.
Color Transforms: Algorithms for converting colors between different color models, enabling
tasks like color correction, image segmentation, and color analysis.
4. Morphological Operations
A technique for estimating the apparent motion of objects between two consecutive image
frames. It involves calculating the pixel-wise displacement vectors that represent the motion
of objects in the scene.
12
Course Overview: Module 4
1. Different Methods of Face Detection
2. PCA for Dimensionality Reduction and other Feature Extractors like HOG, SIFT
13
CSET344 – Course Evaluation (Tentative)
1. Mid-Semester: 20 marks
2. End-Semester: 40 marks
3. Project Work: 20 marks
1. Presentation and Q&A (Individual Student) : 10 marks
2. Functionality and Working Condition: 10 marks
4. Laboratory Continuous Assessment: 20 marks
5. Programming Environment: All experiments will be conducted using the Python programming language
with OpenCV on the Google Colab platform or Visual Studio Code.
6. Module Coverage:
1. Before the Mid-Semester : Modules 1 and 2 will be completed.
2. After the Mid-Semester: Modules 3 and 4 will be covered.
7. Question Design: All questions will emphasize logical reasoning and problem-solving.
14
EM Spectrum
Refer: https://www.lumitex.com/blog/visible-light-spectrum
15
Image, Intensity or grey level and Pixel.
It’s a two dimensional function f(x , y) where x, y are the spatial coordinate and the amplitude at that particular
coordinate will be the intensity or grey level.
720 1080
x,y
HD 1920
FULL HD
1320
1320 x 720 1920 x 1080
2100
Image
3800
ULTRA 4k
3800 x 2100
16
Type of Images
0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 255 255 255 0
0 0 0 1 0 0 0 0 255 0
0 1 1 1 0 0 255 255 255 0
R,G,B
0 0 0 1 0 0 0 0 255 0
0 1 1 1 0 0 255 255 255 0
0 0 0 0 0 0 0 0 0 0
17
CSET344/CMCA544
Image and Video Processing
Scanners
Image Acquisition Cameras
Hard Drives
Image Storage Solid State Drives (SSD)
Image Enhancement
Image Restoration
Image Processing Image Segmentation
Image Analysis
Refer: https://www.lumitex.com/blog/visible-light-spectrum
20
Image Sampling and Quantization
21
Image Sampling and Quantization
Z
Sampling : Discretizing the time axis or coordinate.
A B
22
Representation of Digital images
0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 255 255 255 0
0 0 0 1 0 0 0 0 255 0
0 1 1 1 0 0 255 255 255 0
R,G,B
0 0 0 1 0 0 0 0 255 0
0 1 1 1 0 0 255 255 255 0
0 0 0 0 0 0 0 0 0 0
23
Representation of digital image
It’s a two dimensional function f(x , y) where x, y are the spatial coordinate and the amplitude at that particular
coordinate will be the intensity or grey level.
24
Basic Terminologies
0 0 0 0 0 720 1080
0 255 255 255 0
0 0 0 255 0
F(4,4)
0 255 255 255 0 HD 1920
FULL HD
1320
1320 x 720 1920 x 1080
0 0 0 255 0
0 255 255 255 0
0 0 0 0 0 2100
3800
ULTRA 4k
3800 x 2100
25
Basic Terminologies
Spatial Domain
Lets say size of the image is M x N and its a 8-bit image. Total bits required = M x N x k.
No. of intensity levels = 2^k. if 8 bit image then 2^8 = 256 intensity levels or Grey levels (0 to 255).
26
Basic Terminologies
Dynamic Range, Contrast and Contrast Ratio
Dynamic Range: Dynamic range of any image processing system is the ratio of maximum measurable intensity
to minimum detectable intensity.
Dynamic range in terms of images or image contrast or contrast ratio: Difference between highest and lowest
intensity levels in an image.
Resolution means how many Dots per inch (DPI) or Pixel per inch (PPI). It directly refer to the clarity of the
image. If resolution is high, it means more information or details can be identified in better way.
27
Basic Terminologies
Spatial Resolution
Spatial Resolution: Capability of sensor to distinguish between two closely spaced objects.
Higher Spatial Resolution: Pixel size is small and one can see more details.
Lower Spatial Resolution: Pixel size is big and one can not distinguish between two closely spaced objects.
28
Basic Terminologies
Intensity Resolution
29
Basic Relationship Between Pixels
(x-1,y)
(x,y-1) p(x,y) (x,y+1) 8 Neighbors of P N8(p) = N4(P) + ND(P)
(x+1,y)
(x-1,y-1) (x-1,y) (x-1,y+1)
(x,y-1) p(x,y) (x+1,y+1)
Four Diagonal Neighbors of P,ND(P)
(x+1,y-1) (x+1,y) (x+1,y+1)
(x-1,y-1) (x-1,y+1)
p(x,y)
(x+1,y-1) (x+1,y+1)
30
Distance Measures
1.Euclidean Distance:
[(x-s)^2 + (y-t)^2]1/2
31
Basic Relationship Between Pixels
2 2 2 2 2 2
2 1 2 2 1 1 1 2
2 1 0 1 2 2 1 0 1 2
2 1 2 2 1 1 1 2
2 2 2 2 2 2
32
Image Enhancement in the Spatial Domain
Spatial Domain
34
Intensity Transformation
35
Intensity Transformation: Image
Negative
Motivation : These kind of transformation is used to enhance grey level information embedded in the dark region of
an image or it is required when black area is dominant in size as compared to white region.
S=L–1–r
where L = Maximum Intensity Level
r = Input Intensity Level
S = Output Intensity Level
Consider 8-bit (0 - 255). Where L = 255.
10
20
30
40
36
Intensity Transformation: Log Transformations
Motivation : These transformation used to expand the dark pixel in an image while compressing the higher-level
values.
S = clog(1+r), where L = Maximum Intensity Level
r = Input Intensity Level
S = Output Intensity Level, C = constant. C = L-1/log(1+rmax)
r S = C log(1+r)
Consider 8-bit image. Where L = 255 and rmax = 255
0
Calculate S value ?
1
5
200
220
240
37
Intensity Transformation: Power Law Transformations (Gamma Correction)
Motivation : Visual quality of image may be hampered by illumination condition or wrong setting of camera sensor.
To rectify the same, one can utilized power law transformation or Gamma Corrections.
Basic idea is to raise the pixel value with certain power to improve the overall brightness and contrast of
the image.
S = c r^y,
where
3 x 3 Input Image
10 200 150
20 100 90 S = c r^y
70 50 220
C = 255
r = image(x,y)/ 255
39
Piecewise Linear Transformation Function: Contrast Stretching
Motivation : Low Contrast image can result from poor illumination, lack of dynamic range in the imaging sensor
or even thought the wrong setting of a lens aperture during image acquisition.
Contrast stretching expands the intensity range to utilize the full dynamic range of the sensor.
40
Piecewise Linear Transformation Function: Contrast Stretching
S = (r – Imin) x ((Omax-Omin)/(Imax - Imin)) + Omin S = Output Intensity Level
r = Input Intensity Level
Omax = Maximum Output
Omin = Minimum Output
Before Transformation Imax = Maximum input
Imin = Minimum input
10 5 150
20 100 90
Apply Contrast Stretching for r =10
70 50 30
Omax = 255, Omin = 0
After Transformation Imax = 150, Imin = 5
41
Piecewise Linear Transformation Function: Thresholding
output Intensity s
If r1 = r2
S1 = 0 and S2 = L-1
Input Intensity r
42
CSET344/CMCA544
Image and Video Processing
P(rk) = h(rk) / MN
Application
1. Image Enhancement
2. Image Thresholding
3. Image Segmentation
4. Image Analysis
44
Histogram Examples
45
Histogram Example
Histogram ? Intensity or Grey Level Frequency Normalized
Histogram
For a 3-bit image and size is 3x 3
1 3 3/9
1 2 6
2 1 1/9
6 1 3
3 1 1/9
1 6 6
6 4 4/9
46
Histogram Equalization
Its a technique used in image processing to improve the contrast of an image. It works by redistributing the intensity values
of the pixels in an image so that the histogram becomes more uniform.
Sk = T(rk)
Sk = L-1
Where –
L = number of possible intensity levels
Sk = output intensity levels
rk = input intensity levels
Why it is required ?
To enhance the contrast of an image, especially when the pixel intensity values are concentrated in a narrow range
(e.g., very dark or very bright images).
48
Histogram Equalization
49
Histogram Equalization Example
Consider a 3 bit image of size 64x64 (4096) with intensity distribution shown in the
below table. Calculate the Equalized histogram.
Sk = T(rk)
S = L-1x(Pk) = 7x0.19 = 1.33
Sk = L-1 50
Histogram Equalization Example
Consider a 3 bit image of size 64x64 with intensity distribution shown in the below
table. Calculate the Equalized histogram.
rk nk P(rk) Sk Approximate Value Updated nk Updated
of Sk P(rk)
0 790 0.19 1.33 1 790 790/4096
1 1023 0.25 3.08 3 1023
2 850 0.21 4.55 5 850
3 656 0.16 5.67 6 656+329 = 985
4 329 0.08 6.23 6
5 245 0.06 6.65 7 245+122+81= 448
6 122 0.03 6.86 7
7 81 0.02 7.00 7
Sk = T(rk)
Sk = L-1
51
Concept of Kernal or Filter or Convolution Mask
X1
W1
W1X1 + W2X2
W2
X2
52
Spatial Correlation and Convolution: Padding size (M-1)/2 or (N-1)/2
Input Image 0 0 0 0 0 0 0
0 0 0 0 0 Kernel
0 0 0 0 0 0 0
0 0 0 0 0 1 2 3 0 0 0 0 0 0 0
0 0 1 0 0 4 5 6 0 0 0 1 0 0 0
0 0 0 0 0 7 8 9 0 0 0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Correlation Convolution
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 9 8 7 0 0 0 0 1 2 3 0 0
0 0 6 5 4 0 0 0 0 4 5 6 0 0
0 0 3 2 1 0 0 0 0 7 8 9 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 53
Smoothing Spatial Filters
Smoothing Spatial Filter
Median Filters
Box Car or Mean
Filter
Max Filter
Weighted Avg.
Filter
Min Filter
Gaussian Filters
54
Image Smoothening: Box Car Filter
A filter that computes the average of pixels in the neighborhood blurs an image. Computing an average is analogous to
integration.
Or
A filter that reduces the sharp transition in the intensity called as smoothening or low pass filtering.
Convolving a smoothening kernel with image result in image blurring and the amount of blurring is always depends on
the size of the kernel.
Kernal Normalized Kernal
1 1 1 0.11 0.11 0.11
1/9 x 1 1 1 = 0.11 0.11 0.11
1 1 1 0.11 0.11 0.11
1 1 1 1
1 1 1 1
1/16 x
1 1 1 1
1 1 1 1 55
Image Smoothening: Box Car Filter
Comparison of outputs between Normalized and Non-Normalized Kernel
Image Normalized Kernel
1 2 3 0.11 0.11 0.11
4 5 6 0.11 0.11 0.11 0.11+0.22+0.33+0.44+0.55+0.66+0.77+0.88+0.99 = 4.95
7 8 9 0.11 0.11 0.11
56
Working Example: Padding size (M-1)/2 or (N-1)/2
Input Image
1 2 5 3 4 Kernel
5 6 7 8 9 0.11 0.11 0.11
2 3 4 5 6 0.11 0.11 0.11
3 6 8 4 2 0.11 0.11 0.11
1 5 6 8 7
1 2 1
1/16 x 2 4 2
1 2 1
57
Image Smoothening: Gaussian
Filter
58
Image Smoothening: Gaussian
Filter
Calculate the gaussian Kernel for 3x3 Kernel
Consider SD = 1
X=0,y=0 : SD =1 : 1/2pi =
59
CSET344/CMCA544
Image and Video Processing
61
Image Smoothening: Gaussian
Filter
Calculate the Gaussian Kernel for size
62
Image Smoothening: Gaussian
Filter
Sigma =1 Sigma =2 Sigma =3
63
Smoothing Spatial Filters
Smoothing Spatial Filter
64
Max Filter, Min Filter, Median Filter
65
Examples : Max Filter, Min Filter. Assume Kernel size is 3 x 3
0 0 0 0 0 0 0
0 3 7 17 18 13 0
0 10 5 2 20 5 0
Min. Filter Output
0 9 8 13 1 7 0
0 16 8 7 20 19 0 0 0 0 0 0
0 14 19 3 30 10 0 0 2 1 1 0
0 0 0 0 0 0 0 0 2 1 1 0
0 3 1 1 0
0 0 0 0 0
0 0 0 0 0 0 0
0 3 7 17 18 13 0
0 10 5 2 20 5 0
0 9 8 13 1 7 0
0 16 8 7 20 19 0
Median Filter Output
0 14 19 3 30 10 0
0 0 0 0 0 0 0 0 3 5 5 0
5 8 8 13 5
68
Comparison Between Max., Min. and Median Filters output
69
Image Denoising
70
Image Denoising
71
Edge Detection
Prewitt
Sobel
Edge Detector
Laplacian
Edge: Edge pixels are the pixels at which intensity of an image Changes abruptly.
Line: it may be viewed as a thin edge segment where intensity of background on either side of line is either
much higher or much lower.
Sample Image
0 0 0 7 7 7 0 0 0
Step Edge
First Derivative
Second Derivative
Zero Crossing
76
Edge
77
Edge
78
Edge
Observations
2. Second order derivative have the stronger response for point, thin lines and noise.
3. Second order derivative produces double edge response at ramp and step transition in
intensity.
4. The sign of second derivative used to determine whether a transition into an edge from light
79
Edge
Original Image First Derivative Second Derivative
Gradient Vector
83
Edge Detection Image Gradient and its properties
Edge : An Abrupt or Sudden change in intensity which will help to identify the edges.
84
Edge Detection Image Gradient and its properties
0 1 1 Z1 Z2 Z3
0 0 1 Z4 Z5 Z6
0 0 0 Z7 Z8 Z9
85
Edge Detectors
Prewitt
Sobel
Edge Detector
Laplacian
-1 -1 -1 -1 0 1
0 0 0 -1 0 1
1 1 1 -1 0 1
-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1
-1 -2 -1 -1 0 1 50 50 150
0 0 0 -2 0 2 50 50 150
1 2 1 -1 0 1
Note: Sobel operator has better noise
suppression capability as compared to
Prewitt. 88
Sobel Edge Detectors
Original Image Gradient in x direction
Thresholding
helps to avoid
the Minor Edges.
Note: When interest lies in high lightening the principal edge and maintaining as much connectivity
as possible, it is common practice to use both smoothening and thresholding.
91
Laplacian of Gaussian (LoG)
Limitation of Prewitt and Sobel Operators
1. They only able to detect the edges in horizontal and vertical direction.
2. For different type of images kernel size will be different.
1.Second derivative could able to localize edges in the better way as compared to the first derivative.
3. Edge detector should be isotropic i.e. it could detect edges in all the directions.
4.Larger Kernel should able to detect blurry edges and small kernel could able to detect the sharply focused fine
details.
LoG : Gaussian function first smooth the image and Laplacian will find the second derivative of gaussian
function which directly helps to locate the edge.
92
Laplacian of Gaussian (LoG)
LoG : Gaussian function first smooth the image and Laplacian
will find the second derivative of gaussian function which
directly helps to locate the edge.
Laplacian Function
Laplacian of Gaussian
93
Laplacian of Gaussian (LoG)
10 10 10 10 10
10 10 10 10 10 -1 -1 -1
100 100 100 100 100 -1 8 -1
100 100 100 100 100 -1 -1 -1
10 10 10 10 10
3 by 3 Kernel
Image
Output Image
94
Laplacian of Gaussian (LoG)
10 10 10 10 10
10 10 10 10 10 -1 -1 -1
100 100 100 100 100 -1 8 -1
100 100 100 100 100 -1 -1 -1
10 10 10 10 10
3 by 3 Kernel
Image
95