Image Acquisition - Digitization
Image Acquisition - Digitization
4/3/2025 (#/62) 2
Simple questions
• What intensity differences can we
distinguish?
• What is the spatial resolution of our eye?
• How accurately we estimate and compare
distances and areas?
• How do we sense colors?
• By which features can we detect and
distinguish objects?
4/3/2025 (#/62) 3
Test images a) Parallel lines
with up to 5%
Distances and areas estimations
difference in
length.
b) Circles with
up to 10%
difference in
radius.
c) The vertical
line appears
longer but
actually has the
same length as
the horizontal
line.
d) Deception by perspective: the upper line appears longer
4/3/2025 (#/62) 4
than the lower one but actually same length.
Brightness
• Intensity and brightness are two different
phenomena.
• intensity is a physical property and can be
measured.
• brightness is a psycho-visual concept and may
be described as the sensation to the light
intensity and not just simple function of intensity.
• The contrast may be defined as the difference in
perceived brightness.
4/3/2025 (#/62) 5
Mach band pattern
Is it the same level of
darkness around area D
and B ?
The brightness pattern
perceived is a darker stripe
in region D and a brighter
one in the region B whereas
actually the region from D to
B has the same intensity.
Note: it was named for
Ernst Mach who
discovered
4/3/2025
the (#/62) 6
phenomenon in 1865.
Mach band pattern
Mach bands
4/3/2025 (#/62) 7
Simultaneous contrast
• contrast sensitivity of the eye refers to the ratio of
the difference in brightness B1 (of an object) and
brightness B (of its immediate surrounding) to B.
• Which small square is the darkest one ?
All the small squares have
exactly the same intensity, but
they appear to the eye
progressively darker as the
background becomes brighter.
Region’s perceived brightness
4/3/2025 does
(#/62)not depend simply on its
8
Human Perception Phenomena
Eye fills non-existing
information
Or
wrongly perceives
geometrical properties of
the object
visual illusions
4/3/2025 (#/62) 9
Example of Digital Image Acquisition Process
4/3/2025 (#/62) 10
Image Formation
• For natural images we need a light • Light reflects from a
source ( λ:wavelength of the source): point and the reflected
E (x; y; z; λ): incident light on a light is captured by an
point (x; y; z) world coordinates of imaging device c (x; y; z;
the point λ) = E(x; y; z; λ) × r(x; y;
• Each point in the scene has a z; λ)
reflectivity function: r (x; y; z; λ)
4/3/2025 (#/62) 11
Inside the Camera - Projection
4/3/2025 (#/62) 12
Projections
• There are two types of projections (P) of interest to us:
– 1. Perspective Projection
• Objects closer to the capture device appear bigger. Most
image formation situations can be considered to be under
this category, including images taken by camera and the
human eye.
– 2. Orthographic Projection
• This is “unnatural”. Objects appear the same size
regardless of their distance to the “capture device”.
4/3/2025 (#/62) 14
Example - Orthographic
4/3/2025 (#/62) 15
Inside the Camera - Sensitivity
4/3/2025 (#/62) 17
Digital Image Formation
4/3/2025 (#/62) 18
Sampling
4/3/2025 (#/62) 19
Sampling (Contd.)
4/3/2025 (#/62) 20
Sampling
Sampling
4/3/2025 (#/62) 21
Quantization
max max
max max
a) Continuous image
b) Intensity value
along the scan line
b ab
c) Sampling and
a quantization
d) Digital scan line
c d
4/3/2025 (#/62) 23
Quantization
• fc (i; j) (i = 0,…, N-1; j = 0,…, M -1). We have the
second step of discretization left.
• fc (i; j) in [fmin, fmax]; for all i and j.
• Discretize the values fc (i; j) to P levels (P=2t) as
follows:
– Let Q = (fmax - fmin)/P .
• fq (i; j) = Q(fc (i; j))
– where Q(fc (i; j)) = (k + 1/2) Q + fmin
– if and only if fmin + k Q ≤ fc (i; j) < fmin + (k + 1) Q
• for k = 0,…, P-1
4/3/2025 (#/62) 24
Quantization (Contd.)
4/3/2025 (#/62) 25
Images as Matrices
• A digital image can be considered a matrix whose row and
column indices identify a point in the image and the
corresponding matrix element value identifies the gray level at
that point.
4/3/2025 (#/62) 27
Matrix Representation
183 160 94 153 194 163 132 165
183 153 116 176 187 166 130 169
179 168 171 182 179 170 131 167
177 177 179 177 179 165 131 167
178 178 179 176 182 164 130 171
179 180 180 179 183 169 132 169
179 179 180 182 183 170 129 173
180 179 181 179 181 170 130 169
Divide into
8x8 blocks
H=256
4/3/2025 (#/62) 29
Gray level
4/3/2025 (#/62) 32
Circle with radius 80
for i = 1 to 256
for j = 1 to 256
dist = sqrt( ((i -128)ˆ2 +
(j -128)ˆ2))
if (dist < 80)
B(i, j) = 255;
else
B(i, j) = 0;
image(C);
4/3/2025 (#/62) 33
Circle with radius 80
for i = 1 to 256
for j = 1 to 256
C(i; j) = A(i; j) * B(i; j)/255;
image(C);
Warning: Some processing will take an image A with
A(i; j) into a new matrix B which may not have integer
entries!
In these cases we must suitably scale and round the
elements of B in order to display it as an image.
4/3/2025 (#/62) 34
Resolution
• Resolution (how much detail you can see)
depends on sampling and gray levels.
• the bigger the sampling rate (n) and the
gray scale (g), the better the
approximation of the digitized image from
the original.
• the more the quantization scale becomes,
the bigger the size of the digitized image.
4/3/2025 (#/62) 35
Spatial Resolution
A 1024x1024, 8 bit image subsampled down to 32x32 pixels. Gray level 256
4/3/2025 (#/62) 36
Pixel replica
a b c
d e f
(a) 1024x1024
(b) 512x512
(c) 256x256
(d) 128x128
(e) 64x64
(f) 32x32
if4/3/2025
the resolution is decreased
(#/62)
too much, the 37
checkerboard effect can occur.
Zooming and Shrinking
• Zooming:
– Step 1: creates new pixel locations
– Step 2: assignment of graylevels to these
new locations.
4/3/2025 (#/62) 38
Zooming
12 x 11 12 x 22
Nearest neighbor interpolation
12 12
4/3/2025 (#/62) 39
Zooming
11 x 12 22 x 12
22
12
4/3/2025 (#/62) 40
Zooming
• Bilinear interpolation
f(x,y) = ax+by+cxy+d
here a,b,c,d are values corresponds to the
intensity of neighbor pixels
4/3/2025 (#/62) 41
Zooming
a b c
zoomed to
1024x1024
from 128x128
64x64 32x32
nearest
neighbor
interpolation
d e f
by using
bilinear
interpolation
4/3/2025 (#/62) 42
Shrinking
• Same as zooming, but reverse
• Row duplication row deletion
• Expand the grid and determine the
intensity
– Either by NNI, or
– Bilinear interpolation
4/3/2025 (#/62) 43
False contouring
(a) Gray level = 16
(b) Gray level = 8
(c) Gray level = 4
(d) Gray level = 2
if the gray scale is not enough, the
smooth area will be affected.
False contouring can occur on the
smooth area which has fine gray
scales.
(a) (b)
(c) (d)
4/3/2025 (#/62) 44
Nonuniform sampling
• for a fixed value of spatial resolution, the
appearance of the image can be improved
by using adaptive sampling rates.
• fine sampling required in the
neighborhood of sharp gray-level
transitions.
• coarse sampling utilized in relatively
smooth regions.
4/3/2025 (#/62) 45
Example
4/3/2025 (#/62) 46
Example
• an image with a face superimposed on a uniform
background.
• background little detailed information
coarse sampling is enough.
• face more detail fine sampling.
• if we can use adaptive sampling, the quality of
the image is improved.
• Moreover, we should care more around the
boundary of the object sharp gray-level
transmission from object to background.
4/3/2025 (#/62) 47
Nonuniform quantization
• unequally spaced levels in quantization
process influences on the decreasing the
number of gray level.
– use few gray levels in the neighborhood of
boundaries. Why ? eye is relatively poor to
estimate shades of gray near abrupt level
changes.
– use more gray levels on smooth area in order
to avoid the “false contouring”.
4/3/2025 (#/62) 48
Basic Relationship between
pixels
• Neighbors of a pixel
• Connectivity
• Labeling of Connected Components
• Relations, Equivalences, and Transitive
Closure
• Distance Measures
• Arithmetic/Logic Operations
4/3/2025 (#/62) 49
Neighbors of a pixel
• a pixel p at coordinate (x,y) has 4
– N4(p) : 4-neighbors of p 4 P 4
• (x+1, y), (x-1,y),(x,y+1), (x,y-1) 4
• Nd(p) : 4-diagonal neighbors of
p d d
• (x+1, y+1), (x+1,y-1),(x-1,y+1), (x- P
1,y-1)
d d
• N8(p) : 8-neighbors of p :
– a combination of N4 (p) and Nd (p) 8 8 8
8 P 8
4/3/2025 (#/62)
8 8 8 50
Adjacency of pixels
• Let V be the set of gray-level values used to
defined adjacency
– 4-adjacency: two pixels p and q with values
from set V are 4-adjacent if q is in the set N4(p)
– 8-adjacency: two pixels p and q with values
from set V are 8-adjacent if q is in the set N8(p)
– m-adjacency: two pixels p and q with values
from set V are m-adjacent if
• q is in the set N4(p), or
• q is in the set Nd(p) and set N4(p) N4(q) has no
pixels whose values are from V
4/3/2025 (#/62) 51
Adjacency of pixels
•
V={1,2,3,4,5,6,7,8,9,10}
1 3 7
– {3} 4-adj.
11 6 13
– {1,3,7,9} 8-adj.
18 15 9
– {3} m-adj. (I)
– {9} m-adj. (II)
– {7} not m-adj. By {II}
– {11,13,18,15} not adj.
4/3/2025 (#/62) 52
Adjacency (contd.)
• Two image subset S1 and S2 are adjacent if
some of pixels in S1 is adjacent to some of S2.
• A path from pixel p with coordinates (x,y) to pixel
q with coordinates (s,t) is a sequence of distinct
pixels with coordinates (x0,y0), (x1,y1),…(xn,yn)
where (x0,y0)= (x,y) , (xn,yn) = (s,t) and (xi,yi) is
adjacent to (xi-1,yi-1)
• n is the length of the path
• we can define 4-,8-, or m-paths depending on
type of adjacency specified.
4/3/2025 (#/62) 53
Adjacency (contd.)
0 1 1 0 1 1 0 1 1
0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1
a b c
m-adjacent (8-path ambiguous) m-path no ambiguous
4/3/2025 (#/62) 54
Definitions
• Let S be a subset of pixels and p and q
are said to be connected in S if there
exists a path between p and q which
completely lies in S.
• In S, a set of pixels which are connected in
S is called a connected component. If
number of component is 1, it is connected
set.
4/3/2025 (#/62) 55
Definitions
• A connected set of pixels is called region
• Boundary (border or contour) of a region is
a set of pixels in the region that have one
or more neighbors that are not member of
the region.
4/3/2025 (#/62) 56
Labeling of Connected Components
(4-connected) [binary]
• Scan the image from left to right
• Let p denote the pixel at any step in the
scanning process.
• Let r denote the upper neighbor of p.
• Let t denote the left-hand neighbors of p.
• when we get to p, points r and t have
already been encountered and labeled if
they were 1’s.
r
4/3/2025 (#/62) t p 57
Labeling of Connected
Components
• if the value of p = 0, move on.
• if the value of p = 1, examine r and t.
– if they are both 0, assign a new label to p.
– if only one of them is 1, assign its label to p.
– if they are both 1
• if they have the same label, assign that label to p.
• if not, assign one of the labels to p and make a note that the two
labels are equivalent. (r and t are connected through p).
• at the end of the scan, all points with value 1 have
been labeled.
• do a second scan, assign a new label for each
equivalent labels.
4/3/2025 (#/62) 58
Component labeling (4)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 0 0 1 1 1 0 1 1 0 0 2 2 2
0 1 1 0 0 0 1 1 0 1 1 0 0 0 2 2
0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0 0 3 3 0 0 0
0 0 0 1 1 0 0 0 0 0 0 3 3 0 0 0
0 0 0 1 1 0 0 0 0 0 0 3 3 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 1 0 0 0 1 1 1 0 1 0 0 0
0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0
0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 1 1 0 0 2 2 2 0 3 3 0 0
1 1 1 0 0 1 1 0 2 2 2 0 0 3 3 0
0 0 0 0 0 1 1 1 0 0 0 0 0 3 3 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Labeling of Connected
Components (8-connected)
• do the same way but examine also the upper
diagonal neighbors of p.
• if p is 0, move on.
• if p is 1
– if all four neighbors are 0, assign a new label to p.
– if only one of the neighbors is 1, assign its label to p.
– if two or more neighbors are 1, assign one of the label
to p and make a note of equivalent classes.
• do the second round and introduce a unique
label to each equivalent class.
4/3/2025 (#/62) 60
Component labeling (8)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 0 0 1 1 1 0 1 1 0 0 2 2 2
0 1 1 0 0 0 1 1 0 1 1 0 0 0 2 2
0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 1 0 0 0 1 1 1 0 1 0 0 0
0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0
0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 1 1 0 0 2 2 2 0 3 3 0 0
1 1 1 0 0 1 1 0 2 2 2 0 0 3 3 0
0 0 0 0 0 1 1 1 0 0 0 0 0 3 3 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Distances between pixels
• For pixels p, q and z say, (x,y), (s,t) and
(v,w) be the locations. The distance
function is
– D(p,q) >=0 ( =0 if p=q)
– D(p,q) = D(q,p)
– D(p,z)<= D(p,q) + D(q,z)
• Euclidean distance De (p,q) = ( x s) 2 ( y t ) 2
4/3/2025 (#/62) 62
Distances
• D4 distances (city block distance)
|x-s| + |y-t|
2
2 1 2
2 1 0 1 2
2 1 2
2
4/3/2025 (#/62) 63
Distances
• D8 distances (chessboard distance)
max(|x-s|,|y-t|)
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
4/3/2025 (#/62) 64