title: Converting a given 2d array into a binary image using opencv in python
body: <p><strong>So here is the incomplete code</strong></p>
  <pre><code>import cv2
  import numpy as np
  arr= np.zeros((30,30))
  # bw_image = &lt;missing part&gt;
  cv2.imshow(&quot;BW Image&quot;,bw_image)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  
  #please use arr at 4th line to complete the code
  </code></pre>
  <p>I am actually new to this and don't know how to convert a given 2d array into a binary image using opencv.<br />
  Please use the name &quot;arr&quot; for the missing part, as in my code, the array is not a zeros array, instead it has some random values of 0 and 255 of 400x400 shape.</p>