Linear-programming approach to color-recipe formulations

4
JOURNAL OF THE OPTICAL SOCIETY OF AMERICA Linear-programming approach to color-recipe formulations Pierre R. BMlanger Department of Electrical Engineering, McGill University, Montreal, Quebec, Canada H3C3G1 (Received 20 March 1974) A new algorithm is suggested for color-recipe formulation. Whereas previous algorithms solved for recipes using, in turn, all possible combinations of three colorants from a given list, the new algorithm finds directly both the colorants to be used and their proportions. This is done by fitting the problem to a linear program and using existing solution algorithms. Index Heading: Color. The question of which colorants to use and their proportions has always been important to the colorist. There are usually many answers to such questions because a given color can usually be obtained by several different colorant mixtures. Until the mid sixties, recipe formulation relied mostly on the intuition of experienced dyers. The advent of the digital computer prompted some dyestuff manu- facturers to give him some help. The program developed by Preston and Tough' at ICI calculated the colorant concentrations needed in a recipe, given a particular set of three colorants. The program developed by Allen 2 at American Cyanamid went further; given a set of up to 12 colorants, the computer solved the color equations for all combinations of 3 colorants. The program output was a list, in order of increasing cost, of feasible combinations. The colorist using that program was relieved, to some extent, of the burden of choosing the colorants; however, the difficult task of choosing the basic 12 dyes in the list still remained. The combinatorial approach to colorant selection quickly becomes unmanageable as the number of colorants in the inventory increases. There are 220 combinations of three to be taken from a list of 12. For a list of 20, the number jumps to 1140; for a list of 100, there are 161 700 possibilities. Clearly, auto- matic selection from a relatively large inventory must rely on another approach. This paper presents such an approach. The colorant- selection problem is formulated as a linear-program- ming (LP) problem, in which the lowest-cost recipe is to be selected from all of the dyes in the inventory. A property of linear programming is that only a few of the variables in the solution have nonzero values: this property leads directly to a least-cost match with from 3 to 6 colorants, depending on the metamerism tolerance imposed at the outset. That match can be computed in a few seconds. Second-best, third-best, etc. recipes can be obtained by use of readily available features of linear programs. In this paper, basic color relationships are first expressed in terms of matrices; the optimization prob- lem is then posed, and linearization is used to convert the problem to LP form; finally, the application of linear-programming algorithms to this problem is explored, as well as recipe refinement and correction. I. BASIC RELATIONSHIPS The tristimulus values under CIE illuminant C are Xc Ec(X)xt(X)R(X)dX, (la) Ye= Ec(X)g(X)R(X) dX, (lb) Zc= Ec(X)2(X)R(X) dX. (Ic) Here Xc, Yc, and Zc are the tristimulus values, Ec (X) is the spectral power of CIE illuminant C, x(X), g(X), 2(X) are the CIE weighting functions for the standard observer, and R(X) is the reflectance. The integrals are carried out over the visible range of wavelengths. We approximate Eqs. (1) by a finite sum over N wavelengths. To streamline the notation, we define the vectors and matrices, R T =[R(X,) R(X 2 ) ... R(XN)], OT{X= Vc Ye ZC], X Ec(X,)x(X1) ... Ec(XN)X (XN) EEc] = Ec(XI) (Xi) ... Ec(XN)(XN)1 Ec(X1)2(X1) ... Ec(XvN)2(XN) where the superscript T denotes transposition. Equa- tion (1) then becomes Oc = [Ec]R. (2) Similarly, the tristimulus vector under illuminant A can be written OA= [EA]R. (3) For a small difference AO between two color vectors, the color difference can be written in the form AE 2 = AOT[QIAO, (4) 1541 VOLUME 64, NUMBER 11 NOVEMBER 1974

Transcript of Linear-programming approach to color-recipe formulations

Page 1: Linear-programming approach to color-recipe formulations

JOURNAL OF THE OPTICAL SOCIETY OF AMERICA

Linear-programming approach to color-recipe formulations

