1 /*****************************************************************************/ 2 // Copyright 2006-2019 Adobe Systems Incorporated 3 // All Rights Reserved. 4 // 5 // NOTICE: Adobe permits you to use, modify, and distribute this file in 6 // accordance with the terms of the Adobe license agreement accompanying it. 7 /*****************************************************************************/ 8 9 /** \file 10 * Class for holding a specific color transform. 11 */ 12 13 #ifndef __dng_color_spec__ 14 #define __dng_color_spec__ 15 16 /*****************************************************************************/ 17 18 #include "dng_classes.h" 19 #include "dng_matrix.h" 20 #include "dng_types.h" 21 #include "dng_xy_coord.h" 22 23 /*****************************************************************************/ 24 25 /// \brief Compute a 3x3 matrix which maps colors from white point white1 to 26 /// white point white2 27 /// 28 /// Uses linearized Bradford adaptation matrix to compute a mapping from 29 /// colors measured with one white point (white1) to another (white2). 30 31 dng_matrix_3by3 MapWhiteMatrix (const dng_xy_coord &white1, 32 const dng_xy_coord &white2); 33 34 /*****************************************************************************/ 35 36 /// Color transform taking into account white point and camera calibration and 37 /// individual calibration from DNG negative. 38 39 class dng_color_spec 40 { 41 42 private: 43 44 uint32 fChannels; 45 46 real64 fTemperature1; 47 real64 fTemperature2; 48 49 dng_matrix fColorMatrix1; 50 dng_matrix fColorMatrix2; 51 52 dng_matrix fForwardMatrix1; 53 dng_matrix fForwardMatrix2; 54 55 dng_matrix fReductionMatrix1; 56 dng_matrix fReductionMatrix2; 57 58 dng_matrix fCameraCalibration1; 59 dng_matrix fCameraCalibration2; 60 61 dng_matrix fAnalogBalance; 62 63 dng_xy_coord fWhiteXY; 64 65 dng_vector fCameraWhite; 66 dng_matrix fCameraToPCS; 67 68 dng_matrix fPCStoCamera; 69 70 public: 71 72 /// Read calibration info from DNG negative and construct a 73 /// dng_color_spec. 74 75 dng_color_spec (const dng_negative &negative, 76 const dng_camera_profile *profile); 77 ~dng_color_spec()78 virtual ~dng_color_spec () 79 { 80 } 81 82 /// Number of channels used for this color transform. Three 83 /// for most cameras. 84 Channels()85 uint32 Channels () const 86 { 87 return fChannels; 88 } 89 90 /// Setter for white point. Value is as XY colorspace coordinate. 91 /// \param white White point to set as an XY value. 92 93 void SetWhiteXY (const dng_xy_coord &white); 94 95 /// Getter for white point. Value is as XY colorspace coordinate. 96 /// \retval XY value of white point. 97 98 const dng_xy_coord & WhiteXY () const; 99 100 /// Return white point in camera native color coordinates. 101 /// \retval A dng_vector with components ranging from 0.0 to 1.0 102 /// that is normalized such that one component is equal to 1.0 . 103 104 const dng_vector & CameraWhite () const; 105 106 /// Getter for camera to Profile Connection Space color transform. 107 /// \retval A transform that takes into account all camera calibration 108 /// transforms and white point. 109 110 const dng_matrix & CameraToPCS () const; 111 112 /// Getter for Profile Connection Space to camera color transform. 113 /// \retval A transform that takes into account all camera calibration 114 /// transforms and white point. 115 116 const dng_matrix & PCStoCamera () const; 117 118 /// Return the XY value to use for SetWhiteXY for a given camera color 119 /// space coordinate as the white point. 120 /// \param neutral A camera color space value to use for white point. 121 /// Components range from 0.0 to 1.0 and should be normalized such that 122 /// the largest value is 1.0 . 123 /// \retval White point in XY space that makes neutral map to this 124 /// XY value as closely as possible. 125 126 dng_xy_coord NeutralToXY (const dng_vector &neutral); 127 128 private: 129 130 dng_matrix FindXYZtoCamera (const dng_xy_coord &white, 131 dng_matrix *forwardMatrix = NULL, 132 dng_matrix *reductionMatrix = NULL, 133 dng_matrix *cameraCalibration = NULL); 134 135 }; 136 137 /*****************************************************************************/ 138 139 #endif 140 141 /*****************************************************************************/ 142