title: OpenCV Erode and Dilate switched
body: <p>I'm curious why does when I try to dilate the picture, the background expands, and the object in the foreground shrink. And when I try to erode the picture, the background shrinks, and the object expands. should it be the other way around?</p>
  
  <pre><code> int type = 2;
      int size = 5;
      Mat element = getStructuringElement( type, Size( 2*size + 1, 2*size + 1), Point( size, size ));
      switch( filterEnhan )
      {
          case 0: out=img.clone();
              break;
          case 1: morphologyEx(img, out, MORPH_DILATE, element);
              break;
          case 2: morphologyEx(img, out, MORPH_ERODE, element);
              break;
          case 3:morphologyEx(img, out, MORPH_OPEN, element);
              break;
      }
  </code></pre>
  
  <p>Original image :
  <img src="https://i.stack.imgur.com/hzCvC.png" alt="Original Image"></p>
  
  <p>After dilatation : 
  <img src="https://i.stack.imgur.com/HqnGB.png" alt="After dilatation:"></p>
  
  <p>After erosion:
  <img src="https://i.stack.imgur.com/ZqZOk.png" alt="After Erosion:"></p>