Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def get_bayer_masks(n_rows, n_cols):
- R = [[0, 1], [0, 0]]
- G = [[1, 0], [0, 1]]
- B = [[0, 0], [1, 0]]
- return np.stack(
- [
- np.tile(R, ((n_rows + 1)//2, (n_cols + 1)//2))[:n_rows,:n_cols],
- np.tile(G, ((n_rows + 1)//2, (n_cols + 1)//2))[:n_rows,:n_cols],
- np.tile(B, ((n_rows + 1)//2, (n_cols + 1)//2))[:n_rows,:n_cols]
- ],
- axis = 2
- )
- def get_colored_img(raw_img):
- masks = get_bayer_masks(*raw_img.shape)
- return np.stack(
- [
- raw_img*masks[...,0],
- raw_img*masks[...,1],
- raw_img*masks[...,2]
- ],
- axis = 2
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement