I have a particular np.array data 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.
I've already tried:
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)
But cv2.imshow is not giving the image as expected, but with strange distortion...
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?
Thanks.
datanp.float64? Also, converting 65535 to 255 to me seems that your expected input type isnp.uint16, notnp.float64. - rayryeng