I frequently convert 16-bit grayscale image data to 8-bit image data for display. It\'s almost always useful to adjust the minimum and maximum display intensity to highlight
I would avoid casting the image to float, you could do something like:
import numpy as np
def display(image, display_min, display_max):
# Here I set copy=True in order to ensure the original image is not
# modified. If you don't mind modifying the original image, you can
# set copy=False or skip this step.
image = np.array(image, copy=True)
image.clip(display_min, display_max, out=image)
image -= display_min
image //= (display_min - display_max + 1) / 256.
image = image.astype(np.uint8)
# Display image
Here an optional copy of the image is made in it's native data type and an 8 bit copy is make on the last line.