f1 = zeros(256,256);
f2 = ones(256,256);
f3 = ones(256,256);
f4 = zeros(256,256);
f = [f1,f2;f3,f4];
imshow(f)
%two symmetric filters
w = ones(31);               %accumulator
w1 = ones(31,31)/(31^2);    %average filter
%default boundary option, padding the border of the image with zeros 
%the edges between black and white in the filtered image are blurred
g = imfilter(f,w1);
figure(2), imshow(g,[])
%to solve this problem use 
% 1. use boundary option 'replicate' 
g1 = imfilter(f,w1,'replicate');
figure(3), imshow(g1,[])
% 2. use boundary option 'symmetric' 
g2 = imfilter(f,w1,'symmetric');
figure(4), imshow(g2,[])
%using boundary option 'circular'
%the edges between black and white in the filtered image are blurred
%the same problem as zero padding
g3 = imfilter(f,w1,'circular');
figure(5), imshow(g3,[])
%scaling effect of using imfilter with an image of class uint8
%clipping caused some data loss
%coeffecients of the mask did not sum to the range [0 1],resulting 
%in filtered values outside the [0 255] range;
%to avoid this problem , we have the option of normalizing the 
%coeffecients by (31)^2, so the sum would be 1, or inputting the 
%data in double format
f8 = im2uint8(f);
g8 = imfilter(f8,w1,'replicate');
figure(6), imshow(g8,[]);



