Professional Documents
Culture Documents
CoSc4113
Chapter 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 belows
diagram:Fourier Inverse Fourier
Transform Transform
2
3.1.1 Spatial Domain vs Transform Domain
g ( x, y ) T [ f ( x, y )]) (3.1-1)
f ( x, y ) : input image Spatial – Transform
g ( x, y ) : output image domain domain
3
Spatial Domain Process
4
Spatial Domain Process
- Contrast stretching, Thresholding
Intensity transformation
function
6
3.2.1 Image Negatives (p130)
Image negatives
intensity level s ( 0 ~ 255)
s L 1 r
Output image –
Input image –
intensity level r ( 0 ~ 255)
7
Image Negatives
Image negatives
s L 1 r
8
Example: Image Negatives
Ex:
w w=686
h
Ex:
h=790
Small
lesion
9
3.2.2 Log Transformations (p131)
Log Transformations
s c log(1 r )
10
Example: Log Transformations
11
3.2.3 Power-Law (Gamma) Transformations
s cr
12
Power-Law (Gamma) Transformations
void DibGammaCorrection(CDib& dib, float gamma)
{ register int i, j;
float invgamma = 1.f / gamma;
s cr
13
Example: Gamma Corrections - p134
s=r2.5
s=r0.5
s=r2.5
14
Example: Gamma Transformations
Cathode ray tube
(CRT) devices have an
s=r2.5 intensity-to-voltage
response that is a
power function, with
exponents varying
from approximately
s r1/2.5 1.8 to 2.5
s=r0.4
s=r2.5
15
Example: Gamma Transformations
s=r0.6
(a) original
16
s=r0.4 s=r0.3
Example: Gamma Transformations
s=r3.0
s=r4.0
s=r5.0
17
Piecewise-Linear Transformations
► Contrast Stretching
— Expands the range of intensity levels in an image so that it spans
the full intensity range of the recording medium or display device.
► Intensity-level Slicing
— Highlighting a specific range of intensities in an image often is of
interest.
18
pollen 꽃가루 , x700
19
Highlight the major
blood vessels and
study the shape of the
flow of the contrast
medium (to detect
blockages, etc.)
21
Bit-plane Slicing
22
Bit-plane Slicing
Bit 8, 7 Bit 8, 7, 6 Bit 8, t, 6, 5
23
► Experiment 3.1
image negative
Contrast stretching
24
3.3 Histogram Processing (p142)
► 3.3.1 Histogram Equalization
25
Histogram Processing
Histogram h( rk ) nk n0 n1 n2
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
29
30
3.3.1 Histogram Equalization
The intensity levels are assumed in the interval [0, L-1]. ex. [0, 255]
r : input variable – intensity level of input image, s: the output variable for output image
Relation between r and s is transformation function T. Then ..
s = T (r) 0<= r <= L -1 (3.3-1)
that produce an output intensity level s for every pixel in input image having intensity r. We
assume that:
(a) T( r) is a “monotonically increasing function” in 0 <= r <=L-1; and
(b) 0 <= T( r) <= L-1 for 0 <= r <=L-1
Then, We use the inverse
r = T-1 ( s) 0<= s <=L-1 (3.2-2)
In which case we change the condition (a) to (a’) :
(a’) T( r) is a “strictly monotonically increasing function” in 0 <= r <=L-1;
Condition (a’) guarantees that the mapping from s back to r will be one-to-on, preventing ambiguities.
(page 144)
T(r)
T(r)
r r
31
Histogram Equalization
3.3.1 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)
32
Histogram Equalization (page 146)
( L 1) pr ( r ) (3.3 5)
We see that as (eq. 3.3-6) shows, the resulting ps(s) always is uniform,
33
independently of the form of pr(r). Fig 3.18 ilustrates these concepts:
Histogram Equalization
Exercise 3.4: Illustration of eqs. (3.3-4) and (3.3-6)
• Suppose that the intensity values in an image have the PDF
2r
pr ( r ) ( L 1) 2 for 0 r L 1
0 otherwise r
• From eq. (3.3-4) 2
r
s T (r ) ( L 1) pr ( w)dw
2 r 2 w r
2
L 1 0
w dw
L 1 L 1
2
0
ds
1
2r dr
( L 1) 2
ds
1
2r d r 2
( L 1) 2 dr L 1
2r L 1
( L 1) 2 2r
1
L 1 34
• As expected, the result ps (s) is a uniform PDF and independent of the form of p r(r)
Histogram Equalization
Exercise 3.4: Illustration of eqs. (3.3-4) and (3.3-6)
• Suppose that the intensity values in an image have the PDF
2r
pr ( r ) ( L 1) 2 for 0 r L 1
0 otherwise r
• From eq. (3.3-4) 2
r
s T (r ) ( L 1) pr ( w)dw
2 r 2 w r
2
L 1 0
w dw
L 1 L 1
2
0
ds
1
2r dr
( L 1) 2
ds
1
2r d r 2
( L 1) 2 dr L 1
2r L 1
( L 1) 2 2r
1
L 1 35
• As expected, the result ps (s) is a uniform PDF and independent of the form of p r(r)
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 36
Example 3.5 : Histogram Equalization ★★★
(page 148)
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has
the intensity distribution shown in following table.
Get the histogram equalization transformation function and give the ps(sk)
for each sk.
37
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
3
1
s1 T ( r1 ) 7 pr ( rj ) 7 (0.19 0.25) 3.08
j 0
s2 4.55 5 s3 5.67 6
s4 6.23 6 s5 6.65 7
s6 6.86 7 s7 7.00 7
38
Example: Histogram Equalization
39
Histogram Equalization Ex3.5
“lenna.bmp” image
and histogram
“lenna.bmp” image
after histogram
equalization
43
Histogram Equalization
Input image vs Histogram equalized image
11.08
“camera man” image
and histogram
44
Histogram Equalization
Histogram equalization does not give us always better images.
45
46
Question
Is histogram equalization always good?
No
47
Histogram Matching (Specification)
Histogram matching (histogram specification)
— generate a processed image that has a specified histogram
1
z G (s) G 1
T (r ) (3.3-11)
49
Histogram Matching: Procedure
1) Obtain pr(r) from the input image and then obtain the values of s
r
s ( L 1) pr ( w)dw (3.3-13)
0
2) Use the specified PDF and obtain the transformation function G(z)
z
G ( z ) ( L 1) pz (t )dt s (3.3-14)
0
4) inverse transformation process : Obtain the output image by first equalizing the
input image using eq. (3.3-10); the pixel values in this image are the s values.
Perform the inverse mapping z = G-1(s) to obtain the corresponding pixel in
output image. The PDF of the output image will be the specified PDF.
z G 1 ( s ) (3.3-16) 50
Histogram Matching: Example 3.7 (page 153)
0, otherwise
Find the transformation function that will produce an image
whose intensity PDF is
3z 2
, for 0 z ( L -1)
pz ( z ) ( L 1) 3
0, otherwise
51
Histogram Matching: Example
1) Find the histogram equalization transformation for the input image
r
s T (r ) ( L 1) pr ( w)dw ( L 1)
r 2w r2
dw
0 0 ( L 1) 2
L 1
2) Find the histogram equalization transformation for the specified histogram
z z 3t 2 z3
G ( z ) ( L 1) pz (t )dt ( L 1) dt s
0 0 ( L 1) 3
( L 1) 2
52
Example: Histogram Matching
53
Example: Histogram Matching
55
Local Histogram Processing
11/15
Define a neighborhood and move its center from pixel to
pixel
56
Local Histogram Processing: Example
(P 161)
57
3.3.4 Using Histogram Statistics
for Image Enhancement
Average Intensity L 1 M 1 N 1
1
m ri p (ri )
MN
f ( x, y )
x 0 y 0
i 0
L 1
un (r ) (ri m) n p (ri )
i 0
Variance L 1 M 1 N 1
1
u2 (r ) (ri m) p (ri ) f ( x, y ) m
2 2 2
i 0
MN x 0 y 0
58
Using Histogram Statistics
for Image Enhancement
The nth moment of r about its mean: (from section 2.6.8)
L 1
un (r ) (ri m) n p (ri )
i 0
Average Intensity m:
L 1 M 1 N 1
1
m ri p (ri )
MN
f ( x, y )
x 0 y 0
i 0
Variance = the second moment:
L 1 M 1 N 1
1
u2 (r ) (ri m) p(ri ) f ( x, y ) m
2 2 2
MN x 0 y 0
i 0
59
Spatial Filtering
A spatial filter consists of
(a) a neighborhood, and
(b) a predefined operation
Spatial filter
mask
Image section
under filter 61
Spatial Correlation
a=(m-1)/2, b=(m-1)/2
Ex) an image of size MxN with a filter of size mxn
m=3, n=3 a=(3-1)/2= 2/2=1, b=1
62
Spatial Convolution
a b
w( x, y ) f ( x, y ) w( s, t ) f ( x s, y t )
s a t b
1, 0, w( 1, 0) f(x-1, y)
Smoothing Spatial Filters
64
Spatial Smoothing Linear Filters
w(s, t ) f ( x s, y t )
g ( x, y ) s a t b
a b
w(s, t )
s a t b
where m 2a 1, n 2b 1.
65
Two Smoothing Averaging Filter Masks
66
Example: Gross Representation of Objects
67
Order-statistic (Nonlinear) Filters
— Nonlinear
69
Sharpening Spatial Filters
► Foundation
► Laplacian Operator
70
Sharpening Spatial Filters: Foundation
f
f ( x 1) f ( x)
x
2 f
f ( x 1) f ( x 1) 2 f ( x)
x 2
71
72
Sharpening Spatial Filters: Laplace Operator
g ( x, y ) f ( x, y ) c 2 f ( x, y )
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
c -1 if 2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c 1 if either of the other two filters is used.
73
74
Unsharp Masking and Highboost Filtering
► Un sharp masking
Sharpen images consists of subtracting an unsharp (smoothed)
version of an image from the original image
e.g., printing and publishing industry
► Steps
1. Blur the original image
75
Unsharp Masking: Demo
76
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
77
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
78
Thank You
79