Spatial Filtering Spatial Filtering Spatial Filtering Filtering Example 1: 111 -121 -1-11 3 2 1 2 2 1 3 2 32 21 22 32 Rotate 1-1-1 12-1 111 Step 1 3 2 1 2 2 1 3 2 32 21 22 32 5 3 2 1 2 2 1 3 2 32 21 22 32 1-2-1 24-1 111 1-1-1 12-1 111 Step 2 3 2 1 2 2 1 3 2 32 21 22 32 45 3 2 1 2 2 1 3 2 32 21 22 32 3-1-2 24-2 111 1-1-1 12-1 111 Step 3 3 2 1 2 2 1 3 2 32 21 22 32 4 45 3 2 1 2 2 1 3 2 32 21 22 32 3-3-1 34-2 111 1-1-1 12-1 111 Step 4 3 2 1 2 2 1 3 2 32 21 22 32 4 4 -25 3 2 1 2 2 1 3 2 32 21 22 32 1-3-3 16-2 111 1-1-1 12-1 111 Step 5 3 2 1 2 2 1 3 2 32 21 22 32 4 4 9 -25 3 2 1 2 2 1 3 2 32 21 22 32 2-2-1 14-1 221 1-1-1 12-1 111 Step 6 3 2 1 2 2 1 3 2 32 21 22 32 6 4 4 9 -25 3 2 1 2 2 1 3 2 32 21 22 32 1-2-2 32-2 222 1-1-1 12-1 111 [...]... 5 5 2 6 3 3 6 6 3 6 3 3 6 6 3 5 2 2 5 5 2 linear spatial filtering g = imfilter(f, w, filtering_ mode, boundary_options, size_options) w is the filter filtering mode= corr, conv boundary options=p, replicate, symmetric, circular size options=full, same Options for function imfilter linear spatial filtering w=fspecial(‘type’, parameters); linear spatial filtering h = fspecial(type) h = fspecial(type,... Linear Spatial Filtering using function imfilter Some small programs (Matlab code) demonstrates Linear Spatial Filtering using function imfilter kid=imread('kid02.jpg'); w=[1 1 1;1 -8 1;1 1 1]; C=imfilter(kid, w,'corr', 'replicate', 'same'); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(4*C);title(mat2str(w),'FontSize',20); W= 1 1 1 1 −8 1 1 1 1 Linear Spatial. .. for n = 1+r:N-r for m = 1+r:M-r % Extract a window of size (2r+1)x(2r+1) around (m,n) w = x(m+(-r:r),n+(-r:r)); y(m,n)=sum(sum(w.*h)); end end subplot(1, 2, 1), imshow(x) subplot(1, 2, 2), imshow(y) Spatial Filtering Padarray function Generally: B = padarray(A,padsize,method,direction) B = padarray(A,padsize) pads an array A with zeros, where padsize defines the amount of padding to add in each dimension... w,'corr', 'replicate', 'same'); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(4*C);title(mat2str(w),'FontSize',20); W= 1 1 1 1 −8 1 1 1 1 Linear Spatial Filtering . as if we tiled blocks of data I1 = 3 1 2 3 1 6 4 5 6 4 3 1 2 3 1 6 4 5 6 4 3 1 2 3 1 6 4 5 6 4 replicates >>I=[1 2 3; 4 5 6] I = 1 2 3 4 5 6 Pads I with a whole border of 2 rows and 1. Spatial Filtering Spatial Filtering Spatial Filtering Filtering Example 1: 111 -121 -1-11 3 2 1 2 2 1 3 2 32 21 22 32 Rotate 1-1-1 12-1 111 Step. 4 9 -25 3 2 1 2 2 1 3 2 32 21 22 32 2-2-1 14- 1 221 1-1-1 12-1 111 Step 6 3 2 1 2 2 1 3 2 32 21 22 32 6 4 4 9 -25 3 2 1 2 2 1 3 2 32 21 22 32 1-2-2 32-2 222 1-1-1 12-1 111 Final Result 12 7 6 4 8 6 14 4 59 59 511 -25 3 2 1 2 2 1 3 2 32 21 22 32 1-1-1 12-1 111 Build