Created
December 13, 2017 06:51
-
-
Save ndahlquist/805eb6e3f5b8bfc88d79ae8214a95438 to your computer and use it in GitHub Desktop.
This file contains 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 rawpy | |
import imageio | |
raw = rawpy.imread('RAW_2017_12_12_22_08_32_701.dng') | |
print(raw.raw_image.shape) | |
# (3032, 4032) | |
def save_plane(plane, name): | |
# Dumb tone-mapping. (The raw file is 16 bit, but we can only display 8 bits). | |
plane //= 2 | |
# Clamp to 0-255. | |
plane[plane > 255] = 255 | |
plane = plane.astype('uint8') | |
imageio.imsave(name, plane) | |
# Save each of the four image planes as a separate png. | |
save_plane(raw.raw_image[::2, ::2], '0.png') | |
save_plane(raw.raw_image[::2, 1::2], '1.png') | |
save_plane(raw.raw_image[1::2, ::2], '2.png') | |
save_plane(raw.raw_image[1::2, 1::2], '3.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment