DIGITAL IMAGE PROCESSING
IMAGE ENHANCEMENT TECHNIQUES
PREPARED BY: DR. ANIRBAN BOSE
DEPT. OF CSE
DR. B. C. ROY ENGINEERING COLLEGE,
DURGAPUR
IMAGE ENHANCEMENT TECHNIQUES
Objective process an image so that the result is more
– suitable than the original image for a specific
application.
Methods
1. Spatial Domain
direct manipulation of pixels of the
image
2. Frequency Domain
modifying the Fourier Transform of an
image
IMAGE ENHANCEMENT IN SPATIAL
DOMAIN
These techniques operate directly on the pixels.
More efficient computation and requires less
processing resources to implement
Spatial Domain Process is defined by
g(x,y)=T[f(x,y)]
T is an operator on f defined over a
neighborhood of point (x,y)
OUTPUT INPUT
IMAGE IMAGE
IMAGE ENHANCEMENT IN SPATIAL DOMAIN
y
(x,y)
3x3 neighborhood of
(x,y)
Image f
Smallest possible neighborhood size is
x 1x1,
it can be 5x5, 7x7 or 9x9 etc.
IMAGE ENHANCEMENT IN SPATIAL
DOMAIN
1x1 neighborhood operation is called as point processing and is
represented by the transformation function s= T(r). Where 's' and 'r'
represents the intensity of 'g' and 'f' respectively
Contrast Thresholding
stretching Function
function
INTENSITY TRANSFORMATION FUNCTION
Image Negative
Let the image has an intensity level in the range [0 L-1], then
the intensity transformation is given by s=L-1-r
s=T(
r) L-1
intensity
Output
0 L- r
Input 1
intensity
INTENSITY TRANSFORMATION
FUNCTION
Log Transformations
For an image having intensity ranging from [0 L-1], log
transformation is given
by s=c log(1+r) , where c is a constant
Maps the narrow range of
s=T( low
r)
L-
intensityvalues
wider range of output
of input levels
1 to
levels.
Higher range of high intensity
intensity
input levels is mapped to
Output
narrow range of out put levels.
0 L- r
Input 1
intensity
INTENSITY TRANSFORMATION
FUNCTION
Log Transformations
The Log function has the important characteristic that it compresses the
dynamic range of images with large variation in the pixel value. Classical
example is displaying Fourier spectrum.
Fourier spectrum has the values in the range 0 to 1.5x106. These
values are scaled linearly for the display in 8 bit system.
Fourier Log transformation with
spectrum c=1
INTENSITY TRANSFORMATION FUNCTION
Power-law (Gamma ) Transformations
This has the basic form s=c rγ ,where c and γ are positive constants
Fractional values of γ maps a
narrow range of dark input
values into a wider range of
output values. Opposite of this
also true for higher values of
input levels.
These are also called as gamma
correction due to the exponent
in the power law equation.
Plot for c=1
INTENSITY TRANSFORMATION
FUNCTION
Power-law (Gamma ) Transformations
CRT an intensity to
that is a
device power
function with exponent varying
from approximately 1.8 to 2.5.
have
Such
voltage display system would
produce images that are darker
response
than intended.
Pre-processed image with
gamma correction s=r0.4.
before input to the display
device
INTENSITY TRANSFORMATION FUNCTION
Gamma correction is very
important when to reproduce an
image exactly on a display
system.
Power-law
used transformations
in general purpose are
also
contrast stretching.
INTENSITY TRANSFORMATION FUNCTION
MRI of Result of a Result of a Result of a
fractured transformati transformati transformati
human spine on for on for γ=0.4 on for γ=0.3
γ=0.6
INTENSITY TRANSFORMATION FUNCTION
Result of a
Arial
transformation for c=1
image
and γ=3
INTENSITY TRANSFORMATION FUNCTION
Result of a Result of a
transformation transformation for c=1
for c=1 and γ=4 and γ=5
PIECEWISE LINEAR TRANSFORMATION
FUNCTIONS
Contrast stretching
Low contrast images result from the following
Poor illumination
lack of dynamic range in the imaging sensor
Wrong settings of the lens aperture during acquisition
It is a process that expands the range of intensity levels in an
image so that it spans full intensity range of the recording
medium or display device
PIECEWISE LINEAR TRANSFORMATION
FUNCTIONS
Contrast
stretching L- Controls the shape of the
1
(r2,s2) transformation function
3L/
4
output intensity
L/ T(r)
2
level, s
L/ (r1,s1)
4
0 L/4 L/2 3L/4
0 L-1
Input intensity level, r
PIECEWISE LINEAR TRANSFORMATION
FUNCTIONS
Contrast stretching
Suppose r1=s1 and
r2=s2
L- L-
1 1
(r2,s2) (r2,=
3L/ 3L/
4 4 s2)
output intensity
output intensity
L/ T(r) L/ T(r
2 2 )
L/ L/
level, s
level, s
4 (r1,s1) 4 (r1,=s1)
0 0
0 L/4 L/2 3L/4 L- 0 L/4 L/2 3L/4
1 L-1
Input intensity Input intensity level, r
PIECEWISE LINEAR TRANSFORMATION
FUNCTIONS
Contrast stretching
Suppose r1=r2 and s1=0 and
s2=L-1
L- (r2
L-
1 1 )
(r2,s2)
3L/ 3L/
4 4
output intensity
output intensity
L/ T(r) L/ T(r)
2 2
L/ L/
level, s
level, s
4 (r1,s1) 4 (r1)
0 0
0 L/4 L/2 3L/4 L- 0 L/4 L/2 3L/4 L-
1 1
Input intensity Input intensity
PIECEWISE LINEAR TRANSFORMATION
FUNCTIONS
Contrast stretching
Intermediate values of (r1,s1) and (r2,s2) produces various degree of
spread in
the intensity
L-1
(r2,s2
3L/
)
4
output intensity
T(r
L/ )
2
L/
level, s
4 (r1,s1)
0
0 L/4 L/2 3L/4 L-
1
Input intensity
PIECEWISE LINEAR TRANSFORMATION
FUNCTIONS
Contrast stretching
(Example)
(r1,s1)=(rmin, 0) and
(r2,s2)=(rmax,L-1)
3L/
L-1 rmax,L-1
4
output intensity
L/ T(r
2 )
L/ rmin, 0
level, s
4
0
0 L/4 L/2 3L/4 L-
1
Input intensity
level, r
Piecewise Linear transformation
functions
Contrast stretching
(Example) CONTRAST STRETCHED IMAGE
POOR CONTRAST IMAGE
Piecewise Linear transformation
functions
Contrast stretching
(Example)
POOR CONTRAST IMAGE
PIECEWISE LINEAR TRANSFORMATION
FUNCTIONS
Intensity Level slicing
Highlighting specific range of
intensities
Example :
Enhancing features
such as masses
of water in
the satellite
imagery
Enhancing flaws in X-ray
images.
PIECEWISE LINEAR TRANSFORMATION FUNCTIONS
Intensity Level
slicing
L-1
s T(r)
0 r
L-
1
PIECEWISE LINEAR TRANSFORMATION FUNCTIONS
Intensity Level
slicing
L-1
s T(r)
0 r
L-
1
Piecewise Linear transformation
functions
Intensity Level slicing
(Example)
Piecewise Linear transformation
functions
Intensity Level slicing
(Example)
PIECEWISE LINEAR TRANSFORMATION FUNCTIONS
Bit Plane slicing (Example)
Each pixels are digital number comprising of bits
For a 256 level gray-scale image there are 8 bits for each pixel
We can highlight the contribution of these bits to total image
appearance
Example pixel value =135 1
1000011 0
0
1 0
0
1
1
1
PIECEWISE LINEAR TRANSFORMATION FUNCTIONS
Bit Plane slicing
(Example)
An 8 bit gray
scale image
Contribution of
bit plane 8
HISTOGRAM
PROCESSING
Let the intensity level in the image be in the range
from [0 L-1] Histogram is a discrete function h(rk)=nk, intensity
where r is the kth and n is the number of pixels in the value
k k
image with pixel level rk.
This histogram is normalized by dividing each component by total
number of
pixels in the image. Thus normalized histogram is given by,
nk
p(rk ) for k 0,1,2,3......L 1
MN
p(rk) is an estimate of the probability of occurrence of intensity
level rk in an image. (Sum all the components=1)
HISTOGRAM
PROCESSING
HISTOGRAM
PROCESSING
600
0
500
0
400
0
300
0
200
0
1000 5 10 15 20 25
0 0 0 0 0 0
0
HISTOGRAM PROCESSING
700
0
600
0
500
0
400
0
300
0
200
0
0 5 10 15 20 25
100 0 0 0 0 0
0
0
HISTOGRAM
PROCESSING
700
0
600
0
500
0
400
0
300
0
200
0
0 5 10 15 20 25
100 0 0 0 0 0
0
0
HISTOGRAM
PROCESSING
400
0
350
0
300
0
250
0
200
0
150
0
100
00 5 10 15 20 25
0 0 0 0 0
500
0
HISTOGRAM EQUALIZATION
Let us denote r [0, L-1] as intensities of the image to be processed
r=0 corresponding to black and r=L-1 representing white.
Let the intensity transformation is defined by s=T(r) , where 0
≤ r ≤ L-1
T(r) is monotonically increasing function in the interval 0 ≤
r ≤ L-1
0 ≤ T(r) ≤ L-1 and 0 ≤ r ≤ L-1
Suppose we use the inverse operation as r=T-1(s) , then the
condition should
be strictly monotonically increasing.
HISTOGRAM EQUALIZATION
Satisfies the conditionT(r) Strictly
is monotonically
monotonically
function in the interval 0 ≤ increasing mapping
increasing
r ≤ L- is one to one in
1 and 0 ≤ T(r) ≤ L-1 both the directions.
and 0 ≤ r
HISTOGRAM EQUALIZATION
Let us consider intensity levels in the image as random
variables in the interval 0 to L-1.
Let us defined the Probability Density Function (PDF) as pr(r) and
ps(s) for
r and s respectively.
If pr(r) and T(r) are known, where T(r) is continuous and
differentiable over the PDF range
dr , then
s p (s)r p (r) ds
Cumulative
The transformation function is of the form Distribution
r Function (CDF) of
s random variable
0
r
T (r)
HISTOGRAM EQUALIZATION
The transformation function of this form satisfies both the
conditions we have seen.
Now let us compute ps(s), we know s=T(r)
Substituting this for ps(s),
ds dT we get
dr
(r) ps (s) pr (r)
ds
dr dr r
d 1
(L-1) pr (w)dw pr (r)
dr 0 (L 1) pr
(L 1) pr 1 (r)
(r) 0 s L 1
L
1
HISTOGRAM
EQUALIZATION
Which is a uniform probability density function, this means ,
performing intensity transformation yields a random variable s
characterized by uniform PDF.
It can be noted that T(r) depends on pr(r) but ps(s) is always
uniform and independently of the form of pr(r).
HISTOGRAM EQUALIZATION
(EXAMPLE)
Suppose intensity values in an image have
the PDF
2r
for 0 r (L
pr (r) (L 1)
1)2
0 otherwise
r r
2 r2
s T (r) (L 1) pr (w)dw wdw
0
(L 0
1) (L 1)
Suppose L-1=9 and pixel at location say (x,y) has the value r=3,
then
s=T(r)= r2/9=1
HISTOGRAM EQUALIZATION
(EXAMPLE)
The PDF of the intensities in the new
image is
1
dr 2r ds
ps (s) pr (r) (L 1)2
ds
dr
2r d r2 1
(L 1)2 dr L
Assume r is positive
and L>1
1
Result is uniform PDF
(L 1) 2
L 1
2r 2r (L 1) 1
HISTOGRAM EQUALIZATION
For the discrete values of the histogram , we deal with summation
instead of integration
nk
p(rk ) k 0,1,2,.......L 1
MN
The discrete form of transformation is
given by
k
sk T (rk ) (L 1) pr (rj )
j 0
(L k
nj k 0,1,2,........L 1
1)
j 0
MN
The input pixel rk is mapped to output pixel sk
The transformation (mapping) T(rk) is called as histogram equalization
or histogram linearization.
Histogram Equalization
(Example)
Let us consider a 3 bit image (L=8) of 64 x 64 (MN=4096), has
the intensity distribution shown below.
HISTOGRAM EQUALIZATION
(EXAMPLE)
From the equation of histogram equalization ,
we have
0
s0 T (r0 ) 7 pr (rj ) 7pr (r0 ) 1.33
j0
s1 T (r1 ) 7 1 pr (rj ) 7pr (r0 ) 7 pr 3.08
j0
(r1 )
Similarly compute s2, s3, s4,
s5 , s6 , s7
HISTOGRAM EQUALIZATION (EXAMPLE)
s0 1.33 1
s1 3.08 3
s2 4.55 5
s3 5.67 6
s4 6.23 6
s5 6.65 7
s6 6.86 7
s7 7.00 7
HISTOGRAM MATCHING (SPECIFICATION)
Histogram equalization is an automatic enhancement.
Some times shape of the histogram can be
specified based on the requirement.
The method used to generate a processed image that has a
specified histogram is called histogram matching or histogram
specification
nk
p(rk ) k 0,1,2,.......L 1
MN
The discrete form of transformation is
given by
k
sk T (L pr (rj )
(rk ) 1) j 0
k
nj k 0,1,2,........L 1
(LMN j 0
HISTOGRAM MATCHING
(SPECIFICATION)
Let pz(z) is the specified PDF, which is going to be the PDF of
the output image. So we have
q
G(z q ) (L 1) pz (zi ) sk
j 0
Desired value zq=G-1(sk)
This will give value of z for each value of s, by performing
mapping of s to z
Histogram matching (Specification)
Let us consider a 3 bit image (L=8) of 64 x 64 (MN=4096), has
the intensity distribution shown below.
HISTOGRAM MATCHING
(SPECIFICATION)
Specified histogram is given as follows
STEP 1 : Scaled histogram-equalized
values s 1.33 1
zq Pz(zq) 0
Z0=0 0.00 s1 3.08 3
Z1=1 0.00 s2 4.55 5
Z2=2 0.00 s3 5.67 6
Z3=3 0.15
s4 6.23 6
Z4=4 0.20
s5 6.65 7
Z5=5 0.30
s6 6.86 7
Z6=6 0.20
Z7=7 0.15 s7 7.00 7
HISTOGRAM MATCHING
(SPECIFICATION)
•STEP 2 : Compute all the values of transformation function G,
0
G(z0 ) 7 p z (z j )
j 0
0
G(z1 ) p z (z j ) 7[ p(z0 ) p(z1 )]
7 j 0
G(z2 ) 0.00 G(z3 ) 1.05 G(z 4 ) 2.45 G(z5 )
G(z6 ) 5.95 G(z ) 4.55 7
7.00
These fractional values are converted to integer values
as shown
HISTOGRAM MATCHING (SPECIFICATION)
G(z0) 0.00 0
G(z1) 0.00 0
G(z2) 0.00 0
G(z3) 1.05 1
G(z4) 2.45 2
G(z5) 4.55 5
G(z6) 5.95 6
G(z7) 7.00 7
The condition of strictly monotonic is
violated
EXAMPLE: HISTOGRAM
MATCHING
Obtain the scaled histogram-equalized values,
𝑠0=1,𝑠1=3,𝑠2=5,𝑠3=6,𝑠4=6,𝑠5=7,𝑠6=7,𝑠7=7.
Compute all the values of the transformation function G,
0
G ( z0 ) 7 pz ( z j ) 0.00 0
j 0
G ( z1 ) 0.00 0 G( z2 ) 0.00 0
G ( z3 ) 1.05 1 s0 G( z4 ) 2.45 2 s1
G ( z5 ) 4.55 5 s2 G( z6 ) 5.95 6 s3 s4
G ( z7 ) 7.00 7 s5 s6 s7
EXAMPLE: HISTOGRAM MATCHING
s0 1, s1 3, s2 5, s3 6, s4 7, rk zq
s5 7, s6 7, s7 7. 0 3
1 4
rk 2 5
0
3 6
1
2 4 7
3 5 7
4
6 7
5
6 7 7
7
HISTOGRAM MATCHING (SPECIFICATION)
To handle this situation following procedure is used
Find the smallest value of zq so that the value G(zq) is closest to
sk .
For example s0=1, and G(z3)=1, which is a perfect match for
this case, here s0 -> z3 , i.e. every pixel whose value is 1 in
the histogram equalized image is mapped to pixel valued 3
sk in the histogram
zq specified image. Continuing this we get,
1 3
3 4
5 5
6 6
7 7