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))
RGB2RAW(RGGB)
最新推荐文章于 2024-07-12 18:51:59 发布