summaryrefslogtreecommitdiff
path: root/source/dng_color_spec.h
blob: c8fcbeadaa20a2130e46d3b73ab70e424ee7927f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*****************************************************************************/
// Copyright 2006-2008 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/

/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_color_spec.h#1 $ */ 
/* $DateTime: 2012/05/30 13:28:51 $ */
/* $Change: 832332 $ */
/* $Author: tknoll $ */

/** \file
 * Class for holding a specific color transform.
*/

#ifndef __dng_color_spec__
#define __dng_color_spec__

/*****************************************************************************/

#include "dng_classes.h"
#include "dng_matrix.h"
#include "dng_types.h"
#include "dng_xy_coord.h"

/*****************************************************************************/

/// \brief Compute a 3x3 matrix which maps colors from white point white1 to
/// white point white2
///
/// Uses linearized Bradford adaptation matrix to compute a mapping from 
/// colors measured with one white point (white1) to another (white2).

dng_matrix_3by3 MapWhiteMatrix (const dng_xy_coord &white1,
						   		const dng_xy_coord &white2);
						   
/*****************************************************************************/

/// Color transform taking into account white point and camera calibration and
/// individual calibration from DNG negative.

class dng_color_spec
	{
	
	private:
	
		uint32 fChannels;
	
		real64 fTemperature1;
		real64 fTemperature2;
		
		dng_matrix fColorMatrix1;
		dng_matrix fColorMatrix2;
		
		dng_matrix fForwardMatrix1;
		dng_matrix fForwardMatrix2;
		
		dng_matrix fReductionMatrix1;
		dng_matrix fReductionMatrix2;
		
		dng_matrix fCameraCalibration1;
		dng_matrix fCameraCalibration2;
		
		dng_matrix fAnalogBalance;
		
		dng_xy_coord fWhiteXY;
		
		dng_vector fCameraWhite;
		dng_matrix fCameraToPCS;
		
		dng_matrix fPCStoCamera;
		
	public:

		/// Read calibration info from DNG negative and construct a 
		/// dng_color_spec.

		dng_color_spec (const dng_negative &negative,
					    const dng_camera_profile *profile);
					    
		virtual ~dng_color_spec ()
			{
			}

		/// Number of channels used for this color transform. Three
		/// for most cameras.

		uint32 Channels () const
			{
			return fChannels;
			}

		/// Setter for white point. Value is as XY colorspace coordinate.
		/// \param white White point to set as an XY value. 

		void SetWhiteXY (const dng_xy_coord &white);
		
		/// Getter for white point. Value is as XY colorspace coordinate. 
		/// \retval XY value of white point.

		const dng_xy_coord & WhiteXY () const;

		/// Return white point in camera native color coordinates.
		/// \retval A dng_vector with components ranging from 0.0 to 1.0 
		/// that is normalized such that one component is equal to 1.0 .

		const dng_vector & CameraWhite () const;
			
		/// Getter for camera to Profile Connection Space color transform.
		/// \retval A transform that takes into account all camera calibration
		/// transforms and white point. 

		const dng_matrix & CameraToPCS () const;

		/// Getter for Profile Connection Space to camera color transform.
		/// \retval A transform that takes into account all camera calibration
		/// transforms and white point. 

		const dng_matrix & PCStoCamera () const;

		/// Return the XY value to use for SetWhiteXY for a given camera color
		/// space coordinate as the white point.
		/// \param neutral A camera color space value to use for white point.
		/// Components range from 0.0 to 1.0 and should be normalized such that
		/// the largest value is 1.0 .
		/// \retval White point in XY space that makes neutral map to this
		/// XY value as closely as possible.

		dng_xy_coord NeutralToXY (const dng_vector &neutral);

	private:
	
		dng_matrix FindXYZtoCamera (const dng_xy_coord &white,
									dng_matrix *forwardMatrix = NULL,
									dng_matrix *reductionMatrix = NULL,
									dng_matrix *cameraCalibration = NULL);
	
	};

/*****************************************************************************/

#endif

/*****************************************************************************/