Skip to content

Instantly share code, notes, and snippets.

@companje
Created December 24, 2021 12:14
Show Gist options
  • Save companje/85e94ea96629ddaf1219f137b225fd69 to your computer and use it in GitHub Desktop.
Save companje/85e94ea96629ddaf1219f137b225fd69 to your computer and use it in GitHub Desktop.
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

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