module-3
module-3
Image f(, y)
point in an image
Fig. 3.1 :A3x3 neighborhood about a(x, y)
77
76
\mage Py Image Enhancement
Transformation
Pointprocessing imagedepends
only on the
gray level at 3.2 Some Basic Gray level
in an that. Ol3.2.1 |Image Negatives
Enhancement atany valueoffat(uy)and Tbbecomes agray-level
point
case, gdepends
the fornms=
onlyonthe
T(r)
leveloff(: y),
4,y).
s-graylevel
ofg transtormal luns
transformation.
The negative of an image with gray levels in the range
S = L-|-r
[0, L- 1] is obtained by using negative
---- (3.2)
Point r-gray isnot often used becauseit does not give more flexibility, The more %
Whereprocessing white or gray detailembedded in
in Fig. 31 This processing isparticularly suited for enhancing dominant
3x3 as shown 3 x3 This type of in size. Fig. 3.3(a) is a
neighborhood i.e.,coefficients areas are
determine the nature neighbg of an image especially when the black
larger
methodis using kernel. The mask of process hdark regions the negative of the image in Fig. 3.3 (a). Fractured bone is
called mark, filter or sharpening etc., Contrast stretching. lOr in image of fractured bone. Fig. 3.3(b) is
smoothing(Blurring),
transformation log-transformation,
and histogram processing are point processing methods for image enhanc POWe more clearly visible in negativeimage
Fig. 3.3(b) than in Fig. 3.3 (a).
Contrast stretching
Low contrast image occur due to poor lighting conditions or due to small dynamic va,
image sensors.
image sensOrs, non linearity of
which makes the e object distinguishablep
Contrast is the difference in visual properties
background. (b) Negative Image
(a) Original Inage
Increasing contrast means increasing the gray level difference between neighbor nivd. Fig. 3.3 : Example of image negatives
has the form shown in Fig. 3.2(a), where r is the input image gray levels, s is the pre
(output) image gray levels. The effect of this transformation would be to produce an iny L-1
highercontrastthan the original by i.e., thresholding the levels below mand brightening the:
above min the original image.ln the limiting case T(r) as shown in Fig. 3.2 (b) prodcsi Negative
level image (binary image).
nth root
s=Tr) s=T(r) 3LI4
slevel,
Light
Light log
gray nth power
+ OutputL/2
Tr)
Dart
Dart
L/4
Inverse log
Dart Identity
+Light
(a) Dart Light
Fig. 3.2 : Grey (b)
0
3L/4 L-1
level L/4 LI2
Y=2.5 Gamma
U4 cOrrection
Image viewed on moritor
Y=5.0
Y= 10.0
Y= 25.0 D Monitor
U4
64 3L/4
125 190
L-1
Fig. 3.5 : Plot of Input gray level, r 255
the power law
transformations forthe various values of"'' with he=lin all cases Gamma corrected image
Fig. 3.8 (a) is the original washedout light image of' a man under a bridgc. Fig. 3.8 (b) is the
result of power-lawtranslormation with c= Iand gamma =4. Fig. 3.8 (c) and Fig. 3.8 (d) are the
result of power law transformation with c= Iand gamma =5 and 6 respectively. Note that as
gamma increased from 4 to 6 more details became visible because contrast has increased.
LI4
(r,s)
S T(r)
A
L-1 A B L-1
(a) This transformation highlights range
(b) This transformation highlights range
(A, B]of gray levels and reduces all
others to a constant level. A, B]but preserves all other levels.
Fig. 3.10 : Gray level slicing
The transformation shown in Fig. 3.10 (a) transfor1nations
Fig. 3.10 (b) brightens the desired range of gray produces abinary image with only two gray d) Image bit plane 5 e) Image bit plane 4
) Image bit plane 3
(d)
1 |(L-)p, () L-1
---- (3.1O)
p.(0) =-, 0sssL-I
Asp,(9) =-|: we recongnize p. (s) as a uniform probability density function.
equation (3.10) resultingp.(s) is
From equation (3.8) T() depends onp.(r) but as indicated by
T(r) always uniform independent of the form ofp().
instead of probability density
For discrete values we deal with probabilities and summations approximated
r, in an image is
function and integrals. The probability of occurrence of gray level
by
---- (3.11)
P.) = k = 0, 1, 2, .......L-1
The processedimage is obtained by mapping cach pixel with level r, in the input imageim of applying
Fig. 3.15 shows the four images from Fig. 3.13. Fig. 3.15 (b) shows the result low contrast
plot of p.(r) versus r, is called cach of these images. The dark image, light image and
image. A Istogh histogram equalization on
corresponding pixel with level s, inthe output (3.12) is called histogram equalization. image after undergoing histogram cqualization has a
significant improvement. The fourth image
The transformation(mapping) given by equation probability The dsg donot have a significant improvement. Fig. 3.15 (c) shows
the
transformation will produce the discrete
equivalent of a uniform density fung which is a high contrast image
(a). The histogram of
resnective histogram equalization transformation for the images in Fig. 3.I5 that,
which would be a uniform histogram. the equilized images are shown in Fig. 3.15 (c). It is
interesting to observe even though the
bistogranm are different, the histogram equilized images are visually simillar.
Example for historgram equilization
Problem 1
4 Perform image histogram equilazation for the image shown in fig. 3.16
[0 0 0 1 1]
2 2 2 23
33 3 3 3
|0 0 0 7 7|
Fig. 3.16
Solution:
with size 5 x5
Considera hypotetical image shown in the fig. 3.16
given image is 7. So 3 bits are required to represent
The maximum value of the pixel in the 8
number of possible gray levels in the image is
each value of the value. Therefore the
(0 to 7).
be drawn as shown in the figure.
The histogram of the given image can
Plr)
1
8
7
6
5
4
0.28
3 0.24
0.24
0.16
2 0.08
.1 7
4 5 6
1 2 3
(a) (b)
(C) (d)
Fig. 3.15: Example of image
kistogram equilization transformation
90 Image PrOCk Enhancement 91
Image
Calculations to draw histogram
6 6/25 =0.24
6
7 7/25=0.28
7 5
4/25 =0.16 6
4 4
5
.28 3
6 6/25 =0.24 .24 .24
16 2
4 0 0/25 = 0 .08
5 O/25=0 6 7
1 2 3 4 5 1 2
6 O/25 =0
The histogram of the histogram The transformation function is given by
7 2 2/25 =0.08 equalized image is
The histogram equalized image can be calculated as follows. The new gray levels of s, = Tr)=(L-) p.;), k=0, 1,2...-1
J=)
s=-r-2r
0.8
then r = 1t/|
For histogram equalization T(r) is only 0.6
the output image is uniform.
needed, but it is necessary to show that resulting Ddi
0.4
The derivative of S with respect to r is
given by 0.2
ds
0.2 0.4 0.6 0.8
dr
The inverse transformation from sback to r will be denoted by r=T(s), 0< Fig. 3.17
where it is assumed that T'(s) also ssl
3.3.2 Histogram Matching
monotonically increasing in the interval 0<rs1satisfies condition (a) T(r) is a single valued a In histogram matching, the shape of the histogram that we wish the processed image to have
(b) 0<T()slfor 0s rsi is specified.
condition (a) preserves the order from black to The method used to generate a processed image that has a specified histogram is called
(b) guarantees amapping that is consistant with the white in the gray scale, while conditi histogram matching.
interval [0, I] only the solution. r allowed range of pixel values, since r lies in tb
The probability density
=T-(s) =1-J1-s is valid. Development of the meio
following equation. function of S is obtained by Consider a image with input gray levels r and its shape of the histogram is specified with gray
substituting the above results into levels z.
Let r andz are continuous random variable, where r and z are the gray levels of the input and
Ouput (processed) images respectively. Let p(r) and p.() are probability density functions of r
respectively. p(r) can be estimated from the given input image. P,(2) can be obtained from
and z output image
ne specified histogramp (:) is the specified probability density function that we wish
to have. Let s be a random variable with the property.
of integration
Where wis a dummy variable Equation (3.17) a mapping from the levels in the original image into corresponding levelss
let random variable S, has property function
based on the histogram of the original image. Equation (3.18) computes a transformation
equation (3.19) gives us the discrete gray levels of the
S,= G) =(L- I) p.()dt =s s Gfrom the given histogram p.(z). Finally
image with that histogram.
Where t isadummyvariable of integration Implementation
equations that
It then follows from these two dimensional
G(z) = T() = s Each set of gray levels {r), {s,) and (z),j=0, 1, 2, ......- 1, is a one -
lookups between a
condition arrav of dimensionLx1. All mappings from rto sfrom s toz are simple table
..must satisfy the arrays as shown in the Fig. 3.18. Each of the elements of these arrays,
z= G()= G' [T)) oiven pixel value and these the location
subscript k denotes
for example, s, contains two important pieces of information. The
The transfornation T(r) can be obtained from p(r) of the input image. The transtormahe elementin the array and sdenotes the value at that location. We need to be concermed only
function G() can be obtained because p(2) is given. Assuming that G exists and that it stiwith integer pixel values. Forexample in the 8bit image L= 256, range is Oto 255. The procedure
condition (a) and (b). Equation (3.13) to equation (3.16) show that an image with a sperit or histogram matching may be summrised as follows:
probability density function can be obtained from an input image by using the following procet. 1. Obtain the histogram of the given image.
r,.
1. Obtain the tranformation function T(r) using equation (3.13). 2. Use equation (3.17) to precompute a mapped level s, for each level
2. Use equation (3.14) to obtain the transformation function Giz). 3. Obtain the transformation function G from the given P.(z) using equation (3.18).
3. Obtain the inverse tranformation function G-!. s, using the iterative scheme.
4. Precompute z, for each value of
is r,, map this value to its
4. Obtain the output image by applying equation (3.16) to all the pixels in the input image. 5. For each pixel in the original image, if the value of that pixel
The result of this procedure will be an image whose gray levels z
have the specified corresponding level s then map level s, into the final z,.
P.().
For Discrete values
The discrete formulation of
equation (3.13) is given by -Gz)
T)
--- (3.
j=0 (b)
(a)
L-1
n
(2-) ik=0.I. 2,3, ...L-l (a)
0
(b)
j=0 MN j=0
When nis the number of pixels in
and Lis the numbertotal the image. n, is the
of discrete gray
levels. number of pixel with gray 1
Similarly the discrete
p.(2), i=0, 1,..., L- lformulation of
and has the formequation (3.14) is obtained from the given
histog"
(c)
V, =G(z) =
The discrete k = 0, 1, 2,
(L-1))P.(,) j=0
=s, 0
0
(c)
version of equation (3.16) is ...
., L-]
from r, to s, via T(r). (b) Mapping of z, to
its corresponding value
given by () Graphical interpretation of mapping mapping from s, to its corresponding value of z,.
from equation (3.17) <,= G[Tr)) k= 0, v, via G(z), (c) Inverse
Zy= G(s) k=0, 1, 1,2, 2, ..... -] --o3.19
Fig. 3.18 : Graplhical
representation of histogrammatching
...., L- 1
96
that Fig.
istogram 3.19
Fig.
(b) 3.19 2000 4000 6000 8000 10000 12000 14000r
ization the is (a) 0
Fig.
Fig.
histogram is
the 3.20 50
3.19: (a)
image :
is Example 100 Example
the of (C)
good the of I50
Sunflower
image image image
oach 200
in an and
Fig. seeds its 250
its
to istogram
ce 3.19 histogram
(a). which 2000 4000 6000 8000 1000
for 128 192 1200; 1400
the At is 64+ for
thkistogranm
e has
e.
first histogram 50
more
64
nce,matching Trasnformation
100
dark
it (b) 128 function matching (b)
200150250
isonepixels
192 Image
ProC.
might by
conclu' t intastU
ofthe
Fig. histogram. original transofrm of moved TheEnhancement Image
3.19 the
inverse mor e histogram Fig.
Fig.
Number of pixels X> matched Sampling histogram, 3.21darker towards 3.20
Output gray levels
O 5.25+ o 3.50 5.25 (a)
7.00f transformation function
1.75: and The
1.75 3.50 7.00
transformationG this (apixels.
) of (a)
Histogram image. the
function butshows shown upper shows he
64 has image
Input
levels
gray 64 Observe the the
function into a inone
Fig. 128 equalized smoother manually Fig. histogram as
128192255 hal f also
3.21 that
are is
(2) 256 3.20
192255 shown
: immatched
age obtained asequally transitionspecified (b) thequalized
e
of
Result shown low gray in
2 in spaced gray the
of Figimage
. in by function of scale. Figimage
Histogram 3.20(a). applying
Fig. discrete levels levels .
is3.21 This 3.20which
1000 I500: 2000 2500 visually (c). inthat are
matclhing 0
500
tvalues
he the mapped is(c).
Fig.
histogram preserves
dark because, Notc has
50 better produced a
3.21 region light,
100 to how
than (d) the hiobserve gh washed
150 equalization
shows generalof all
the th e the gray the
200 input the desired gray levels
the gray out
250 shape equalization appearance.
Histogram
image specified and scale. levels
because
G(s) of
in the are
image Solution: 3.22(6).fig. 98
" ProblemExampl
3e
Perform The Consider
following calculated
is Perform
|I1 2 |2 3
histogram the 3.22(a)
Fig. 1 2 2 2
for
5
11
2 2 2 Histogram histogram
procedure and x5 1-
equilization 2 2 7 77 2
plot
hypothentical
2 2 7 71
has 3 4 5 64 7
fig.
in matching
for be
to
0.24
P,(S|)
3.22(c). matching
followed
the
1
image for
given 2
0.52 an
The image
0.04 as
to
image. 3.22(c) 3 desiredshown .2 3 4 .5.6 .74 .84 .9 14
perform Fig. PIZ) shown
4
0.1
histogram in
histogram 5 fig. 0,2 in
3.22(a). 3.22(b)
Fig. fig.
6
0.3
0.2 shown
is 3.22(a)
matching. The 0.1
0.1 histogram to
histogram in the
fig. 0.1
Irmage
Pr
3.22(b). 0,1
of
the
for
Enhancement
Image
"
forZ, Perform The
7 6 4 2 1 0
6 5 4 3 2 0
histogram
histogram
5/25 O/25=0O/25=0O/25=0
=0.2 =0.04
1/25 =0.52 6/25 0/25=0
13/25 =0.24
equivalization
0.1 0.1 0.1 0.1 0.3 0.2 0.1 (2)P, 1 2 3 4 54 6 equilization
7
S
1
transformation
for
J=0
the 10.80 0.80 0.80 0.80 0.76 0.24 0
3
1 0.9 0.8 0.7 0.6 0.3 0.1 0
given J=0
4 +
desiredfunction
5
6
given is
given
histogram.
by
x7=77 0.8 0.3 0.1 1
x7=0.7 Ix7=7 70.80 0.76 0.24
0.80 0.80 0.80 0x7=0=0
x7=
0.9 0.7x7= 4.9 5
x 0.6x7=4.2 4 0x7=0 0
x x x x x x
7=5.6 x
7 7=2.1 7 7=7=5.32
= = 7= 7=
6.3 5.6 5.6 J=0
5.6 5.6 1.68
s6 = s
6 2 6 6 6 6 5 =2
99
100
by
\mage Pr Image Enhancement 101
function is given
Equalization Transformation
The resultant histogram after histogram matching is given by.
P(z,)
0.52
5
4
3
2.4 0.2
.24 0.04
0.1
2 3 4 5
Problem 4
" Perform matching An image has the gray level pdf p(r) shown in fig a. It is desired to transform the gray levels
of this so that they will have the specified p(z) shown in Fig. b. Assume continuous quantities and
given image desired histogram find the transformation in terms of r and zthat will accomplish this.
finally r, ’ 4Pr) 4 P(r)
Equalization Transformation function is given by
2
Given image Desired histogram Finally
S 1
0
Sk
0
| -
2 1 2
2
Fig. 3.23
-5 -2 2 4
Solution:
3 6 4 3 3 We know that
4
4 4 5 ---- (1)
5 6 s = T) - [p.(*) dv
5
6 6 6 where w is a dummy variable of integration
6
6 5
77 -7. 7 7
using straight line equation between Pand Q. PO=-2r+2
While mapping find the smallest value [-2r+2 0srsl
procedure to the required mapping from r, to of Zso that the value S is the closest to S. K So, p(r) = else where
---- (2)
Z, as shown in
table. straight line mentioned in
Applying the above transformation mentioned in equation ( )to a
equation (2) we get
T() = S= (-2w +2)dw =-p² +2r ---- (3)
102
derived
the
histogrampdf andlapply transformation
\mane Image Enhancement
103
the
Nowconsider
and
the points R |B in Fig. (b)i) is given by
line cquationbetween
Thestright |2z 0srsl
P.() = 0 else where
1n =
i=0
is given by
Ho=1,, =0, the second moment
L-l ---- (3.21)
4,(r) = X-m)'p(;)
\mage p Image Enhancement 105
104
(r).
r denoted by o
4() is varianceof the square ro0t of the
Thestandard
The
deviationis defined simply as variance.
mean is the measure of average gray level in an image. The variance is the tmca Variance o' =
L-1
-m P(a)
i=0
average contrastin an image. The global mean and variance are measured over an enite,
and are useful adjustments of overall intensity and contrast. The local mean and varia 9
measured over an predefined region ofthe image and are useful for adjustments of inten i=0
contrast over a predefined region of theimage. Let(, y) be the coordinates ofa pixel in an;
and let s denote a neighborhood(Submage of specified size centered at (x, y). The mean 3-4).
16
16
computed using the expression.
m, of the pixels in s can be (4-4+(5-4)+(6-4'(7-4
l6 16
(s./)Es
(8-4+(9-4)'=7437 =7
16
neigborhood.
where r, is the gray levelat coordinates (s, 1) in the
operations
pr )is the neighborhoodnormalized histogram component corresponding to that ul 3.3.4 Enhancement Using Arithmetic / Logic between
gray level. The gray - level variance of the pixels in regions, is given by performed on a pixel by pixel basisselecting
operations involving images are
Arithmetic / logic for
masking i.e.,
images. The logical operation AND and OR are used for
two or more
(s)es, sub images in an image.
The localmean is a measure of average gray level in neighborhood s, and the variang
standard deviation] is a measure of contrast in that neighborhood.
Example to illustrate the calculation of variance and means for the given image matrix.
1 2-4 8
2 01 5
A=
35 6 4
|6 7 9 0|
Mean:
m =
i=0
Here
L= 100
mask
inages forOR andAND
Fig. 3.24: Example represents a binary I
m= P) the OR and AND image masks. Light area processing. In the
Fig.3.24 (b) and (c)
shows Interest (ROI)
i=)
binary 0. Masking is
used in Region Of of the input
represents a chair. In case of OR Mask if any one
and dark the lamp behind the always one, irrespective
2
M=0x+lx+2x3x+4x image ROI is the top of input is one, the output is
16 dv 2 +6X 8ven
output follows the other input. Ifany ofthe by Truth table.
16 16 16 S Zero, better understand
16 16 of the other input. This can be
+7x-+8x
16 16
+9x
16
3.9375 4
106
talble of OR
\mage Pi Image Enhancement
107
Truth
B
0 0’
1
0
0 1
1 level bit
a) Original image b) 3lower order gray
planes set to zero
dark region dof the mask
image information only at the as
So OR mask will pass the if anyone of the input.is one output followsthe sho,
of (c).
IfFig.any3.24 Conversely in AND mask, other
the input is zero, the output is always zero, irrespective of the other input. Thisa
table of AND.
better understand by Truth
Truth table of AND
B Y
<- - A 0’
c)Difference between d) Histogram equalized
(a) and (b) difference image
image substraction
Fig. 3.25 :Example of obtained by
shows the image identical
0
Sunflower seeds image Fig. 3.25 (b) are almost
the images
1 1 Fig. 3.25 (a) showssignificant bit planes of the image in (a). The are lost. The pixel by pixel
least four little fine details
discarding the image and image appears
difference in contrast of theshown in Fig. 3.25 (c). The difference
So AND mask will pass the image information at light region of the mask as sho expect a slight two images is details in the image. histogram
Fig. 3.24 (e) difference between these pixel values. So in order to bringout 3.25 (d).
ofsmall in Fig.
almost black bccause the result is shown
on the image and
Image Subtraction equalization is performed
The difference between two images f(x, y) and h (x, y)
expressed as
& i,y) = f( y) hlr, y)
Image subtration is usedinthe area of medical imaging called I mask mode radiography.y.ot
case h(x, y), the mask is an x - ray image of a region of apatients body. AContrast medur
injected into the patient's bloodstream, take the image of the same anatomical region asfl mask subtracted
out
The netc effect of subtracting the
mask from each c) Image with
of TVimagt
that the areas that are
Image values should be different between f(x, y) andsample
h(x, y)
in the incoming Stream
appear in
as enhancedde
a) Mask Image
in the range the image
can range from a (0-255) image is displayed using 8 bits. The values
difference as
image
255 to every pixel and minimum of- 255 to a maximum of 255. One methoddis i to
8 - bit range from 0tothen divide by 2. It is not theent
255. guaranteed that the values willdifference
negative is added to all the Second method is to find the
cover
an
pixels in the value of the min
difference image and multiplied lby 255/max. ofa
contrast
taken afterejectionstream
b) Image
medium intothe
blood substraction
of image
application
3.26: Practical
Fig.
108
blood stream image prior
to injection of an contrast
\rmage P 109
Fig. 3.25 (a) shows the injection Fig. 3.25(b)showss the image of blood Image Enhancernent
streamm.Fetiium
time of
bloodstream after some subtracted out in which blood stream is visible the response (R) is
Eorthe 3x3 ilter mask at a point (x, y) in the image,
shows theimage with
mask
more in dea R=w(-I, -)f(- l, y-1) + w(-1,0) f(r-1. y) +... -..(3.29)
Image Averaging + w (1, )f(r+ 1. y + )
+ w (0, 0) f(x, y) t .... w (1, 0)f (+ 1, y)
astrophotography, but it the computation of the sum of products
Image averaging is common in high - end does give good
requires severalimages oftthe same
The mask is centered at (x,y) of the image whenm=2u+ 1 and n = 2b+ 1, where a and b are
assume that
night photography. Averaging takes place. For a mask of size mX. We filter mask of
low light
different
and
noise pattern. Averaging reduces the noise without compromising detailsSas icach
t
sCene non-negative integers. In general, linear filtering
of an image fof size Mx N with a
signal to noise matix (SNR) of the. image. Noise in the image is trurely random, inag size m xn is given by the
expression.
fluctuations above and belowactual image data will gradually even out as one
more images. averageS TN g(1, y) = s=-0 (z-h
w(s,)f (x+s,y+ t) -.-(3.30)
Consider a noisy image g(x, y) formed by the addition of noise n(a, y)to an
f(xy): that is original; where 1= (m-1)/ and b=
8 ,y) =f, y) + n4, y) Image origin
E| (,)} =fu. y)
A
square matrix w(s, 1) is a f(x+1,y-1 f(x+1,ylF(x+1,y-1
spatial
iltering in images. The called
than pixels. values filter
of this mask, kernel, template orrwindow whenit is used
The
simply of moving the
i mechani
filtersmmask spatial
of
fi lterin g
matrix (filter) are ra
are inreferred to as coefficients.Cons
is centered Pixels of image
for the filter window. Atfrom point to point il ustrated Fig. section under
produc
by asum offilter Mechanisms of spatial filtering
mas Fig. 3.27: The image section
x3 mask of the
spanned by the
The Magnified view show a 3