Digital Image Processing
Dr. RajibKumar Jha
Associate Professor
Depart of Electrical Engineering
Indian Institute of Technology Patna [email protected]
1
Lecture Notes-2025
Contents
•Image digitization.
•Sampling of images.
•Image reconstruction from the sampled signal.
•Image Quantization
•Dither
•Neighborhood of Pixels
•Connectivity
•Adjacency
•Path
•Algorithm for Connected Component Analysis
3
Sampling & Quantization
4
1-Dimensional Sampling
•Sampling frequency, f
S=1/Δt
S
•Reducingsamplingintervalby1/2meansincreasing
samplingfrequencybytwice,i.e.,moreinformation
contentiskeptinthesampledsignal.
•Nowquestioniswhatshouldbethesampling
frequencybywhichmaximuminformationofthe
signalcanbekept.
If Δt
S
’
= Δt
S/2 the f
’
S
=
1/Δt
S
’
= 2/Δt
S= 2f
S
Resolution is same but size is varying
1024
512
256
128
64
32
16
Reduce the file size of pixels => Save image as close as possible to
the original
Image Quantization
•Quantization is a mapping of a continuous variable �to a
discrete variable �
′.
•�
′
∈�
1,�
2,�
3,…..�
??????
•�
•Mapping is generally staircase representation.
•Quantization Rule: Define a set of decision or transition levels.
•{t
k, k=1,2,……..L+1};Where t
1is minimum value and t
L+1is
maximum value
•�
′
=r
kif t
k<u<t
k+1
17
Quantization �
′
18
Staircase Quantizer
Sampling & Quantization Response
19
LetusseetheeffectofquantizationonReconstructedSignal
Quantization Error = Quantized signal –Input signal
Diagonal Neighbors & 8-Neighbors
•A pixel p has 4 diagonal neighbors N
D(p)
•The points of N
4(p) and N
D(p) together are
called 8-neighbors of p.
•N
8(p)= N
4(p) U N
D(p)
•If p is a boundary pixels then both N
D(p) and
N
8(p) will have less number of pixels.
34
(x-1, y-1) (x-1, y+1)
P(x,y)
(x+1,y-1) (x+1,y+1)
(x-1, y-1)(x-1,y)(x-1, y+1)
(x,y-1)P(x,y)(x,y+1)
(x+1,y-1)(x+1,y)(x+1,y+1)
8-neighbors
diagonal neighbors
Adjacency
•Two pixels p and q are adjacent if they are connected
–4-adjacency—
–8-adjacency---
–m-adjacency---
•Dependingonthetypeofconnectivityused
•TwoimagesubsetsS
iandS
jareadjacentifpixelpεS
iandqεS
j
suchthatpandqareadjacent.
38
Connected Component Labeling
•If l(p) =1 and both r and t are 1’s, then
•If L(r)=L(t) and L(p)=L(r)
•If L(r) ≠L(t) then assign 1 to labels to p and make a note that the
two labels are equivalent.
•At the end of the scan all pixels with value 1 are labeled.
•Some labels are equivalent.
•During 2
nd
pass process equivalent pairs to form equivalence class.
•Assign a different label to each class.
•In the 2
nd
pass through the image replace each label by the label
assigned to its equivalence class.
44
Example
45
(1,2),(3,4), (1,5)
(1,2), (1,5)=1
(3,4)=3
Algorithm Demonstration
46
Connectivity
47
Distance measures
•Take 3-pixels at locations p, q and z
•P=(x,y); q=(s,t) and z=(u,v)
•D is a distance function or metric if
•D(p,q)≥0;
•If D(p,q)=0 if p=q
•D(p.q)=D(q,p)
•D(p,z)≤D(p,q)+D(q,z)
48
Euclidean Distance
•??????
??????�,�=[(�−�)
2
+(�−�)
2
]
1
2
•Set of points S={q|(D(p,q) ≤ r)} are the points contained in a
disc of radius r cantered at p.
49
•D
4distance or city-block distance or Manhattan Distance:
•D
4(p,q)=|x-s|+|y-t|
•Points having city block distance from p less than or equal to r
from diamond centered at p.
50
City-Block Distance
Arithmetic/Logical Operation
•Following Arithmetic/logical operations between two pixels p
and q are used extensively.
•P+q;p-q; p*q p%qArithmetic operation
•AND OR; NOT Logical operation
•Logical operations are applied on binary images only.
56
Addition of two images
57
Addition of 2-images
58
Subtraction of two images
59
Subtraction of two images
60
Multiplying by a constant
61
Division of two images
62
DivingDCTcoefficientmatrixelementwise
bythequantizationmatrixandroundingto
nearestinteger.
Ex:round(-415/16)=round(-25.93)=26
Logical Operation:
Negative Operation (NOT(A))
63
Negative Operation
64
Negative Operation
65
Convolution operation
66
Z
1 Z
2 Z
3
Z
4 Z
5 Z
6
Z
7 Z
8 Z
9
W
1 W
2 W
3
W
4 W
5 W
6
W
7 W
8 W
9
Z
R=W
1Z
1+W
2Z
2+……..+W
9Z
9
??????=1
9
�
??????�
??????
For averaging operation divide by N=9;
Results of Image Averaging operation
67
Avg= fspecial('average',[5 5]);
Neighborhood operations
•Various important operations can be implemented by proper
selection of coefficients W.
•Noise filtering
•Thinning
•Edge detection
•Image enhancement
•Etc..
71
Contents
•Basic Transformations –Translation, Scaling and
Rotation in both 2D and 3D
•Inverse Transformations
•Perspective Transformation
•Inverse Perspective Transformation
73