Вы находитесь на странице: 1из 23

ECE/OPTI533 Digital Image Processing class notes

165

Dr. Robert A. Schowengerdt

2003

Distinct from restoration, which is processing designed to


recover true object using blur and noise reduction on a degraded
image

Usually empirical techniques, with ad hoc parameters (whatever


works)

Cosmetic processing

Image enhancement aims to improve visual quality

noisy

blurry

Recorded images often exhibit problems such as:

MOTIVATION

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

166

Dr. Robert A. Schowengerdt

Fourier filters can also be used to extract image components

The corresponding HP component is equal to the original image


minus the LP component

Weighted moving average of input pixels

Extract the LP component by convolution with a Low-Pass Filter


(LPF)

2003

The High-Pass (HP) component contains the small area variations, which determine
the sharpness and neighborhood contrast (micro-contrast)

The Low-Pass (LP) component contains the large area variations, which determine
the local-to-global contrast (macro-contrast) of the image

image ( m, n ) = LP ( m, n ) + HP ( m, n )

Write any image as the sum of two components,

TWO-COMPONENT IMAGE MODEL

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

image(m,n)

2-D LP and HP examples

167

7 x 7 LPF

3 x 3 LPF

LP(m,n)

Dr. Robert A. Schowengerdt

HP(m,n)

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

3 x 3 example

image ( m, n ) =
=
=
=

1/9x

LPF

168

1/9x

-1

+8

-1

-1

-1

-1

Dr. Robert A. Schowengerdt

-1

-1

-1

HPF

LP ( m, n ) + HP ( m, n )
LPF imag e ( m, n ) + HPF imag e ( m, n )
[ LPF + HPF ] imag e ( m, n )
( m, n ) imag e ( m, n )

Linearity of convolution implies LP and HP filters add

Convolution Filter for HP Component

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

30

30
index

40

40

50

1x3 HP

input

50

60

60

50

100

150

ECE/OPTI533 Digital Image Processing class notes

index

169

-50

20

20

-50

10

10

20

40

60

80

100

120

1x3 LP

input

140

50

100

150

20

40

60

80

100

120

140

1-D LP and HP examples

10

10

20

20

40

40

50

1x7 HP

input

50

60

60

Dr. Robert A. Schowengerdt

index

30

30
index

1x7 LP

input

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

DN

DN

DN
DN

ECE/OPTI533 Digital Image Processing class notes

zero image mean, greatly reduce variance

sum of filter weights = 0

remove large features

preserve small features

HPFs

preserve image mean, reduce variance

sum of filter weights = 1

remove small features

preserve large features

LPFs

General Filter Properties

170

0
-100

500

1000

1500

2000

2500

3000

3500

0
-100

200

400

600

800

1000

0
-100

200

400

600

800

1000

-50

-50

-50

150

150

100

150

HP-component

100

LP-component

100

original

Dr. Robert A. Schowengerdt

50
DN

50
DN

50
DN

Example histograms

200

200

200

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

number of pixels
number of pixels
number of pixels

2 2 2
1 9 2 +25 2
2 2 2

1 1 1
1 9 1 +17 1
1 1 1

3 3 3
1 9 3 +33 3
3 3 3

K=3

ECE/OPTI533 Digital Image Processing class notes

171

Dr. Robert A. Schowengerdt

2003

Larger K increases high-frequency boost, but also amplifies noise

K=2

K=1

3 x 3 convolution filter weights for K = 1, 2 and 3

HB ( m, n ;K ) = original ( m, n ) + K HP ( m, n )
= ( K + 1 )original ( m, n ) K LP ( m, n ) , K > 0

Parametric example

Boosts amplitude of the high spatial frequency components


(details) (unsharp masking darkroom technique)

High-Boost Filter (HBF)

IMAGE ENHANCEMENT II (CONVOLUTION)

K=3

K=2

ECE/OPTI533 Digital Image Processing class notes

K=1

original

Application to photographic image

172

Dr. Robert A. Schowengerdt

noise
amplification
trade-off with
sharpening

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

6 < DN < 231

original

Must clip GL at 0
and 255 to
maximize
contrast

HBFs increase
DN range

173

Dr. Robert A. Schowengerdt

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

min-max stretch

ECE/OPTI533 Digital Image Processing class notes

HB with K = 1
-53 < DN < 310

174

Dr. Robert A. Schowengerdt

clipped

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

min-max stretch

ECE/OPTI533 Digital Image Processing class notes

HB with K = 2
-132 < DN < 417

175

Dr. Robert A. Schowengerdt

clipped
2003

IMAGE ENHANCEMENT II (CONVOLUTION)

min-max stretch

ECE/OPTI533 Digital Image Processing class notes

HB with K = 3
-218 < DN < 525

176

Dr. Robert A. Schowengerdt

clipped

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

unstretched

ECE/OPTI533 Digital Image Processing class notes

HB original = K x HP
HB with K = 3

177

Dr. Robert A. Schowengerdt

