You are on page 1of 22

Digital Image Processing

Digital Image Processing

Image
ImageEnhancement
Enhancement
Background
Background
 Very first step in Digital Image Processing.
 Very first step in Digital Image Processing.
 It is purely subjective.
 It is purely subjective.
 It is a cosmetic procedure.
 It is a cosmetic procedure.
 It improves subjective qualities of images.
 It improves subjective qualities of images.
 It has two domains:
 It has two domains:
 Spatial domain
 Spatial domain
 Frequency domain
 Frequency domain
Spatial
SpatialDomain
Domain
 Spatial means working in space i.e. (given image).
 Spatial means working in space i.e. (given image).
 It means working with pixel values or raw data.
 It means working with pixel values or raw data.
 Let g( x, y) be original image where g is gray level values
 Let g( x, y) be original image where g is gray level values
& ( x, y) is co-ordinates
& ( x, y) is co-ordinates
 For 8-bit image, g can take values from 0 – 255
 For 8-bit image, g can take values from 0 – 255
where 0 – BLACK ,
where 0 – BLACK ,
255 – WHITE &
255 – WHITE &
others - shades of GRAY
others - shades of GRAY
Spatial
SpatialDomain
Domain
 In an image with size 256 x 256, ( x, y) can assume any
 In an image with size 256 x 256, ( x, y) can assume any
value from (0 , 0) to (255 , 255).
value from (0 , 0) to (255 , 255).
(0 , 0) Y
(0 , 0) Y

X (255, 255)
X (255, 255)
Spatial
SpatialDomain
Domain
 Applying transform modifies the image
 Applying transform modifies the image
f(x,y) = T g(x,y)
f(x,y) = T g(x,y)
where,
where,
g(x,y) is original image
g(x,y) is original image
T is transformation applied on g(x,y)
T is transformation applied on g(x,y)
f(x,y) is new modified image
f(x,y) is new modified image
 In spatial domain techniques simply T changes.
 In spatial domain techniques simply T changes.
 Spatial domain enhancement is carried out in two ways:
 Spatial domain enhancement is carried out in two ways:
Point processing
Point processing
Neighborhood processing
Neighborhood processing
Point
PointProcessing
Processing
 Here, we work on singe pixel i.e. T is 1 x 1 operator.
 Here, we work on singe pixel i.e. T is 1 x 1 operator.
New image depends on transform T and original image.
New image depends on transform T and original image.
 Some important examples of point processing are:
 Some important examples of point processing are:
 Digital Negative
 Digital Negative
 Contrast Stretching
 Contrast Stretching
 Thresholding
 Thresholding
 Gray level slicing
 Gray level slicing
 Bit plane slicing
 Bit plane slicing
 Dynamic range compression
 Dynamic range compression
Point
PointProcessing
Processing
 Identity Transformation:
 Identity Transformation:
255 T
255 T

Modified
Gray Level
125
125

s
s 10
10
0
0 10 125 255
10 125
Original Gray Level r 255
Original Gray Level r
• It does not modify the input image at all.
• It does not modify the input image at all.
• In general, s = r
• In general, s = r
Point
PointProcessing
Processing
1) Digital Image Negative:
1) Digital Image Negative:
 Useful in large applications e.g. X-ray images.
 Useful in large applications e.g. X-ray images.
Negative means inverting gray levels.
Negative means inverting gray levels.

255
255
Output Gray level 200
Output Gray level 200
s
s

55
55
0 55 200 255
0 55 200 r 255
Input image intensity
Input image intensity r
Point
PointProcessing
Processing
Digital Negative can be obtained by:
Digital Negative can be obtained by:

s = 255 – r (where, rmax = 255)


s = 255 – r (where, rmax = 255)
when, r = 0; s = 255
when, r = 0;&s if
= 255
r = 255; s = 0
& if r = 255; s = 0

Generally, s = (L-1) –r
Generally, s = (L-1) –r
where, L – total number of gray levels (e.g. 256 for 8-bit image)
where, L – total number of gray levels (e.g. 256 for 8-bit image)
Point
PointProcessing
Processing
2) Contrast Stretching:
2) Contrast Stretching:

255
255
w (r2, s2) n
w (r2, s2) n

Output
Output
Image
Image
Intensity s m
Intensity
level
s m
level

(r1, s1)
v l (r1, s1)
v l
0 a b 255
0 a rb 255
r
Input Image Intensity level
Input Image Intensity level
Point
PointProcessing
Processing
Reasons:

Reasons:
Poor Illumination
 Poor Illumination
 Wrong setting of lens aperture
 Wrong setting of lens aperture
 Idea behind Contrast Stretching is to make dark portion darker and bright
 Idea behind Contrast Stretching is to make dark portion darker and bright
portion brighter.
portion brighter.
 In above figure, dotted line indicated Identity Transformation & solid line
 In above figure, dotted line indicated Identity Transformation & solid line
indicates Contrast Stretching.
indicates Contrast Stretching.
 Dark portion is being made darker by assigning slope of < 1.
Bright
Dark portion
portion is
is being
being made
made brighter
darker bybyassigning
assigningslope
slopeofof<>1.1.
Any
Bright portion
set of slopes is being
cant made brighter
be generalized for by
allassigning slope of > 1.
kind of images.
 Any set of slopes cant be generalized for all kind of images.
Formulation is given below:
Formulation is given below:
s = l.r ; for 0 ≤ r ≤ a
s==m(r-a)
l.r + v ; ; forfora 0
≤≤ r ≤r ≤
ba
= =n(r-b)
m(r-a) + v ; ; for
+w forb a≤≤r r≤≤L-1
b
= n(r-b) + w ; for b ≤ r ≤ L-1
Point
PointProcessing
Processing
3) Thresholding:
3) Thresholding:

255
255

Output
Output
Image
Image s
Intensity
Intensity
level
s
level

0 a 255
0 ar 255
r
Input Image Intensity level
Input Image Intensity level
Point
PointProcessing
Processing
 Extreme Contrast Stretching yields Thresholding.
 Extreme Contrast Stretching yields Thresholding.
 In Contrast Stretching figure, if l & n slope are made ZERO & if m slope is
 In Contrast Stretching figure, if l & n slope are made ZERO & if m slope is
increased then we get Thresholding Transformation.
increased then we get Thresholding Transformation.
 If r1 = r2, s1 = 0 & s2 = L-1
 If r1 =Thresholding
r2, s1 = 0 function.
& s2 = L-1
Then we get
Then we get Thresholding function.
 Expression goes as under:
 Expression goes as under:
s = 0; if r ≤ a
s=s =L 0;
– 1if;rif≤r a>a
s = L – 1 ; if where,
r >a L is number of Gray levels.
where, L is number of Gray levels.
Note: It is a subjective phenomenon.
Note: It is aimage
Thresholded subjective phenomenon.
has maximum contrast as it has only BLACK & WHITE gray
Thresholded
values. image has maximum contrast as it has only BLACK & WHITE gray
values.
Point
PointProcessing
Processing
4) Gray Level Slicing (Intensity Slicing):
4) Gray Level Slicing (Intensity Slicing):

L-1 L-1
L-1 L-1

s s
s s

0 a b L-1 0 a b L-1
0 a r b L-1 0 a r b L-1
r background
fig. (1) Slicing w/o fig. (2) Slicingr with background
fig. (1) Slicing w/o background fig. (2) Slicing with background
Point
PointProcessing
Processing
 Thresholding splits the image in 2 parts
 Thresholding splits the image in 2 parts
At times, we need to highlight a specific range of gray levels.
At times, we need to highlight a specific range of gray levels.
eg. X-ray scan, CT scan
eg. X-ray scan, CT scan
 It looks similar to thresholding except that we select a band of gray levels.
 It looks similar to thresholding except that we select a band of gray levels.
Formulation of Gray level slicing w/o background (fig. 1):
Formulation of Gray level slicing w/o background (fig. 1):
s = L-1 ; for a ≤ r ≤ b
s==0 L-1 ; ; otherwise
for a ≤ r ≤ b
=0
 No background at all. ; otherwise
 No background at all.
Sometimes we may need to retain the background.
Sometimes we may need to retain the background.
 Formulation of Gray level slicing with background (fig. 2):
 Formulation of Gray level slicing with background (fig. 2):
s = L-1 ; for a ≤ r ≤ b
s==r L-1 ; ; otherwise
for a ≤ r ≤ b
=r ; otherwise
Point
PointProcessing
Processing
5) Bit Plane Slicing:
5) Bit Plane Slicing:
 Here, we find the contribution made by each bit to the final image.
 Here, we find the contribution made by each bit to the final image.
 Consider a 256 x 256 image with 256 gray levels i.e. 8-bit representation for

eachConsider a 256
pixel. E.g. x 256
BLACK is image with 256
represented gray levels i.e.
as 0000_0000 & 8-bit
WHITErepresentation
by 1111_1111.for
each pixel. E.g. BLACK is represented as 0000_0000 & WHITE by 1111_1111.
 Consider LSB value of each pixel & plot image. Continue till MSB is reached.
 Consider LSB value of each pixel & plot image. Continue till MSB is reached.
All 8 images will be binary.
All 8 images will be binary.
 Observing the images we conclude that
 Observing the images we conclude that
Higher order images contain visually sufficient data.
Higher
Lower order
order images
bits contain
contain visually
suitable sufficient
details of image.data.
Lower
 Hence, order
BPS bitsused
can be contain suitable
in Image details of image.
Compression.
 Hence, BPS can be used in Image Compression.
We can transmit only higher order bits & remove lower order bits.
We can transmit only higher order bits & remove lower order bits.
E.g. Steganography
E.g. Steganography
Point
PointProcessing
Processing
Ex. Plot bit planes of the given 3 x 3 image.
Ex. Plot bit planes of the given 3 x 3 image.
1 2 0 1 - 00000001 001 010 000
1 2 0 2 -1 00000010
- 00000001 001 010 000
4 3 2 0 2- 00000000
- 00000010 100 011 010
4 3 2 40 - 00000000
- 00000100 100 011 010
7 5 2 34- -00000011
00000100 111 101 010
7 5 2 2 -300000010
- 00000011 111 101 010
72 - 00000010
- 00000111
Max. Intensity is 7 thus 3 – bits 5 7- -00000101
00000111
Max. Intensity is 7 thus 3 – bits 2 -5 00000010
- 00000101
2 - 00000010
1 0 0 0 1 0 0 0 0
1 0 0 0 1 0 0 0 0
0 1 0 0 1 1 1 0 0
0 1 0 0 1 1 1 0 0
1 1 0 1 0 1 1 1 0
1 1 0 1 0 1 1 1 0
LSB plane Middle Plane MSB Plane
LSB plane Middle Plane MSB Plane
Point
PointProcessing
Processing
6) Dynamic Range Compression (Log transformation):
6) Dynamic Range Compression (Log transformation):

s
s

r
 At times, dynamic range of imagerexceeds the capability of display device.
 At times, dynamic range of image exceeds the capability of display device.
 Some pixel values are so large that the other low value pixel gets obscured.

E.g. Some pixel
stars in dayvalues arenot
time are so large
visiblethat the other
though lowdue
present value pixel gets
to large obscured.
intensity of sun.
E.g. stars in day time are not visible though present due to large intensity of sun.
 Thus dynamic range needs to be compressed.
 Thus dynamic range needs to be compressed.
Point
PointProcessing
Processing
 Log operator is an excellent compression function.
 Log operator is an excellent compression function.

 Thus, Dynamic range compression is achieved using log operator.


 Thus, Dynamic range compression is achieved using log operator.

Formulation:
Formulation:
s = C.ln(1 + |r|)
s = C.ln(1 + |r|)where, C – normalization constant
where,r C
–– normalization
input intensity constant
r – input intensity
Point
PointProcessing
Processing
7) Power law Transform:
7) Power law Transform:

γ<1
γ <s1
γ=1 s
γ =γ1> 1
γ>1

r
r
f(x, y) = C .g(x, y)γ γ
f(x, y) = C .g(x, y)
s = C. rγ γwhere, C & γ are positive constants
s = C. r where, C & γ are positive constants
Point
PointProcessing
Processing
The Transformation is shown for different values of ‘γ’ which is also the gamma
The Transformation is shown for different values of ‘γ’ which is also the gamma
correction factor.
correction factor.

 By changing γ, we obtain the family of transformation curves.


 By changing γ, we obtain the family of transformation curves.

Nonlinearity encountered during image capturing, storing & displaying can be


Nonlinearity encountered during image capturing, storing & displaying can be
corrected using gamma correction.
corrected using gamma correction.

 Power Law Transform can be used to increase dynamic range of image.


 Power Law Transform can be used to increase dynamic range of image.
End of Point Processing
End of Point Processing

You might also like