No BSD License  

Highlights from
Basic Image Processing

from Basic Image Processing by Sandeep
This will help those who start doing Image Processing with Matlab

spatialfilt.m
function[y]=spatialfilt(a,b)
% a-image s- size of mask b-mask assuming mask is a square matrix
s=length(b);
if(mod(s,2)==0)
    s=s+1;
end
s1=size(a);
r1=(s-1)/2;
c1=(s-1)/2;
y=a;
for i=1+r1:(s1(1)-r1)
    for j=1+c1:(s1(2)-c1)
       y(i,j)=sum(sum(b.*a((i-r1):(i+r1),(j-c1):(j+c1))));
    end
end

Contact us at files@mathworks.com