Search This Blog

Thursday, August 5, 2010

A real example (part #2)

Now that we have a language to quantify the differences in colors how do we make use of it.

Let's take our example with the green logo from the previous post and assume that documents to print contain this logo.   Further, we assume that if we print the document "as is" the logo color is wrong.

So the first thing we need is a mechanism to name a set of transforms for application to some input.   We will use pseudo XML that use parends instead of greater/less than to avoid blogger bugs.  So we might say:

(TRANSFORMS)
  (TRANSFORM name='fix_logo')
  ...
  (/TRANSFORM)
(/TRANSFORMS)

We also need a way to talk about the colors (outside a mathematical context) we are interested and we need tell our system what to do with those colors.  To do this we use sets of colorant values along with an identifying color type, for example CMYK(0,.2,0,.01).  In practice we want to restrict our color specifications a bit more so we create some more complicated color types: "CMYK" means stroke CMYK color, "cmyk" means fill CMYK color, "icmyk" mean image CMYK color, and so on (the other types are just combinations of these basic types).  So we could say something like:

(COLOR name="c1" type="CMYK0,.2,0,.01)" /)

Finally we need a way to talk about the mathematical transforms and what colors, if any, they might use.  We're not going to put the mathematical parts out here.  Instead we will assign names to them like this:

(OPERATION name="fix_green" input="c1" output="c2" function="shader1" param=".75" ... /)

So here we have a transform called fix_green that takes as an input color c1 and transforms it to c2 via a function shader1shader1 is controlled by some additional parameters identified by the param attribute.  The shader1 function controls the stretching and shrinking operations we've describe earlier. For our purposes here we can imagine shader1 to use the param value to control how closely an input color has to match c1 in order to convert it to c2.

Putting it all together we might end up with something like this:

(TRANSFORMS)
  (COLOR name="c1" type="CMYK0,.2,0,.01)" /)
  (OPERATION name="fix_green" input="c1" output="c2" function="shader1" param=".75" ... /)
  ...
  (TRANSFORM name='fix_logo_A')
    (APPLY name="fix_green"\)
    (APPLY name="fix_red" \)
  (/TRANSFORM)
(/TRANSFORMS)


Next we need a way to tell our system when to apply the fix_logo_A transform.  To do this we need some meta data that associates a page in a stream of documents to alter with a transform.  We might use something like this:

(DOCUMENT id='0123456' transform='fix_logo_A'/)
(DOCUMENT id='0123457' transform='fix_logo_B'/)
(DOCUMENT id='0123458' transform='fix_logo_A'/)
...

This let's us selectively apply transformations based on inputs.

Note:  There is no reason that parameters like param='.75' have to be static relative to the document stream.  We could, for example, also say

(DOCUMENT id='0123456' transform='fix_logo_A' param='.65' /)

It really all depends on what you need to do.

So now we can describe the color changes we are interested in.  We have a programmatic way that supports parameterization to allow us to control the color changes with data.

However, there are still some items we have to cover in order to define a complete system (which we will do in subsequent posts):
  1. How do we figure out what transforms should do?
  2. How do we figure out what color to change and what to change them to?
  3. How do we handle differences in color between devices?

No comments:

Post a Comment