-1

I am trying to write(save) a int16 numpy array as an image using openCV. Find the numpy file of an image in the link below: https://drive.google.com/file/d/1nEq_CeNmSgacARa2ADr_f_qVaSfJSZZX/view?usp=sharing The image I saved in bmp or png or tiff format is look like this: Uint16

I converted the numpy array to uint8 and the image become very dark and the maximum value of the image is just 34 as shown below: uint8

Please let me know how to properly save and visualize this int16 format image.

Note: plt.imshow of int16 numpy array showing proper visual. matplotlib_imshow

1 Answers1

-1

I have saved the image properly using the following syntax

from skimage.util import img_as_ubyte

img=np.load('brain.npy')

img1=img/img.max()

img2=img_as_ubyte(img1)

cv2.imwrite('brain_u8.png', img2) correct_output

  • 3
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 15 '22 at 03:44