%%%%%%%%%%%%%%%%%%%%%%%%%%%% CODE FOR THE AVERAGE & EDGE DETECTOR FILTERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;
clc;
u=imread('londonbridge.jpg');
I=rgb2gray(u);
[r,c]= size(I)
I(1,1)=0;
for j=1:r
for i=2:(c-1)
I_avg_filter(j,i+1)=(I(j,i)+I(j,i+1))/2; end
end
for j=1:r
for i=2:(c-1) I_edge_detector(j,i+1)=(I(j,i)-I(j,i+1)); end
end
subplot(3,2,1);
imshow(u);
title('Original Image');
subplot(3,2,2);
imshow(I);
title('Original Image in Gray scale');
subplot(3,2,3);
imshow(I_avg_filter);
title('Image using Average Filter');
subplot(3,2,4);
imshow(I_edge_detector);
title('Image using Edge Detector');
--Apanja 09:59, 14 October 2009 (UTC)Ananya Panja