LC NHIU trong min khng gian 9172020 1

  • Slides: 43
Download presentation
LỌC NHIỄU trong miền không gian 9/17/2020 1

LỌC NHIỄU trong miền không gian 9/17/2020 1

Lọc nhiễu trong miền không gian 1. Arithmetic mean Filter 2. Geometric mean filter

Lọc nhiễu trong miền không gian 1. Arithmetic mean Filter 2. Geometric mean filter 3. Harmonic mean filter 4. Contra-harmonic mean filter 5. Meadian filter 6. Max-and-min filter 7. Alpha-trimed mean filter 8. Gausian filter 9/17/2020 2

Mô hình khôi phục ảnh g(x, y) = f(x, y)*h(x, y) + n(x, y),

Mô hình khôi phục ảnh g(x, y) = f(x, y)*h(x, y) + n(x, y), (x, y) f(x, y) - ảnh đầu vào (ảnh gốc) h(x, y) – hàm tác động ảnh n(x, y) – nhiễu cộng g(x, y) - ảnh nhận được Tiêu chí: Ảnh g(x, y) phải gần với ảnh f(x, y) g(x, y) f(x, y), (x, y) 9/17/2020 3

Mô hình khôi phục ảnh Xét mô hình g(x, y) = f(x, y) +

Mô hình khôi phục ảnh Xét mô hình g(x, y) = f(x, y) + n(x, y), (x, y) n(x, y) – nhiễu cộng, tuần hoàn 9/17/2020 4

1. Arithmetic Mean Filters Kí hiệu W(x, y) là một lân cận chữ nhật

1. Arithmetic Mean Filters Kí hiệu W(x, y) là một lân cận chữ nhật kích thước a b của điểm (x, y) (điểm (x, y) trùng với tâm hình chữ nhật). (đ Thông thường, W(x, y) được chọn là lân cận 3× 3 của (x, y) 9/17/2020 5

1. Arithmetic Mean Filter (i, j) = 1, (i, j) W(x, y), =9 9/17/2020

1. Arithmetic Mean Filter (i, j) = 1, (i, j) W(x, y), =9 9/17/2020 Mean Filters (i, j) = 1, (i, j) W(x, y){x, y), (x, y) = 2, =10 (i, j) {1, 2, 4} (i, j) W(x, y) =16 6

1. Arithmetic Mean Filter 9/17/2020 Mean Filters 7

1. Arithmetic Mean Filter 9/17/2020 Mean Filters 7

1. Arithmetic Mean Filters For y = 2 To H - 1 For x

1. Arithmetic Mean Filters For y = 2 To H - 1 For x = 2 To W - 1 ds = Hx(1, 1)*f(y-1, x-1) + Hx(1, 2)*f(y-1, x) + Hx(1, 3)*f(y-1, x+1) Hx(2, 1)*f(y, x-1) + Hx(2, 2)*f(y, x) + Hx(2, 3)*f(y, x+1) Hx(3, 1)*f(y+1, x-1) + Hx(3, 2)*f(y+1, x) + Hx(3, 3)*f(y+1, x+1 Q(y, x) = Round(ds / dt) Next: Next For y = 2 To H - 1 For x = 2 To W - 1 ds = 0 For p = 1 To 3 For q = 1 To 3 ds = ds + Hx(p, q) * f(y + p - 2, x + q - 2) Next: Next Q(y, x) = Round(ds / dt) Next: Next 9/17/2020 8

1. Arithmetic Mean Filters 9/17/2020 9

1. Arithmetic Mean Filters 9/17/2020 9

2. Geometric Mean Filters W(x, y) là lân cận chữ nhật kích thước a

2. Geometric Mean Filters W(x, y) là lân cận chữ nhật kích thước a b của điểm (x, y) Thông thường, W(x, y) được chọn là lân cận 3× 3 của (x, y) 9/17/2020 10

2. Geometric Mean Filters For y = 2 To H - 1 For x

2. Geometric Mean Filters For y = 2 To H - 1 For x = 2 To W - 1 ds = f(y-1, x-1) * f(y-1, x+1) * f(y, * f(y+1, x-1) * f(y+1, x+1 Q(y, x) = ds^(1/9) Next: Next x-1) * f(y, x) * f(y, x+1) For y = 2 To H - 1 For x = 2 To W - 1 ds = 1 For p = 1 To 3 For q = 1 To 3 ds = ds * f(y + p - 2, x + q - 2) Next: Next Q(y, x) = Round(ds ^(1/9)) Next: Next 9/17/2020 11

2. Geometric Mean Filter 9/17/2020 Mean Filters 12

2. Geometric Mean Filter 9/17/2020 Mean Filters 12

3. Harmonic Mean Filters W(x, y) là lân cận chữ nhật kích thước a

3. Harmonic Mean Filters W(x, y) là lân cận chữ nhật kích thước a b của điểm (x, y) Thông thường, W(x, y) được chọn là lân cận 3× 3 của (x, y) 9/17/2020 13

3. Harmonic Mean Filters For y = 2 To H - 1 For x

3. Harmonic Mean Filters For y = 2 To H - 1 For x = 2 To W - 1 ds = 0 For p = 1 To 3 For q = 1 To 3 ds = ds + (1/ f(y + p - 2, x + q - 2)) Next: Next Q(y, x) = Round (9 / ds) Next: Next 9/17/2020 14

3. Harmonic Mean Filter 9/17/2020 Mean Filters 15

3. Harmonic Mean Filter 9/17/2020 Mean Filters 15

4. Contraharmonic Mean Filter W(x, y) là lân cận chữ nhật kích thước a

4. Contraharmonic Mean Filter W(x, y) là lân cận chữ nhật kích thước a b của điểm (x, y) Thông thường, W(x, y) được chọn là lân cận 3× 3 của (x, y) Khi Q = -1, contraharmonic trở thành harmonicmean filter. 9/17/2020 16

4. Contraharmonic Mean Filter For y = 2 To H - 1 For x

4. Contraharmonic Mean Filter For y = 2 To H - 1 For x = 2 To W - 1 dt = 0 dm=0 For p = 1 To 3 For q = 1 To 3 dt = dt + (f(y + p - 2, x + q - 2))^(Q+1) dm = dm + (f(y + p - 2, x + q - 2))^Q Next: Next Q(y, x) = Round (dt / dm) Next: Next 9/17/2020 17

4. Contraharmonic Mean Filter 9/17/2020 18

4. Contraharmonic Mean Filter 9/17/2020 18

4. Contraharmonic Mean Filter Ảnh gốc Q= -3 Q=-2 Q=-1 9/17/2020 Q= 3 Q=

4. Contraharmonic Mean Filter Ảnh gốc Q= -3 Q=-2 Q=-1 9/17/2020 Q= 3 Q= 2 Q= 1 19

4. Contraharmonic Mean Filter abc def a) b) c) d) e) f) Q=-2 Ảnh

