digital image processing image enhancement part iv

24
Digital Image Processing Image Enhancement Part IV

Upload: nora-holland

Post on 30-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Digital Image Processing Image Enhancement Part IV

Digital Image Processing

Image Enhancement

Part IV

Page 2: Digital Image Processing Image Enhancement Part IV

Nonlinear Filtering

• Nonlinear Filters– Cannot be expressed as convolution– Cannot be expressed as frequency shaping

• “Nonlinear” Means Everything (other than linear)– Need to be more specific– Often heuristic– We will study some “nice” ones

Page 3: Digital Image Processing Image Enhancement Part IV

Impulsive (Salt & Pepper) Noise

),(

0

255

),(

nmX

nmY

with probability pa

with probability pb

with probability 1 - pa - pb

noisy pixels

clean pixels

X: noise-free image, Y: noisy image

• Definition– Each pixel in an image has a probability pa or pb of

being contaminated by a white dot (salt) or a black dot (pepper)

add salt & pepper noise

Page 4: Digital Image Processing Image Enhancement Part IV

Order-Statistics Filtersnonlinear spatial filters response is based on ordering (ranking) the pixels contained in the image area encompassed by the filterreplacing of the center pixel with the value determined by the ranking result

Page 5: Digital Image Processing Image Enhancement Part IV

Median FilteringMedian filter

replaces the pixel value by the median value in the neighborhoodThe principal function is to force distinct gray level points to be more like their neighbors.excellent noise-reduction capabilities with less blurring than linear smoothing filterseffective for impulse noise (salt-and-pepper noise)

Min: Set the pixel value to the minimum in the neighbourhood

Max: Set the pixel value to the maximum in the neighbourhoodcf.) max filter → R = max {zk | k = 1,2,…,9}

min filter → R = min {zk | k = 1,2,…,9}

Page 6: Digital Image Processing Image Enhancement Part IV

Order-Statistics Filters

– Given a set of numbers

Denote the OS as

such that

• Applying Median Filtersto Images– Use sliding windows

(similar to spatial linear filters)– Typical windows:

3x3, 5x5, 7x7, other shapes ……

},,,{ 1221 Mxxx x

},,,{ )12()2()1( MOS xxx x

)12()1()2()1( MM xxxx

)1(1221 },,,{ MM xxxxMedian middle value

max value

min value

Page 7: Digital Image Processing Image Enhancement Part IV

Median Filters

original noisy (pa = pb = 0.1)

median filtered 3x3 window median filtered 5x5 windowFrom MATLAB sample

images

Page 8: Digital Image Processing Image Enhancement Part IV

Iterative Median Filters

From [Gonzalez & Woods]

• Idea: repeatedly apply median filters

1 time

2 times

3 times

Page 9: Digital Image Processing Image Enhancement Part IV

Switching Median Filters

From [Wang & Zhang]

• Motivation– Regular median filters change both “bad” and “good”

pixels

• Idea– Detect/classify “bad” and “good” pixels– Filter “bad” pixels only

Page 10: Digital Image Processing Image Enhancement Part IV

original noisy (pa = pb = 0.1)

regular 5x5 median filtered switching 5x5 median filtered

Switching Median Filters

From MATLAB sample images

Page 11: Digital Image Processing Image Enhancement Part IV

Order Statistics (OS) Filters

• Recall Order Statistics:

For

OS

such that

• OS filter: General Form

• Special Cases

},,,{ 1221 Mxxx x

)12(1221 },,,{ MM xxxxMax

)1(1221 },,,{ MM xxxxMedian

},,,{ )12()2()1( MOS xxx x

)12()1()2()1( MM xxxx

)1(1221 },,,{ xxxxMin M

)(

12

11221 },,,{ i

M

iiM xwxxxOS

1

12

1

M

iiw

}0,,0,0,1{}{ iw

}1,,0,0,0{}{ iw

}0,,1,0,0{}{ iw

where

(M+1)-th

Page 12: Digital Image Processing Image Enhancement Part IV

Order Statistics (OS) Filters

• Note: An OS Filter is Uniquely Defined by {wi}

• Example 1:

• Example 2:

)2()1()(1221 25.05.025.0},,,{ MMMM xxxxxxOS

}0,,4/1,2/1,4/1,,0{}{ iw

(M+1)-thM-th (M+2)-th

then

12

1)(1221 12

1},,,{

M

iiM x

MxxxOS

)12/(}1,,1,1{}{ Mwi

}12,,1,,{}12,,1,{ )( MixMeanMixMean ii

then

Page 13: Digital Image Processing Image Enhancement Part IV

Examples

5

6

6

0

7

8

8

7

5

6

6

5

15

8

8

7

0 0 0 0

0 0 0 0

0

0

0

0

0

0

0

0

0

0

0

0

5

6

6

0

7

8

8

7

5

6

6

5

15

8

8

7

0

6

5

5

6

7

0

7

5

5

6

0

7

0

7

6

• A 4x4 grayscale image is given by

1) Filter the image with a 3x3 median filter, after zero-padding at the image borders

