horshack

rawBayerToChannels.m

Apr 5th, 2021
670
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %%
  2. %% Splits an interleaved bayer image into individual RGGB channels
  3. %%
  4. %% Parameters:
  5. %% cfaPatternStr - CFA pattern. Must be RGGB or GBRG
  6. %% imgData - Interleaved bayer image
  7. %%
  8. %% Returns:
  9. %% Four separate color channels from bayer data: r, g1, g2, b
  10. %%
  11. function [r, g1, g2, b] = rawBayerToChannels(cfaPatternStr, imgData)
  12.  
  13.   switch (cfaPatternStr)
  14.     case "RGGB"
  15.       redGreen1_FirstRow = 1;
  16.       green2Blue_FirstRow = 2;
  17.     case "GBRG"
  18.       redGreen1_FirstRow = 2;
  19.       green2Blue_FirstRow = 1;
  20.     otherwise
  21.       assert(0, "Unsupported CFA pattern string");
  22.   end
  23.  
  24.   r  = imgData(redGreen1_FirstRow:2:end, 1:2:end);
  25.   g1 = imgData(redGreen1_FirstRow:2:end, 2:2:end);
  26.   g2 = imgData(green2Blue_FirstRow:2:end, 1:2:end);
  27.   b  = imgData(green2Blue_FirstRow:2:end, 2:2:end);
  28.  
  29. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×