title: Implementing IMFILTER in matlab
body: <p>I am trying to filter an image with out using <code>imfilter</code>. I should get the same results as <code>imfilter</code> but I keep getting diffrent results. Can someone tell me where I went wrong?</p>
  
  <pre><code>orignal=imread('obj6__17.png');
  filter=1/9*[-1 -1 -1 ; -1 17 -1 ; -1 -1 -1];
  s=size(orignal);
  r=zeros(s(1));
  temp = zeros(3);
  
  for i= 2: s(1)-1
  for j = 2: s(2)-1
  
      for n= 1: 3
          for m= 1:3
              temp(n,m)=orignal(i+2-n,j+2-m)*filter(n,m);
          end
      end
      r(i,j)=sum(single(sum(temp)));
  end
  end
  </code></pre>