Image EnhancementI(2)
Image EnhancementI(2)
Introduction
• The objective of enhancement is to process
an image so that it appears more suitable
than original image for a specific application.
• Approaches are categorically two types:
– Spatial domain based approach
• Direct manipulation of pixel value
– Frequency domain based approach
• Transform image into Fourier/DCT domain and then
apply the method
Introduction
• At the time of digitization, transmission
and scanning, etc. there are some form of
degradation at the output.
– If reason behind this is known, then by
inverse operation original image can be
obtained. This is called image restoration.
– If no such knowledge or information, then
quality can be improved for some application
by some process. This is known as image
enhancement.
Introduction
• Enhancement of quality => increasing the
dominance of some features ( at the cost
of suppression of some features).
• The enhancement techniques are divided
into three categories:
– Contrast intensification
– Noise cleaning or smoothing
– Edge sharpening
Simple processing
• Transpose
– B(i,j) = A(j,i)
Simple processing
• Flip Vertical
– B(i,M-I-j) = A(i,j)
Simple processing
• Cropping
B(k,l) = A(n1+k,n2+l); k= 0 to N1-1 and l=0 to N2-1
Sample mean and variance
1 N 1 M 1
• Mean (ma) =
MN i 0 j 0
A(i, j )
• Std. dev(σ) = N 1 M 1 2
A(i, j) m
1
a
MN i 0 j 0
Principle Objective of
Enhancement
• Process an image so that the result will be
more suitable than the original image for a
specific application.
T
neighborhood g(x,y)
operator
around f(x,y)
Gamma=4.0 Gamma=4.0
Linear transformations
• Identity function, Negative function,
single
• Piecewise-Linear Transformation
Functions
– Advantage
• The form of piecewise functions can be arbitrarily
complex
– Disadvantage:
• Their specification requires considerably more user
input
Piecewise-Linear Transformation
Functions
• r=T(s)
• r = alpha1 * l
= alpha2 * (l-l1) +
alpha1 * l1
= alpha3 * (l-l2) + alpha1
* l1 + alpha2 * (l2 - l1)
Alpha > 1 range stretching
< 1 compression
= identity
0 to l1
0 to l1 – l2
0 to L-1– l2
Contrast Stretching
• increase the dynamic
range of the gray
levels in the image
• a low-contrast image :
result from poor
illumination, lack of
dynamic range in the
imaging sensor, or
even wrong setting of
a lens aperture of
image acquisition.
Contrast Stretching
• The location
(r1,s1) and (r2,s2)
control the (r2,s2)
transformation.
– If (r1=s1) and
(r2=s2), then
identical function
(r1,s1)
– If (r1=r2) and
(s1=0 and s2=L-1)
thresholding
function
Contrast Stretching
• In general r1<=r2 and
s1<=s2
– Single valued and (r2,s2)
monotonically increasing
function
– Preserves the order of
grey-level and reduces the
chances of artifact (r1,s1)
– Normally, r1 =rmin , s1=0
and r2=rmax , s2=L-1
Piecewise-Linear discontinuous
Transformation Functions
0 to l1
0 to l1 – l2
0 to L-1– l2
Gray-level slicing
• Highlighting a specific
range of gray levels in an
image
– Display a high value of all
gray levels in the range of
interest
• transformation
highlights range [A,B] of
gray level and reduces
all others to a constant
level
• transformation
highlights range [A,B]
but preserves all other
levels
Results
Input Output
Bit-plane slicing
• Highlighting the
contribution made to total
image appearance by
specific bits
• Suppose each pixel is
represented by 8 bits
• Higher-order bits contain
the majority of the visually
significant data
• Useful for analyzing the
relative importance
played by each bit of the
image
Bit-plane slicing
7 6
Original image 5 4 3
2 1 0
Simple Image Statistics-
Histogram
• Let S be a set and define #S as the cardinality of
this set
– The histogram hA(l) (l=0,…,255) of the image A is
defined as:
hA(l) = #{(i,j) | A(i,j)=l, i=0,…,N-1; j=0,…,M-1}
255
h
l 0
A (l ) Number of pixels in A
For(i=0;i<255;i++)
H[i]=0;
for(i=0;i<N;i++)
for(j=0;j<M;j++)
H[A(i,j)]++;
Histogram
A hA(l)
Histogram
A hA(l)
Histogram
A hA(l)
Normalized Histogram
• dividing each of histogram at gray level rk
by the total number of pixels, n
– P(rk) = nk /n
• P(rk) gives an estimate of the probability
of occurrence of gray level rk
• The sum of all components of a
normalized histogram is equal to 1
Histogram Processing
• Basic for numerous spatial domain
processing techniques.
• Used effectively for image enhancement
• Information inherent in histograms also is
useful in image compression and
segmentation.
Example
Example
Histogram Equalization
• Contrast stretching means histogram stretching
• the low-contrast image’s histogram is narrow
and centered toward the middle of the gray
scale, if we distribute the histogram to a wider
range the quality of the image will be improved.
• We can do it by adjusting the probability density
function of the original histogram of the image so
that the probability spread equally.
Histogram transformation
• s = T(r) where 0 <= r
<=1
• T(r) satisfies
– T(r) is single valued
and monotonically
increasingly in the
interval 0 <= r <= 1
– 0 <= T(r) <= 1 for 0
<= r <= 1
2 Conditions of T(r)
• Single-valued (one-to-one relationship)
guarantees that the inverse transformation will
exist
• Monotonicity condition preserves the increasing
order from black to white in the output image
thus it won’t cause a negative image
• 0 <=T(r) <=1 for 0 <= r <= 1 guarantees that the
output gray levels will be in the same range as
the input levels.
• The inverse transformation from s back to r is
r = T -1 (s) ; 0 <=s <=1
Probability Density Function
• The gray levels in an image may be
viewed as random variables in the interval
[0,1]
• PDF is one of the fundamental descriptors
of a random variable
Discrete
transformation function
• The probability of occurrence of gray level in an
image is approximated by
pr(rk) = nk/n , k= 0 to L-1
neighborhood
average g(x,y)
around f(x,y)
.1 .1 .1
.1 .1 .1
4 7 2 1 6 -
6 5 3 2 8
.1 .1 .1
.1 .1 .1
4 7 2 1 6 -
6 5 3 2 8
.1 .1 .1
.1 .1 .1
4 7 2 1 6 -
6 5 3 2 8
.1 .1 .1
.1 .1 .1
3 2 1 2 2 - - - - -
6 5 3 2 8
.1 .1 .1
.1 .1 .1
3 2 1 2 2 - - - - -
6 5 3 2 8
.1 .1 .1
.1 .1 .1
3 2 1 2 2 - - - - -
6 5 3 2 8
.1 .1 .1
.1 .1 .1
3 2 1 2 2 - - - - -
.1 .1 .1
.1 .1 .1
3 2 1 2 2 - - - - -
.1 .1 .1
.1 .1 .1
3 2 1 2 2 - - - - -
3 2 1 2 2 - - - - -
6 5 3 2 8 - - - - -
neighborhood
median g(x,y)
around f(x,y)
Result of Filtering
Unsharp masking
Gradient Operator
• first derivatives are implemented
using the magnitude of the
gradient.
Gradient Operator
Gradient Mask
• simplest approximation, 2x2
Gradient Mask
• Roberts cross-gradient operators, 2x2
Gradient Mask
• Sobel operators, 3x3
Note
• the summation of coefficients in all masks
equals 0, indicating that they would give a
response of 0 in an area of constant gray
level.