histogram-equalized

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

1 +2 1

2nd
derivative

1 0
0 +1
1 0 0
0 +2 0
0 0 1

1
+1
1
+2
1

m=n

0 0 1
0 +2 0
1 0 0

0 1
+1 0

sin
0
-sin-cos cos

azimuthal

ECE/OPTI533 Digital Image Processing class notes

178

Dr. Robert A. Schowengerdt

Can also implement directional LPFs to remove details in a


given direction

1 +1

1st
derivative

direction

Convolution filter weights

Directional 1st and 2nd derivatives

Extract details in a given direction

Directional HPFs

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

Example directional HPF results

179

derivative direction

Dr. Robert A. Schowengerdt

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

linear not circular convolution

h net = h 1 h 2

where the equivalent filter is:

= f h net

= f ( h1 h2 )

g = ( f h1 ) h2

Example with two filters

180

Sequentially applied convolution


filters can be cascaded into a single
filter

Cascaded Linear Filters

1/9x

hnet
6
9

4
6

2
3

Dr. Robert A. Schowengerdt

symmetric

1/9x

h2

1/9x

h1

Example

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

181

Dr. Robert A. Schowengerdt

2003

To apply along rows, the weights within each window row must be
constant (but do not have to be equal from row-to-row)

repeat steps 3 and 4 until done

subtract leftmost column sum and add new rightmost


column sum to obtain current output pixel

move window one pixel along row

add column sums to obtain current output pixel (leftmost


output pixel in row only)

generate column sum of weighted input pixels

Box-Filter Algorithm
(along rows)

Very efficient recursive algorithm for certain configurations of


window weights

The Box-Filter Algorithm

IMAGE ENHANCEMENT II (CONVOLUTION)

Cm1 Cm2 Cm3

f ( k, 2 )h ( m k, 2 )

f ( k, 3 )h ( m k, 3 )

C m2 =

C m3 =

ECE/OPTI533 Digital Image Processing class notes

g ( m, 2 ) = C m1 + C m2 + C m3

f ( k, 1 )h ( m k, 1 )

C m1 =

at beginning of each output


row m

column sums

182

Dr. Robert A. Schowengerdt

= g ( m, 2 ) C m1 + C m4

g ( m, 3 ) = C m2 + C m3 + C m4

Cm1 Cm2 Cm3 Cm4

at next pixel in output row m

Box-filter algorithm (3 x 3 example)

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

183

For large images, speed is nearly independent of filter size

Dr. Robert A. Schowengerdt

2003

Can also be implemented in row direction by maintaining stack


of w1 most-recently processed rows in memory

Number of operations grows linearly with number of rows in filter

2w1 + 1 total/output pixel

2 adds

(w1 - 1) adds

w1 multiplies

w1 x w2 filter

7 total/output pixel

2 adds (pixel recursion)

2 adds (Cm4)

3 multiplies (Cm4)

3 x 3 filter

Number of operations/output pixel

IMAGE ENHANCEMENT II (CONVOLUTION)

2
2

2
3

symmetric

1
1
1

=
1/25x

h1

ECE/OPTI533 Digital Image Processing class notes

1/35x

hnet

1
1

symmetric

1
1

1
1

184

Gaussian LPF LPF LPF

Example decomposition into box filters

or approximated by cascaded box filters, e.g.

high-pass = original image - low-pass

1/9x

1
1

1
1

symmetric

h2

Some filters can be written as combinations of box filters, e.g.

Extension of box-filter algorithm

Dr. Robert A. Schowengerdt

h3

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

Non-physical result in border region

Not equal to convolution using Discrete


Fourier Transforms

reduce the window size near border

185

repeat the nearest valid output pixels to N x N

extend input image with zeros or other values


(nearest pixel or image mean); truncate after
linear convolution to N x N

Several possible solutions (aka tricks):

Must fill empty rows and columns around


border of output image

Strong practical reasons to maintain same


size output image as input image (N x N)

Linear

LINEAR VERSUS CIRCULAR


CONVOLUTION

Dr. Robert A. Schowengerdt

border region for 3 x 3 filter

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

k=0l=0


f ( k, l )h c ( m k, n l )

ECE/OPTI533 Digital Image Processing class notes

Non-physical result in border region

Equal to convolution using Discrete Fourier


Transforms

extract center M x N result for output image

186

linear convolution of W x W filter with periodic


extension of M x N image

Equivalent to:

h c ( m, n ) = h ( m moduloM , n moduloN )

where

g cir ( m, n ) =

M 1N 1

Modify defining equation,

Assume image and filter are each M x N

Circular (periodic)

Dr. Robert A. Schowengerdt

2-D periodic extension of image

2003

IMAGE ENHANCEMENT II (CONVOLUTION)

ECE/OPTI533 Digital Image Processing class notes

Example with 3 x 3 filter

187

Dr. Robert A. Schowengerdt

2003

IMAGE ENHANCEMENT II (CONVOLUTION)