Pierre R. BMlangerDepartment of Electrical Engineering, McGill University, Montreal, Quebec, Canada H3C3G1

(Received 20 March 1974)

A new algorithm is suggested for color-recipe formulation. Whereas previous algorithms solved for recipesusing, in turn, all possible combinations of three colorants from a given list, the new algorithm findsdirectly both the colorants to be used and their proportions. This is done by fitting the problem to a linearprogram and using existing solution algorithms.

Index Heading: Color.

The question of which colorants to use and theirproportions has always been important to the colorist.There are usually many answers to such questionsbecause a given color can usually be obtained by severaldifferent colorant mixtures.

Until the mid sixties, recipe formulation relied mostlyon the intuition of experienced dyers. The advent ofthe digital computer prompted some dyestuff manu-facturers to give him some help. The program developedby Preston and Tough' at ICI calculated the colorantconcentrations needed in a recipe, given a particularset of three colorants. The program developed byAllen2 at American Cyanamid went further; given aset of up to 12 colorants, the computer solved the colorequations for all combinations of 3 colorants. Theprogram output was a list, in order of increasing cost,of feasible combinations. The colorist using thatprogram was relieved, to some extent, of the burden ofchoosing the colorants; however, the difficult task ofchoosing the basic 12 dyes in the list still remained.

The combinatorial approach to colorant selectionquickly becomes unmanageable as the number ofcolorants in the inventory increases. There are 220combinations of three to be taken from a list of 12.For a list of 20, the number jumps to 1140; for a listof 100, there are 161 700 possibilities. Clearly, auto-matic selection from a relatively large inventory mustrely on another approach.

This paper presents such an approach. The colorant-selection problem is formulated as a linear-program-ming (LP) problem, in which the lowest-cost recipeis to be selected from all of the dyes in the inventory.A property of linear programming is that only a fewof the variables in the solution have nonzero values:this property leads directly to a least-cost match withfrom 3 to 6 colorants, depending on the metamerismtolerance imposed at the outset. That match can becomputed in a few seconds. Second-best, third-best,etc. recipes can be obtained by use of readily availablefeatures of linear programs.

In this paper, basic color relationships are firstexpressed in terms of matrices; the optimization prob-lem is then posed, and linearization is used to convertthe problem to LP form; finally, the application of

linear-programming algorithms to this problem isexplored, as well as recipe refinement and correction.

I. BASIC RELATIONSHIPS

The tristimulus values under CIE illuminant C are

Xc Ec(X)xt(X)R(X) dX, (la)

Ye= Ec(X)g(X)R(X) dX, (lb)

Zc= Ec(X)2(X)R(X) dX. (Ic)

Here Xc, Yc, and Zc are the tristimulus values, Ec (X)is the spectral power of CIE illuminant C, x(X), g(X),2(X) are the CIE weighting functions for the standardobserver, and R(X) is the reflectance. The integrals arecarried out over the visible range of wavelengths.

We approximate Eqs. (1) by a finite sum over Nwavelengths. To streamline the notation, we definethe vectors and matrices,

RT =[R(X,) R(X2) ... R(XN)],

OT{X= Vc Ye ZC],

X Ec(X,)x(X1) ... Ec(XN)X (XN)

EEc] = Ec(XI) (Xi) ... Ec(XN)(XN)1

Ec(X1)2(X1) ... Ec(XvN)2(XN)

where the superscript T denotes transposition. Equa-tion (1) then becomes

Oc = [Ec]R. (2)

Similarly, the tristimulus vector under illuminant Acan be written

OA= [EA]R. (3)

For a small difference AO between two color vectors,the color difference can be written in the form

