Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 38 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
38
Dung lượng
2,04 MB
Nội dung
T ng c ng nh: l c khơng gian • T ng c ng nh mi n không gian đ c mô t nh : nh t ng c ng Bi n đ i g(m,n) = T(f)(m,n) nh ban đ u • Bi n đ i T có th n tính hay phi n Tr Khoa Tốn - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Xác đ nh T • N u T n tính thay đ i b t bi n (linear and shift invariant - LSI), có đ c tính PSS (point-spread sequence) h(m,n) , Tr Khoa Tốn - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Xác đ nh T • Trong th c t , đ gi m tính tốn h(k,l) = for (k,l) ∉ Δ • • • v i Δ m t t p nh (t p láng gi ng) Δ đ c g i xác đ nh c a h Trong mi n t n s đ c mơ t nh : G(u,v) = He(u,v) Fe(u,v) Có nhi u phép toán LSI dùng mi n t n s nh “phép l c” L c theo m t gi i h n c ng đ c xem nh phép toán Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Xác đ nh T • Ví d (tr ng h p 1-D): L c b ng thơng th p Tr Khoa Tốn - Tin h c CuuDuongThanCong.com L c b ng thông cao ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt • N u h(m, n) m t m t n 3x3 w1 w2 w3 h= w4 w5 w6 w7 w8 w9 Tr Khoa Tốn - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt • Giá tr g(m,n) đ c tính b ng cách tr t m t n qua m • C n th n biên c a có th ch i pixel c a nh f(m,n) đ c bi t pixel n m nh f(m,n) gi i quy t, n: – M t n đ c c t ng n t i biên (Biên t do) – M r ng thêm dòng/c t t i biên (Hi u ch nh biên) – Biên đ c “bao b c xung quanh” (Chu k biên) • Trong MATLAB dùng l nh filter2 d a l nh conv2 Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Các l c làm tr n nh • Làm tr n nh thu c phép bi n đ i nh- nh, • phép bi n đ i làm khác bi t gi a pixel không nhi u Phép l c tr n dùng cho: – Làm m nh (Blurring): ây b c ti n x lý nh m lo i b b t chi ti t nh (không c n thi t) tr c trích đ i t ng c n thi t (l n), hay làm t ng chi ti t nh – Gi m nhi u (Noise reduction): Gi m b t tác đ ng c a nhi u Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Làm tr n nh b ng m t n trung bình (l c khơng gian b ng th p) • Có th áp d ng m t n trung bình (averaging mask) • • đ làm tr n M t m t n trung bình m t n có t ng tr ng b ng c tính d a láng gi ng, nên m t n cịn có tên trung bình láng gi ng (neighborhood averaging) Vài lo i 3x3: • Phép tốn t ng đ ng l c b ng thông th p Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Ví d làm m nh nh ban đ u M t n trung bình Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt N =3 N =7 Ví d làm m N = 11 N = 21 Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt L c High-boost • Quan sát th y g(m,n) = Af(m,n) – lowpass(f(m,n)) = (A-1)f(m,n) + f(m,n) – lowpass(f(m,n)) = (A-1)f(m,n) + hipass(f(m,n)) • K t qu gi ng nh ban đ u nh ng c nh s n i b t h n Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Ví d nh ban đ u L c b ng thông cao Tr Khoa Toán - Tin h c CuuDuongThanCong.com L c High-boost ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt L c theo đ o hàm • Trung bình quan tâm làm m chi ti t nh b ng • • cách xem xét quan h trung bình hay tích h p xung quanh M t cách t nhiên, đ o hàm cho tay nhìn v s thay đ i đ d c Phép tốn đ o hàm thơng d ng gradient: ∂f ( x , y ) = f ( x + 1, y ) − f ( x , y ) ∂x ∂f ( x , y ) = f ( x , y + 1) − f ( x , y ) ∂y Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt C nh gradient đ m c a c nh b ng đ l n c a gradient H ng c a c nh b ng góc c a gradient Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt L c theo đ o hàm • l n c a gradient: • Th ng x p x • Xem xét vùng r i r c hóa đ l n c a gradient nh: z1 z2 z3 z4 z5 z6 z7 z8 z9 • Chúng ta có th x p x Tr Khoa Tốn - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt L c theo đ o hàm ⎡1⎤ • Có th cài đ t theo m t n : h1 = ⎢ ⎥ h2 = [1 −1] ⎣ −1⎦ • Theo đó: • M t l a ch n khác, có th x p x : • S cài đ t theo h = ⎡ 1 ⎢ 0⎤ ⎡ 1⎤ vaø h2 = ⎢ ⎥ ⎥ 1 − − ⎣ ⎦ ⎣ ⎦ • Thì Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt L c theo đ o hàm • M t n sau đ c g i phép tốn gradient chéo Robert (Roberts crossgradient operator) • Phép tốn Robert phép tốn Prewitt/Sobel (trình bày sau) đ c dùng đ xác đ nh c nh, nên đ c g i xác đ nh c nh Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Ví d : phép tốn gradient-chéo Robert nh ban đ u Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Ví d ⎡1⎤ h1 = ⎢ ⎥ vaø h2 = [1 −1] ⎣ −1⎦ Tr Khoa Toán - Tin h c CuuDuongThanCong.com ⎡1 ⎤ ⎡ 1⎤ h1 = ⎢ vaø h2 = ⎢ ⎥ ⎥ ⎣ −1⎦ ⎣ −1 ⎦ ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Phép toán Prewitt • X p x gradient t t h n: • Có th đ c cài đ t nh m t n : ⎡ − − − 1⎤ ⎡ − 1⎤ h1 = ⎢ 0 ⎥ vaø h2 = ⎢ − 1⎥ ⎢ ⎥ ⎢ ⎥ 1 ⎥⎦ ⎢⎣ ⎢⎣ − 1⎥⎦ • V i cơng th c: Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Phép tốn Sobel • M t x p x khác: 2 1/2 [[( ) ( )] [( ) ( )] = z + z + z − z + z + z + z + z + z − z + z + z ∇f 9 ] ⎡ −1 −2 −1⎤ ⎡ −1 ⎤ h1 = ⎢ 0 ⎥ vaø h2 = ⎢ −2 ⎥ ⎢ ⎥ ⎢ ⎥ ⎢⎣ ⎥⎦ ⎢⎣ −1 ⎥⎦ • ây đ c g i phép toán Sobel Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt Ví d Prewitt Sobel Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt • LINEAR SPATIAL FILTERING • • • • >> f=imread(fish.jpg’); %load in checkerboard figure % g=imfilter(f,w,filtering_mode, boundary_options,size_options) % f is the input image , w is the filter mask % Filtering mode: – – • % Boundary options: – – – – • % % % % P without quotes (default) - pad image with zeros ‘replicate’ - extend image by replicating border pixels ‘symmetric’ - extend image by mirroring it across its border ‘circular’ - extend image byrepeating it (one period of a periodic function) % Size options: – – • % ‘corr’ filtering is done using correlation % ‘conv’ filtering is done using convolution flips mask 180 degrees % % ‘full’ - output is the same size as the padded image ‘same’ - output is the same size as the input >> w=ones(9); • >> gd=imfilter(f,w); • >> imshow( gd, [ ]) – – • • • • % create a 9x9 filter (not normalized) % filter using default values % [ ] causes MATLAB to display using low and high % gray levels of input image % Good for low dynamic range >> gr=imfilter(f,w,’replicate’); % pad using replication >> figure, imshow(gr, [ ]) % >> gs=imfilter(f,w,’symmetric’); % pad using symmetry >> figure, imshow(gs, [ ]) % show this figure in a new window Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt • LINEAR SPATIAL FILTERING • >> f=imread(fig3.15(a).jpg’); • >> w=ones(9); • %load in checkerboard figure % create a 9x9 filter (not normalized) – % f is of type double in [0,1] by default >> f8=im2uint8(f); % converts image to uint8, i.e., integers in range [0,255] • >> g8r=imfilter(f8,w,’replicate’); • % pad using replication – % imfilter creates an output of same data class as input, i.e., uint(8) >> imshow( g8r, [ ]) % clipping caused data loss since filter was not normalized Tr Khoa Toán - Tin h c CuuDuongThanCong.com ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt • >> f=imread(‘fish.jpg’); %load in checkerboard figure • >> w=fspecial(‘type’, parameters); % create filter mask • % filter types: – – – – – – • • • • • >> >> >> >> • • • • • >> >> >> >> >> % % % % % % ‘average’, default is 3x3 ‘gaussian’, default is 3x3 and sigma=0.5 ‘laplacian, default alpha=0.5 ‘prewitt’, vertical gradient, default is 3x3 Get horizontal by wh=w’ ‘sobel’, vertical gradient, default is 3x3 ‘unsharp’, default is 3x3 with alpha=0.2 f=imread(‘Moon.jpg’); %load in lunar north pole image w4=fspecial(‘laplacian’,0) % creates 3x3 laplacian, alpha=0 [0:1] w8=[1 1;1 -8 1;1 1] % create a Laplacian that fspecial can’t f=im2double(f); % output same as input unit8 so % negative values are truncated % Convert to double to keep negative values • g4=f-imfilter(f,w4,’replicate’); g8=f-imfilter(f,w8,’replicate’); imshow(f) imshow(g4) imshow(g8) Tr Khoa Toán - Tin h c CuuDuongThanCong.com % filter using default values % filter using default values % display original image % display g4 processed image % display g8 processed image ng HKHTN Tp.HCM 2007 https://fb.com/tailieudientucntt ... truncated % Convert to double to keep negative values • g4=f-imfilter(f,w4,’replicate’); g8=f-imfilter(f,w8,’replicate’); imshow(f) imshow(g4) imshow(g8) Tr Khoa Toán - Tin h c CuuDuongThanCong.com... làm khác bi t gi a pixel không nhi u Phép l c tr n dùng cho: – Làm m nh (Blurring): ây b c ti n x lý nh m lo i b b t chi ti t nh (không c n thi t) tr c trích đ i t ng c n thi t (l n), hay làm t... b ng c tính d a láng gi ng, nên m t n cịn có tên trung bình láng gi ng (neighborhood averaging) Vài lo i 3x3: • Phép tốn t ng đ ng l c b ng thông th p Tr Khoa Toán - Tin h c CuuDuongThanCong.com