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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
/*****************************************************************************/
// Copyright 2007 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_hue_sat_map.h#2 $ */
/* $DateTime: 2012/07/31 22:04:34 $ */
/* $Change: 840853 $ */
/* $Author: tknoll $ */
/** \file
* Table-based color correction data structure.
*/
/*****************************************************************************/
#ifndef __dng_hue_sat_map__
#define __dng_hue_sat_map__
/*****************************************************************************/
#include "dng_classes.h"
#include "dng_ref_counted_block.h"
#include "dng_types.h"
/*****************************************************************************/
/// \brief A 3D table that maps HSV (hue, saturation, and value) floating-point
/// input coordinates in the range [0,1] to delta signals. The table must have at
/// least 1 sample in the hue dimension, at least 2 samples in the saturation
/// dimension, and at least 1 sample in the value dimension. Tables are stored in
/// value-hue-saturation order.
class dng_hue_sat_map
{
public:
/// HSV delta signal. \param fHueShift is a delta value specified in degrees.
/// This parameter, added to the original hue, determines the output hue. A
/// value of 0 means no change. \param fSatScale and \param fValScale are
/// scale factors that are applied to saturation and value components,
/// respectively. These scale factors, multiplied by the original saturation
/// and value, determine the output saturation and value. A scale factor of
/// 1.0 means no change.
struct HSBModify
{
real32 fHueShift;
real32 fSatScale;
real32 fValScale;
};
private:
uint32 fHueDivisions;
uint32 fSatDivisions;
uint32 fValDivisions;
uint32 fHueStep;
uint32 fValStep;
dng_ref_counted_block fDeltas;
HSBModify *SafeGetDeltas ()
{
return (HSBModify *) fDeltas.Buffer_real32 ();
}
public:
/// Construct an empty (and invalid) hue sat map.
dng_hue_sat_map ();
/// Copy an existing hue sat map.
dng_hue_sat_map (const dng_hue_sat_map &src);
/// Copy an existing hue sat map.
dng_hue_sat_map & operator= (const dng_hue_sat_map &rhs);
/// Destructor.
virtual ~dng_hue_sat_map ();
/// Is this hue sat map invalid?
bool IsNull () const
{
return !IsValid ();
}
/// Is this hue sat map valid?
bool IsValid () const
{
return fHueDivisions > 0 &&
fSatDivisions > 1 &&
fValDivisions > 0 &&
fDeltas.Buffer ();
}
/// Clear the hue sat map, making it invalid.
void SetInvalid ()
{
fHueDivisions = 0;
fSatDivisions = 0;
fValDivisions = 0;
fHueStep = 0;
fValStep = 0;
fDeltas.Clear ();
}
/// Get the table dimensions (number of samples in each dimension).
void GetDivisions (uint32 &hueDivisions,
uint32 &satDivisions,
uint32 &valDivisions) const
{
hueDivisions = fHueDivisions;
satDivisions = fSatDivisions;
valDivisions = fValDivisions;
}
/// Set the table dimensions (number of samples in each dimension). This
/// erases any existing table data.
void SetDivisions (uint32 hueDivisions,
uint32 satDivisions,
uint32 valDivisions = 1);
/// Get a specific table entry, specified by table indices.
void GetDelta (uint32 hueDiv,
uint32 satDiv,
uint32 valDiv,
HSBModify &modify) const;
/// Make sure the table is writeable.
void EnsureWriteable ()
{
fDeltas.EnsureWriteable ();
}
/// Set a specific table entry, specified by table indices.
void SetDelta (uint32 hueDiv,
uint32 satDiv,
uint32 valDiv,
const HSBModify &modify)
{
EnsureWriteable ();
SetDeltaKnownWriteable (hueDiv,
satDiv,
valDiv,
modify);
}
/// Same as SetDelta, without checking that the table is writeable.
void SetDeltaKnownWriteable (uint32 hueDiv,
uint32 satDiv,
uint32 valDiv,
const HSBModify &modify);
/// Get the total number of samples (across all dimensions).
uint32 DeltasCount () const
{
return fValDivisions *
fHueDivisions *
fSatDivisions;
}
/// Direct read/write access to table entries. The entries are stored in
/// value-hue-saturation order (outer to inner).
HSBModify *GetDeltas ()
{
EnsureWriteable ();
return (HSBModify *) fDeltas.Buffer_real32 ();
}
/// Direct read-only access to table entries. The entries are stored in
/// value-hue-saturation order (outer to inner).
const HSBModify *GetConstDeltas () const
{
return (const HSBModify *) fDeltas.Buffer_real32 ();
}
/// Equality test.
bool operator== (const dng_hue_sat_map &rhs) const;
/// Compute a linearly-interpolated hue sat map (i.e., delta and scale factors)
/// from the specified tables, with the specified weight. map1 and map2 must
/// have the same dimensions.
static dng_hue_sat_map * Interpolate (const dng_hue_sat_map &map1,
const dng_hue_sat_map &map2,
real64 weight1);
};
/*****************************************************************************/
#endif
/*****************************************************************************/
|