chapter 3 image enhancement in the spatial domain

60
Chapter 3 Image Enhancement in the Spatial Domain

Upload: oliver-barton

Post on 17-Dec-2015

245 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Chapter 3 Image Enhancement in the Spatial Domain

Chapter 3

Image Enhancement in the Spatial Domain

Page 2: Chapter 3 Image Enhancement in the Spatial Domain

2

Background

Spatial domain refers to the aggregated of pixels composing an image.

Spatial domain methods are procedures that operate directly on these pixels.

Spatial domain processes will be denoted by the expression

g(x,y)=T [ f(x,y) ]where f(x,y) is the input image, g(x,y) is the processed image, and T is an operator of f

Page 3: Chapter 3 Image Enhancement in the Spatial Domain

3

Some Basic Gray Level Transformations

Discussing gray-level transformation functions. The value of pixels, before and after processing are related by an expression of the form

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.

Page 4: Chapter 3 Image Enhancement in the Spatial Domain

4

Gray Level Transformations

Image NegativesLog TransformationsExponential TransformationsPower-Law Transformations

Page 5: Chapter 3 Image Enhancement in the Spatial Domain

5

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

Page 6: Chapter 3 Image Enhancement in the Spatial Domain

6

Page 7: Chapter 3 Image Enhancement in the Spatial Domain

7

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 r0

Page 8: Chapter 3 Image Enhancement in the Spatial Domain

8

C = 0.8

C = 1.0

Page 9: Chapter 3 Image Enhancement in the Spatial Domain

9

Exponential Transformations

The general form of the log transformation shown in

s = c exp(r)

Where c is constant, and it is assumed that r0

Page 10: Chapter 3 Image Enhancement in the Spatial Domain

10

C = 0.8

C = 1.0

Page 11: Chapter 3 Image Enhancement in the Spatial Domain

11

Power-Law Transformations

Power-law transformations have the basic form

Sometime above Equation is written as

crs Where c and are positive constant.

)( rcs

Page 12: Chapter 3 Image Enhancement in the Spatial Domain

12

= 0.5

= 1.0

= 5.0

Page 13: Chapter 3 Image Enhancement in the Spatial Domain

13

Piecewise-Linear Transformation Functions

Translate MappingContrast stretchingGray-level slicingBit-plane slicing

Page 14: Chapter 3 Image Enhancement in the Spatial Domain

14

Translate Mapping

Page 15: Chapter 3 Image Enhancement in the Spatial Domain

15

Contrast stretching

One of the simplest piecewise linear functions is a contrast-stretching transformation.

The idea behind contrast stretching is to increase the dynamic range of the gray levels in the image being processed.

Page 16: Chapter 3 Image Enhancement in the Spatial Domain

16

Contrast stretching

Page 17: Chapter 3 Image Enhancement in the Spatial Domain

17

Contrast stretching

Page 18: Chapter 3 Image Enhancement in the Spatial Domain

18

Gray-level slicing

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

There are several ways of doing level slicing, but most of them are variations of two basic themes.

One approach is to display a high value for all gray levels in the range of interest and a low value for all other gray levels.

Page 19: Chapter 3 Image Enhancement in the Spatial Domain

19

Gray-level slicing

255255 00

Page 20: Chapter 3 Image Enhancement in the Spatial Domain

20

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 an image is represented b y 8 bits. Imagine that the image is composed of eight 1-bit planes, ranging from bit-plane 0, the least significant bit to bit-plane 7, the most significant bit.

Page 21: Chapter 3 Image Enhancement in the Spatial Domain

21

10110011

1

1

0

0

1

1

0

1

Bit-plane 0(least significant)

Bit-plane 7(most significant)

Page 22: Chapter 3 Image Enhancement in the Spatial Domain

22

Bit-plane slicing

Bit-plane 7 Bit-plane 6 Bit-plane 4 Bit-plane 1

Original Image

Page 23: Chapter 3 Image Enhancement in the Spatial Domain

23

Histogram Processing

The histogram of a digital image with gray levels in the range [0,L-1] is a discrete function

kk nrh )(

Where rk is the kth gray level and nk is the number of pixels in the image havinggray level rk

Page 24: Chapter 3 Image Enhancement in the Spatial Domain

24

HISTOGRAM

363622

Image 16x14 = 224 pixels

130

0 1 2 3 level

pixels

Page 25: Chapter 3 Image Enhancement in the Spatial Domain

25

Role of Histogram Processing

The role of histogram processing in image enhancement exampleDark imageLight imageLow contrastHigh contrast

Page 26: Chapter 3 Image Enhancement in the Spatial Domain

26

Histogram Processing

Histogram EqualizationHistogram Matching(Specification)Local Enhancement

Page 27: Chapter 3 Image Enhancement in the Spatial Domain

27

Initial part of discussion

Let r represent the gray levels of the image to be enhanced.

Normally, we have used pixel values in the interval [0,L-1], but now we assume that r has been normalized to the interval [0,1], with r=0 representing black and r=1 representing white.

Page 28: Chapter 3 Image Enhancement in the Spatial Domain

28

Histogram Equalization

We focus attention on transformations of the form

10)( rwhererTs

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 ≤ 1; and(b) 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1

That produce a level s for every pixel value r in the original image.

Page 29: Chapter 3 Image Enhancement in the Spatial Domain

29

Reason of Condition

The requirement in (a) that T9r) 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.

Page 30: Chapter 3 Image Enhancement in the Spatial Domain

30

Transformation function

T(r)

rk

sk=T(rk)

0 1Level r

Level s

Page 31: Chapter 3 Image Enhancement in the Spatial Domain

31

Note

The inverse transformation from s back to r is denoted

10)(1 rwhererTs

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.

Page 32: Chapter 3 Image Enhancement in the Spatial Domain

32

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

Page 33: Chapter 3 Image Enhancement in the Spatial Domain

33

PDF

The PDF (probability density function) is denoted by p(x)

ตั�วอย่�าง การทอย่ลู�กเตั�า ความน่�าจะเป็�น่ท��ลู�กเตั�าจะขึ้��น่หน่�าตั�างๆ เป็�น่ดั�งตั�อไป็น่��

1 2 3 4 5 6

1/6

หน่�าลู�กเตั�า

pdf

Page 34: Chapter 3 Image Enhancement in the Spatial Domain

34

CDF

The CDF (cumulative density function) is denoted by P(x)

ตั�วอย่�าง การทอย่ลู�กเตั�า ความน่�าจะเป็�น่ท��ลู�กเตั�าจะขึ้��น่หน่�าตั�างๆ เป็�น่ดั�งตั�อไป็น่��

1 2 3 4 5 6

1

หน่�าลู�กเตั�า

cdf

1/6

Page 35: Chapter 3 Image Enhancement in the Spatial Domain

35

Relation between PDF and CDF

PDF can find from this equation

CDF can find from this equation

)()]([

)( xPdx

xPdxp

nx

xx

n dxxpxxP0

)()(

Page 36: Chapter 3 Image Enhancement in the Spatial Domain

36

Idea of Histogram Equalization

The gray levels in an image may be viewed as random variables in the interval [0,1].

ds

drrpsp rs )()(

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

r

r dwwprTs0

)()(

Page 37: Chapter 3 Image Enhancement in the Spatial Domain

37

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.

)(

)(

)(

0

rp

dwwpdr

d

dr

rdT

dr

ds

r

r

r

Page 38: Chapter 3 Image Enhancement in the Spatial Domain

38

Idea of Histogram Equalization

Substituting into the first equaltion

10,1

)(

1)(

)()(

s

rprp

ds

drrpsp

rr

rs

Page 39: Chapter 3 Image Enhancement in the Spatial Domain

39

Idea of Histogram Equalization

The probability of occurrence of gray level rk in an image is approximated by

1,...,2,1,0)( Lkn

nrp k

kk

1,...,2,1,0

)()(

0

0

Lkn

n

rprTs

k

j

j

k

jjrkk

Page 40: Chapter 3 Image Enhancement in the Spatial Domain

40

Histogram Equalization

Page 41: Chapter 3 Image Enhancement in the Spatial Domain

41

Example forHistogram Equalizationจงท"าฮิ$สโตัแกรม อ�ควอไร

เซชั่��น่ ขึ้องภาพท��ม�ราย่ลูะเอ�ย่ดัตั�อไป็น่��

ค�าส�

จ"าน่วน่พ$กเซลู

(nj)

0 30

1 50

2 100

3 1500

4 2300

5 4000

6 200

7 20

ส�ตัร1,..,1,0,

0

Lkn

ns

k

j

jk

8200

202004000230015001005030

1

0

L

jjnn

Page 42: Chapter 3 Image Enhancement in the Spatial Domain

42

Example forHistogram Equalization

7

00037.0

8200

3000

00

n

n

n

ns

j

j

7

00098.0

8200

80

8200

5030101

01

n

nn

n

ns

j

j

7

0022.0

8200

180

8200

10050302102

02

n

nnn

n

ns

j

j

7

1205.0

8200

1680

8200

150010050303

03

j

j

n

ns

7

3485.0

8200

3980

8200

2300150010050304

04

j

j

n

ns

7

7973.0

8200

7980

8200

40002300150010050305

05

j

j

n

ns

7

7998.0

8200

8180

8200

20040002300150010050306

06

j

j

n

ns

7

71

8200

8200

8200

2020040002300150010050307

07

j

j

n

ns

Page 43: Chapter 3 Image Enhancement in the Spatial Domain

43

Example forHistogram Equalization

Page 44: Chapter 3 Image Enhancement in the Spatial Domain

44

Example forHistogram Equalization(2)

ค�าส�(k)

จ"าน่วน่พ$กเซลู(nj)

0 30 30 0.0037 0.0256

1 50 80 0.0098 0.0683

2 100 180 0.0220 0.1537

3 1500 1680 0.2050 1.4241

4 2300 3980 0.4854 3.3976

5 4000 7980 0.9732 6.8122

6 200 8180 0.9976 6.9830

7 20 8200 1.0000 7.0000

k

j

j

n

n

0

k

jjn

0

k

j

jk n

nLs

0

)1(

Page 45: Chapter 3 Image Enhancement in the Spatial Domain

45

Histogram Specification

can called “Histogram Matching”Histogram equalization automatically

determines a transformation function that seeks to produce an output image that has a uniform histogram.

In particular, it is useful sometimes to be able to specify the shape of the histogram that we wish the processed image to have.

Page 46: Chapter 3 Image Enhancement in the Spatial Domain

46

Meaning:Histogram SpecificationIn this notation, r and z denote the gray

levels of the input and output (processed) images, respectively.

We can estimate pr(r) from the given image

While pz(z) is the specified probability density function that we wish the output image to have

Page 47: Chapter 3 Image Enhancement in the Spatial Domain

47

Meaning:Histogram SpecificationLet s be a random variable with the

property

Suppose that we define a random variable z with property

Then two equations imply G(z)=T(r)

)1()()(0

r

r dwwprTs

)2()()(0

sdttpzGz

z

)3()]([)( 11 rTGsGz

Page 48: Chapter 3 Image Enhancement in the Spatial Domain

48

Procedure:Histogram Specification

1) Use Eq.(1) to obtain the transformation function T(r)

2) Use Eq.(2) to obtain the transformation function G(z)

3) Obtain the inverse transformation function G-

1

4) Obtain the output image by applying Eq.(3) to all the pixels in the input image

Page 49: Chapter 3 Image Enhancement in the Spatial Domain

49

Specified histogram

Input Image

Page 50: Chapter 3 Image Enhancement in the Spatial Domain

50

Result form Histogram Specification

Page 51: Chapter 3 Image Enhancement in the Spatial Domain

51

Local Enhancement

Normally, Transformation function based on the content of an entire image.

Some cases it is necessary to enhance details over small areas in an image.

The histogram processing techniques are easily adaptable to local enhancement.

Page 52: Chapter 3 Image Enhancement in the Spatial Domain

52

Local Enhancement

Pixel-to-pixel translation Nonoverlapping region

Page 53: Chapter 3 Image Enhancement in the Spatial Domain

53

Local Equalization

Page 54: Chapter 3 Image Enhancement in the Spatial Domain

54

Enhancement Using Arithmetic/Logic OperationsAre performed on a pixel-by-pixel basis

between two or more imagesLogic operations are concerned with the ability

to implement the AND, OR, and NOT logic operators because these three operators are functionally complete.

Arithmetic operations are concerned about +,-,*, / and so on (arithmetic operators)

Page 55: Chapter 3 Image Enhancement in the Spatial Domain

55

Image Subtraction

The difference between two images f(x,y) and h(x,y) expressed as

g(x,y) = f(x,y) – h(x,y)

Page 56: Chapter 3 Image Enhancement in the Spatial Domain

56

Page 57: Chapter 3 Image Enhancement in the Spatial Domain

57

Image Averaging

Consider a noisy image g(x,y) formed by the addition of noise to original image f(x,y)

The objective of this procedure is to reduce the noise content.

),(),(),( yxyxfyxg noise is where η(x,y)

Where the assumption is that at every pair of coordinates(x,y) the noise is uncorrelated and has zero average value.

Page 58: Chapter 3 Image Enhancement in the Spatial Domain

58

Image Averaging

Let there are K different noisy imagesIf an image is formed by

averaging K different noisy images

K

ii yxg

Kyxg

1

),(1

),(

),( yxg

Page 59: Chapter 3 Image Enhancement in the Spatial Domain

59

Image Averaging (Gray Scale)

2images

5images

10images

20images

1 image

Page 60: Chapter 3 Image Enhancement in the Spatial Domain

60

Image Averaging (Color Image)

Average image

(1) (2) (3)