Reputation: 301
I have to split raw image (.DNG) into different channels. CV does not support these formats, and I can't find rawpy function for that.
Upvotes: 1
Views: 1662
Reputation: 207455
Use rawpy
to convert your DNG into a Numpy array like this:
#!/usr/bin/env python3
import rawpy
import imageio
with rawpy.imread('image.dng') as raw:
rgb = raw.postprocess(gamma=(1,1), no_auto_bright=True, output_bps=16)
Then you can use Numpy to extract the channels and save like this:
# Extract Red, Green and Blue channels and save as separate files
R = rgb[:,:,0]
G = rgb[:,:,1]
B = rgb[:,:,2]
imageio.imsave('R.tif', R)
imageio.imsave('G.tif', G)
imageio.imsave('B.tif', B)
Or you can use OpenCV cv2.split()
to separate the channels:
import cv2
R, G, B = cv2.split(rgb)
Upvotes: 2