AE 2= AOT[QIAO, (4)

1541

VOLUME 64, NUMBER 11 NOVEMBER 1974

Page 2: Linear-programming approach to color-recipe formulations

1542PIERRE R. B1ELANGER

where AE is the color difference and [Q] is a 3X3symmetric positive-definite matrix whose elementvalues depend on the color unit used and on the refer-ence point in color space. Most color-difference formulasare not explicitely defined as in Eq. (4), the MacAdamformula being the exception. However, color difference,in any unit, can always be so expressed for small AO.Equation (4) can be considered as the leading term of aTaylor series; the linear term must be absent, otherwiseboth positive and negative color differences could beobtained merely by changing the sign of AO.

The degree of metamerism of a match can be definedin a number of ways. We choose to define metamerismas the color difference under illuminant A betweentwo samples that match under illuminant C. Thisdefinition is not critical to the work described here.

We need to relate the reflectance to the colorantconcentrations. We assume a relationship of the form

f{R(Xi)) =o(Xi) +cia(Xi) + * +cnan(Xi)X

i=1, 2, - *-N. (5)

Here the ci are colorant concentrations, the functionsai(Xi) are characteristic of colorant j, while ao(xi)characterizes the substrate. The number of colorantsused is n. In Eq. (5), f{R} is a nonlinear function of R.We assume that this function can be inverted; that is,we assume that we can calculate R uniquely, given thevalue of f{R}.

The Kubelka-Munk equation is of this form, with

f(R(X) ={(1-R(Xi)}2

2R(Xi)

it may be uniquely inverted by the formula

R(XA) =- +f (Xi)) +{f2(X,)+2f (Xi)}i.

Passing again to vector notation, we define

fT =[{R(X,)},f{R(X 2 )}, * *f{R(XN)}],

Fal(Xl) a2(XI) ... an(Xi 1)[A]= al(X) a2(X2) ... an(X 2 )

Ofi(xN) a!2(XN)-* *a.(N

US0'= [a0(X1),a0(X2), - -aoO(Xv)],and

CT= [c1,c2 , C.] -

Equation (5) becomes

f=ao+[A]c (6)

Since R(Xi) is a function of the colorant concentra-tions, we may write

R=R(c). (7)

II. PROBLEM STATEMENT

The problem is to find a least-cost match underilluminant C, subject to a constraint on the degree ofmetamerism.

More precisely, let Oc* and OA* be the target tri-stimulus vectors under illuminants C and A, respec-tively. Define the cost vector9'T= [31,/32, * * * .n]where 3j is the cost per unit concentration of the jthcolorant. Define also the tristimulus difference

AOA = OA* -[EA]R(c).

The problem is to choose c so as to minimizeobjective function

J = gTc,

subject to the constraints

ciŽ0, i=1,2, ***n

[Eoc]R(c) = Oc*

AOAT[Q]AOA• MmaX2

(8)

the

(9)

(10)

(11)

(12)

where Mma. is the metamerism tolerance.This statement of the problem assumes that a selec-

tion of n colorants has been made. In general, n mustbe at least 3 to meet the three equality constraints ofEq. (11). Because the solution of this optimizationproblem could conceivably admit a solution with up ton nonzero concentrations, it would appear necessary tolimit n at the outset to the maximum-permissiblenumber of colorants in the recipe. This was done inprevious efforts, e.g., Preston and Tough' and Allen,2

where n was limited to 3. The LP algorithm dispenseswith this automatically by using only a small numberof nonzero concentrations in the solution.

III. LINEARIZATION

A major step forward was taken by Allen3 in 1965.In essence, he linearized the color equation using thereflectance of the target sample as the reference. If R*is the vector describing the reflectance of the target,Allen's equations are

dR\[Ec]R*+[Ec]t (a)o-f*}

OR\+[Eel )[A]c=Oc* (13)

with a similar equation to express OA*. Here, the vectorf* is obtained by inserting R(Xi)=R*(Xi) in Eq. (5).The matrix [dR/Of] is aln NXN diagonal matrix; tocalculate its ii element, we invert Eq. (5) to find R(Xi)in terms of f(Xi), we differentiate with respect to f, andwe evaluate the result at f=f* (Xi)-

Vol. 641542

Page 3: Linear-programming approach to color-recipe formulations

November1974 LINEAR-PROGRAMMING COLOR-RECIPE FORMULATIONS

'3l~

FIG. 1. Illustrating the metamerism-constraint ellipse and therectangular approximation in two dimensions.

Letting Oc=oc*, and recalling that [EC]R*=0*, weobtain

R\ aRdEEc]% {afao-f*}+[EC](-)[EA ]C =O. (14)

In general, the solution of Eq. (14) will not satisfythe nonlinear Eq. (11); however, it turns out that ifthere exists a c that yields a spectrophotometric match,that same c will satisfy both Eq. (11) and the linearizedapproximation Eq. (13). A practical consequence ofthis fact is that the solution of Eq. (14) will be a goodapproximation to the solution of Eq. (11) if the meta-merism of the match is low.

Using an expression similar to Eq. (13) for OA, andusing also

OA =OA =A * =OA- [EAIR*,

we find that

/dR\ R\AOA= [EA] (aj ){O-f*)+[EA]k E)[A]c. (15)

So far, we have a linear objective function, Eq. (9),a set of linear equality constraints, Eq. (14), andpositiveness constraints on the variables, Eq. (10).We shall now replace the quadratic constraint, Eq.(12), by a set of linear constraints to permit the use oflinear programming.

Geometrically, Eq. (12) restricts the tip of the vectorAOA to lie on or within an ellipsoid. We shall change thisto require that the tip of AOA lie on or within therectangular prism that circumscribes the ellipsoid. Todo this, let vi, v2, and V 3 be the eigenvectors of [Q]corresponding to the eigenvalues P1, P2, and p3, respec-tively. We assume that the eigenvectors have beennormalized to unity length. Because [Q] is symmetric,

the eigenvalues are real and the eigenvectors aremutually orthogonal. The fact that [Q] is positivedefinite ensures that the eigenvalues are positive.Consequently, v1, v2, and V3 are the directions of theprincipal axes of the ellipsoid

AOAT[Q]EQ A = Mmax 2

The lengths of the semimajor axes are, respectively,Mmax//pI, Mmax/VP2, and Mmx/ Vp.3 These geometricconsiderations are illustrated in Fig. 1, for the case of

X two dimensions.A Reasoning from Fig. 1, we see that IAOA will be

contained within the rectangle if, and only if, itsprojection on v1 (v2) does not exceed Mmax/V/pi(Mmax/-\p2) in magnitude. That is expressed by thethree constraint relationships

Mmax Mmax- <ViTAOA < A

Vpi Vpii= 1, 2, 3.

Those constraints are less stringent than the con-straint of Eq. (12), because AOA is allowed to lie outsidethe ellipsoid, towards the corners of the circumscribingprism. The greatest degree of metamerism for a AOAsatisfying Eq. (16) is V3Mm8 X, and occurs when thetip of AOA touches any corner of the prism. We cancompensate for that effect by using a smaller Mmax.

IV. LINEAR-PROGRAMMING SOLUTION

Replacing Eqs. (11) and (12) of the original formu-lation by the approximations developed in the preceed-ing section, we arrive at the new optimization problem.Minimize

J=Tc, (17)

subject to the constraints

cj<0, j= 1, 2, * *-, (18)

/aR\ /dR\EEc] EA[]c+EEc] -) ao- f I= 0, (19)

