Created
October 28, 2021 08:28
-
-
Save tvercaut/f31dcc3180b80c7cda50ab23d0eceb06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import imageio | |
url = 'https://archive.org/download/10thframekixxc64800dpi48bit/10th%20Frame%20%28Kixx%29_C64_Cassette_800dpi_48bit.tif' | |
im0 = imageio.imread(url) | |
print('im0:',np.min(im0),np.max(im0),im0.shape,im0.dtype) | |
im0gray = 0.299*np.float32(im0[:,:,0]) + 0.587*np.float32(im0[:,:,1]) + 0.114*np.float32(im0[:,:,2]) | |
im0gray = im0gray / np.max(im0gray) | |
im1 = np.uint16(np.round( im0gray*((1<<10)-1) )) | |
print('im1:',np.min(im1),np.max(im1),im1.shape,im1.dtype) | |
imageio.imwrite('sample10bit.png',im1) | |
plt.figure() | |
plt.imshow(np.float32(im0)/(1<<16)) | |
plt.figure() | |
plt.imshow(im1,cmap='gray') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment