Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%
- %% Splits an interleaved bayer image into individual RGGB channels
- %%
- %% Parameters:
- %% cfaPatternStr - CFA pattern. Must be RGGB or GBRG
- %% imgData - Interleaved bayer image
- %%
- %% Returns:
- %% Four separate color channels from bayer data: r, g1, g2, b
- %%
- function [r, g1, g2, b] = rawBayerToChannels(cfaPatternStr, imgData)
- switch (cfaPatternStr)
- case "RGGB"
- redGreen1_FirstRow = 1;
- green2Blue_FirstRow = 2;
- case "GBRG"
- redGreen1_FirstRow = 2;
- green2Blue_FirstRow = 1;
- otherwise
- assert(0, "Unsupported CFA pattern string");
- end
- r = imgData(redGreen1_FirstRow:2:end, 1:2:end);
- g1 = imgData(redGreen1_FirstRow:2:end, 2:2:end);
- g2 = imgData(green2Blue_FirstRow:2:end, 1:2:end);
- b = imgData(green2Blue_FirstRow:2:end, 2:2:end);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement