Convert np.array of type float64 to type uint8 scaling values : <p>I have a particular np.array <em>data</em> which represents a particular grayscale image.
I need to use SimpleBlobDetector() that unfortunately only accepts 8bit images, so I need to convert this image, obviously having a quality-loss.</p>

<p>I've already tried:</p>

<pre><code>import numpy as np
import cv2
[...]
data = data / data.max() #normalizes data in range 0 - 255
data = 255 * data
img = data.astype(np.uint8)
cv2.imshow("Window", img)
</code></pre>

<p>But <em>cv2.imshow</em> is not giving the image as expected, but with strange distortion...</p>

<p>In the end, I only need to convert a np.float64 to np.uint8 scaling all the values and truncating the rest, eg. 65535 becomes 255, 65534 becomes 254 and so on.... Any help?</p>

<p>Thanks.</p>
