Ł local enhancement Łmedian filteringmanj/ece178w04/enhancepart3.pdf02/07/2002 local enhancement 2...

36
02/07/2002 Local Enhancement 1 Local Enhancement Local Enhancement Median filtering

Upload: others

Post on 31-May-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 1

Local Enhancement

� Local Enhancement�Median filtering

Page 2: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 2

Local enhancement

Sometimes LocalEnhancement is Preferred.

Malab: BlkProc operation for block processing.

Left: original �tire� image.

Page 3: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 3

Histogram equalized

Page 4: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 4

Local histogram equalized

F=@ histeq;I=imread(�tire.tif�);J=blkproc(I,[20 20], F);

Page 5: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 5

Fig 3.23: Another example

Page 6: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 6

Local Contrast Enhancement

� Enhancing local contrastg (x,y) = A( x,y ) [ f (x,y) - m (x,y) ] + m (x,y)

A (x,y) = k M / σ(x,y) 0 < k < 1

M : Global meanm (x,y) , σ (x,y) : Local mean and standard dev.

Areas with low contrast ! Larger gain A (x,y) (fig 3.24-3.26)

Page 7: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 7

Fig 3.24

Page 8: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 8

Fig 3.25

Page 9: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 9

Fig 3.26

Page 10: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 10

Image Subtraction

g (x,y) = f (x,y) - h (x,y)h(x,y)�a low pass filtered version of f(x,y).

� Application in medical imaging --�mask mode radiography�

� H(x,y) is the mask, e.g., an X-ray image of part of a body; f(x,y) �incoming image after injecting a contrast medium.

Page 11: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 11

Subtraction: an example

Page 12: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 12

Fig 3.28: mask mode radiography

Page 13: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 13

Averaging

Fig 3.30

and

Uncorrelated zero mean

duces the noise variance

2 2

2

g x y f x y x y

g x yM

g x y

E g x y f x yM

x y

x y

x y

ii

M

g

( , ) ( , ) ( , )

( , ) ( , )

( ( , )) ( , ) ( , )

( , )

( , ) Re

= +

=

= =

=∑

η

σ σ

ησ

η

η

1

11

Page 14: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 14

Fig 3.30

Page 15: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 15

Another example Images with additiveGausian Noise; IndependentSamples.

I=imnoise(J,�Gaussian�);

Page 16: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 16

Averaged image

Left: averaged image (10 samples); Right: original image

Page 17: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 17

Spatial filtering

Frequency

Spatial

0

LPFHPF BPF

Page 18: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 18

Smoothing (Low Pass) Filtering

ωωωω1111 ωωωω2222 ωωωω3333

ωωωω4444 ωωωω5555 ωωωω6666

ωωωω7777 ωωωω8888 ωωωω9999

f1 f2 f3

(x,y)

Replace f (x,y) with

Linear filter

LPF: reduces additive noise" blurs the image! sharpness details are lost (Example: Local averaging)

Fig 3.35

f x y fii

i

^( , ) =∑ω

Page 19: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 19

Fig 3.35: smoothing

Page 20: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 20

Fig 3.36: another example

Page 21: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 21

Median filtering

Replace f (x,y) with median [ f (x� , y�) ](x� , y�) E neighbourhood

� Useful in eliminating intensity spikes. ( salt & pepper noise)� Better at preserving edges.

Example:

10101010 20202020 20202020

20202020 15151515 20202020

25252525 20202020 100100100100

( 10,15,20,20,20,20,20,25,100)

Median=20 So replace (15) with (20)

Page 22: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 22

Median Filter: Root Signal

Repeated applications of median filter to a signal resultsin an invariant signal called the �root signal�.A root signal is invariant to further application of the medina filter.

ExampleExample: 1-D signal: Median filter length = 30 0 0 1 2 1 2 1 2 1 0 0 00 0 0 1 1 2 1 2 1 1 0 0 00 0 0 1 1 1 2 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 root signal

Page 23: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 23

Invariant Signals

Invariant signals to a median filter:

ConstantMonotonically

increasing decreasing

length?

Page 24: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 24

Fig 3.37: Median Filtering example

Page 25: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 25

Media Filter: another example

Original and with salt & pepper noiseimnoise(image, �salt & pepper�);

Page 26: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 26

Donoised images

Local averagingK=filter2(fspecial(�average�,3),image)/255.

Median filteredL=medfil2(image, [3 3]);

Page 27: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 27

Sharpening Filters

� Enhance finer image details (such as edges)� Detect region /object boundaries.

−1−1−1−1 −1−1−1−1 −1−1−1−1−1−1−1−1 8 8 8 8 −1−1−1−1−1−1−1−1 −1−1−1−1 −1−1−1−1

Example:

Page 28: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 28

Edges (Fig 3.38)

Page 29: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 29

Unsharp Masking

Subtract Low pass filtered version from the original emphasizes high frequency information

I� = A ( Original) - Low passHP = O - LP A > 1I� = ( A - 1 ) O + HPA = 1 => I� = HP A > 1 => LF components added back.

Page 30: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 30

Fig 3.43 �example of unsharp masking

Page 31: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 31

Derivative Filters

−1−1−1−1 −1−1−1−1 −1−1−1−1−1−1−1−1 ω ω ω ω −1−1−1−1−1−1−1−1 −1−1−1−1 −1−1−1−1

1/9 Gradient

∇ =LNM

OQP

∇ =FHGIKJ +FHGIKJ

LNMM

OQPP

f fx

fy

f fx

fy

T∂∂

∂∂

∂∂

∂∂

2 21

2

Page 32: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 32

Edge Detection

Gradient based methods

xx0 xx0

f(x)f�(x)

xx0

f �(x)

f(x) d(.)/dx | . | Thresholdf�(x)

|f�(x)|

<

> Localmax

No

Yes X0 is anedge

Not an edge X0 not an edge

∇ =FHG

IKJf f

xfy

T∂∂

∂∂

Page 33: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 33

Digital edge detectors

z1 z3

z4 z5 z6

z7 z8 z9

z2

Robert�s operator

1 00 -1

0 1-1 0

prewitt

| z5-z9 | | z6-z8 |

-1 -1 -10 0 01 1 1

-1 0 1-1 0 1-1 0 1

Sobel�s

-1 -2 -10 0 01 2 1

-1 0 1-2 0 2-1 0 1

∇ ≈ − + −

∇ ≈ − + −

f z z z z

f z z z z

5 82

5 62

5 8 5 6

12b g b g

Page 34: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 34

Fig 3.45: Sobel edge detector

Page 35: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 35

Laplacian based edge detectors

11 -4 1

1

�Rotationally symmetric, linear operator�Check for the zero crossings to detect edges�Second derivatives => sensitive to noise.

∇ = +22

2

2

2f fx

fy

∂∂

∂∂

Page 36: Ł Local Enhancement ŁMedian filteringmanj/ece178W04/EnhancePart3.pdf02/07/2002 Local Enhancement 2 Local enhancement Sometimes Local Enhancement is Preferred. Malab: BlkProc operation

02/07/2002 Local Enhancement 36

Fig 3.40: an example