-vi TEEAJ ) (ao- f I }-vi EEA I -)EA ]c

Mmax

Vpii= 1, 2, 3 (20)

R AR\Vi T [EA -)O-f*} +VViT [EA3 [A d c

Mmax

Vpii= 1, 2, 3, (21)

The problem has now been cast in LP form. This isdesirable, because of the following reasons.

1543

Page 4: Linear-programming approach to color-recipe formulations

1544PIERRE R. BtLANGER

(i) Good LP algorithms are readily available, andcan solve problems with a thousand or more constraintequations. The present problem, with nine constraints,is therefore easy.

(ii) The total number of nonzero variables in an LPsolution is, at most, equal to the number of constraintequations. Because Eqs. (20) and (21) represent a setof upper and lower bounds to a set of only three linearfunctions, it turns out that the number of nonzerovariables in the solution is, in fact, at most 6. Therefore,no matter how large the number of available colorants,the program will pick at most 6 nonzero concentrations.It seems that this will occur only under very-stringentmetamerism tolerances; our experience, admittedlylimited, shows that the number of colorants chosen tosatisfy a metamerism tolerance of 3 MacAdam unitsis usually 3 or 4. This eliminates the necessity of tryingall possible colorant combinations. The completeinventory of colorants can be considered; the algorithmchooses the most-favorable colorants and theirconcentrations.

(iii) The savings in computation time can be con-siderable if the inventory is sufficiently large. On ourIBM System 360 Model 75, the time required to solvean LP with 9 constraints is approximately 0.15n s,where n is the number of colorants. On the other hand,because there are n(n-1)(n-2)/6 combinations of 3from a list of n colorants, and because the solution of a3X3 equation on the same computer requires 0.005 s,the computation time for the systematic solution of allpossible sets of 3 colorants is 0.005[n(n- 1) (n-2)/6].On this basis, the combinatorial approach is fasterthan the LP for n< 14. The LP is faster for n> 14, andthe difference grows rapidly with n; for n= 100, the LPsolution would take 15 s, whereas the combinatorialsolution would require 15.1 min. This assumes, ofcourse, that only 3-colorant combinations are examined;the ability of the LP to introduce more colorantsautomatically, as required by the metamerism con-straint, is another point in its favor.

(iv) Most LP algorithms allow the user to proceedsuccessively from the optimal solution to the secondbest, third best, and so on. This can be done in a matterof milliseconds, and provides the opportunity for thecolorist to temper the mechanical solution with judg-ment based on considerations external to the LP.

V. RECIPE REFINEMENT

Because the LP solution is based on an approximation,the values provided will not usually be an exact solutionof Eq. (11), although we usually found it to be close.The solution can be iteratively refined by successiveuse of the LP. This may be done by

Step 1. Solve in the manner described for initialcolorant selection and concentrations.

Step 2. Computef{R(Xi)} as per Eq. (5), and invertto find R(xi), i= 1, 2, * * *N. Using Eq. (2), compute Oc.If Oc is sufficiently close to Oc*, stop; otherwise, go toStep 3.

Step 3. Compute aoo(Xi) =f{R(Xi)}, i= 1, 2, *N; ineffect, we consider a new substrate whose reflectanceis that calculated to result from the application ofcolorants in the concentrations given by the LP. Werepeat the LP with ao(Xi) as the new substrate, usingonly the colorants selected in Step 1. The concentrationvariables will represent concentration adjustments;consequently, we must replace the vector c in Eqs.(19)-(21) by the vector Cnew-Cold. Here, Cold is theknown vector of concentration values used in Step 2,while Cnew represents the corrected values. Havingsolved for Cnew, go back to Step 2. 1

It is impossible to prove the convergence of thisprocedure because it is essentially a Newton-Raphsonsolution to a set of nonlinear equations. As such, it willconverge if the starting point is sufficiently close to thesolution. This has been found to be the case becausewe seek recipes with low metamerism, and this tendsto make the linear approximation a good one.

VI. CONCLUSIONS

We have described a new color-recipe algorithmwhose principal advantage is to avoid the combinatorialapproach common to all previous schemes. The algo-rithm makes use of readily available LP packages, someof which may be used on relatively small machines.

The performance of this or any other colorant-determination algorithm in a practical situation stilldepends on the accuracy of the mathematical represen-tation of the physical phenomenon. This requiresaccurate assessment of the colorant-characteristic func-tions aj(Xi). It would be possible to use recursiveparameter-identification techniques to improve thesefunctions by using the results of past dyeings.

ACKNOVWLEDGMENT

I performed the work described in 1965-1967, as aSystems Analyst with the Foxboro Co., Foxboro, Mass.I am indebted to Foxboro for initiating the work andfor allowing publication of this paper.

REFERENCES

IC. Preston and D. Tough, Color Engineering 3, 19 (1965).2E. Allen, American Dyestuff Reporter 54, 57 (1965).3E. Allen, J. Opt. Soc. Am. 56, 1256 (1966).

1544 Vol. 64