0

I have a .tiff file/image. When I use the following code to visualize it inline in a python notebook, it looks like the following. Code and image shown below -

orig_img_path = os.path.join("/path/to/tiff/1000.tiff")
img_orig = Image.open(orig_img_path,"r")
img_arr = np.array(img_orig) 
min_pix, max_pix = np.amin(img_arr), np.amax(img_arr)
plt.imshow(img_arr, vmin = min_pix, vmax = max_pix, cmap = 'gray')
plt.show()

The image looks like the following -

enter image description here

Whereas the same image when viewed through the standard image viewer on my MacBook looks like so -

enter image description here

I am wondering why is there so much difference between the images when viewed through different methods. It seems like the one which is viewed through ipynb is much grayer than the one which viewed through simply on Mac.

Thanks and please let me know if I am missing anything.

-- Megh

Megh
  • 67
  • 1
  • 1
  • 7
  • Check the range and `dtype` of your pixels `print(min_pix, max_pix, img_arr.dtype)` – Mark Setchell Aug 21 '22 at 06:42
  • Does this answer your question? [Displaying Tiff images in ipynb or jupyter notebook](https://stackoverflow.com/questions/73424132/displaying-tiff-images-in-ipynb-or-jupyter-notebook) – code-lukas Aug 24 '22 at 12:43

0 Answers0