Basic Concepts in Digital Image Processing
Image Resampling & Interpolation
Need to resample the image when
• Rescaling
• Geometrical transformation
Interpolation methods:
• Nearest neighbor
• Fast and simple
• Loss of sharpness
• Artifacts (checkerboard)
• Bilinear
• Bicubic
• Images are sharpest
• Fine details are preserved
• Slow https://www.i2tutorials.com/what-is-geometric-
transformation/
Image Resampling & Interpolation
NN Bilinear Bicubic
Original
72dpi
1250dpi
150dpi
Image Interpolation – Nearest Neighbor
Assign each pixel in the output image with the nearest neighbor in the input image.
Image Interpolation Examples by R. Islam
Image Interpolation – Bilinear
Image Interpolation Examples by R. Islam
Review of Adjacency
Adjacency is the relationship between two pixels p and q
V is a set of intensity values used to define adjacency
• Binary image: V={1} or V={0}
• Gray level image:
Intensity constraints
Three types of adjacency:
4-adjacency 8-adjacency m-adjacency
X
p
and
Connectivity
• Path from p to q: a sequence of distinct and adjacent pixels with
coordinates
Starting point p ending point q
adjacent
• Closed path: if the starting point is the same as the ending point
• p and q are connected: if there is a path from p to q in S
• Connected component: all the pixels in S connected to p
• Connected set: S has only one connected component
Are they connected sets?
4-adjacency: No 8-adjacency: Yes
Boundaries
• Inner boundary (boundary) -- the set of pixels each of which
has at least one background neighbor
• Outer boundary – the boundary pixels in the background
Distance Measures
For pixels p, q, and z, with coordinates (x,y), (s,t) and (v,w), D
is a distance function or metric if
(a) D( p, q) 0
(b) D( p, q) 0 if p q
(c) D( p, q) D(q, p)
(d) D( p, z) D( p, q) D(q, z)
Distance Measures
Euclidean distance De ( p, q) (x s) 2 ( y t) 2
City-block (D4) distance D4 ( p, q) | x s | | y t |
Chessboard (D8) distance (Chebyshev distance)
D8 ( p, q) max(| x s |, | y t |)
Distance: Sample Problem
D4 distance p
6
D8 distance
5 q
Euclidean distance
𝟏 + 𝟓𝟐
Distance vs length of a path?
Mathematic Tools
Array/Matrix operations
Linearity:
Arithmetic Operations – single pixel operations
• Image averaging, image subtraction, image multiplication
Set and logic operations
Spatial operations
• Single pixel operations and neighborhood operations
Image transformation
Mathematic Tools
Array versus Matrix operations
Array Multiplications
𝒂𝟏𝟏 𝒂𝟏𝟐 ∙ 𝒃𝟏𝟏 𝒃𝟏𝟐
=
𝒂𝟏𝟏𝒃𝟏𝟏 𝒂𝟏𝟐𝒃𝟏𝟐
𝒂𝟐𝟏 𝒂𝟐𝟐 𝒃𝟐𝟏 𝒃𝟐𝟐 𝒂𝟐𝟏𝒃𝟐𝟏 𝒂𝟐𝟐𝒃𝟐𝟐
Matrix Multiplications
𝒂𝟏𝟏 𝒂𝟏𝟐 𝒃𝟏𝟏 𝒃𝟏𝟐 𝒂 𝒃 + 𝒂𝟏𝟐𝒃𝟐𝟏 𝒂𝟏𝟏𝒃𝟏𝟐 + 𝒂𝟏𝟐𝒃𝟐𝟐
𝒂𝟐𝟏 𝒂𝟐𝟐 × = 𝟏𝟏 𝟏𝟏
𝒃𝟐𝟏 𝒃𝟐𝟐 𝒂𝟐𝟏𝒃𝟏𝟏 + 𝒂𝟐𝟐𝒃𝟐𝟏 𝒂𝟐𝟏𝒃𝟏𝟐 + 𝒂𝟐𝟐𝒃𝟐𝟐
Image Averaging – Noise Reduction
Assumption: the noise is uncorrelated in image and has zero mean
Image Subtraction – Enhance Difference
Image Subtraction
The images used in averaging & subtraction must be
registered!
Image Multiplication
g(x,y)=f(x,y)h(x,y)
Notes on Arithmetic Operations
• The images used in averaging & subtraction must
be registered!
• Output images should be normalized to the range of
[0,255]
Set Operations Based on Intensities
Complement – negative image
𝑨𝒄 = 𝒙, 𝒚, 𝑲 − 𝒛 𝒙, 𝒚, 𝒛 ∈ 𝑨
𝑨𝖴 𝑩= max 𝑎, 𝑏 𝑎𝜖𝐴, 𝑏𝜖𝐵}
Logic Operations for Binary Image
Spatial Operations
Perform directly on the pixels of the given image
• Intensity transformation – change the intensity
• Single pixel operations s=T(z)
• Neighborhood operations
• Geometric spatial transformations – change the
coordinates
Single pixel operations
• Determined by
• Transformation function T
• Input intensity value
• Not depend on other pixels and position
Neighborhood Operations
Image smoothing
g(x, y)
1
f (r, c)
mn (r,c)S xy
Other examples:
•Interpolation
•Image filtering
Geometric Spatial Transformations
Nearest neighbor Bilinear Bicubic
Note: a neighborhood operation, i.e., interpolation, is
required following geometric transformation
Fourier Transforms and Filtering
Fourier Transform
Probability Methods
𝑧𝑘 is the kth intensity value
𝑛𝑘 is the number of pixels having the intensity value 𝑧𝑘
Probability of an intensity value
L1
nk
p(z k )
MN
, p(z
k 1
k ) 1
Probability Methods
Spatial Domain
g(x,y)=T [f(x,y)]
spatial filter
Contrast stretch
Soft thresholding (logistic function) Hard thresholding (step function)
Some Basic Intensity Transformation
Functions
• Thresholding – Logistic function
• Log transformation
• Power-law (Gamma correction)
• Piecewise-linear transformation
• Histogram processing
Some Basic Intensity Transformation
Functions
Image Negative: s=L-1-r
Image Enhancement Using Gamma Correction
Power-Law (Gamma) Transformations for
Contrast Manipulation
Washed-out appearance caused
by a small gamma value
Power-Law (Gamma) Transformations for
Contrast Manipulation
Piecewise-Linear Transformation Functions:
Contrast Stretching
Piecewise-Linear Transformation Functions:
Bit-Plane Slicing
An Example
Use for Image Compression
original
Less bit planes are sufficient to obtain an acceptable details, while
require half of the storage
Example
https://janithabandara.medium.com/image-compression-using-bit-plane-
slicing-opencvsharp-without-pre-defined-functions-608a61d252b7
Histogram Processing
Histogram
h(rk ) nk
Normalized histogram
p(rk ) nk / MN
255
p(r ) 1
k
k 0