EC8093 Unit 2
EC8093 Unit 2
Histogram Methods
Enhancement
Techniques
Frequency Domain
Spatial
Operates on FT of
Operates on pixels
Image
Chapter 2.1
SPATIAL DOMAIN
APPROACHES
SPATIAL DOMAIN APPROACHES
SPATIAL DOMAIN
POINT GLOBAL
MASK PROCESSING OPERATION
PROCESSING
Point Processing
Simplest kind of range transformations are these
independent of position x,y:
g = T(f)
Ex: Histogram
Equalization
Types of Spatial Domain Enhancement
Techniques
SPATIAL DOMAIN
Gray Level
Transformation
The negative of an image with gray levels in the range[0,L-1] is obtained by using
the negative transformation.
since the input image is an 8 bpp image, so the number of levels in this
image are 256. Putting 256 in the equation, we get this
s = 255 – r
So each value is subtracted by 255
Digital Negative
L
Negative
GAMMA=8
GAMMA=6
Piecewise linear transformation
• Principle Advantage: Some important transformations can be
formulated only as a piecewise function.
• Principle Disadvantage: Their specification requires more
user input that previous transformations
• Types:
Piecewise linear
transformation
7 6
5 4 3
2 1 0
Chapter 2.2
HISTOGRAM PROCESSING
Histogram
• Histogram of an image , like other histograms also shows frequency.
But an image histogram , shows frequency of pixels intensity values.
• In an image histogram, the x axis shows the gray level intensities
and the y axis shows the frequency of these intensities.
• Gray-level histogram is a function showing, for each gray level, the
number of pixels in the image that have that gray level.
• Normalized histogram (probability):
nk = hist[k ] =
( )
1
f x, y =k
pk = nk / N
• Application: X-ray of a bone of a body, computer vision.
38
Histogram Example
Types of image based on histogram components
Types of image based on histogram components
Histogram Equalization
• Histogram equalization:
– To improve the contrast of an image
– To transform an image in such a way that the transformed image has a
nearly uniform distribution of pixel values
• Transformation:
– Assume r has been normalized to the interval [0,1], with r = 0
representing black and r = 1 representing white
s = T (r ) 0 r 1
– The transformation function satisfies the following conditions:
• T(r) is single-valued and monotonically increasing in the interval 0 r 1
• 0 T (r ) 1 for 0 r 1
Histogram Equalization
• For Example:
Histogram Equalization
Leibniz’s Rule: State that the derivative integral with respect to its
upper limit is simply the integrand valuated at the
limit.
dr 1
p s ( s ) = pr ( r ) = pr ( r ) =1 0 s 1
ds pr ( r )
• In discrete version:
– The probability of occurrence of gray level rk in an image is
nk
pr ( r ) = k = 0,1,2,..., L − 1
n
n : the total number of pixels in the image
nk : the number of pixels that have gray level rk
L : the total number of possible gray levels in the image
– The transformation function is
k k nj
sk = T (rk ) = pr (rj ) = k = 0,1,2,..., L − 1
j =0 j =0 n
Example:
3. Find the value of zk for each value of sk using iterative scheme such
that,(G(zk)-sk)=0.
3. This function is finally used to map the gray level of the pixel
centered in the neighborhood.
4. Move the centre of the neighborhood and repeat the procedure.
HISTOGRAM STATISTICS FOR IMAGE ENHANCEMENT
i =0
where m is the mean value of r
L −1
m = ri p(ri )
i =0
i =0
where m is the mean value of r
L −1
m = ri p(ri )
i =0
mSxy = r
s ,tS xy
s ,t p (rs.t )
➢ The Local gray level variance mean of the pixels in region Sxy can be
computed as
S2 =
xy s,t S xy p(rs.t )
[ r − m
( s ,t )S xy
] 2
Use of histogram statistics for image enhancement
Example : Enhancement based on Local statistics
Use of histogram statistics for image enhancement
Example : Enhancement based on Local statistics
Use of histogram statistics for image enhancement
Example : Enhancement based on Local statistics
Image Enhancement Using Arithmetic and
Logical Operations
AND
OR
Image Subtraction
Example:1
Image Subraction
Example:1
g ( x, y ) = f ( x, y ) + ( x, y )
where f (x, y): an original image
( x, y ) : the addition of noise
• One simple way to reduce this granular noise is to take several
identical pictures and average them, thus smoothing out the
randomness.
Noise Reduction by Image Averaging
Example:Adding Gausian Noise
• This concept called convolution. Filter masks are sometimes called convolution
masks or convolution kernels. It can be written as
mn
R= z
( i =1)
i i
w(s, t ) f ( x + s, y + t )
g ( x, y ) = s = − at = − b
a b
w(s, t )
s = − at = − b
• Order-statistic filters
– Median filter: to reduce impulse noise (salt-and-
pepper noise)
Use of second Order derivatives for enhancement (or)
Laplacian Operators
2 f = [ f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1) + f ( x, y − 1)] − 4 f ( x)
Use of second Order derivatives for enhancement (or)
Laplacian Operators
Use of second Order derivatives for enhancement (or)
Laplacian Operators
→Eq.(3-7-5)
Use of First Order derivatives for enhancement (or)
Gradient Operators
1
f 2 f 2
1 2
f = mag(f ) = G + G 2 2 2
= +
x y
x y
f G x + G y
Robert’s Cross Operator
• The simplest approximations to a first-order
derivative that satisfy the conditions stated in that
section are
Gx = (z9-z5) and Gy = (z8-z6)
z1 z2 z3 f = ( z 9 − z 5 ) 2 + ( z8 − z 6 ) 2
z4 z5 z6 f z 9 − z 5 + z8 − z 6
z7 z8 z9 Roberts Cross Gradient Operators
Gx Gy
-1 0 0 -1
0
-1 -1 0
Sobel’s Operator
• Mask of even size are awkward to apply.
• The smallest filter mask should be 3x3.
• The difference between the third and first rows of the 3x3
mage region approximate derivative in x-direction, and the
difference between the third and first column approximate
derivative in y-direction.
f ( z7 + 2 z8 + z9 ) − ( z1 + 2 z 2 + z3 ) + ( z3 + 2 z6 + z9 ) − ( z1 + 2 z 4 + z7 )
-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1
Prewitt’s Operator
• Mask of even size are uncomfortable to implement.
• The smallest odd sized filter mask should be 3x3.
• The difference between the third and first rows of the 3x3 mage
region approximate derivative in x-direction, and the difference
between the third and first column approximate derivative in y-
direction.
f ( z7 + z8 + z9 ) − ( z1 + z2 + z3 ) + ( z3 + z6 + z9 ) − ( z1 + z4 + z7 )
-1 -1 -1 -1 0 1
0 0 0 -1 0 1
1 1 1 -1 0 1
Applications of gradient operators
• For automated inspection in industries
• For detection of defects
• To enhance small discontinuities
• To eliminate slowly changing background features
Use of First Order derivatives for enhancement (or)
Gradient Using Sobel Operators
Unsharp masking
• A process to sharpen images consists of subtracting a
blurred version of an image from the image itself. This
process, called unsharp masking, is expressed as
f s ( x, y ) = f ( x, y ) − f ( x, y )
f hb ( x, y ) = Af ( x, y ) − f ( x, y ) where A 1
f hb ( x, y ) = ( A − 1) f ( x, y ) + f ( x, y ) − f ( x, y )
f hb ( x, y ) = ( A − 1) f ( x, y ) + f s ( x, y )
0 -1 0 -1 -1 -1
-1 A+4 -1 -1 A+8 -1
0 -1 0 -1 -1 -1
Applications of Spatial enhancement filters
• Printing industry
• Image based product inspection
• Forensics
• Microscopy
• Surveillance
EC8093 DIGITAL IMAGE PROCESSING
UNIT 2 IMAGE ENHANCEMENT
PART 2
Chapter 2.4
Image Enhancement in the
Frequency Domain
Frequency Domain Processing
• Edges and sharp transitions (e.g., noise) in an image
contribute significantly to high-frequency content of FT.
• Low frequency contents in the FT are responsible to the
general appearance of the image over smooth areas.
• Blurring (smoothing) is achieved by attenuating range of
high frequency components of FT.
3
INTRODUCTION TO FOURIER TRANSFORM AND THE
FREQUENCY DOMAIN
M −1 N −1
1
F (u, v) =
MN
x =0 y =0
f ( x, y )e − j 2 (ux / M + vy / N )
Lowpass filter
Highpass filter
Some Basic Filters And Their Functions
Frequency Domain filters
• Types:
Frequency domain
filters
IFT: g(x,y)=F-1[G(U,V)]
• The simplest lowpass filter is a filter that “cuts off” all high-
frequency components of the Fourier transform that are at a
distance greater than a specified distance D0 from the origin of
the transform.
• The transfer function of an ideal lowpass filter
1 if D(u, v) D0
H (u, v) =
0 if D(u, v) D0
where D(u,v) : the distance from point (u,v) to the center of ther
frequency rectangle
1
D(u, v) = (u − M / 2) 2 + (v − N / 2) 2 2
Ideal Low Pass Filters(ILPFs)
• The simplest lowpass filter is a filter that “cuts off” all high-
frequency components of the Fourier transform that are at a
distance greater than a specified distance D0 from the origin of
the transform.
• The transfer function of an ideal lowpass filter
1 if D(u, v) D0
H (u, v) =
0 if D(u, v) D0
where D(u,v) : the distance from point (u,v) to the center of
ther frequency rectangle
1
D(u, v) = (u − M / 2) + (v − N / 2)
2 2 2
Ideal Low Pass Filters(ILPFs)
Ideal Low Pass Filters(ILPFs)
Ideal Low Pass Filters(ILPFs)
Ideal Low Pass
Filters(ILPFs):
Example
frequency
spatial
Butterworth Low Bass Filters with order n
1
H (u, v) =
1 + D(u, v) / D0
2n
Butterworth Lowpass
Filters (BLPFs)
n=2
D0=5,15,30,80,and 230
Butterworth Low Bass Filters(BLPFs)
Spatial Representation
− D 2 ( u ,v ) / 2 D02
H (u, v) = e
Gaussian Lowpass
Filters (FLPFs)
D0=5,15,30,80,and 230
Sharpening Frequency Domain Filters
H hp (u, v) = 1 − H lp (u, v)
Ideal highpass filter
0 if D(u, v) D0
H (u, v) =
1 if D(u, v) D0
− D 2 ( u ,v ) / 2 D02
H (u, v) = 1 − e
High pass Filters Spatial Representations
Ideal High pass Filters
0 if D(u, v) D0
H (u, v) =
1 if D(u, v) D0
Butterworth High pass Filters
1
H (u, v) =
1 + D0 / D(u, v)
2n
Gaussian High pass Filters
− D 2 ( u ,v ) / 2 D02
H (u , v) = 1 − e
Chapter-2.5
Homomorphic Filtering
Illumination-Reflectance model
• We can view an image f(x,y) as a product of two
components:
32
Homomorphic Filtering
• In some images, the quality of the image has reduced
because of non-uniform illumination.
• Homomorphic filtering can be used to perform
illumination correction.
f(x,y) = i (x,y) . r (x,y)
33
Homomorphic Filtering
Enhanced s(x,y)
image g(x,y) exp IDFT
34
Homomorphic Filtering
35
Homomorphic Filtering Procedure
• Step 1: ln→ F{ab} ≠ F {a} . F{b}
37
Homomorphic Filtering: Example 1
38
Homomorphic Filtering: Example 2
39
Advantages
• Good control over illumination and reflectance
components.