4. Contraharmonic Mean Filter abc def a) b) c) d) e) f) Q=-2 Ảnh gốc Q=2 Q=-1 Q=0 Q=1 9/17/2020 20

5. Median filter g(x, y) = median {f(i, j), (i, j) W(x, y)} Let

5. Median filter g(x, y) = median {f(i, j), (i, j) W(x, y)} Let given sequence of numbers: x 1, x 2, . . . , xm+1, xm+2, . . . , x 2 m+1 (1) The value xk {x 1, . . . , x 2 m+1} is called median of sequence (1) if exist: m elements from {x 1, . . . , x 2 m+1}{xk} are not greater than xk, and m others not smaller than xk 9/17/2020 21

5. Median filter Example 1 The median of sequence 1, equal 2, 5, 4

5. Median filter Example 1 The median of sequence 1, equal 2, 5, 4 4 because 2 entries: and 2 others: 9/17/2020 9, {1, 2} are not bigger than 4 {9, 5} are not smaller than 4. 22

5. Median filter Example 2 The median of sequence 15, 17, 18, 16, 78,

5. Median filter Example 2 The median of sequence 15, 17, 18, 16, 78, 17, 15, 20 equal 17 because 4 entries are not bigger than 17 and 4 others are not smaller than 17 15, 17, 9/17/2020 18, 16, 78, 17, 15, 20 23

5. Median filter The original image and filtered by median filter 9/17/2020 24

5. Median filter The original image and filtered by median filter 9/17/2020 24

5. Median filter The original image and filtered by median filter Effect: For images

5. Median filter The original image and filtered by median filter Effect: For images corrupted by bipolar or unipolar impulse noise – called salt-and-pepper noise (particularly effective) 9/17/2020 25

5. Median filter 1. Put the windows 3 3 such that center of the

5. Median filter 1. Put the windows 3 3 such that center of the windows at the point (x, y). 2. Order the pixels of the windows to a sequence in brightness from smallest to largest 3. Set g(x, y) = centered of a sequence Put to sequence x y 15 17 18 16 78 17 17 15 20 9/17/2020 Odered sequence 15, 17, 18, 16, 78, 17, 15, 20 15, 16, 17, 17, 18, 20, 78 g(x, y) = 17 26

5. Median filter For y = 2 To H - 1 For x =

5. Median filter For y = 2 To H - 1 For x = 2 To W - 1 For k = 1 To 3 For q = 1 To 3 D((k-1)*3+q) = f(y+k-2, x+q-2) Next k: Next q Sort: D(1) D(2) . . . D(9) g(x, y) = D(5) Next x: Next y 9/17/2020 27

Max and min filter Max filter For 1 y M, 1 x N: f^(x,

Max and min filter Max filter For 1 y M, 1 x N: f^(x, y) = max {f(i, j): (i, j) W(x, y) }, Min filter For 1 y M, 1 x N: f^(x, y) = min {f(i, j): (i, j) W(x, y) }, Midpoint Filter For 1 y M, 1 x N: f^(x, y) =[min{f(i, j): (i, j) W(x, y)}+ max{f(i, j): (i, j) W(x, y)}]/2 9/17/2020 28

Max filter For y = 1 To H - 2 For x = 1

Max filter For y = 1 To H - 2 For x = 1 To W - 2 1) For k = 1 To 3 For q = 1 To 3 D((k-1)*3+q) = Getpixel(y+k-2, x+q-2) Next k: Next q 2) Sort D: D(1) D(2) . . . D(9) 3) f^(x, y) = D(9) Next x: Next y 9/17/2020 29

Min filter For y = 1 To H - 2 For x = 1

Min filter For y = 1 To H - 2 For x = 1 To W - 2 1) For k = 1 To 3 For q = 1 To 3 D((k-1)*3+q) = Getpixel(y+k-2, x+q-2) Next k: Next q 2) Sort D: D(1) D(2) . . . D(9) 3) f^(x, y) = D(1) Next x: Next y 9/17/2020 30

Midpoint filter For y = 1 To H - 2 For x = 1

Midpoint filter For y = 1 To H - 2 For x = 1 To W - 2 1) For k = 1 To 3 For q = 1 To 3 D((k-1)*3+q) = Getpixel(y+k-2, x+q-2) Next k: Next q 2) Sort D: D(1) D(2) . . . D(9) 3) f^(x, y) = (D(1)+D(9))/2 Next x: Next y 9/17/2020 31

Alpha-trimmed mean filter Define: • m, n are dimentions of neighborhood W(x, y) •

Alpha-trimmed mean filter Define: • m, n are dimentions of neighborhood W(x, y) • d is an integer value in range [0. . mn-1] • fr(x, y) is remaning of f(x, y) after deletion d/2 lowest and d/2 highest in W(x, y) remark: 1) If d=0 Alpha-trimmed mean filter become arthmetic filter 2) If d=mn-1 Alpha-trimmed mean filter become median filter 9/17/2020 32

Alpha-trimmed mean filter a bcde a) b) c) d) e) 9/17/2020 Origin image d=0

Alpha-trimmed mean filter a bcde a) b) c) d) e) 9/17/2020 Origin image d=0 d=2 d=4 d=6 33

Alpha-trimmed mean filter ab cde a) b) c) d) e) 9/17/2020 Origin image d=0

Alpha-trimmed mean filter ab cde a) b) c) d) e) 9/17/2020 Origin image d=0 d=2 d=4 d=6 34

Alpha-trimmed mean filter ab cde a) b) c) d) e) 9/17/2020 Origin image d=0

Alpha-trimmed mean filter ab cde a) b) c) d) e) 9/17/2020 Origin image d=0 d=2 d=4 d=6 35

Alpha-trimmed mean filter a) Origin image 9/17/2020 d=6 36

Alpha-trimmed mean filter a) Origin image 9/17/2020 d=6 36

Alpha-trimmed mean filter d=? For i = 2 To H - 1 For j

Alpha-trimmed mean filter d=? For i = 2 To H - 1 For j = 2 To W - 1 x(1. . 9) = f(i -1. . i+1, j – 1. . j+1) Sắp xếp: x(1) ≤. . ≤x(9) g(i, j) = {x(d/2) +. . . +x(9 -d/2)}/(9 -d) 9/17/2020 37

Alpha-trimmed mean filter d=? For i = 2 To H - 1 For j

Alpha-trimmed mean filter d=? For i = 2 To H - 1 For j = 2 To W - 1 For k = 1 To 3 For q = 1 To 3 x((k - 1) * 3 + q) = f(i + k - 2, j + q - 2) For t = 1 To 8 k=t For v = k To 9 If x(v) < x(k) Then k = v tg = x(k): x(k) = xx(t): xx(t) = tg ts = 0 For t = 1 + d/2 to 9 - d/2 ts = ts + x(t) g(i, j) = ts/(9 -d) 9/17/2020 38

Gauusian smoothing where: 1) x is the distance from the origin in the horizontal

Gauusian smoothing where: 1) x is the distance from the origin in the horizontal axis, 2) y is the distance from the origin in the vertical axis, and 3) σ is the standard deviation of the Gaussian distribution. 9/17/2020 39

Gausian smoothing This figure shows a suitable integer-valued convolution kernel that approximates a Gaussian

Gausian smoothing This figure shows a suitable integer-valued convolution kernel that approximates a Gaussian with a of 1. 0 and distance from origin is 2 9/17/2020 40

Gausian smoothing The original and filtered images byte gaussian smoothing operation 9/17/2020 41

Gausian smoothing The original and filtered images byte gaussian smoothing operation 9/17/2020 41

Gausian smoothing The original and filtered images byte gaussian smoothing operation 9/17/2020 42

Gausian smoothing The original and filtered images byte gaussian smoothing operation 9/17/2020 42

Gausian smoothing The original and filtered images byte gaussian smoothing operation 9/17/2020 43

Gausian smoothing The original and filtered images byte gaussian smoothing operation 9/17/2020 43