|
a |
|
b/Visualize.py |
|
|
1 |
# This code converts a 16bit uint TIFF image (that can not be displayed by normal monitors) to a Visualizable TIFF image |
|
|
2 |
|
|
|
3 |
import PIL.Image as pil_image |
|
|
4 |
import io |
|
|
5 |
import numpy as np |
|
|
6 |
path='path to the TIFF image' |
|
|
7 |
save_path='path to save the Visualizable image' |
|
|
8 |
with open(path, 'rb') as f: |
|
|
9 |
tif = pil_image.open(io.BytesIO(f.read())) |
|
|
10 |
array=np.array(tif) |
|
|
11 |
max_val=np.amax(array) |
|
|
12 |
normalized=(array/max_val) |
|
|
13 |
im = pil_image.fromarray(normalized) |
|
|
14 |
im.save(save_path) |