5

6

6

0

7

8

8

7

5

6

6

5

15

8

8

7

zero-paddingmedianfiltering

impulse?

impulse?

Page 14: Digital Image Processing Image Enhancement Part IV

Examples

5

6

6

0

7

8

8

7

5

6

6

5

15

8

8

7

5 6 7 8

5 6 7 8

5

0

5

5

5

5

8

8

8

8

8

8

5

6

6

0

7

8

8

7

5

6

6

5

15

8

8

7

5

6

6

5

7

8

8

7

5

6

6

5

7

8

8

7

2) Filter the image with a 3x3 median filter, after replicate-padding at the image borders

replicate-padding

medianfiltering

impulse cleaned!

Page 15: Digital Image Processing Image Enhancement Part IV

5

6

6

5

7

8

8

7.25

5

6

6

5

7.25

8

8

7.25

Examples3) Filter the image with a 3x3 OS filter, after

replicate-padding at the image borders. The weighting factors of the OS filter are given by

{wi | i = 1, …, 9} = {0, 0, 0, ¼, ½, ¼, 0, 0, 0}

5

6

6

0

7

8

8

7

5

6

6

5

15

8

8

7

5 6 7 8

5 6 7 8

5

0

5

5

5

5

8

8

8

8

8

8

5

6

6

0

7

8

8

7

5

6

6

5

15

8

8

7

replicate-padding

OSfiltering

Page 16: Digital Image Processing Image Enhancement Part IV

Gradient the term gradient is used for a gradual blend of colour which can

be considered as an even gradation from low to high values At each image point, the gradient vector points in the direction of

largest possible intensity increase, the length of the gradient vector corresponds to the rate of

change in that direction. Two types of gradients, with blue arrows to indicate the direction

of the gradient

Page 17: Digital Image Processing Image Enhancement Part IV

Sobel operatorsRepresents a rather inaccurate approximation of the image gradientThe operator calculates the gradient of the image intensity at each pointGiving the direction of the largest possible increase from light to dark and the rate of change in that direction The result therefore shows how "abruptly" or "smoothly" the image changes at that point

Page 18: Digital Image Processing Image Enhancement Part IV

Sobel Example

Page 19: Digital Image Processing Image Enhancement Part IV

Sobel ExampleGrayscaleimage of a brick wall & a bike rack

scale image of a brick wall& a bike rack

Page 20: Digital Image Processing Image Enhancement Part IV

Combining Spatial Enhancement Methods

Successful image enhancement is typically not achieved using a single operationRather we combine a range of techniques in order to achieve a final resultThis example will focus on enhancing the bone scan to the right

Page 21: Digital Image Processing Image Enhancement Part IV

Combining Spatial Enhancement Methods

Laplacian filter of bone scan (a)

Sharpened version of bone scan achieved by subtracting (a) and (b) Sobel filter of bone

scan (a)

(a)

(b)

(c)

(d)

Page 22: Digital Image Processing Image Enhancement Part IV

Combining Spatial Enhancement Methods

Ima

ge

s ta

ken

fro

m G

on

zale

z &

Wo

od

s, D

igita

l Im

ag

e P

roce

ssin

g (

20

02

)

The product of (c) and (e) which will be used as a mask

Sharpened image which is sum of (a) and (f)

Result of applying a power-law trans. to (g)

(e)

(f)

(g)

(h)

Image (d) smoothed with a 5*5 averaging filter

Page 23: Digital Image Processing Image Enhancement Part IV

Combining Spatial Enhancement Methods Compare the original and final images

Ima

ge

s ta

ken

fro

m G

on

zale

z &

Wo

od

s, D

igita

l Im

ag

e P

roce

ssin

g (

20

02

)

Page 24: Digital Image Processing Image Enhancement Part IV

assignments Chapter 3 1, 6, 10, 12, 18, 22, 23.