Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import numpy as np
  2. def get_bayer_masks(n_rows, n_cols):
  3. R = [[0, 1], [0, 0]]
  4. G = [[1, 0], [0, 1]]
  5. B = [[0, 0], [1, 0]]
  6. return np.stack(
  7. [
  8. np.tile(R, ((n_rows + 1)//2, (n_cols + 1)//2))[:n_rows,:n_cols],
  9. np.tile(G, ((n_rows + 1)//2, (n_cols + 1)//2))[:n_rows,:n_cols],
  10. np.tile(B, ((n_rows + 1)//2, (n_cols + 1)//2))[:n_rows,:n_cols]
  11. ],
  12. axis = 2
  13. )
  14. def get_colored_img(raw_img):
  15. masks = get_bayer_masks(*raw_img.shape)
  16. return np.stack(
  17. [
  18. raw_img*masks[...,0],
  19. raw_img*masks[...,1],
  20. raw_img*masks[...,2]
  21. ],
  22. axis = 2
  23. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement