Advertisement
horshack

swapRedBlueChannels.m

Apr 5th, 2021 (edited)
2,918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.59 KB | None | 0 0
  1. %%
  2. %% Swaps the Red and Blue channels of an A7 III raw image
  3. %%
  4. function swapRedBlueChannels()
  5.  
  6.   cfaPatternStr = "RGGB";
  7.  
  8.   %% read raw data generated by LibRaw's unprocessed_raw.exe
  9.   imgDataIn = imread("in.ARW.pgm");
  10.   imgDataIn = resize(imgDataIn, 4024, 6024); % A73 visible dimensions
  11.  
  12.   %% split the raw data into its separate RGGB channels
  13.   [r, g1, g2, b] = rawBayerToChannels(cfaPatternStr, imgDataIn);
  14.  
  15.   %% for fun, swap the R and B channels
  16.   imgDataOut = channelsToRawBayer(cfaPatternStr, b, g1, g2, r);
  17.  
  18.   %% write a PGM with the new data
  19.   imwrite(imgDataOut, "out.pgm");
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement