Lec 3
Lec 3
Transform domain
This method transforms the input images into a transform domain,
processes some operation in the domain, and applies the inverse transform to
return to the spatial domain as shown in below diagram:
3
Spatial Domain vs Transform Domain
g ( x, y ) T [ f ( x, y )])
f ( x, y ) : input image Spatial – Transform
g ( x, y ) : output image domain domain
4
Spatial Domain Process
5
Spatial Domain Process
- Contrast stretching, Thresholding
6
Basic Intensity Transformation Functions
Intensity transformation
function
7
Image Negatives (p130)
intensity level s ( 0 ~ 255)
Image negatives
s L 1 r
Output image –
r=0 s= (256-1)-0
=255
r=128 s=(256-1)-128
=127
r=255 s=(256-1)-255 = 0
Input image –
intensity level r ( 0 ~
255) 8
Image Negatives
Image negatives
s L 1 r
9
Example: Image Negatives
Ex:
w w=686
h
Ex:
h=790
Small
lesion
10
Log Transformations (p131)
Log Transformations
s c log(1 r )
11
Example: Log Transformations
12
Power-Law (Gamma) Transformations
s cr
13
Power-Law (Gamma) Transformations
void DibGammaCorrection(CDib& dib, float gamma)
{ register int i, j;
float invgamma = 1.f / gamma;
}
s cr
14
Example: Gamma Corrections - p134
s=r2.5
s=r0.5
s=r2.5
15
Example: Gamma Transformations
Cathode ray tube
(CRT) devices have
s=r2.5 an intensity-to-
voltage response
that is a power
function, with
exponents varying
s r1/2.5 from approximately
1.8 to 2.5
s=r0.
4 s=r2.5
16
Example: Gamma Transformations
s=r0.6
(a) original
17
s=r0.4 s=r0.3
Example: Gamma Transformations
s=r3.0
s=r4.0
s=r5.0 18
Exercise
– Image negative
19
Spatial Filtering (p 166)
20
Spatial Filtering (p 166)
• Linear spatial filtering of an image of size MxN with a filter of size mxn is
given by the expression
a b
g ( x, y ) w(s, t ) f ( x s, y t )
s a t b
Here,
a=(m-1)/2, b=(n-1)/2
Spatial
filter mask
Image section
under filter
22
Spatial Correlation
24
Histogram Processing (p142)
• Histogram Equalization
• Histogram Matching
25
Histogram Processing
n0 n1 n2
Histogram h( rk ) nk
0 1 2 3 ..... 254 255
nk
Normalized histogram p( rk )
MN
nk : the number of pixels in the image of
size M N with intensity rk
26
Histogram Processing
• Exercise:
27
Histogram Processing
28
29
Histogram Equalization
histogram equalization
• Probability theory: (page 145)
If pr(r) and T(r) are known, and T(r) is continuous and differentiable
over the range of values of interest,
then the PDF of the transformed (mapped) variable s can be obtained
using: dr
p s ( s ) pr ( r ) (3.3 3)
ds
• The PDF of the output intensity variable s is determined by the PDF of input r and
the transformation function [ recall that r and s are related by T( r)].
r
s T (r ) ( L 1) pr ( w)dw (3.3 4)
0
The right side of this equation is CDF (Cumulative distribution function)
of random variable r.
1) Transformation function of e.q. 3.3-4 satisfies condtion (a)
because the area under the function cannot decrease as r increases
2) When the upper limit of this eq. is r=(L-1), the integral evaluates to 1,
this satisfies condition (b)
30
Histogram Equalization (page 148)
nk
Normalized histogram p( rk )
MN
nk : the number of pixels in the image of
size M N with intensity rk
Continuous case:
r
s T ( r ) ( L 1) pr ( w) dw Eq. (3.3-4)
0
The right side of the eq. is recognized as the cumulative distribution
function (CDF) of random variable r.
Discrete values:
k
sk T ( rk ) ( L 1) pr ( rj ) Eq. (3.3-8)
j 0
k nj L 1 k
( L 1) nj k=0,1,..., L-1
j 0 MN MN j 0
31
Example 3.5 : Histogram Equalization ★★★
(page 148)
32
Example: Histogram Equalization
• Use eq. 3.3-8 for sk :
Discrete values:
k
sk T ( rk ) ( L 1) pr ( rj ) Eq. (3.3-8)
j 0
Solution:
0
s0 T (r0 ) 7 pr (rj ) 7 0.19 1.33 1
j 0
1
s1 T ( r1 ) 7 pr ( rj ) 7 (0.19 0.25) 3.08
j 0
3
s2 4.55 5 s3 5.67 6
s4 6.23 6 s5 6.65 7
s6 6.86 7 s7 7.00 7
33
Example: Histogram Equalization
34
Histogram Equalization Ex3.5
Exercise:
37
Histogram Equalization
Input image vs Histogram equalized image
“lenna.bmp”
image and
histogram
“lenna.bmp”
image after
histogram
equalization
38
Histogram Equalization
Input image vs Histogram equalized image
11.08
“camera man”
image and
histogram
39
Histogram Equalization
Histogram equalization does not give us always better images.
“child” image
after histogram
equalization
40
Question
Is histogram equalization always good?
No
41
Thank You !!!
42