clc
clear 
img=imread('sample.bmp');
s=3;
[row,col]=size(img);
r=row+s-2;
c=col+s-2;
img2=zeros(r,c); 
% copy ax
for i=1:row
for j=1:col
if(i<=row && j<=col)
img2(i+1,j+1)=img(i,j);
end
end
end
% anjame amale correlation
% anjame amale miyangin giri ba maske 3x3
for i=s-1:r
for j=s-1:c
temp1=0;
temp2=0;
if(i<r && j<c)
temp1=img2(i-1,j-1).W((+ array1(i-1,j)+ array1(i-1,j+1)+ array1(i,j-1)+ array1(i,j+1)+...
    array1(i+1,j-1)+array1(i+1,j)+array1(i+1,j+1)+array1(i,j);
temp2=temp1/9;
array2(i,j)=temp2;
end
end
end

