21.06.2014 Views

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Two-dimensional trigonometric basis of C m,n :<br />

}<br />

tensor product matrices<br />

{(F m ) :,j (F n ) T :,l , 1 ≤ j ≤ m, 1 ≤ l ≤ n . (7.2.13)<br />

10<br />

Original<br />

10<br />

Blurred image<br />

Basis transform: for y j1 ,j 2<br />

∈ C, 0 ≤ j 1 < m, 0 ≤ j 2 < n compute (nested DFTs !)<br />

20<br />

20<br />

c k1 ,k 2<br />

=<br />

m−1 ∑<br />

n−1 ∑<br />

j 1 =0 j 2 =0<br />

y j1 ,j 2<br />

ω j 1k 1<br />

m ω j 2k 2<br />

n , 0 ≤ k 1 < m, 0 ≤ k 2 < n .<br />

30<br />

40<br />

50<br />

30<br />

40<br />

50<br />

MATLAB function: fft2(Y) .<br />

60<br />

60<br />

70<br />

70<br />

80<br />

80<br />

Two-dimensional DFT by nested one-dimensional DFTs (7.2.8):<br />

90 Fig. 96<br />

120<br />

20 40 60 80 100<br />

90 Fig. 97<br />

120<br />

20 40 60 80 100<br />

Here:<br />

fft2(Y) = fft(fft(Y).’).’<br />

.’ simply transposes the matrix (no complex conjugation)<br />

Example 7.2.17 (Deblurring by DFT).<br />

Gray-scale pixel image P ∈ R m,n , actually P ∈ {0, ...,255} m,n , see Ex. 5.3.9.<br />

( )<br />

pl,k ˆ= periodically extended image:<br />

l,k∈Z<br />

p l,j = (P) l+1,j+1 for 1 ≤ l ≤ m, 1 ≤ j ≤ n , p l,j = p l+m,j+n ∀l,k ∈ Z .<br />

Blurring = pixel values get replaced by weighted averages of near-by pixel values<br />

c l,j =<br />

(effect of distortion in optical transmission systems)<br />

L∑<br />

blurred image<br />

L∑<br />

k=−L q=−L<br />

s k,q p l+k,j+q ,<br />

point spread function<br />

0 ≤ l < m ,<br />

0 ≤ j < n ,<br />

L ∈ {1, . ..,min{m, n}} . (7.2.14)<br />

Ôº º¾<br />

Code 7.2.19: MATLAB deblurring experiment<br />

1 % Generate artifical “image”<br />

2 P = kron ( magic ( 3 ) , ones (30 ,40) ) ∗31;<br />

3 c o l = [ 0 : 1 / 2 5 4 : 1 ] ’ ∗ [ 1 , 1 , 1 ] ;<br />

4 figure ; image (P) ; colormap ( c o l ) ; t i t l e ( ’ O r i g i n a l ’ ) ;<br />

5 p r i n t −depsc2 ’ . . / PICTURES/ dborigimage . eps ’ ;<br />

Ôº º¾<br />

6 % Generate point spread function<br />

7 L = 5 ; S = psf ( L ) ;<br />

8 % Blur image<br />

9 C = b l u r (P, S) ;<br />

10 figure ; image ( f l o o r (C) ) ; colormap ( c o l ) ; t i t l e ( ’ Blurred image ’ ) ;<br />

11 p r i n t −depsc2 ’ . . / PICTURES/ dbblurredimage . eps ’ ;<br />

12 % Deblur image<br />

13 D = deblur (C,S) ;<br />

14 figure ; image ( f l o o r ( real (D) ) ) ; colormap ( c o l ) ;<br />

15 f p r i n t f ( ’ D i f f e r e n c e o f images ( Frobenius norm ) : %f \ n ’ ,norm(P−D) ) ;<br />

Usually:<br />

L small, s k,m ≥ 0, ∑ L<br />

k=−L<br />

∑ Lq=−L<br />

s k,q = 1 (an averaging)<br />

Code 7.2.18: point spread function<br />

Used in test calculations: L = 5<br />

1 function S = psf ( L )<br />

1<br />

s k,q =<br />

1 + k 2 + q 2 . 2 [ X,Y] = meshgrid(−L : 1 : L,−L : 1 : L ) ;<br />

3 S = 1 . / ( 1 +X.∗X+Y.∗Y) ;<br />

4 S = S /sum(sum(S) ) ;<br />

Ôº º¾<br />

Ôº º¾

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!