Debian Codegraph @

gamut/gammap.txt

raw
1
2 Author: Graeme W. Gill
3 Date: 2000/10/28
4 Updated: 2006/1/17
5
6 Discussion of the gamut mapping algorithm used in Argyll:
7
8
9 Jam Morovic provides an extensive summary of previous Gamut Mapping Algoriths
10 (GMA) in his thesis "To Develop a Universal Gamut Mapping Algorithm".
11
12 Mark Fairchild and Gustav Braun also discuss some interesting aspects of
13 gamut mapping in "General-Purpose Gamut-Mapping Algorithms: Evaluation
14 of Contrast-Preserving Rescaling Functions for Color Gamut Mapping".
15
16 One thing that is striking in reading the current Gamut Mapping
17 literature, is the schism between gamut mapping, and gammut clipping.
18
19 A number of studies have indicated the satisfactory results from performing
20 gamut clipping by mapping out of gamut points to the closest point
21 within gamut, using a minumim delta E criteria. Ideally this would be
22 in a perceptually uniform space, and in practical spaces (ie L*a*b* space),
23 it appears a mapping that weightes luminance errors twice as much as
24 hue and saturation errors is the most satisfactory
25 (ie. Katoh & Ito 1996, Ebner & Fairchild 1997).
26 This approach makes perfect sense if the perceptually linear
27 delta E spaces is working as its should :- providing a means of
28 computing the minimal perceptual error between two colors.
29
30 Almost all the gamut mapping algorithms on the other hand, take a
31 completely different approach. They are dominated by algorithms with
32 appeal for their mathematical and algorithmic simplicity, rather than
33 any objective sense. Clipping along a line of constant hue, in a
34 particular direction, with some sort of compression along line
35 length curve seems to be a favourite.
36 My own experience with such an approach used for gamut clipping
37 shows up the logical flaws in this approach. In printed media, for
38 instance, the yellow dye tends to have a very sharp cusp in (say) Lab
39 space. When mapping along a line towards the neutral axis, it is almost
40 impossible to come up with a choice of line direction that
41 doesn't severly distort the clipped color. It is often extremely
42 de-saturated at the point the line hits the gamut boundary. Line
43 directions that take some account of the equivalent yellow cusp
44 in the target gamut improve the situation, but it seems highly
45 illogical to choosing an algorithm that gives a result with such
46 high delta E's, measured in any colorspace !
47
48 My conclusion is this: If we are working in a good perceptually
49 uniform space (ie. L*a*b*, Luv or CIECAM02), then we want to minimise
50 the delta E of the gamut mapped points at all times (this is the point
51 of using a perceptually uniform space !). This means that points
52 on the source gamut surface, should map to the target surface in
53 a very similar way to which they would be mapped using gamut clipping,
54 ie. minimum delta E. The distinction between gamut mapping and clipping
55 only becomes evident then, when we consider points that fall within
56 both gamuts. For pure gamut clipping, these points should not be
57 modified. For gamut mapping they should be modified in a way that
58 trades off increased absolute delta E, for reduced delta E relative
59 to surrounding colors.
60
61 [ Saturation intent brings some factors other than minimum
62 delta E into the picture, but minumum delta E is a good
63 starting point. ]
64
65 Gamut clipping should not be something separate to gamut mapping,
66 but should just be one extreme in a continuum of gamut mapping
67 choices.
68
69 A consideration revealed by Jam Morovic's work, is that it may be
70 desirable to treat colors on and close to the neutral axis a little
71 differently that those saturated colors near the gamut surface.
72 It seems desirable to align and compress the neutral axis to
73 give a good gray-scale mapping, as well as preserving the
74 relative colorimetry of low saturation colors.
75
76 Mark fairchild's work also indicates the desirablility of
77 trying to maintain the relative contrast of image data after
78 compression. This can be achieved by using a sigmoidal
79 mapping during compression (often called a soft knee compression
80 characteristic), rather than linear compression. Gamut
81 clipping can be considered to be an extreme example of
82 knee compression, where the knee is "hard".
83
84 A final consideration is how the various user intents are going
85 to be accomodated. One of the nice features of a consistent
86 clipping/compression approach is that many of the distinctions
87 between different intents seems to disappear.
88
89 Description of algorithms used:
90
91 The algorithm chosen here is (as far as I am aware) a new one,
92 that tries to combine all the considerations made above.
93
94 The gamut mapping is divided into two parts, mapping the luminance
95 axis orthogonally to other considerations, and then dealling
96 with any remaining gamut compression or expansion.
97
98 The basic transform mechanism is broken down into three part;
99 Aligning the neutral axes, mapping the luminence coordinate,
100 performing an overall 3D -> 3D mapping to compress and/or
101 expand the gamut surface. The rotation uses a matrix, the 1D -> 1D
102 luminence mapping uses a RSPL regular spline that is available
103 in Argyll, and the 3D -> 3D mapping also uses a RSPL.
104 By controlling the number, extent and strength of the sample
105 point mapping used to create the RSPL, it is possible to arrive
106 at a smooth mapping that has (controllable) areas of influence
107 between different regions, and can achieve sigmoid like "soft"
108 clipping curves.
109
110
111 Aligning the neutral axes.
112
113 The first step is to align the neutral axes. If the
114 colorspace used is an appearance space (Such as CIECAM02 Jab),
115 then the white points will already be close together, but may not
116 exactly cooincide. The black points will also probably differ.
117 There are a number of options for dealing with this. One
118 option would be to assume that people adapt to black points
119 the same way they adapt to the white points of a colorspace
120 or image. Research and experiemnce indicates that this
121 may not be the case though. If we assume that people
122 do not in general adapt to the black points of a colorspace,
123 then a consequence is that it is difficult to fully exploit
124 the full dynamic range of the colorspace, since a
125 source black that is misaligned with the destination black
126 will probably not be able to achieve as low a J value,
127 and this can noticably affect the percieved quality of
128 an image.
129
130 The compromise I deemed the best in Argyll, is to
131 assume that people do not adapt to black points,
132 and that therefore only the white points should be
133 aligned by rotating the source space around 0,0,0
134 to line them up. The minimum J value on the other hand,
135 is mapped as if the black points were being fully
136 adapted to, and at the point that the source
137 neutral axis would leave the destination gamut,
138 it is clipped to the destination.
139
140 This gives a neutral axis in the destination that looks
141 the same as that of the source, while fully exploiting the
142 dynamic range of the destination colorspace. Since
143 the departure of the mapped neutral axis from neutral
144 only occurs in very dark colors, its deviation is not
145 usually visible.
146
147 [ The code allows for 4 possible black point/neutral
148 axis mapping algorithm, set by the value of bph:
149 Adapt source black point to destination, giving full black range.
150 Don't adapt black point to destination, giving compromised black range.
151 Don't adapt black point, bend it to dest. at end, giving full black range.
152 Don't adapt black point, clip it to dest. at end, giving full black range.
153 ]
154
155 Note that the black point mapping is performed by manipulating
156 J independently of the color components (a & b). In adapting
157 color from one space to another, this proves to be the correct
158 approach, maintaining the appearance of an image when
159 transformed to different device colorspaces.
160 This should not be confused with the situation where
161 optical flare or haze is being removed or simulated,
162 in which case the black point mapping should be done in a
163 linear light colorspace (such as XYZ), and will have an
164 effect simulaniously on lightness and saturation.
165
166
167 Mapping the luminence range.
168
169 The luminence mapping is acheived by created a small number of
170 mapping points, and then created a detailed RSPL (Regular Spline)
171 based on the points. The end points (which are heavily weighted
172 to ensure the overall range mapping is useful) are created
173 simply from the known J values of the source and destination
174 white and black points (taking into consuideration what
175 J values will result from possible gamut boundary clipping).
176
177 Middle points are introduced to either give a linear mapping (in J),
178 or to introduce a slight range compression aimed at preserving
179 the contrast ratio of the image.
180
181
182 Maping 3D gamut points.
183
184 The mapping points created for determinining the 3D compression or
185 expansioin are created from the source gamut surface verticies
186 that lie outside the destinatio gamut. The raw mapping for the
187 outside of the gamut is created by itterative optimisation,
188 that strikes a weighted balance between three different
189 factors: Mapping to the closest point on the destination surface,
190 Mapping in a way that is smoothly consistent with neighbour
191 mapping rays, and Mapping radially to the center of the colorspace.
192 By manipulating the weighting factors (held in a gammapweights
193 structure), it is possible to control to some degree the
194 nature of the gamut mapping.
195
196 Some compensation is applied to the vectors to try and counteract
197 the effects of the vector and (subsequent) RSPL smoothing.
198 This smoothing may cause the mapping to end up outside the
199 destination gamut, so we try and make sure that such smoothing
200 effects over rather than under-compress.
201
202 In addition to the suface mapping points, the 1D neutral axis
203 mapping is maintained by introducing a string of points
204 down the 3D neutral axis, to ensure that the 3D surface mappings
205 do not alter it.
206
207 Closer to the surface, optional "knee" mapping points
208 are also added, in an attempt to cause the inner
209 3D mapping to be more linear, with the compression (or
210 expansion) being concentrated near the surface of the
211 gamuts ("Sigma" compression).
212
213 Limitations and future challenges:
214
215 After re-working the gamut mapping in December 2005/January 2006,
216 the following challenges remain:
217
218 1) For saturation mapping in particular, the handling of hue
219 mapping using the "nearest" weighting isn't very flexible.
220 It's not possible to map RGB Cyan to CMYK Cyan without
221 introducing unacceptable side effects.
222
223 To solve this, I would have to add some extra mapping controls
224 and gamut information. For each gamut the 6 major "cusps" would
225 have to be identified (either directly from the colorant
226 combinations, or indrectly by locating the point on the gamut
227 surface with the largest C (?) in each hextant), and
228 then a means of warping the hue angle (and Luminence ??)
229 in each hextant.
230
231 The gammapweights structure would be expanded to add a weight
232 as to how much the source hue cusps would be distorted.
233
234 [Added to the code by Feb '06]
235
236
237 2) There is not much flexibility in what the gammapweights
238 weightings can achive. Some controls simply don't work
239 very well. Often increases in saturation in one area (at
240 the transitions between major colors) are bought at the
241 expense of the middle of the major colors becomming
242 very "flat" and desaturated. This is generally when we
243 are in a region in which the source gamut is within the
244 destination gamut.
245
246 3) Geting smoothness and saturation is very difficult
247 for some reason. The "relative error" weights do spread
248 things out, but at the cost of obvious banding (why ? -
249 possible answer - reflects the roughness of the gamut surface.
250 Solution is to use better algorithm for gamut surface extraction ?? ).
251 Increasing the 3D RSPL smoothness seems to have no
252 effect (why ?). Reducing absolute chroma weight improves
253 smoothness, but at the cost of reduced saturation and increased
254 lightness.
255
256
257
258
259