RGB2RAW(RGGB)

imgpath='C:/Users/EDY/Desktop/Training/074/'
ip2 = '262A2582'
ip22 = '.tif'
im3 = '.raw'
a = cv2.imread('{}{}{}'.format(imgpath,ip2,ip22),-1)
print(a)
#img=skimage.imread(imgpath)
# r=img[:,:,0]
# g=img[:,:,1]
# b=img[:,:,2]
# nir=img[:,:,3]
a = a/(2**16)
#a = a.astype(np.uint16)

print(a)
#gb = a[:,:,1]
#rggb = np.concatenate((a,gb),1)
rggb = np.zeros([1000,1500])
print(rggb.shape)

for i in range(500):
    for j in range(750):
        rggb[2 * i, 2 * j] = a[2*i, 2*j, 1]  # gb
        rggb[2 * i, 2 * j + 1] = a[2*i, 2*j+1, 2]  # b
        rggb[2 * i + 1, 2 * j] = a[2*i+1, 2*j, 0]  # r
        rggb[2 * i + 1, 2 * j + 1] = a[2*i+1, 2*j+1, 1]  # gr


# rggb[::2,:,0] = a[:,:,0]
# rggb[:,:,1] = a[:,:,1]
# rggb[:,:,2] = a[:,:,1]
# rggb[:,:,3] = a[:,:,2]
# out = RawUtils.rggb2bayer(rggb)


rggb = rggb*4095
rggb[rggb>4096] = 4096
out = rggb.astype(np.uint16)
out.tofile('{}{}{}'.format(imgpath,ip2,im3))
print(rggb.shape)
print(out)
print(a.shape)
#print(np.clip(a,0,1))

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SetMaker

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值