9 #include <OpenImageIO/imagebuf.h>
10 #include <aliceVision/image/Image.hpp>
21 constexpr
double xyz_sRGB[3][3] = {{0.4360747, 0.3850649, 0.1430804}, {0.2225045, 0.7168786, 0.0606169}, {0.0139322, 0.0971045, 0.7141733}};
22 constexpr
double sRGB_xyz[3][3] = {{3.1338561, -1.6168667, -0.4906146}, {-0.9787684, 1.9161415, 0.0334540}, {0.0719453, -0.2289914, 1.4052427}};
24 constexpr
double xyz_prophoto[3][3] = {{0.7976749, 0.1351917, 0.0313534}, {0.2880402, 0.7118741, 0.0000857}, {0.0000000, 0.0000000, 0.8252100}};
25 constexpr
double prophoto_xyz[3][3] = {{1.3459433, -0.2556075, -0.0511118}, {-0.5445989, 1.5081673, 0.0205351}, {0.0000000, 0.0000000, 1.2118128}};
27 constexpr
double xyz_AdobeRGB[3][3] = {{0.6097559, 0.2052401, 0.1492240}, {0.3111242, 0.6256560, 0.0632197}, {0.0194811, 0.0608902, 0.7448387}};
28 constexpr
double AdobeRGB_xyz[3][3] = {{1.9624274, -0.6105343, -0.3413404}, {-0.9787684, 1.9161415, 0.0334540}, {0.0286869, -0.1406752, 1.3487655}};
31 enum class LightSource
41 DAYLIGHT_FLUORESCENT = 12,
42 DAYWHITE_FLUORESCENT = 13,
43 COOL_WHITE_FLUORESCENT = 14,
44 WHITE_FLUORESCENT = 15,
45 WARM_WHITE_FLUORESCENT = 16,
46 STANDARD_LIGHT_A = 17,
47 STANDARD_LIGHT_B = 18,
48 STANDARD_LIGHT_C = 19,
53 ISO_STUDIO_TUNGSTEN = 24,
57 double calibrationIlluminantToTemperature(LightSource light);
68 void Set(
const std::vector<double>& v_xy);
69 void Apply(
float& ir,
float& ig,
float& ib)
const;
70 float operator[](
const float idx)
const {
return getval(idx); }
73 void RGBTone(
float& maxval,
float& medval,
float& minval)
const;
74 float getval(
const float idx)
const;
76 std::vector<float> ffffToneCurve = std::vector<float>(65536, 0.f);
84 bool apply_hue_shift =
true;
85 bool apply_baseline_exposure_offset =
true;
86 bool use_tone_curve =
true;
87 bool apply_look_table =
true;
88 std::string working_space =
"sRGB";
96 std::string filename =
"";
97 std::string profileCalibrationSignature =
"";
99 bool has_color_matrix_1 =
false;
100 bool has_color_matrix_2 =
false;
101 bool has_camera_calibration_1 =
false;
102 bool has_camera_calibration_2 =
false;
103 bool has_forward_matrix_1 =
false;
104 bool has_forward_matrix_2 =
false;
105 bool has_look_table =
false;
106 bool has_hue_sat_map =
false;
107 bool has_tone_curve =
false;
108 bool has_baseline_exposure_offset =
false;
110 short light_source_1 = 0;
111 short light_source_2 = 0;
112 double temperature_1 = 0.0;
113 double temperature_2 = 0.0;
126 using Triple = std::array<double, 3>;
127 using Matrix = std::array<Triple, 3>;
135 explicit DCPProfile(
const std::string& filename);
142 void Load(
const std::string& filename);
148 void Load(
const std::map<std::string, std::string>& metadata);
155 void getMatrices(
const std::string& type, std::vector<Matrix>& v_Mat)
const;
169 void setMatrices(
const std::string& type, std::vector<Matrix>& v_Mat);
187 const Triple& neutral,
189 const bool sourceIsRaw =
false,
190 const bool useColorMatrixOnly =
true)
const;
201 const Triple& neutral,
203 const bool sourceIsRaw =
false,
204 const bool useColorMatrixOnly =
false)
const;
242 unsigned int array_count;
257 void hsdApply(
const HsdTableInfo& table_info,
const std::vector<HsbModify>& table_base,
float& h,
float& s,
float& v)
const;
259 Matrix matMult(
const Matrix& A,
const Matrix& B)
const;
260 Triple matMult(
const Matrix& M,
const Triple& V)
const;
261 Matrix matInv(
const Matrix& M)
const;
263 Matrix getInterpolatedMatrix(
const double cct,
const std::string& type)
const;
264 void getChromaticityCoordinatesFromXyz(
const Triple& xyz,
double& x,
double& y)
const;
265 Triple getXyzFromChromaticityCoordinates(
const double x,
const double y)
const;
266 Triple getXyzFromTemperature(
const double cct,
const double tint = 0.f)
const;
267 void setChromaticityCoordinates(
const double x,
const double y,
double& cct,
double& tint)
const;
268 void getChromaticityCoordinates(
const double cct,
const double tint,
double& x,
double& y)
const;
269 void getChromaticityCoordinatesFromCameraNeutral(
const Matrix& analogBalance,
const Triple& asShotNeutral,
double& x,
double& y)
const;
270 Matrix getChromaticAdaptationMatrix(
const Triple& xyzSource,
const Triple& xyzTarget)
const;
271 Matrix getCameraToXyzD50Matrix(
const double x,
const double y)
const;
272 Matrix getCameraToSrgbLinearMatrix(
const double x,
const double y)
const;
273 Matrix getCameraToACES2065Matrix(
const Triple& asShotNeutral,
275 const bool sourceIsRaw =
false,
276 const bool useColorMatrixOnly =
false)
const;
280 Matrix color_matrix_1;
281 Matrix color_matrix_2;
282 Matrix camera_calibration_1;
283 Matrix camera_calibration_2;
284 Matrix analogBalance;
285 Matrix forward_matrix_1;
286 Matrix forward_matrix_2;
287 double baseline_exposure_offset;
288 std::vector<HsbModify> deltas_1;
289 std::vector<HsbModify> deltas_2;
290 std::vector<HsbModify> look_table;
291 HsdTableInfo delta_info;
292 HsdTableInfo look_info;
318 int load(
const std::string& databaseDirPath,
bool force =
false);
329 inline bool empty() {
return dcpFilenamesList.empty(); }
335 inline size_t size() {
return dcpFilenamesList.size(); }
358 std::string folderName;
360 std::vector<std::string> dcpFilenamesList;
362 std::map<std::string, DCPProfile> dcpStore;