0% found this document useful (0 votes)
44 views56 pages

UNIT 2 Image Enhancement in Spatial Domain and Frequency Domain - 1

The document discusses image enhancement techniques in both spatial and frequency domains, focusing on methods to improve image suitability for specific applications. It covers various operations such as point processing, neighborhood processing, and different gray level transformations including contrast stretching and histogram equalization. Additionally, it explains the mathematical foundations of these techniques, including probability density functions and cumulative distribution functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views56 pages

UNIT 2 Image Enhancement in Spatial Domain and Frequency Domain - 1

The document discusses image enhancement techniques in both spatial and frequency domains, focusing on methods to improve image suitability for specific applications. It covers various operations such as point processing, neighborhood processing, and different gray level transformations including contrast stretching and histogram equalization. Additionally, it explains the mathematical foundations of these techniques, including probability density functions and cumulative distribution functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

EC 703:

Image Processing and


Computer Vision

By:
Dr. Hemant S. Goklani
ECE Department
IIIT, Surat
UNIT 2
Image Enhancement in Spatial Domain
and Frequency Domain

UNIT2_1:
Image Enhancement in the Spatial Domain
Image Enhancement
 Goal: process an image so that the result is more
suitable than the original image for a specific
application
 Visual interpretation
 Problem oriented
Image enhancement example
Two categories
 There is no general theory of image
enhancement
 Spatial domain
 Direct manipulation of pixels
 Point processing
 Neighborhood processing
 Frequency domain
 Modify the Fourier transform of an image
Outline: spatial domain operations
 Background
 Gray level transformations
 Arithmetic/logic operations
Background
 Spatial domain processing
 g(x,y)=T[ f(x,y) ] f(x,y) g(x,y)
T
 f(x,y): input image

 g(x,y): output image

 T: operator

 Defined over some neighborhood of (x,y)


Background (cont.)

* T applies to each pixel


in the input image

* T operates over
neighborhood of (x,y)
Point processing
 1x1 neighborhood
 Gray level transformation, or point processing

 s = T(r) Where r is values of pixel before process


 s is values of pixel after process
 T is a transformation that maps a pixel value
r into a pixel value s.

contrast
stretching thresholding
Neighborhood processing
 A larger predefined neighborhood
 Ex. 3x3 neighborhood
 mask, filters, kernels, templates, windows
 Mask processing or filtering
Some Basic Gray Level Transformations

 Image negatives (complement)


 Log transformation
 Power-law transform
 Piece-wise linear transform
 Gray level slicing
 Bit plane slicing
Some gray level transformations

•Lookup table
•Functional form
Image Negatives
 The negative of an image with gray L levels is
given by the expression

s=L–1–r
Where r is value of input pixel, and
s is value of processed pixel
Suitable for images with dominant black areas
Log Transformations
 The general form of the log transformation shown
in

s = c log(1+r)

Where c is constant, and it is assumed that r  0

Compress the dynamic range of images with large variation


in pixel values
C = 1.0

C = 0.8
Example: Log transformations
 log(fft2(I)) : log of Fourier transform

log

2d Fourier transform
Exponential Transformations
 The general form of the log transformation
shown in

s = c exp(r)

Where c is constant, and it is assumed that r  0


C = 1.0

C = 0.8
Power-Law Transformations
 Power-law transformations have the basic form


s  cr
Where c and  are positive constant.

 Sometime above Equation is written as



s  c(r   )
 = 0.5

 = 1.0

 = 5.0
>1
<1
: gamma display, printers, scanners follow power-law
Gamma correction
Example: Gamma correction

 CRT: intensity-to- =2.5


voltage response
follow a power-law.
1.8<<2.5
=1/2.5
=2.5
Power-law: <1

 Expand dark gray


levels

=0.6

=0.4 =0.3
Power-law: >1

 Expand light
gray levels

=3

=4 =5
Piece-wise linear transformations
control point

 Advantage: the
piecewise function
can be arbitrarily
complex
Contrast Stretching
 Low contrast image can result from poor illumination,
lack of dynamic range in the imaging sensor, or even
wrong setting of a lens aperture during image
acquisition.
 The idea behind the contrast stretching is to increase
the dynamic range of the gray levels in the image being
processed.
Contrast Stretching
L-1 (r2,s2)  The location points (r1,s1)
Output and (r2,s2) control the shape
Gray level of the transformation function
s
T(r)
0 (r1,s1)  If r1=s1 and r2=s2, the
0 L-1 transformation is a linear
Input gray level, r function that produces no
changes in gray levels

 If r1=r2, s1=0 and s2=L-1 the transformation becomes


thresholding function that creates a binary image

 Intermediate values of (r1,s1) and (r2,s2) produces


various degrees of spread in the gray levels of the output image,
Gray level slicing

Output L-1 L-1


Gray level Output D T(r)
T(r)
s D Gray level
s
C
0 0
0 A B L-1 0 A B L-1
Input gray level, r Input gray level, r

• Highlighting a specific range of gray levels in an image often is


desired
•Applications include enhancing features such as masses of
water in satellite imagery and enhancing flows in X-rays images.
Contrast
stretching
Contrast Streching
Gray-level slicing
 Highlighting a specific range of gray levels
Bit-plane slicing
 Instead of highlighting gray level ranges, highlighting
the contribution made to total image appearance by
specific bits might be desired.

 Suppose that each pixel in the image is represented by


8-bits. Imagine that the image is composed off eight 1-
bit planes, ranging from bit-plane 0 for the least
significant bit to bit plane 7 for most significant bit
Bit-plane slicing
* Highlight specific bits

1
0
0
1
0
1
0
0
Ex. 15010 bit-planes of an image
(gray level 0~255)
Bit-plane slicing: example
For image
compression

7 6

5 4 3

2 1 0
Histogram Processing
 The histogram of a digital image with gray levels in
the range [0,L-1] is a discrete function
h(rk )  nk

Where, rk is the kth gray level and


nk is the number of pixels in the image having gray level rk

 In an image processing context, the histogram of an image


normally refers to a histogram of the pixel intensity values
 This histogram is a graph showing the number of pixels in an
image at each different intensity value found in that image
HISTOGRAM
pixels
130

36 36
22

0 1 2 3 level
Image 16 x 14 = 224 pixels
Histogram
The (intensity or brightness) histogram shows how many
times a particular grey level (intensity) appears in an image.
For example, 0 - black, 255 – white
7

0 1 1 2 4 6
5

2 1 0 0 2 4
3

5 2 0 0 4 2
1

1 1 2 4 1 0
0 1 2 3 4 5 6

image histogram
Image Histograms
x-axis – values of intensities
y-axis – their frequencies
Histogram Processing
Histogram h(rk )  nk
rk is the k th intensity value
nk is the number of pixels in the image with intensity rk

nk
Normalized histogram p( rk ) 
MN
nk : the number of pixels in the image of
size M  N with intensity rk
Histogram Processing
 Histogram Equalization

 Histogram Matching(Specification)

 Local Enhancement
Fundamental of random variable
 PDF (Probability Density Function) is the
probability of each element
 CDF (Cumulative Distribution Function) is
summation of the probability of the element
that value less than or equal this element
PDF
 The PDF (probability density function) is denoted
by p(x)

pdf

1/6

1 2 3 4 5 6
CDF
 The CDF (cumulative density function) is
denoted by P(x)

cdf
1

1/6
1 2 3 4 5 6
Relation between PDF and CDF

 PDF can find from this equation

d [ P( x)]
p ( x)   P( x)
dx
 CDF can find from this equation
xn

P ( x  xn )   p( x)dx
x  x0
Histogram Equalization

 We focus attention on transformations of the


form
s  T (r ) where 0  r  1
That produce a level s for every pixel value r in the
original image.

And we assume that the transformation function T(r)


satisfies the following conditions:
(a) T(r) is single-valued and monotonically increasing
in the interval 0 ≤ r ≤ L - 1; and
(b) 0 ≤ T(r) ≤ L - 1 for 0 ≤ r ≤ L - 1
Reason of Condition
 The requirement in (a) that T(r) be single valued is
needed to guarantee that the inverse transformation
will exist, and the monotonicity condition preserves the
increasing order from black to white in the output
image
 Condition (b) guarantees that the output gray levels will
be in the same range as the input levels
Transformation function

Level s

sk=T(rk) T(r)

Level r
0 rk 1
Note

 The inverse transformation from s back to r is denoted

1
s  T (r ) where 0  r  1

There are some cases that even if T(r) satisfies conditions


(a) and (b), it is possible that the corresponding inverse
T-1(s) may fail to be single valued.
Idea of Histogram Equalization

 The gray levels in an image may be viewed as random


variables in the interval [0,1]
Let pr(r) denote the pdf of random variable r and
ps(s) denote the pdf of random variable s; if pr(r) and T(r) are
known and T-1(s) satisfies condition (a), the formula should be

dr
p s ( s )  pr ( r )
ds
r
s  T (r )   pr ( w)dw
0
Idea of Histogram Equalization

 By Leibniz’s rule that the derivative of a definite


integral with respect to its upper limit is simply the
integrand evaluated at that limit

ds dT (r )

dr dr
d  
r
   pr ( w)dw
dr  0 
 pr ( r )
Idea of Histogram Equalization

 Substituting into the first equation

dr
p s ( s )  pr ( r )
ds
1
 pr ( r )
pr ( r )
 1, 0  s  1
Idea of Histogram Equalization

 The probability of occurrence of gray level rk in an


image is approximated by
nk
pk (rk )  k  0,1,2,..., L  1
n
k
sk  T (rk )   pr (rj )
j 0
k nj
 k  0,1,2,..., L  1
j 0 n
Histogram Equalization
THANK YOU

You might also like