Image Enhancement and
Point Processing
Enhancement
Objective of enhancement
Make an image more suitable than the original for a
specific application
Often for human perception
Two broad categories
Spatial domain
Point processing (intensity transforms)
Spatial filters
(pixel neighborhoods)
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)
()
Image using pixels r
255
r = input pixel intensity
s = output pixel intensity
Image using pixels s
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
Contrast is ratio of L_max to L_min
rk
Image Histogram
Histograms are not unique
Point-processing
s
Darker
T(r)
()
T( )
T(r)
Li ht
Lighter
s=T(r) manipulates an images histogram
Simple Transform: Inverse
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
[Slight departure from histogram manipulation discussion]
Gray Level Slicing
1 Byte
(gray level)
1
1
0
1
11
Consider the
b/w image at
each kth bit
Gray Level Image (Mandrill)
Bit Planes Slices
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
Digital Light Processing (DLP) Projector
Micro-mirror device
mirror is either on or off
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
That is, we want a flat histogram, where each
gray level, rk, appears (N/rm) times
where rm is the maximum gray level
N is number of pixels in the image
Find T(r) to equalize a histogram
A
Assume variable
i bl r h
has b
been normalized
li d
between [0-1]
s = T(r),
( ), such that
(a) T(r) is single-valued and monotonically
increasing in the interval 0 <= r <= 1
(b) 0 <= T(r) <= 1 for 0 <= r <= 1
Conditions (a) and (b) [from previous slide]
(a)
preserves the order from black to white in the gray
scale
(which
( hi h preserves th
the b
basic
i appearance off an iimage))
(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
CDF satisfies (a) and (b)
Cumulative Distribution Function
r
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
Cumulative Distribution Function of r
w is a dummy variable
C.D.F. to value r is a sum of all
probabilities for 0 to r.
Formula
dr
p s ( s ) = pr ( r )
ds
ds
= pr (r )
dr
1
p s ( s ) = pr ( r )
pr (r
(r )
We have a relationship between that the probability
of ps(s) is equal to the probability of pr(r) times the
derivative of dr and ds.
The change of s = T(r) with respect to r, is exactly
the probability of r occurring, i.e. pr(r). Look at the
previous slides
slide s C
C.D.F.
D F to consider this
this. All changes
in T(r) are from the summation of pr(r).
This means that the probability of ps(s) occurring is
exactly 1 for all s. This is our goal of an equalized
histogram,
g
, we want to transfer r such that s is
equally probable.
CDF is for continuous functions
But images are not continuous
Lets look at the discrete approximation
pp
k
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
Resulting Equalized Histogram
Not perfect. Can only be perfect
for continuous variables. But, you
can see that the results are pretty
good and the contrast of the image
is much better.
Histogram Equalization
Can significantly improve image appearance
Automatic
Derived
D i d completely
l t l ffrom th
the iimage iinputt
Nice pre-processing step before image comparison
Account for different lighting conditions
Account for different camera/device properties
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
The inverse of T can be found by
y inverting
g
the table
r = T-1[s]
May require some interpolation to build this
table
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
We would like to enhance details over small
areas
Note, these are neighborhood operators
not point-processing
but it is related to histogram so we introduce it here
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
Enhancement based on other properties
We can build local enhancements on other pixel intensity
properties in a neighborhood
Intensity Mean
Average Brightness
Variance (or standard deviation)
A measure of contrast
Enhancement based on mean and
variance ((standard deviation))
g(x,y) = A(x,y)*[f(x,y) m(x,y)] + m(x,y)
A(x,y) = k
m(x y) and s(x
m(x,y)
s(x,y)
y)
M
s(x,y)
0<k<1
local mean and standard deviation compute in neighborhood around (x,y)
M
global mean
k
is a constant (user-defined)
(
)
Enhancement based on mean and
variance (standard deviation)
g(x,y) = A(x,y)*[f(x,y) m(x,y)] + m(x,y)
A, m, s depend on neighborhood of (x,y)
A is amplifying
p y g the difference between f(x,y)
( ,y) and local mean
(This can be controlled by k)
A is inversely proportional to the standard deviation of the intensity in the
neighborhood
Areas with low contrast receive larger gain
The local mean m(x,y) is added back to restore the average intensity level
of the
o
e image
age in the
e local
oca region
eg o
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
g(x,y) = abs(fmask(x,y) f(x,y)) < T ? abs(fmask(x,y) f(x,y)) : 0;
Usually define some threshold. So if the change is less than
some threshold, we will ignore it.
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
Say you have a set of gi(x,y)
Image
g Averaging
g g
The image mean is
1
g ( x, y ) =
M
g ( x, y )
i=0
Then it follows that
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
So, as we average more iimages (M iincreases)) th
S
the
standard deviation decreases and g(x,y) -> f(x,y).
Averaging Example
(a) original
(b-f) M=2,8,16,32,120
g ( x, y) =
1
( x, y)
M
Extra: Color Transfer
between Images
Original Image
Target Image
Result
Decorrelated color space - l space
Transfer the mean and standard of
chromaticity channels
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