Documente Academic
Documente Profesional
Documente Cultură
Image Formation
Dr. Muhammad Jehanzeb
Department of CS
Fatima Jinnah Women University
Rawalpindi
Image Formation
ob
j
ec
t
lens
image
pla
ne
lig
h
ts
ou
rce
Image Formation
Image Formation
projection
projection
through
through lens
lens
image
image of
of object
object
4
Image Formation
projection
projection onto
onto
discrete
discrete sensor
sensor
array
array
digital
digital camera
camera
5
Image Formation
Sampling
Sampling
Image Formation
sensors
sensors register
register
average
average color
color
sampled
sampled image
image
7
Image Formation
Quantization
Quantization
Image Formation
real image
sampled
quantized
sampled &
quantized
10
For Rs. 2
Return 5
For Rs. 7
Return 5
For Rs. 9
Return 10
For Rs. 12
Return 10
For Rs. 23
Return 25
Quantization: Example
Actual change
continuous
continuous colors
colors
mapped
mapped to
to aa finite,
finite,
discrete
discrete set
set of
of
colors.
colors.
continuous color input
12
Quantization:
13
Sampling
14
15
A M O
a
m1 L
a1n
M
amn
Divided into
8x8 blocks
16
L2
0, L 1
Dynamic range Range of values spanned by the gray
scale
17
b M N k
k bit image
18
Spatial Resolution
The spatial resolution of an image is determined by
how sampling was carried out
Three measures we come across when talking about
Image Size/Resolution
19
Spatial Resolution
20
Spatial Resolution
21
The more intensity levels used, the finer the level of detail in
an image
22
Number of Bits
Number of Intensity
Levels
Examples
0, 1
16
256
00110011, 01010101
16
65,536
1010101010101010
23
16 colors
16 million colors
24
25
With
With1-bit
1-bit
quantization,
quantization,the
the
output
intensities
output intensities
are
aretaken
takento
tobe
be
{0,255}.
{0,255}.
26
27
6 bits 64 levels
5 bits 32 levels
4 bits 16 levels
3 bits 8 levels
2 bits 4 levels
1 bit 2 levels
28
29
The picture on the right is fine for counting the number of cars, but not for
reading the number plate
30
Image Interpolation
Image resizing
Three methods
31
Enlarging an Image
Pixel replication
[1 2 3 4 5]
[1 1 2 2 3 3 4 4 5 5] (One step)
[1 1 1 2 2 2 3 3 3 4 4 4 5 5 5] (Two step)
32
Enlarging an Image
Example:
Example:
zoom
zoomthis
this
image
4x
image 4xto
to
get
this
get this
image.
image.
Start
Startwith
withaablank
blankimage
image44times
timesthe
the
linear
dimensions
of
the
original.
linear dimensions of the original.
.
.
.Fill
Fillininevery
every4th
4thpixel
pixelininevery
every4th
4th
row
rowwith
withthe
theoriginal
originalpixel
pixelvalues.
values.
33
Enlarging an Image
Detail
Detailshowing
showingevery
every4th
4thpixel
pixelininevery
every4th
4throw
rowwith
withthe
theoriginal
originalpixel
pixelvalues.
values.
34
Enlarging an Image
Replicate
Replicatethe
thevalues
values
35
Reducing an Image
Pixel Decimation
Example:
Example:
decimate
decimate
this
thisimage
image
4x
to
4x toget
get
this
image.
this image.
Decimation by
a factor of n:
take every nth
pixel in every
nth row
36
Reducing an Image
Example:
Example:
decimate
decimate
this
thisimage
image
4x
to
4x toget
get
this
image.
this image.
Zoom
Zoomininon
onaa
section
sectionfor
foraa
closer
closerlook
lookat
at
the
theprocess
process
37
Reducing an Image
Example:
Example:
decimate
decimate
this
thisimage
image
4x
to
4x toget
get
this
image.
this image.
Keep
Keepevery
every
4th
4thpixel
pixelinin
every
every4th
4throw
row
38
Reducing an Image
Example:
Example:
decimate
decimate
this
thisimage
image
4x
to
4x toget
get
this
image.
this image.
ignore
ignoreall
all
the
theothers
others
39
Reducing an Image
Example:
Example:
decimate
decimate
this
thisimage
image
4x
to
4x toget
get
this
image.
this image.
Copy
Copythem
them
into
intoaanew
new
image.
image.
40
41
Example:
Example:
resize
resizeto
to3/7
3/7
of
ofthe
theoriginal
original
42
Zoom
Zoomininfor
foraa
better
betterlook
look
43
Outlined
Outlinedinin
blue:
blue: 7x7
7x7
pixel
pixelsquares
squares
44
In
Inyellow:
yellow:33pixels
pixels
for
forevery
every77rows,
rows,
33pixels
pixelsfor
forevery
every
77cols.
cols.
45
Keep
Keepthe
the
highlighted
highlighted
pixels
pixels
46
dont
dontkeep
keep
the
theothers.
others.
47
Copy
Copythem
theminto
into
aanew
newimage.
image.
48
Copy
Copythem
theminto
into
aanew
newimage.
image.
49
3/7
3/7times
timesthe
the
linear
lineardimensions
dimensions
of
ofthe
theoriginal
original
50
Detail of
Detail of
resized image
resized image
Resize to 3/7 of
Resize to 3/7 of
the original dims.
the original dims.
51
Original
Original
image
image
Pixels
Pixelsspread
spreadout
out
for
a
7/3
resize
for a 7/3 resize
then
thenfilled
filledin.
in.
52
here
Original
Original
image
image
isisspread
spreadout
outover
over
aa7x7
7x7block
blockhere
here
Detail
Detail
53
3x3
3x3blocks
blocks
distributed
distributedover
over
7x7
7x7blocks
blocks
54
Empty
Emptypixels
pixelsfilled
filled
with
withcolor
colorfrom
fromnonnonempty
pixel
empty pixel
55
Empty
Emptypixels
pixelsfilled
filled
with
withcolor
colorfrom
fromnonnonempty
emptypixel
pixel
56
Original
Original
image
image
7/3
7/3resized
resized
Image Interpolation
Nearest neighbour interpolation
Bilinear Interpolation
Bicubic Interpolation
58
Interpolation: Comparison
Well
Wellenlarge
enlargethis
thisimage
image
by
byaafactor
factorof
of44
via
viabilinear
bilinearinterpolation
interpolation
and
andcompare
compareititto
toaanearest
nearest
neighbor
neighborenlargement.
enlargement.
Interpolation: Comparison
Original
Original
Image
Image
To
Tobetter
bettersee
seewhat
whathappens,
happens,well
welllook
lookat
atthe
theparrots
parrotseye.
eye.
Interpolation: Comparison
Pixel
Pixelreplication
replication
Bilinear
Bilinearinterpolation
interpolation
Interpolation: Comparison
Pixel
Pixelreplication
replication
Bilinear
Bilinearinterpolation
interpolation
Steganography
The science of writing hidden messages in such
a way that no one, apart from the sender and
intended recipient, suspects the existence of
the message
63
Steganography
Before Moving On .
Recall Logical Shift Operators
64
8-bit Image
Steganography
Steganography
6-bit Image
Steganography
If the 6-bit version is
displayed as an 8-bit
image then the 8-bit
pixels all have zeros
in the lower 2 bits:
b
b = 0 or 1
always 0
Image 2
R-Shift 2
R-Shift 6
L-Shift 2
logical
OR
Image Out
Steganography
Steganography
182
1
220
R-Shift 2
0
R-Shift 6
L-Shift 2
180
1
03
0
183
1
Steganography
Steganography
How to
to get
get the
the second
second image
image
How
183
1
L-Shift 6
192
1
Steganography
Steganography
IfIfwe
wehave
haveonly
only44colors
colors(2-bits)
(2-bits)
and
andwe
weput
putthem
themininthe
thelower
lowerorder
order
bits
bits
182
1
03
R-Shift 2
0
L-Shift 2
0
R-Shift 6
03
0
183
What
Whatwould
wouldyou
youdo
do
totoget
getback
backoriginal
original
data?
data?
180
1
No
Noneed
needtotoshift
shiftright
right
1
Steganography
8-bit-per-band,
8-bit-per-band,3-band,
3-band,
original
originalimage
image
70
Steganography
6-bit-per-band,
6-bit-per-band,3-band,
3-band,
quantized
quantizedimage
image
71
Steganography
green-band histogram of 8-bit image
The histograms of the two versions indicate which is which. If the 6-bit version
is displayed as an 8-bit image it has only pixels with values 0, 4, 8, , 252.
72
Steganography
The second image is invisible because the value of each pixel is between 0 and 3.
For any given pixel, its value is added to the to the collocated pixel in the first image
that has a value from the set {0, 4, 8, , 252}. The 2nd image is noise on the 1st.
73
L-Shift 6
Steganography
?
To recover the second image (which is 2 bits per pixel
per band) simply left shift the combined image by 6 bits.
74
L-Shift 6
Steganography
image
Steganography
This is so effective that two
4-bit-per-pixel images can be
superimposed with only the
image in the high-order bits
visible. Both images contain
the same amount of information
but the image in the low-order
bits is effectively invisible
Images
Images11and
and22each
each
have
4-bits
per
pixel
have 4-bits per pixel
when
whencombined.
combined.
Image 1
Image 2
R-Shift 4
R-Shift 4
L-Shift 4
Image Out
76
Steganography
Original
OriginalImage
Image
77
Steganography
Image
Imagequantized
quantizedto
to
4-bits
4-bitsper
perpixel.
pixel.
78
Steganography
Image
Image11ininupper
upper4-bits.
4-bits.
Image
Image22ininlower
lower4-bits.
4-bits.
79
Steganography
Extracted Image
80
Steganography
http://mozaiq.org/encrypt/
81
x+1
y-1
y
y+1
82
Whatare
arethe
thecoordinates
coordinatesof
of
What
eachof
ofthe
theblue
bluepixels
pixels
each
y-1
y+1
x+1
y-1
y
y+1
x+1
y-1
y
y-1
N8 ( p ) N 4 ( p ) N D ( p )
(x-1,y), (x+1,y), (x, y-1),
(x, y+1)
(x-1,y-1), (x+1,y-1), (x-1, y+1),
(x+1, y+1)
85
86
Connectivity
Establishing boundaries of objects and components in
an image
Group the same region by assumption that the pixels
being the same color or equal intensity
Two pixels p & q are connected if
87
Connectivity
V: Set of gray levels used to define the criterion of similarity
4-connectivity
4-connectivity
If gray level ( p, q) V , and q N 4 ( p )
Set
Set of
of gray
gray levels
levelsV
V=={1}
{1}
88
Connectivity
V: Set of gray levels used to define the criterion of similarity
8-connectivity
8-connectivity
If gray level ( p, q) V , and q N 8 ( p )
Set
Set of
of gray
gray levels
levelsV
V== {1}
{1}
89
Connectivity
V: Set of gray levels used to define the criterion of similarity
m-connectivity
m-connectivity(Mixed
(Mixed Connectivity)
Connectivity)
If gray level
90
Example: m Connectivity
Set of gray levels V = {1}
Paths
Path: Let coordinates of pixel p: (x, y), and of pixel q:
(s, t)
A path from p to q 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) 1i n
92
CC labeling 4 Connectivity
Pass
iii.) If they have different labels
Copy the label from the
left.
Update the equivalence
table.
Pass 2
93
CC labeling 4 Connectivity
94
CC labeling 4 Connectivity
95
CC labeling 8 Connectivity
Same
Same algorithm
algorithmbut
but examine
examine also
also the
the upper
upper diagonal
diagonal
neighbors
neighbors of
of pp
96
CC labeling 8 Connectivity
Background pixel
Unlabeled Pixel
Background pixel
Unlabeled Pixel
Label 1
97
CC labeling 8 Connectivity
Background pixel
Background pixel
Unlabeled Pixel
Unlabeled Pixel
Label 1
Label 1
Label 2
Label 2
Label 3
98
CC labeling 8 Connectivity
Background pixel
Background pixel
Unlabeled Pixel
Unlabeled Pixel
Label 1
Label 1
Label 2
Label 2
Label 3
Label 3
99
CC labeling 8 Connectivity
Background pixel
Background pixel
Unlabeled pixel
Unlabeled pixel
Label 1
Label 1
Label 2
Label 2
Label 3
Label 3
100
CC labeling 8 Connectivity
Background pixel
Background pixel
Unlabeled pixel
Unlabeled pixel
Label 1
Label 1
Label 2
Label 2
Label 3
Label 3
Label 4
Label 4
101
Distance Metrics
Let pixels p, q and z have coordinates (x,y), (s,t)
and (u,v) respectively.
D is a distance function or metric if
D(p,q) 0 and
D(p,q) = 0 iff p = q and
D(p,q) = D(q,p) and
D(p,z) D(p,q) + D(q,z)
102
D4 ( p, q ) x s y t
Diamond with center at (x,y)
D4 = 1 are the 4 neighbors of
pixel p(x,y)
103
D8 ( p, q ) max( x s , y t )
Square centered at p(x,y)
D8 = 1 are the 8 neighbors of
pixel p(x,y)
104
Euclidean Distance
De ( p, q ) ( x s ) 2 ( y t ) 2
q(s,t)
r
p(x,y)
Arithmetic Operations
Carried out between corresponding pixel pairs
s ( x, y ) f ( x , y ) g ( x , y )
d ( x, y ) f ( x , y ) g ( x, y )
p ( x, y ) f ( x, y ) g ( x , y )
d ( x, y ) f ( x , y ) g ( x, y )
106
Arithmetic Operations
Conversion to range 0 255
Difference of two 8-bit images: -255 to 255
Sum of two 8-bit images: 0 to 510
Solution?
Set all values < 0 to 0
Set all values > 255 to 255
Full range of arithmetic operation not captured
107
Arithmetic Operations
First perform the operation
f m f min( f )
Then perform
f s K f m max( f m )
108
109
Reading Assignment
2.6.1 Array versus Matrix
Operations
2.6.2 Linear versus NonLinear Operations
*Discussion related to figures 2.22 and 2.23 has not been covered
Material in these slides has been taken from the following resources
Acknowledgements
Digital Image Processing, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley, 2002
Peters, Richard Alan, II, Lectures on Image Processing, Vanderbilt University, Nashville, TN,
April 2008
Brian Mac Namee, Digitial Image Processing, School of Computing, Dublin Institute of
Technology
Computer Vision for Computer Graphics, Mark Borg
112