title: Why do we use an array of ones for a kernel in OpenCV?
body: <p>As I was reading the OpenCV docs today, I came across an interesting group of functions known as morphological transformations. While, I feel like I have a good grasp on the concepts of erosion and dilation, I am unable to understand why we use an array of 1's when performing the morphological transformation. For example, see the code below (referenced from <a href="https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_morphological_ops/py_morphological_ops.html" rel="nofollow noreferrer">Open CV documentation</a>, where the author creates a kernel populated with ones when performing an erosion.</p>
  
  <pre><code>import cv2
  import numpy as np
  
  img = cv2.imread('j.png',0)
  kernel = np.ones((5,5),np.uint8)
  erosion = cv2.erode(img,kernel,iterations = 1)
  </code></pre>
  
  <p>After some research, I understood that the underlying workings of an erosion is simply a 2D convolution where the pixel in question is compared to neighboring pixels, and the local minimum of the picture underneath the kernel is set as the value of the pixel. Yet, this does not help me clarify why we set our kernel to hold one's in the first place. Why not 0's? Why not 255's? The kernel's values should not affect the convolution in any way right?</p>