Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Converting non-image .tiff data to pseudo-images (8-bit greyscale, high contrast).
from PIL import Image
import numpy as np
import os
for fname in os.listdir("."):
if fname.endswith(".tiff"):
maxval = np.max(arr[arr>0])
minval = np.min(arr[arr>0])
arrf = np.array(arr,dtype=np.float)
arrf = np.array(np.round(255.0*arrf/(maxval-minval)),dtype=np.uint8)
im8 = Image.fromarray(arrf)
im8 = im8.resize([500,500])".tiff")+".jpg")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.