Channel sampled by the CFA at (row, col): 0=R, 1=G, 2=B. Indexed by the top-left 2x2 tile of each pattern.
| 399 | // Channel sampled by the CFA at (row, col): 0=R, 1=G, 2=B. Indexed by the |
| 400 | // top-left 2x2 tile of each pattern. |
| 401 | int cfaChannel(BayerPattern pattern, int row, int col) noexcept { |
| 402 | static constexpr int kTiles[4][2][2] = { |
| 403 | {{0, 1}, {1, 2}}, // RGGB |
| 404 | {{1, 0}, {2, 1}}, // GRBG |
| 405 | {{1, 2}, {0, 1}}, // GBRG |
| 406 | {{2, 1}, {1, 0}}, // BGGR |
| 407 | }; |
| 408 | return kTiles[static_cast<int>(pattern)][row & 1][col & 1]; |
| 409 | } |
| 410 | |
| 411 | } // namespace |
| 412 |