Advertisement
Guest User

bay2rg

a guest
Jan 27th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. Algorithm:
  2.  
  3. Read the original image.
  4.  
  5.  
  6.  
  7.  
  8. Separate the original matrix/image in to 3 matrices: R,G,B
  9. Odd Row, Odd Column = B
  10. Odd Row, Even Column = R
  11. Even Row, Odd Column = R
  12. Even Row, Even Column = G
  13.  
  14. generate---
  15.  
  16.  
  17.  
  18.  
  19. Each of these 3 new matrices is missing pixel data
  20. (where the other colours used to be) so use kernels
  21. to fill in missing data.
  22. *Note: In order to prevent addition overflow (>255), normalize the
  23. kernel values so their total sum is 1.
  24. * Also note: The kernel is only applied to pixels where data is missing. No need to colour in pixels that are already coloured.
  25.  
  26. There are 4 possible pixel layouts, so eight 3X3 Kernels are needed:
  27. 1)
  28. RGR
  29. BRB
  30. RGR
  31. 1b) Kernel to colour centre Blue: {(0,0,0),(0.5,0,0.5),(0,0,0)}
  32. 1g) Kernel to colour centre Green: {(0,0.5,0),(0,0,0),(0,0.5,0)}
  33.  
  34. 2)
  35. GRG
  36. RBR
  37. GRG
  38. 2r) Kernel to colour centre Red: {(0,0.25,0),(0.25,0,0.25),(0,0.25,0)}
  39. 2g) Kernel to colour centre Green: {(0.25,0,0.25),(0,0,0),(0.25,0,0.25)}
  40.  
  41.  
  42. 3)
  43. BRB
  44. RGR
  45. BRB
  46. 3b) Kernel to colour centre Blue: {(0.25,0,0.25),(0,0,0),(0.25,0,0.25)}
  47. 3r) Kernel to colour centre Red: {(0,0.25,0),(0.25,0,0.25),(0,0.25,0)}
  48.  
  49. 4)
  50. RBR
  51. GRG
  52. RBR
  53. 4b) Kernel to colour centre Blue: {(0,0.5,0),(0,0,0),(0,0.5,0)}
  54. 4g) Kernel to colour centre Green: {(0,0,0),(0.5,0,0.5),(0,0,0)}
  55.  
  56. Note: Some of these kernels are duplicates, so really only 4 kernels are needed:
  57. i) 1b, 4g -> {(0,0,0),(0.5,0,0.5),(0,0,0)}
  58. ii) 1g, 4b -> {(0,0.5,0),(0,0,0),(0,0.5,0)}
  59. iii) 2g, 3b -> {(0.25,0,0.25),(0,0,0),(0.25,0,0.25)}
  60. iv) 2r, 3r -> {(0,0.25,0),(0.25,0,0.25),(0,0.25,0)}
  61.  
  62.  
  63. This will leave you with 8 separate matrices. Combine the Rs in to a single complete R matrix, combine the Bs in to a complete B matrix, the Gs in to a complete G matrix.
  64.  
  65. Then combine these 3 full matrices in to a single 3-channel color image.
  66.  
  67. Display.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement