430 likes | 440 Views
LỌC NHIỄU trong miền không gian. Lọc nhiễu trong miền không gian. Arithmetic mean Filter Geometric mean filter Harmonic mean filter Contra-harmonic mean filter Meadian filter Max-and-min filter Alpha-trimed mean filter Gausian filter. Mô hình khôi phục ảnh.
E N D
Lọc nhiễu trong miền không gian • Arithmetic mean Filter • Geometric mean filter • Harmonic mean filter • Contra-harmonic mean filter • Meadian filter • Max-and-min filter • Alpha-trimed mean filter • Gausian filter
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)
Xét mô hình Mô hình khôi phục ảnh g(x,y) = f(x,y) + n(x,y), (x,y) n(x,y) – nhiễu cộng, tuần hoàn
Mean Filters Kí hiệu W(x, y) là một lân cận chữ nhật kích thước ab của điểm (x, y) (điểm (x,y) trùng với tâm hình chữ nhật). 1. Arithmetic Mean Filter Thông thường, W(x,y) được chọn là lân cận 3×3 của (x,y)
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 (i,j) = 1, (i,j) W(x,y), =9 1. Arithmetic Mean Filter
Mean Filters 1. Arithmetic Mean Filter
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 1. Arithmetic Mean Filter 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
Mean Filters W(x, y) là lân cận chữ nhật kích thước ab của điểm (x, y) 2.Geometric Mean Filter Thông thường, W(x,y) được chọn là lân cận 3×3 của (x,y)
Mean Filters For y = 2 To H - 1 For x = 2 To W - 1 ds = f(y-1, x-1) * f(y-1,x) * f(y-1,x+1) * f(y, x-1) * f(y, x) * f(y, x+1) * f(y+1,x-1) * f(y+1,x) * f(y+1,x+1 Q(y, x) = ds^(1/9) Next: Next 2.Geometric Mean Filter 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
Mean Filters 2.Geometric Mean Filter
Mean Filters W(x, y) là lân cận chữ nhật kích thước ab của điểm (x, y) 3.Harmonic Mean Filter Thông thường, W(x,y) được chọn là lân cận 3×3 của (x,y)
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 3.Harmonic Mean Filter
Mean Filters 3.Harmonic Mean Filter
W(x, y) là lân cận chữ nhật kích thước ab của điểm (x, y) 4.Contraharmonic Mean Filter 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.
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 4.Contraharmonic Mean Filter
Ảnh gốc Q= -3 Q=-2 Q=-1 Q= 3 Q= 2 Q= 1 Q = 0 4.Contraharmonic Mean Filter
abc def 4.Contraharmonic Mean Filter • Q=-2 • Ảnh gốc • Q=2 • Q=-1 • Q=0 • Q=1
g(x, y) = median {f(i,j), (i,j) W(x,y)} Let given sequence of numbers: x1, x2, ..., xm, xm+1, xm+2,..., x2m, x2m+1 (1) 5. Median filter The value xk {x1,...,x2m+1} is called median of sequence (1) if exist: m elements from {x1,...,x2m+1}\{xk} are not greater than xk, and m others not smaller than xk
Example 1 The median of sequence 1, 2, 9, 5, 4 equal 4 because 2 entries: {1, 2} are not bigger than 4 and 2 others: {9, 5} are not smaller than 4. 5. Median filter
Example 2 The median of sequence 15, 17, 18, 16, 78, 17, 17, 15, 20 equal 17 because 4 entries are not bigger than 17 and 4 others are not smaller than 17 5. Median filter 15, 17,18, 16, 78, 17, 17, 15, 20
5. Median filter The original image and filtered by 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) 5. Median filter
Put the windows 33 such that center of the windows at the point (x, y). • Order the pixels of the windows to a sequence in brightness from smallest to largest • Set g(x, y) = centered of a sequence Put to sequence 15, 17, 18, 16, 78, 17, 17, 15, 20 5. Median filter Odered sequence 15, 15, 16, 17, 17, 17, 18, 20, 78 g(x,y) = 17
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
Max and min filter Max filter For 1 y M, 1x N: f^(x, y) = max {f(i, j): (i, j) W(x, y) }, Min filter For 1 y M, 1x N: f^(x, y) = min {f(i, j): (i, j) W(x, y) }, Midpoint Filter For 1 y M, 1x N: f^(x, y) =[min{f(i, j):(i, j)W(x, y)}+ max{f(i, j):(i, j)W(x, y)}]/2
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
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
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
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) Alpha-trimmed mean filter • remark: • If d=0 Alpha-trimmed mean filter become arthmetic filter • If d=mn-1 Alpha-trimmed mean filter become median filter
a bcde Alpha-trimmed mean filter • Origin image • d = 0 • d = 2 • d = 4 • d = 6
ab cde • Origin image • d = 0 • d = 2 • d = 4 • d = 6 Alpha-trimmed mean filter
ab cde • Origin image • d = 0 • d = 2 • d = 4 • d = 6 Alpha-trimmed mean filter
Alpha-trimmed mean filter • Origin image d = 6
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) 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) Alpha-trimmed mean filter
where: • x is the distance from the origin in the horizontal axis, • y is the distance from the origin in the vertical axis, and • σ is the standard deviation of the Gaussian distribution. Gauusian smoothing
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
Gausian smoothing The original and filtered images byte gaussian smoothing operation
Gausian smoothing The original and filtered images byte gaussian smoothing operation
Gausian smoothing The original and filtered images byte gaussian smoothing operation