<<

CONVEX PROGRAMMING COLOUR CONSTANCY WITH A DIAGONAL-OFFSET MODEL

G. D. Finlayson, S. D. Hordley R. Xu∗

School University of East Anglia Zilhka Neurogenetic Institute School of Computing Sciences University of Southern California Norwich, UK Los Angeles, USA

ABSTRACT Forsyth’s [?] mapping algorithm is one of the most successful colour constancy algorithms and its strength Gamut mapping colour constancy algorithms attempt to map lies in the fact that it makes the uncertainty in the illumin- image RGBs captured under an unknown to corres- ant explicit. So, rather than solving for a single estimate of ponding RGBs under a reference light so as to render im- the scene light, the algorithm recovers the set of all illumin- ages colour constant. While the approach often works well, ants (the feasible set) consistent with a given set of image for a significant number of real images the algorithm deliv- data. To determine the feasible set Forsyth exploited the ers a null solution. We show that the null solution problem observation that the range, or gamut of colours we observe arises because of a failure of the diagonal model of illumina- depends on the illumination. Thus, the gamut of observed tion change on which the algorithm is based. We address the image colours provides information about the colour of the problem by proposing a new diagonal-offset model which scene light. To exploit this observation Forsyth began by has 6 rather than 3 parameters and which is able therefore defining a canonical gamut, denoted C: the set of all RGBs to deal with a wider range of imaging conditions. Based on which can be observed under some reference illumination. this model we formulate a convex programming solution to Next, given an image recorded under an unknown illumin- colour constancy and we show (by testing on real images) ant, Forsyth posed the colour constancy problem as that of that the new algorithm is robust to the failures of the diag- determining the mappings which take the image gamut (the onal model and is capable of delivering very good colour set of all image RGBs) into the canonical gamut. constancy. Key to solving the problem when it is posed in this way is to define the form of the mapping from image to canon- ical gamut. Forsyth modelled this illumination change using 1. INTRODUCTION a set of three scale factors [d1 d2 d3] such that an observed RGB [Ro Go Bo] is mapped to its corresponding RGB un- Image RGBs depend on the reflective properties of the im- der a reference light according to: aged objects and, in equal part, on the spectral properties of  c     o  the light incident upon them. This implies that an image has R d1 0 0 R c o an overall colour cast determined by the colour of the pre-  G  =  0 d2 0   G  (1) c o vailing scene illumination. Identifying and removing this B 0 0 d3 B colour cast is called colour constancy and is important in computer vision because many vision tasks which make use This model is referred to as the diagonal model of illumin- of colour information do so under the assumption that col- ation change because [d1 d2 d3] parameterise a diagonal our is an intrinsic property of the imaged objects and thus matrix. Now, [d1 d2 d3] is a valid mapping (a solution to the colour constancy problem) if and only if ∀ i Dq ∈ C independent of the prevailing illumination conditions. Des- i where D is [d d d ] written as a diagonal matrix and q pite many attempts to solve the colour constancy problem 1 2 3 i (see [?] for a review) no adequate solution has been ob- represents the ith image RGB. For a given image many di- tained. The problem is difficult to solve, in part because it agonal matrices will satisfy this constraint and Forsyth de- is strictly ill-posed. That is, for most images there are many rived an algorithm to recover the whole set of feasible map- combinations of surfaces and illuminant which give rise to pings. Once recovered, a single element of this set is chosen the same image data so that there is an inherent uncertainty (according to some heuristic) as an estimate of the scene il- in the scene illuminant. luminant. Though an elegant theoretical solution to the colour con- ∗R. Xu performed the work while at the University of East Anglia. stancy problem, gamut mapping has a serious shortcoming: on a significant number of real images it returns a null feas- continuing to work with a conservatively sized canonical ible set, i.e. no estimate of the scene illuminant. The un- gamut. derlying cause of this failure of the algorithm is a failure of the diagonal model to accurately model illumination change for all surfaces in the given image. In this paper we address this failure by proposing a modified model of illumination change: a six parameter diagonal-offset model. Adopting this model we show that a simple, convex programming solution to colour constancy can be derived and we demon- strate that this novel algorithm is robust (it always returns a colour constancy solution) and has performance comparable to the original gamut mapping approach. We motivate and Fig. 1. (a) Example of Gamut Mapping Failure. (b) Failure introduce the new model of illumination change in the next corrected by applying a translation to the image gamut. section. In § 3 we formulate a convex programming solution to colour constancy in the context of this model. We present If the gamut mapping algorithm returns a null feasible an empirical evaluation of the algorithm and summarise our set this implies that there is no diagonal mapping which can findings in § 4. simultaneously map all colours in the image gamut into the canonical gamut. However, we might expect that there ex- ists a mapping which maps the image gamut close to the 2. THE DIAGONAL-OFFSET MODEL canonical set. Figure 1a illustrates this idea for the case of 2-d sensor responses. In this example, if in addition to A diagonal model of illumination change is strictly valid the diagonal mapping, we also allow a translation of all for narrow-band camera sensors (or narrow-band illumin- sensor responses, then we can map the image gamut into ants). Of course, real camera sensors are not narrow-band, the canonical set (see Figure 1b). That is, we can find a 3- but even for many broad-band sensors the model is applic- parameter diagonal transform plus a 3-parameter offset term able for most surfaces and illuminants. However, the model which maps any image colour [Ro Go Bo] to a correspond- does break down, particularly for saturated colours (i.e. sur- ing colour [Rc Gc Bc] in the canonical set: faces near the gamut boundary) and this can lead to a failure of the gamut mapping algorithm. Failure can also occur be-  c     o    R d1 0 0 R o1 cause an image contains surfaces which are not represented c o  G  =  0 d2 0   G  +  o2  (2) in the canonical gamut. In either case, gamut mapping al- c o B 0 0 d3 B o3 gorithms can return a null feasible set. Such problems can be avoided by modifying the ca- In practice we expect departures from the diagonal model nonical gamut. For example Finlayson [?] proposed incre- to be quite small and as a result, the offset term [o1 o2 o3] mentally extending the size of the canonical gamut until a will be small relative to the diagonal part [d1 d2 d3]. Thus non-null feasible set is found. A similar approach was pro- in effect, we continue to model illumination change using posed by Barnard et al [?] but in this case error is added a diagonal model (which we know often works well) but in to the observed image data incrementally until the gamut addition we introduce some “slack” into the model in the mapping algorithm returns a non-empty feasible set. Fi- form of the offset term to avoid the null solution problem. nally, in Colour by Correlation [?], a discrete implement- In the ideal case in which the diagonal model is valid, the ation of the gamut mapping idea is implemented. That ap- offset term will be zero. However, if no such valid solution proach effectively counts the number of image colours suc- can be found, a non-zero offset allows for a solution and cessfully mapped into the canonical gamut for a particular thus provides an illuminant estimate even when the diagonal mapping (i.e. a particular illuminant). If there is no map- model fails. ping which successfully maps all image colours into the ca- nonical set the mapping which successfully maps most col- 3. SOLVING FOR COLOUR CONSTANCY ours is chosen. All of these approaches however, detract from the inherent elegance of gamut mapping. Modifying We formulate the colour constancy problem as in the diag- the canonical or observed gamut is at best heuristic and at onal model case: we seek the mapping (or, more generally, worst weakens the gamut constraint so that poor colour con- the set of mappings) which takes the image gamut I into stancy performance is obtained while discretising the prob- the canonical gamut C. The canonical gamut is defined as lem means that we must discretise the number of mappings. C = C(P) where P = {pc, pc, ··· , pc } are RGBs recorded 1 2 n In this paper we seek to re-formulate gamut mapping so that for a representative set of surfaces viewed under the refer- it remains a continuous domain estimation problem while ence light. The function C(·) returns the set of all convex combinations of P so that any convex combination of points If there are N image hull points then we will have N similar in P belongs to the canonical gamut. Without loss of gener- sets of inequalities, one for each hull point. The set of map- ality P is chosen such that ∀ i p ∈/ C(P−p ) where P−p pings which take all image points into the reference gamut i i i 0 denotes the set P with the ith RGB removed. This ensures is thus those mappings which are in all Mj: that P is the set of points on the convex hull of the reference 0 0 gamut. Equation (4) defines a convex polyhedron which M = {do | A do ≤ B} (7) Finlayson et al [?] observed can equally well be character- 0 ised as the intersection of a set of half-spaces 1 rather than where A has the matrices A[Qj | I] (j = 1 . . . m) stacked by the set of hull points P. In 3-dimensions half-spaces are one on top of the other and B is an NM × 1 vector: M defined by plane equations of the form a1R+a2G+a3B ≤ copies of the vector b stacked one on top of another. Thus b. M0 defines the set of feasible mappings. Each member of If the 3-dimensional canonical gamut in sensor RGB this set is a 6-dimensional vector defining a diagonal-offset space has n vertices then it can be shown that it also has N mapping taking the image gamut into the canonical gamut. faces where N is O(n). Each face lies in a plane and only To complete the gamut mapping solution we must select points which lie to one side of the plane (in one half-space) a single mapping from M0 as the scene illuminant estim- are in C. The intersection of all such half-spaces defines the ate. In his original formulation Forsyth chose the mapping canonical gamut. That is, if a point [RGB] is in C it must which maximises the volume of the image gamut when it is satisfy the N half-space inequalities: mapped to the reference gamut. This is achieved by max- imising the determinant d1d2d3 of the diagonal mapping. In a11R + a12G + a13B ≤ b1 our case, in addition to the diagonal mapping we also have a21R + a22G + a23B ≤ b2 to fix the offset term. However, we expect that in many . (3) cases the diagonal part of the model will account for the . illumination change and the offset term will be small (or a R + a G + a B ≤ b N1 N2 N3 N ideally zero). Thus a possible selection strategy is to max- imise the determinant of the diagonal part of the mapping We can summarise this as: p ∈ C ⇔ Ap ≤ b where A is (as Forsyth did) whilst minimising the offset: an N × 3 matrix whose ith row is [ai1 ai2 ai3] and b is an N × 1 vector whose ith component is equal to b . i min −d d d + o 2 + o 2 + o 2 (8) To define the image gamut let Q = {q , q , ··· , q } 1 2 3 1 2 3 1 2 m denote the m points on the convex hull of the set of image where any solution must also satisfy the constraints in (7). RGBs. Then we define the image gamut to be I = C(Q). Since the objective function is non-linear, finding its min- Now, suppose that the jth element of Q, q is to be mapped j imum involves quite significant computational cost. Nev- by a diagonal-offset transform to the canonical gamut where ertheless robust algorithms for solving such minimisation D = diag(d) and o denote the diagonal and offset parts of problems do exist [?] and are well understood. the transform respectively. It follows that the mapped im- In [?] Finlayson et al proposed a selection method for age RGB Dq + o must satisfy the inequalities in (3) which j the original gamut mapping problem in which they maxim- define the canonical gamut. That is: ise d1 + d2 + d3 (the L1 norm of the diagonal model). This   delivers similar performance to that obtained by maximising A Dq + o ≤ b (4) the determinant and has the advantage that the algorithm j can be formulated as a linear programming problem. In our

We can re-write (4) as: A (Qjd + Io) ≤ b where I is the case we would like to maximise the L1 norm of the diag- 3 × 3 identity matrix and Q is q written as a diagonal onal part of the mapping whilst minimising the offset term. j j matrix. Or equivalently, with some algebraic manipulation: We can do this provided that the offset terms are guaranteed always to be positive. In practice this is not the case but we can force positivity by adding extra linear constraints. The A [Qj | I] do ≤ b (5) solution can then also be posed as a linear program: where do = [d1 d2 d3 o1 o2 o3]. The set of inequalities in (5) delimits a set of 6-parameter Diagonal-Offset map- min (−d1 − d2 − d3 + o1 + o2 + o3) (9) pings M0 which map q into the reference gamut: j j 0 subject to: A do ≤ B, o ≥ 0. 0 Another alternative is to leave the offset terms as free M = {d | A [Qj | I] d ≤ b} (6) j o o parameters in the optimisation and construct objective func- 1A plane in 3-dimensional space divides that space into two halves. The tions based only on the diagonal part of the mapping. This set of points which lie to one side of a plane is called a half-space. gives rise to two further optimisation schemes. The first method maximises the L norm and results in a linear pro- 1 Table 1. Summary of performance (details in text). gram: RMS Mean Med Max Fail 0 Max-RGB 8.77 6.30 4.02 26.19 0 min (−d1 − d2 − d3) subject to: A do ≤ B (10) D. M. Max L1 6.68 4.70 2.75 23.87 44 Alternatively we can maximise the determinant of the diag- D. M. Max Det 6.36 4.49 2.75 22.02 44 onal part of the mapping: Eq (8) 6.75 4.90 2.99 22.04 0 Eq (9) 7.29 5.19 3.11 24.17 0 0 min (−d1d2d3) subject to: A do ≤ B (11) Eq (10) 6.78 4.63 2.71 23.16 0 Eq (11) 6.78 4.60 2.67 23.16 0 Equation (11) is similar to Forsyth’s original solution except that the constraints on the possible mappings are different.

4. EMPIRICAL EVALUATION the best performing algorithms. However, the experiment also highlights the fact that the null intersection problem We evaluated the performance of our new algorithm on the of the original gamut mapping algorithm is a real problem: Simon Fraser calibrated test set [?] which comprises 321 for a significant number of images (44) the 3-parameter al- real images. We found that performance for all algorithms gorithms return no solution. Importantly the results for the was improved by using a simple pre-processing strategy in 6-parameter algorithms show that adopting a diagonal-offset which we first we smooth images using a Gaussian kernel model addresses the problem of diagonal model failure. All and then sub-sample images by a factor of 5. Finally we dis- variants of this algorithm return a solution for all 321 im- card image pixels which have either an R, G, or B response ages tested and performance is as good as or better than that of 2 or less (the image data is in the range 0 to 255). of the 3-parameter variants. We formed the canonical gamut used by the algorithm following Barnard et al [?]. We estimate the performance 5. REFERENCES of an algorithm in terms of how well its (3- or 6-parameter) mapping predicts q the RGB of a surface under the [1] Kobus Barnard, Vlad Cardei, and Brian Funt. A comparison of com- w scene light. For example, if p is the RGB of a white sur- putational constancy algorithms; part one: Methodology and w experiments with synthetic images. IEEE Transactions on Image Pro- face under the reference light and the 3-d gamut mapping cessing, 11(9):972–984, 2002. algorithm returns a map Dˆ then p ≈ Dqˆ . Or equival- w w [2] Kobus Barnard, Lindsay Martin, Adam Coath, and Brian Funt. A ently q ≈ Dˆ −1p . Defining ˆq = D−1p we measure w w w w comparison of computational algorithms; part two: the error between this estimate and the RGB of the actual Experiments with image data. IEEE Transactions on Image Pro- scene illuminant white q . In common with other work [?] cessing, 11(9):985–996, 2002. w we use an intensity independent error measure: the angle [3] G. D. Finlayson. Color in Perspective. IEEE Transactions on Pattern between the actual and estimated white. Analysis and Machine Intelligence, 18(10):1034–1038, 1996. Table 1 summarises the results. We compare perform- [4] G. D. Finlayson, S. D. Hordley, and P. M. Hubel. Color by correla- ance to Max RGB (row one) since in the limiting case of tion: A simple, unifying framework for color constancy. IEEE Trans- a cube gamut the gamut mapping algorithm is equivalent actions on Pattern Analysis and Machine Intelligence, 23(11):1209– to Max RGB [?]. We also test two variants of the diag- 1221, 2001. onal model gamut mapping algorithm implemented in the [5] G.D. Finlayson. Retinex viewed as a gamut mapping theory of colour convex programming framework [?] (rows 2-3). Rows 4-7 constancy. In Proceedings of the 8th Congress of the International show the results for the four variants of the new algorithm Colour Association, 1997. introduced in this paper. This table shows the Root Mean [6] Graham D. Finlayson and Ruixia Xu. Convex programming colour Square (RMS), mean, median, and maximum angular er- constancy. In Workshop on Color and Photometric Methods in Com- ror taken over all images for which the algorithms returned puter Vision. IEEE, October 2003. a solution, together with the number of images for which [7] D. A. Forsyth. A Novel Algorithm for Colour Constancy. Interna- no solution was found. We note that given the nature of tional Journal of Computer Vision, 5(1):5–36, 1990. the underlying error distributions, the median statistic is the [8] S. D. Hordley and G. D. Finlayson. Re-evaluating colour constancy most reliable single summary statistic for judging relative algorithms. In Proceedings of the 17th International Conference on algorithm performance [?]. Pattern Recognition, Volume 1, 76–79, 2004. The results of the experiments reveal a number of im- [9] L. Vandenberghe, S. Boyd, and S. P. Wu. Determinant maximization portant points. First, all gamut algorithms deliver good col- with linear matrix inequality constraints. SIAM Journal on Matrix our constancy performance supporting the findings in [?] Analysis and Applications, 19(2):499–533, 1998. where gamut mapping algorithms were found to be amongst