enee631 digital image processing (spring'04) point operations spring ’04 instructor: min wu...

26
ENEE631 Digital Image Processing (Spring'04) Point Operations Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park www.ajconline.umd.edu (select ENEE631 S’04) [email protected] Based on ENEE631 Based on ENEE631 Spring’04 Spring’04 Section 3 Section 3

Upload: dina-quinn

Post on 18-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04)

Point OperationsPoint Operations

Spring ’04 Instructor: Min Wu

ECE Department, Univ. of Maryland, College Park

www.ajconline.umd.edu (select ENEE631 S’04) [email protected]

Based on ENEE631 Based on ENEE631 Spring’04Spring’04Section 3 Section 3

Page 2: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [3]

Image Enhancement via Point OperationsImage Enhancement via Point Operations

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

04

)

Page 3: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [4]

Point Operations / Intensity TransformPoint Operations / Intensity Transform Basic idea

– “Zero memory” operation each output only depend on the

input intensity at the point

– Map a given gray or color level u to a new level v, i.e. v = f ( u )

– Doesn’t bring in new info.– But can improve visual appearance or make features easier to detect

Example-1: Color coordinate transformations

– RGB of each pixel luminance + chrominance components etc.

Example-2: Scalar quantization

– quantize pixel luminance/color with fewer bits

input gray level u

outp

ut g

ray

leve

l

v

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

/20

04

)

Page 4: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [5]

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

04

)

Typical Types of Gray-level TransformationTypical Types of Gray-level Transformation

Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)

Page 5: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [6]

Example: Negative TransformationExample: Negative Transformation

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

04

)

Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)

Page 6: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [7]

Example: Log TransformationExample: Log Transformation

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

04

)

Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)

Page 7: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [8]

Example: Effects of Different GammasExample: Effects of Different Gammas

( “vectors” sample image from Matlab )

L02.2 L0

1/2.2

L0

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 8: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [9]

Gamma Characteristics & Gamma CorrectionGamma Characteristics & Gamma Correction

Non-linearity in CRT display

– Voltage U vs. Displayed luminance L’ L’ ~ U where = 2.0 ~ 2.5

Use preprocessing to compensate -distortion

– U ~ L 1/

– log(L) gives similar compensation curve to -correction

good for many practical applications

– Camera may have L1/c capturing distortion with c = 1.0-1.7

Power-law transformations are also useful for general purpose contrast manipulation

U

L’

L’ = a U

L

U ~ logL

~ L1/

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

/20

04

)

Page 9: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [11]

Luminance HistogramLuminance Histogram

Represents the relative frequency of occurrence of the various gray levels in the image

– For each gray level, count the # of pixels having that level– Can group nearby levels to form a big bin & count #pixels in it

( From Matlab Image Toolbox Guide Fig.10-4 )

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

/20

04

)

Page 10: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [12]

Luminance Histogram (cont’d)Luminance Histogram (cont’d)

Interpretation

– Treat pixel values as i.i.d random variables – Histogram is an estimate of the probability distribution of the r.v.

“Unbalanced” histogram doesn’t fully utilize the dynamic range

– Low contrast image ~ histogram concentrating in a narrow luminance range

– Under-exposed image ~ histogram concentrating on the dark side– Over-exposed image ~ histogram concentrating on the bright side

Balanced histogram gives more pleasant look and reveals rich content

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 11: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [13]

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

04

)

Example: Balanced and Unbalanced Histograms Example: Balanced and Unbalanced Histograms

Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)

Page 12: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [15]

Contrast Stretching for Low-Contrast ImagesContrast Stretching for Low-Contrast Images

Stretch the over-concentrated graylevels in histogram via a nonlinear mapping

– Piece-wise linear stretching function– Assign slopes of the stretching region to be greater than 1

input gray level u

outp

ut g

ray

leve

lv

a bo

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 13: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [16]

Contrast Stretching: ExampleContrast Stretching: Example

original

stretched

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 14: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [17]

Clipping & ThresholdingClipping & Thresholding

Clipping

– Special case of contrast stretching with = = 0

– Useful for noise reduction when interested signal mostly lie in range [a,b]

Thresholding

– Special case of clipping with a = b = T– Useful for binarization of scanned binary

images documents, signatures, fingerprints

input gray level u

outp

ut g

ray

leve

l

v

a bo

input gray level u

outp

ut g

ray

leve

l

v

To

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 15: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [18]

Examples of Histogram EqualizationExamples of Histogram Equalization( From Matlab Image

Toolbox Guide Fig.10-10 & 10-11 )

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 16: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [19]

Equalization Example (cont’d)Equalization Example (cont’d)

original

equalized

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 17: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [20]

Histogram EqualizationHistogram Equalization Goal: Map the luminance of each pixel to a new value such that the

output image has approximately uniform distribution of gray levels

To find what mapping to use: first model pixels as i.i.d. r.v.– How to generate r.v. with desired distribution? Match c.d.f

Want to transform one r.v. with certain p.d.f. to a new r.v. with uniform p.d.f.– For r.v. U with continuous p.d.f. over [0,1], construct a new r.v. V by

a monotonically increasing mapping v(u) such that

– Can show V is uniformly distributed over [0,1] FV(v) = v FV(v) = P(V v) = P( FU(u) v)

= P( U F-1U(v) ) = FU( F-1

U(v) ) = v

– For u in discrete prob. distribution, the output v will be approximately uniform

u

UU dxxpuUPuFv0

)(][)(

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

04

)

Page 18: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [22]

How to Do Histogram Equalization?How to Do Histogram Equalization?

