1# Copyright 2024 The Android Open Source Project. 2 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Noise model constants.""" 15 16 17import matplotlib.colors 18import matplotlib.pyplot as plt 19 20# Standard Bayer color channel names in canonical order. 21BAYER_COLORS = ('R', 'Gr', 'Gb', 'B') 22 23# Standard Bayer color filter arrangements dictionary. 24# The keys are color filter arrangement indices and values are dictionaries 25# mapping standard Bayer color channels to indices. 26BAYER_COLOR_FILTER_MAP = { 27 0: {'R': 0, 'Gr': 1, 'Gb': 2, 'B': 3}, 28 1: {'Gr': 0, 'R': 1, 'B': 2, 'Gb': 3}, 29 2: {'Gb': 0, 'B': 1, 'R': 2, 'Gr': 3}, 30 3: {'B': 0, 'Gb': 1, 'Gr': 2, 'R': 3}, 31} 32 33# Colors for plotting standard Bayer noise model parameters of each channel. 34BAYER_PLOT_COLORS = ('red', 'green', 'black', 'blue') 35 36# Quad Bayer color channel names in canonical order. 37QUAD_BAYER_COLORS = ( 38 'R0', 'R1', 'R2', 'R3', 39 'Gr0', 'Gr1', 'Gr2', 'Gr3', 40 'Gb0', 'Gb1', 'Gb2', 'Gb3', 41 'B0', 'B1', 'B2', 'B3', 42) 43 44# Quad Bayer color filter arrangements dictionary. 45# The keys are color filter arrangement indices and values are dictionaries 46# mapping quad Bayer color channels to indices. 47QUAD_BAYER_COLOR_FILTER_MAP = { 48 0: { 49 'R': [0, 1, 4, 5], 50 'Gr': [2, 3, 6, 7], 51 'Gb': [8, 9, 12, 13], 52 'B': [10, 11, 14, 15], 53 }, 54 1: { 55 'Gr': [0, 1, 4, 5], 56 'R': [2, 3, 6, 7], 57 'B': [8, 9, 12, 13], 58 'Gb': [10, 11, 14, 15], 59 }, 60 2: { 61 'Gb': [0, 1, 4, 5], 62 'B': [2, 3, 6, 7], 63 'R': [8, 9, 12, 13], 64 'Gr': [10, 11, 14, 15], 65 }, 66 3: { 67 'B': [0, 1, 4, 5], 68 'Gb': [2, 3, 6, 7], 69 'Gr': [8, 9, 12, 13], 70 'R': [10, 11, 14, 15], 71 }, 72} 73 74# Colors for plotting noise model parameters of each quad Bayer channel. 75QUAD_BAYER_PLOT_COLORS = ( 76 'pink', 'magenta', 'red', 'darkred', 77 'lightgreen', 'greenyellow', 'lime', 'green', 78 'orange', 'yellow', 'grey', 'black', 79 'lightblue', 'cyan', 'blue', 'darkblue', 80) 81 82NUM_BAYER_CHANNELS = len(BAYER_COLORS) 83NUM_QUAD_BAYER_CHANNELS = len(QUAD_BAYER_COLORS) 84VALID_NUM_CHANNELS = (NUM_BAYER_CHANNELS, NUM_QUAD_BAYER_CHANNELS) 85VALID_RAW_STATS_FORMATS = ( 86 'rawStats', 'rawQuadBayerStats', 87 'raw10Stats', 'raw10QuadBayerStats', 88) 89 90# Rainbow color map used to plot stats samples of different exposure times. 91RAINBOW_CMAP = plt.cm.rainbow 92# Assume the maximum exposure time is 2^12 ms for calibration. 93COLOR_NORM = matplotlib.colors.Normalize(vmin=0, vmax=12) 94COLOR_BAR = plt.cm.ScalarMappable(cmap=RAINBOW_CMAP, norm=COLOR_NORM) 95OUTLIER_MEDIAN_ABS_DEVS_DEFAULT = 3 96