You are on page 1of 49

Digital Image Processing, 3rd ed.

Gonzalez & Woods


www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Intensity transformation T maps the


intensity r0 of a pixel, P, to a new
intensity value s0=T(r0 ).
The mapping is performed using a
transfer function
T

Examples of two transfer functions


• Transformation function does not
take into the intensity of adjacent
pixels.
• It does not increase the number of
intensity values available.
© 1992–2008 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Spatial Filter F maps the intensity Ii of


a pixel, Pi, to a new intensity value
based on its neighborhood.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Example of Intensity Transformations.


• They map L intensity values
a new L intensity value s0

r0
© 1992–2008 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Intensity transformation – Negative


Original mammogram (left) and
the negated mammogram

s0

0 r0 L

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Intensity transformation – Log


Original Fourier spectrum (left) and
the log transformed spectrum (right)
with c = 1

s  c log(1 r)

s0

r0
© 1992–2008 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Power-Law (Gamma) Transformations

s  cr
Where c and γ are positive constants.

It also sometime written as:

s  c(r   )

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Gamma correction
 Gamma correction aims to improve
the correctness of an image when
display on a screen.
 Gamma correction controls the
overall brightness of an image.
 Incorrect images can look
either bleached out, or too
dark.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Gamma correction

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Image Histogram
The image histogram of a digital image with intensity
levels in the range [0,L-1] is a discrete function
h(rk) =nk , where rk is the kth intensity value and nk is
the number of pixels in the image with the intensity rk

Histogram Normalization
It is common to normalize the histogram by dividing
nk by the number of pixels in the image.
The normalized intensity p(rk)= nk /MN estimates the
probability of occurrence of intensity level rk in an
image

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Histogram Equalization

In general we assume
1. T(r) is monotonically increasing
2. 0 ≤ T(r) ≤ L-1 for 0 ≤ r ≤ L-1

Let pr(r) and ps (s) be a probability


density functions. If we assume pr(r) and
T(r) are know, the

dr
p s(s)  p r(r) ds

Image processing interests on the following


formulation, where the right side is the
cumulative distribution
r
function
s  T (r)  (L 1) pr (w)dw
0

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

r
ds dT (r) d  pr (w)dw   (L
dr  dr  (L 1)
r
dr 0 1) p (r)
Use the previous formulation yields, a uniform
probability density function
1  1
dr 
ps(s)  p r(r) ds  p r(r)  

 (L 1) pr (r)  L
Histogram equalization 1 determine the
transformation that seek to produce an
output image that has a uniform histogram.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Histogram Equalization
In the discrete case

k k

k k r j (L 1) j
s  T (r )  (L 1)j
0 p (r )  MN 
j n ; k  0,1,2,.., L
0
1

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Histogram Matching
Let us assume histograms are continuous functions, and let T(r) defined as earlier and G(z)
defined similarly, then
r z
s  T (r)  (L 1) pr And s  G(z)  (L
(w)dw 1) pz (t)dt
0 0
Since T(r) = G(z), then
z  Gshows
This 1
[T (r)]
thatthat
G 1an
(s)image whose intensity levels have a specific probability density
function can be obtained as follow:
1. Obtain pr(r) from the input image and determine the value of s (as above)
2. Use a specified PDF to obtain the transformation function G(z)
3. Compute the inverse transformation z=G-1(s)
4. Obtain the output image by first equalizing the input image (intensity are the s values)
for each intensity (s value) perform the inverse mapping z = G-1(s) to obtain the
corresponding pixel in the output image

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering
Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Spatial Filtering
Applying a 3x3 filter ,w, on the image f
1 1
g(x, y)    w(i, j) f (x  i, y  j)
i1 j 1

Applying a general (2ax2b) filter ,w, on the


image f
a b
g(x, y)    w(i, j) f (x
 i, y  j)
i a j b

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Correlation
Is the process of moving a filter mask
over the image and computing the sum
of products at each location.

Convolution
moves the reversed filter mask over
the image and computing the sum of
products at each location.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

Correlation and Convolution in the


2D space.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

3x3 Spatial filters, which result in a blurring effect. The


blurring depends on the ration between the central value
and the “boundary” values.

The effect of applying averaging filters of size 3,5,9, 15,


and 35.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

In many application we often


apply multiple filters and
some of them may appear
contradicting from the first
glance.

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

First & Second Derivatives


• Let us consider a vertical cut on the
first two images

• The function we get are below each


images

• The first derivative

• Second Derivative

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods


Digital Image Processing, 3rd ed.
Gonzalez & Woods
www.ImageProcessingPlace.com

Chapter 3
Intensity Transformations & Spatial Filtering

© 1992–2008 R. C. Gonzalez & R. E. Woods

You might also like