Approach: map input luminance u to the corresponding v– v will be approximately uniform for u with discrete prob. distribution

b/c all pixels in one bin are mapped to a new bin (no splitting)

gray level u

c.d.

f

P(U<=u)

u0

o

1

255

Fu0

gray level vc.

d.f

P(V<=v)

v0

o

1

255

Fu0

UM

CP

EN

EE

40

8G

Slid

es

(cre

ate

d b

y M

.Wu

© 2

00

2)

Page 19: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [23]

Histogram Equalization AlgorithmHistogram Equalization Algorithm

1-L ..., 0, ifor )(

)()( 1

0

L

ii

iiU

xh

xhxp

ux

iU

i

xpv )(

)1(1

'min

min Lv

vvRoundv

v [0,1]

• Map discrete v [0,1] to v’ {0,…,L-1}• vmin is the smallest positive value of v• vmin 0 1 L-1

ux

iU

i

xpv )( Uniform quantization

u v v’

pU(xi)

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 20: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [24]

Histogram Equalization: A Mini-ExampleHistogram Equalization: A Mini-Example

– xi 0 1 2 3 4 5 6 7 (L=8)– p(xi) 0.1 0.2 0.4 0.15 0.1 0.05 0 0

– v 0.1 0.3 0.7 0.85 0.95 1.0 1.0 1.0

– v’ 0 [1.5] [4.7] [5.8] [6.6] 7 7 7 (L-1)/(1-vmin) = 7.78

0 2 5 6 7 7 7 7

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

)

Page 21: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [25]

Summary: Contrast Stretching vs. Histogram Eq.Summary: Contrast Stretching vs. Histogram Eq.

What are in common?

What are different?

input gray level u

outp

ut g

ray

leve

l

v

a bo

gray level u

c.d.

f

P(U<=u)

u0

o

1

255

Fu0

gray level v

c.d.

f

P(V<=v)

v0

o

1

255

Fu0

Page 22: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [26]

Generalization of Histogram EqualizationGeneralization of Histogram Equalization Histogram specification

– Want output v with specified p.d.f. pV(v)

– Use uniformly distributed r.v. W as an intermediate step

W = FU(u) = FV(v) V = F-1V (FU(u)

)

– Approximation in the intermediate step needed for discrete r.v.

W1 = FU(u) , W2 = FV(v) take v s.t. its w2 is equal to or just above w1

UM

CP

EN

EE

63

1 S

lide

s (c

rea

ted

by

M.W

u ©

20

01

/20

04

)

Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 3)

Page 23: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [28]

Visual QuantizationVisual Quantization

Contouring effect– Visible contours on smoothly changing regions for uniform quantized

luminance values with less than 5-6 bits/pixel human eyes are sensitive to contours

How to reduce contour effect at lower bits/pixel?– Use “dithering” to break contours by adding noise before quantization

8 bits / pixel 4 bits / pixel 2 bits / pixel

UM

CP

EN

EE

40

8G

Slid

es

(cre

ate

d b

y M

.Wu

& R

.Liu

© 2

00

2)

Page 24: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [29]

Use Dithering to Remove Contour ArtifactsUse Dithering to Remove Contour Artifacts

30 31

28 29

31

30

27 28 29

30 31 32

28

27

27

29

31 32 3331

33

31

30

32

33

original

24 24

24 24

24

24

24 24 24

24 24 40

24

24

24

24

24 40 4024

40

24

24

40

40

quantized (step=16)

+3 -1

+2 -1

+1

+2

-3 +2 -1

0 +2 -1

-1

0

-1

+2

+2 +3 -2-1

-1

0

-3

+2

-1

noise pattern

33 30

30 28

32

32

24 30 28

30 33 31

27

27

26

31

33 35 3130

32

31

27

34

32

original + noise

40 24

24 24

40

40

24 24 24

24 40 24

24

24

24

24

40 40 2424

40

24

24

40

40

quantized version of (original + noise)

artificial contour

UM

CP

EN

EE

40

8G

Slid

es

(cre

ate

d b

y M

.Wu

© 2

00

3)

Page 25: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [30]

Dithering for Halftone ImagesDithering for Halftone Images Halftone images

– Extreme case of low bits/pixel: use two colors (b/w) to represent gray shades

Extend the idea of pseudorandom noise quantizer– Upsample each pixel to form a resolution cell of many dots– Form dither signal by tiling halftone screen to be same size as the image– Apply quantizer on the sum of dither signal and image signal

Perceived gray level– Equal to the percentage of black dots perceived in one resolution cell

r(m,n) [0,A]Pseudorandom halftone screen

Luminanceu(m,n) [0,A]

Bi-leveldisplay

v(m,n) v’(m,n)

Threshold

A0

1

UM

CP

EN

EE

40

8G

Slid

es

(cre

ate

d b

y M

.Wu

& R

.Liu

© 2

00

2)

Page 26: ENEE631 Digital Image Processing (Spring'04) Point Operations Spring ’04 Instructor: Min Wu ECE Department, Univ. of Maryland, College Park

ENEE631 Digital Image Processing (Spring'04) Lec3 – Point Operations [31]

Examples of Halftone ImagesExamples of Halftone Images Trade spatial resolution with pixel depth

– Let eyes serve as a low-pass-filter – The average intensity of a cell matches the

intensity of original pixel (or neighborhood)

– May also apply error diffusion

Applications– Photo printing in newspaper and books– Image display in the old black/white monitor– Often use a periodic “dither screen” as noise

pattern

UM

CP

EN

EE

40

8G

Slid

es

(cre

ate

d b

y M

.Wu

& R

.Liu

© 2

00

2)