Advertisement
horshack

channelsToRawBayer.m

Apr 5th, 2021
3,385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.74 KB | None | 0 0
  1. %%
  2. %% Builds an interleaved bayer image from individual RGGB channels
  3. %%
  4. %% Parameters:
  5. %% cfaPatternStr - CFA pattern. Must be RGGB or GBRG
  6. %% r, g1, g2, b - Matricies containing the red, green1, green2, and blue channels
  7. %%
  8. %% Returns:
  9. %% Interleaved bayer image
  10. %%
  11. function [imgData] = channelsToRawBayer(cfaPatternStr, r, g1, g2, b)
  12.   redGreen1  = reshape([r'(:) g1'(:)]', [], size(r,1))';
  13.   green2Blue  = reshape([g2'(:) b'(:)]', [], size(g2,1))';
  14.   if (cfaPatternStr == "RGGB")
  15.     imgData = reshape([redGreen1(:) green2Blue(:)]',2*size(redGreen1,1), []);
  16.   elseif (cfaPatternStr == "GBRG")
  17.     imgData = reshape([green2Blue(:) redGreen1(:)]',2*size(redGreen1,1), []);
  18.   else
  19.     assert(0, "Unsupported CFA pattern string");
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement