Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
16bit grayscale to separate 8 bit color channels
import numpy as np, cv2
src = cv2.imread("moon-elevation-8k-16bit.tif",cv2.IMREAD_UNCHANGED)
h,w = src.shape
dst = np.zeros((h,w,3), np.uint8)
dst[:,:,1] = (src & 0xff00) >> 8
dst[:,:,2] = src & 0x00ff
cv2.imwrite("moon-bump.png",dst)
@companje
Copy link
Author

companje commented Dec 24, 2021

Screenshot 2021-12-24 at 13 24 56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment