title: implementing erosion, dilation in C, C++
body: <p>I have theoretical understanding of how dilation in binary image is done.</p>
  
  <p>AFAIK, If my SE (structuring element) is this </p>
  
  <pre><code>0 1
  1 1. 
  </code></pre>
  
  <p>where . represents the centre, and my image(binary is this)</p>
  
  <pre><code>0 0 0 0 0
  0 1 1 0 0
  0 1 0 0 0
  0 1 0 0 0
  0 0 0 0 0
  </code></pre>
  
  <p>so the result of dilation is </p>
  
  <pre><code>0 1 1 0 0 
  1 1 1 0 0
  1 1 0 0 0
  1 1 0 0 0
  0 0 0 0 0
  </code></pre>
  
  <p>I got above result by shifting Image in 0, +1 (up) and and -1(left) direction, according to SE, and taking the union of all these three shifts.</p>
  
  <p>Now, I need to figure out how to implement this in C, C++.
  I am not sure how to begin and how to take the union of sets.
  I thought of representing original image,three shifted images and final image obtained by taking union; all using matrix.</p>
  
  <p>Is there any place where I can get some sample solution to start with or any ideas to proceed ?</p>
  
  <p>Thanks.</p>