Tải bản đầy đủ

Lecture 03,04,05 intensity transformation and spatial filtering

Intensity transformation and spatial filtering

Digital Image Processing
Lecture 3 – Intensity
Transformation& Spatial Filtering
Lecturer: Ha Dai Duong
Faculty of Information Technology

I. Introduction
„

Spatial Domain vs. Transform Domain
‰

Spatial Domain
„

‰

Image plane itself, directly process the intensity values of the
image plane


Transform (Frequency) domain
„

Process the transform coefficients, not directly process the
intensity values of the image plane

Digital Image Processing

2

1


Intensity transformation and spatial filtering

I. Introduction
„

Spatial Domain Process

g ( x, y ) = T [ f ( x, y )])
f ( x, y ) : input image
g ( x, y ) : output image
T : an operator on f defined over
a neighborhood of point ( x, y )

Digital Image Processing

3

I. Introduction
„

Spatial Domain Process

Digital Image Processing

4

2


Intensity transformation and spatial filtering

II. Intensity transformation function
Intensity transformation function
s = T (r )

5

Digital Image Processing

II. Intensity transformation function
„

Some
basic
Functions

Digital Image Processing

intensity

transformation

6

3


Intensity transformation and spatial filtering

II.1. Negative
Image negatives
s = L −1− r

Digital Image Processing

7

II.1. Negative

Small
lesion

Digital Image Processing

8

4


Intensity transformation and spatial filtering

II.2. Log Transform
Log Transformations
s = c log(1 + r )

Digital Image Processing

9

II.2. Log Transform

Digital Image Processing

10

5


Intensity transformation and spatial filtering

II.3. Power – Law

s = cr γ

Digital Image Processing

11

II.3. Power – Law

Digital Image Processing

12

6


Intensity transformation and spatial filtering

II.3. Power – Law

Digital Image Processing

13

II.4. Piecewise-Linear Transform..
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

Digital Image Processing

14

7


Intensity transformation and spatial filtering

II.4. Piecewise-Linear Transform…

Digital Image Processing

15

Digital Image Processing

16

8


Intensity transformation and spatial filtering

II.5. Bit – Plane Slicing

Digital Image Processing

17

II.5. Bit – Plane Slicing

Digital Image Processing

18

9


Intensity transformation and spatial filtering

III. Histogram processing
„
„
„
„

Histogram Equalization
Histogram Matching
Local Histogram Processing
Using
Histogram
Statistics
Enhancement

Digital Image Processing

for

Image

19

III. 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
MN
nk : the number of pixels in the image of
Normalized histogram p (rk ) =
size M × N with intensity rk
Digital Image Processing

20

10


Intensity transformation and spatial filtering

III. Histogram processing
No. of pixels
6

2

3

3

2

4

2

4

3

3

2

3

5

2

4

2

4

4x4 image
Gray scale = [0,9]

5
4
3
2
1

Gray level
0 1 2 3 4 5 6 7 8 9

Digital Image Processing

histogram
21

III. Histogram processing

Digital Image Processing

22

11


Intensity transformation and spatial filtering

III.1. Histogram Equalization
„

„

As the low-contrast image’s histogram is narrow
and centered toward the middle of the gray scale,
if we distribute the histogram to a wider range the
quality of the image will be improved.
We can do it by adjusting the probability density
function of the original histogram of the image so
that the probability spread equally

23

Digital Image Processing

III.1. Histogram Equalization
„

Histogram transformation
s = T(r)

s
„
„

Where 0 ≤ r ≤ 1
T(r) satisfies
‰

sk= T(rk)
T(r)

‰

0

rk

Digital Image Processing

1

(a). T(r) is single-valued
and monotonically
increasingly in the interval
0≤r≤1
(b). 0 ≤ T(r) ≤ 1 for
0≤r≤1

r
24

12


Intensity transformation and spatial filtering

III.1. Histogram Equalization
„

2 conditions of T(r)
‰

‰

‰

‰

Single-valued (one-to-one relationship) guarantees that
the inverse transformation will exist
Monotonicity condition preserves the increasing order from
black to white in the output image thus it won’t cause a
negative image
0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1 guarantees that the output gray
levels will be in the same range as the input levels.
The inverse transformation from s back to r is
r = T -1(s) ; 0 ≤ s ≤ 1
25

Digital Image Processing

III.1. Histogram Equalization
„

Let
‰
‰

„

pr(r) denote the PDF of random variable r
ps(s) denote the PDF of random variable s

If pr(r) and T(r) are known and T-1(s) satisfies
condition (a) then ps(s) can be obtained using a
formula :

ps(s) = pr(r)
Digital Image Processing

dr
ds
26

13


Intensity transformation and spatial filtering

III.1. Histogram Equalization
„

A transformation function is a cumulative distribution
function (CDF) of random variable r :
r

s = T ( r ) = ∫ pr ( w )dw
0

‰

‰
‰
‰

CDF is an integral of a probability function (always positive) is the
area under the function
Thus, CDF is always single valued and monotonically increasing
Thus, CDF satisfies the condition (a)
We can use CDF as a transformation function

27

Digital Image Processing

III.1. Histogram Equalization
ds dT ( r )
=
dr
dr
r

d ⎡
p
(
w
)
dw
=
⎢ r

dr ⎣ ∫0

= pr ( r )

p s ( s ) = pr ( r )

Substitute and yield

Digital Image Processing

= pr ( r )

dr
ds
1
pr ( r )

= 1 where 0 ≤ s ≤ 1
28

14


Intensity transformation and spatial filtering

III.1. Histogram Equalization
„

Ps(s):
‰

‰
‰

As ps(s) is a probability function, it must be zero outside
the interval [0,1] in this case because its integral over all
values of s must equal 1.
Called ps(s) as a uniform probability density function
ps(s) is always a uniform, independent of the form of
pr(r)

29

Digital Image Processing

III.1. Histogram Equalization
„

Discrete Transformation Function
‰

‰

The probability of occurrence of gray level in an image
is approximated by
n
where k = 0 , 1 , ..., L- 1
p r ( rk ) = k
n
The discrete version of transformation
s k = T ( rk ) =
=

Digital Image Processing

k

nj

j=0

n



k



j=0

pr ( rj )

where k

= 0 , 1 , ..., L- 1
30

15


Intensity transformation and spatial filtering

III.1. Histogram Equalization
„

„

Thus, an output image is obtained by mapping
each pixel with level rk in the input image into a
corresponding pixel with level sk in the output
image
In discrete space, it cannot be proved in general
that this discrete transformation will produce the
discrete equivalent of a uniform probability density
function, which would be a uniform histogram

31

Digital Image Processing

III.1. Histogram Equalization
„

Example

before

Digital Image Processing

after

Histogram
equalization

32

16


Intensity transformation and spatial filtering

III.1. Histogram Equalization
„

Example
before

after

Histogram
equalization

The quality is
not improved
much because
the original
image already
has a broaden
gray-level scale
33

Digital Image Processing

III. Histogram processing
No. of pixels
6

2

3

3

2

4

2

4

3

3

2

3

5

2

4

2

4

4x4 image
Gray scale = [0,9]
Digital Image Processing

5
4
3
2
1

Gray level
0 1 2 3 4 5 6 7 8 9

histogram
34

17


Intensity transformation and spatial filtering

III.1. Histogram Equalization
„

Example

Gray Level

0

1

2

3

4

5

6

7

8

9

No.of pixels

0

0

6

5

4

1

0

0

0

0

0

0

6

11

15

16

16

16

16

16

0

0

0

0

k



n

j=0

k

s=∑
j =0

j

nj
n

sx9

6/
16

3.3
≈3

11 /
15 /
16 /
16/
16/
16/
16/
16
16
16
16
16
16
16

6.1
≈6

8.4
≈8

9

9

9

9

9
35

Digital Image Processing

III.1. Histogram Equalization
„

Example

No. of pixels

3

6

6

3

8

3

8

6

6

3

6

9

3

8

3

8

Output image
Gray scale = [0,9]
Digital Image Processing

6
5
4
3
2
1
0 1 2 3 4 5 6 7 8 9

Gray level
Histogram equalization
36

18


Intensity transformation and spatial filtering

III.2. Histogram Matching
„

Generate a processed image that has a specified
histogram
Let pr ( r ) and pz ( z ) denote the continous probability
density functions of the variables r and z. pz ( z ) is the
specified probability density function.
Let s be the random variable with the probability
r

s = T (r ) = ( L − 1) ∫ pr ( w)dw
0

Define a random variable z with the probability
z

G ( z ) = ( L − 1) ∫ pz (t )dt = s
0

37

Digital Image Processing

III.2. Histogram Matching

r

s = T ( r ) = ( L − 1) ∫ p r ( w ) dw
0

z

G ( z ) = ( L − 1) ∫ p z ( t ) dt = s
0

z = G −1 ( s ) = G −1 [T (r ) ]
Digital Image Processing

38

19


Intensity transformation and spatial filtering

III.2. 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
0

2.

Use the specified PDF and obtain the transformation function
G(z)
z

G ( z ) = ( L − 1) ∫ pz (t )dt = s
0

3.

Mapping from s to z

z = G −1 ( s )
39

Digital Image Processing

III.2. Histogram Matching
„

Example
Assume an image has a gray level probability density function
pr(r) as shown.

⎧ − 2 r + 2 ;0 ≤ r ≤ 1
pr ( r ) = ⎨
; elsewhere
⎩ 0

Pr(r)
2
1

r



p r ( w ) dw = 1

0

0

1

Digital Image Processing

2

r
40

20


Intensity transformation and spatial filtering

III.2. Histogram Matching
Example

„

We would like to apply the histogram specification with the
desired probability density function pz(z) as shown.
Pz(z)
2

⎧ 2z
pz ( z ) = ⎨
⎩ 0

1

z

0

1

2

∫p

z

;0 ≤ z ≤ 1
; elsewhere
z

( w )dw = 1

0

41

Digital Image Processing

III.2. Histogram Matching
Example

„

1. Obtain the transformation function T(r)
r

s=T(r)

s = T ( r ) = ∫ pr ( w )dw
0

1

r

= ∫ ( −2 w + 2 )dw
0

= − w 2 + 2w
0
Digital Image Processing

1

r

r
0

= − r + 2r
2

42

21


Intensity transformation and spatial filtering

III.2. Histogram Matching
„

Example
2. Obtain the transformation function G(z)

z

G ( z ) = ∫ ( 2 w )dw

= z2

0

z
0

= z2

43

Digital Image Processing

III.2. Histogram Matching
„

Example

3. Obtain the inversed transformation function G-1

G ( z ) = T (r )
z 2 = − r 2 + 2r
z = 2r − r 2
We can guarantee that 0 ≤ z ≤1 when 0 ≤ r ≤1
Digital Image Processing

44

22


Intensity transformation and spatial filtering

III.2. Histogram Matching
Procedure in discrete cases

„

1.

Obtain pr(rj) from the input image and then obtain the values of
sk, round the value to the integer range [0, L-1]
k

sk = T (rk ) = ( L − 1)∑ pr (rj ) =
j =0

2.

( L − 1) k
∑ nj
MN j =0

Use the specified PDF and obtain the transformation function
G(zq), round the value to the integer range [0, L-1].
q

G ( zq ) = ( L − 1)∑ pz ( zi ) = sk
i =0

3.

Mapping from sk to zq

zq = G −1 ( sk )
45

Digital Image Processing

III.2. Histogram Matching
„

Example

Digital Image Processing

Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN =
4096) has the intensity distribution shown in the following
table (on the left). Get the histogram transformation function
and make the output image with the specified histogram, listed
in the table on the right.

46

23


Intensity transformation and spatial filtering

III.2. Histogram Matching
„

Example
Obtain the scaled histogram-equalized values,

s0 = 1, s1 = 3, s2 = 5, s3 = 6, s4 = 7,
s5 = 7, s6 = 7, s7 = 7.
Compute all the values of the transformation function G,
0

G ( z0 ) = 7∑ pz ( z j ) = 0.00

→0

j =0

G ( z1 ) = 0.00 → 0

G ( z3 ) = 1.05 → 1
G ( z5 ) = 4.55 → 5

G ( z7 ) = 7.00 → 7

s0
s2

→0
G ( z4 ) = 2.45 → 2 s1
G ( z2 ) = 0.00

G ( z6 ) = 5.95

s4 s5 s6

→ 6 s3

s7
47

Digital Image Processing

III.2. Histogram Matching
„

Example
rk
0
1
2
3
4
5
6
7
Digital Image Processing

s0 = 1, s1 = 3, s2 = 5, s3 = 6, s4 = 7,

rk → zq

s5 = 7, s6 = 7, s7 = 7.

0→3
1→ 4
2→5
3→6
4→7
5→7
6→7
7→7
48

24


Intensity transformation and spatial filtering

III.2. Histogram Matching
„

Example

Digital Image Processing

49

III.2. Histogram Matching
„

Example

Digital Image Processing

50

25


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×

×