03 Point Processing
03 Point Processing
Point Processing
Enhancement
Objective of enhancement
Make an image more suitable than the original for a
specific application
Often for human perception
Frequency domain
Working with frequencies
Spatial
p
Domain
g(x,y) = T[ f(x,y) ]
f(x,y) input image
g(x,y) output image
T is an operator on f
Defined over some neighborhood of (x,y)
can operate on a set of Images
G
Gray-level
l
l ttransformation
f
ti
Simplest form of T
Pixel neighborhood is 1 x 1
Notation: s = T(r)
r,
r s denote gray level of f(x
f(x,y)
y) and g(x
g(x,y)
y) for any
point (x,y)
Plot of s=T(r)
2
255
T(r)
()
255
Example of T(r)
s
s
T(r)
Darker
Lighter
Lighter
Image Histogram
Image Histogram
digital image with gray level [0, L-1]
p(
p(rk) = nk/N
rk is the kth g
gray
y level
nk number of pixels with kth gray level
N total number of pixels
p
k=0,1,2,3,4,5 . . ., L-1
Image Histogram
p(rk) is the probability of the occurrence of gray
graylevel rk
p(rk)
rk
Image Histogram
Histogram can tell you a lot about an image
It is the gray level distribution
T(r)
p(rk)= nk/N
Threshold
rk
Image Histogram
P(rk)
Bright
g Image
g
rk
P(rk)
Dark Image
rk
Image
g Histogram
g
Low Contrast
P(rk)
High Contrast
P(rk)
rk
rk
Image Histogram
Histograms are not unique
Point-processing
s
Darker
T(r)
()
T( )
T(r)
Li ht
Lighter
L-1
T(r)
s = T(r) = (L-1)-r
L-1
Contrast Stretching
High Contrast
T(r)
L-1
P(rk)
s
L-1
P(sk)
Contrast Compressing
Low Contrast
L-1
T(r)
P(rk)
s
r
P(sk)
L-1
Log Compression
L1
L-1
T(r)
s
s = c log(1 + r)
(c is some scale-factor)
Log compression is useful for images that have huge ranges, typically floating
point values well beyond 8-bits. However, you want to display this image using
8-bits, so you use log to compress the range.
Windowing
L1
L-1
T(r)
s
Operating on a window
window
of gray levels ri to r(i+x)
r
L-1
L-1
L-1
L-1
T(r)
s
T(r)
L-1
L-1
T(r)
L-1
Photoshop
p T(r)
( ) manipulation
p
Look under Image
Image->adjustments->curves
>adjustments >curves
s=T(r)
Properties of T(r)
T(r)
Non-Monotonic
(increasing or
decreasing)
No-inverse
Doesnt preserve
gray level ordering
Looks very unnatural
Monotonic
T(r)
s
Inverse
Preserves gray level
ordering (monotonic
increasing)
Looks
Looks nat
natural
ral
1 Byte
(gray level)
1
1
0
1
11
Consider the
b/w image at
each kth bit
bit 8
bit 7
most significant
bit 4
bit 1
Bit-Plane Slicing
Can be used for binary reconstruction
Reconstruct the original
gray level image
Color Wheel
Histogram Equalization
S
Say we wantt an image
i
with
ith equally
ll many pixels
i l
at every gray level
This makes the image look nice
Also maximizes pixel resources
(b)
guarantees
g
a mapping
pp g that is consistent with the
allowed range of pixel values
Histogram Equalization
The
Th histogram
hi t
off the
th input
i
t signal
i
l
Tells us how many signal elements occur with each
level of the input
If we allocate our output levels proportional to the
frequency of our input levels
The output should be uniform
H. Equalization Transform
Cumulative distribution function (CDF) of r
is the appropriate transform
s = T (r ) =
p r ( w ) dw
T(r) = pr (w)dw
s=T(r)
pr((r))
Continuous histogram of r
Assume that the intensity is continuous
in value rr. p(r) can be considered the probability
that an image intensity is value r
Formula
dr
p s ( s ) = pr ( r )
ds
ds
= pr (r )
dr
1
p s ( s ) = pr ( r )
pr (r
(r )
j =0
j =0
s k = T ( rk ) = n j / N = p r ( r j )
sk is output intensity
rk is input
p intensity
y
nj is number of pixels with jth gray level
k = 0, 1, 2, 3, . . L-1 (gray levels)
Example
nk
Image
Histogram
(Notice, this is not normalized
(Notice
normalized, y axis is nk.
To normalize, let y axis = p(rk)= nk /N
rk
Example
p
k
n
j =0
nk
rk
Histogram
(
(Notice,
this is not normalized, y axis is nk.
To normalize, let y axis = p(rk)= nk /N
rk
Example
p
k
Np ( rk ) = n j
nk
nk
j =0
rk
T(r)
sk
Histogram Equalization
Can significantly improve image appearance
Automatic
Derived
D i d completely
l t l ffrom th
the iimage iinputt
r=T-1(s) exists
Assumes a reasonable distribution of the original image
If you have a black-and-white image, this wont work!
Histogram Eq function T
Stored as a look up table
T[r] = s
Note that s may not be an integer value
T and
-1
T
s=T(r)
r=T-1(s)
Histogram Specification
Sometimes we want an image to have
another images histogram
We can do this through equalized
hi t
histograms
H S
H.
Specification
ifi ti
We want our r to map to z, where z is
the histogram of some image
H Specification
H.
We want our r to map to z, where z is
g
of some image
g
the histogram
k
s = T ( r ) = p r ( ri )
j =0
k
v = G ( z ) = p z ( zi )
j =0
G(z)
( ) maps
p from zs histograms
g
to v (an equalized histogram)
z = G T (r )
Conceptual
p
View of Hist Spec
p
k
Image 1
s = T ( r ) = p r ( ri )
j =0
Equalized
Image 1
Equalize hist
Use z=G
z G-1(s)
These images now have
the same distribution.
Image 2
v = G ( z ) = p z ( zi )
j =0
Eq ali e hist
Equalize
Equalized
Image 2
Image 1
with Im2
Hist
Local Enhancement
Histogram equalization is a global operation
Often enhances global details
L
Local
l Hi
Histogram
t
E
Equalization
li ti
(x,y)
place result
,y)
in ((x,y)
Result
calculate histogram
using neighborhood of m x m
( ,y)
about (x,y)
Local Histogram
Apply histogram equalization about a
g
around ((x,y)
,y)
neighborhood
Transform the gray level for pixel (x
(x,y)
y)
Move the neighborhood over the rest of the
g
image
Local Histogram
Reveals detail in local areas
Original
Global Histogram
Local Histogram
A(x,y) = k
M
s(x,y)
0<k<1
M
global mean
k
is a constant (user-defined)
(
)
Example
Original
Enhanced using
local mean and s
Image
g subtraction
g(x,y) = | fmask(x,y) f(x,y) |
MASK
New Image
g
MASK-Image
g
Image Averaging
Consider a noisy image g(x
g(x,y)
y)
g(
g(x,y)
,y) = f(x,y)
( ,y) + ((x,y)
,y)
where (x,y)
(x y) is uncorrelated noise and has zero
average value
Image
g Averaging
g g
The image mean is
1
g ( x, y ) =
M
g ( x, y )
i=0
E { g ( x , y )} = f ( x , y )
2
g ( x, y )
1 2
=
( x, y)
M
Image Averaging
The expected value of g is:
E { g ( x , y )} = f ( x , y )
and we know that the variances of g and at
allll coordinates
di t ((x,y)) =
2
g ( x, y)
1 2
=
( x, y)
M
Image Averaging
Therefore, the standard deviation at any point in
th average iimage iis:
the
g ( x, y ) =
1
( x, y)
M
Averaging Example
(a) original
(b-f) M=2,8,16,32,120
g ( x, y) =
1
( x, y)
M
Original Image
Target Image
Result
Summary
y
Intensity Transforms
Point-processing
Point processing
Manipulation of image histogram
s = T(r)
Histogram
Equalization,
Equalization Specification
Local enhancements
Local Histogram
Based on local mean and deviation
Other
Subtraction, noise-reduction through averaging