title: Behaviour of cv2.imwrite with np.float64 data
body: <p>Looking at the <a href="https://docs.opencv.org/3.4/d4/da8/group__imgcodecs.html" rel="nofollow noreferrer">cv2 documentation</a>, I got the impression that one should be able in Python to match the writing out of <code>np.float64</code> data by a <code>np.clip</code> followed by type coercion to <code>np.uint8</code>. However, this doesn't seem to be the case. Reproducible example:</p>
  <pre><code>import cv2
  import numpy as np
  
  arr = np.random.uniform(low=0, high=300, size=(64,48,3))
  arr2 = np.clip(arr, 0, 255)
  arr3 = arr2.astype(np.uint8)
  
  cv2.imwrite('out1.png', arr)
  cv2.imwrite('out2.png', arr2)
  cv2.imwrite('out3.png', arr3)
  
  arr1a = cv2.imread('out1.png')
  arr2a = cv2.imread('out2.png')
  arr3a = cv2.imread('out3.png')
  print((arr1a==arr2a).all())
  print((arr1a==arr3a).all())
  </code></pre>
  <p>yields <code>True</code> for the first check and <code>False</code> for the second check.</p>
  <p>This indicates that (1) <code>cv2.imwrite</code> indeed calls <code>np.clip(arr, 0, 255)</code> on the array before writing it out; (2) it doesn't then call <code>.astype(np.uint8)</code> (or at least, that's not all).</p>
  <p>My goal is to understand what exactly <code>cv2.imwrite</code> is doing to <code>arr</code>. In other words, how can I calculate an array identical to <code>arr1a</code> in my example above, without saving an intermediate file?</p>