title: Create the 2D blurring matrix in matlab
body: <p>I can apply a filter on an image <code>I</code> by the following code:</p>
  
  <pre><code>h = fspecial('gaussian',20,4);
  blurred = conv2(I,h,'same');
  </code></pre>
  
  <p>The size of the image <code>I</code> is the same as of <code>blurred</code>, I want to write the process of convolution in matrix multiplication form i.e. <code>blurred=H*I(:)</code> so i tried the following:</p>
  
  <pre><code> H=convmtx2(h,size(I));
   blurred=H*I(:);
  </code></pre>
  
  <p>but the size of <code>blurred</code> after reshaping will be larger than of  <code>I</code> because <code>convmtx2</code> return a full convolution matrix, How can i get a convolution matrix that will return only the central part not the full convolution.</p>