2D Convolution by Matlab filter2 command

 

 

²  LP

boy= imread('boy_gray.tif' ');

h= (1/9)*ones(3);

boy_lp=filter2(h,boy);

  % boy 自動被轉成 double 去計算

figure; imshow(uint8(boy_lp))

  % 仔細觀察,發現比原圖模糊(blurred)些

 

Note: Manual Calculation should be demonstrated!

Note: Try  h= (1/25)*ones(5);

 

²  HP (Edge Detection)

boy= imread('boy_gray.tif');

% h= [0 -1 0; -1 4 -1; 0 -1 0];  效果極不明顯

h= [0 0 -1 0 0; 0 -1 -2 -1 0; -1 -2 16 -2 -1; 0 -1 -2 -1 0; 0 0 -1 0 0];

boy_hp=filter2(h,boy);

figure; imshow(uint8(boy_hp))

8-6