0

I have a specific, rather obvious method of modify colors in an image in my mind, but can't find the tools in common graphic programs such as Gimp or Photoshop to do it with.

Color space can be thought of as a three-dimensional vector space, with one natural base being red, green and blue.

For each pair of color triplets there is exactly one linear map from the first triplet to the second triplet of colors. (If the color triplets consist of colors with distinct hues anyway.)

Now I'd like to have that linear transformation, defined by those six colors, applied to each pixel in my image.

Can Gimp, Photoshop or any other known tool do that?

Is there a common buzzword for that kind of operation?

PS: For the benefit of others, Joojaas answer can also be implemented in Gimp by doing:

  1. Colors -> Components -> Decompose
  2. Image -> Mode -> RGB
  3. Then arrange add the multiplication layers like Joojaa described so that it looks like this: enter image description here
  4. Change the solid color layer type to multiply and the group ones to addition.
  • I'm voting to close this question as off-topic because This si not a question about graphics design – joojaa Apr 7 '16 at 10:30
  • 2
    Could you better explain maybe with a picture or diagram what you mean? I think I might know the answer but am not positive based on your description. I'm a designer not a programmer so linear transformation and map means absolutely nothing to me. Explain what it means for a designer though and I might know something. – Ryan Apr 7 '16 at 12:01
  • @Ryan By answering the question, Jooja also described what I mean in a practical way. – John Apr 7 '16 at 21:11
2

You can do this, its just not commonly done and has no builtin function for this in Photoshop or after effects at least in the gui*. Though in general color is not like a vector space and color is not stored linear (doing linear transformation on nonlinear data is a bit problematic, so first turn data linear). Also note that image editors are not floating point calculators. But yes obviously you can treat any data as a liner vector space.

Edity:

You can build a matrix transform if you wish. What you need to work on is the raw channel data. Do this in Photoshop mostly this works in any other app as well.

  1. Duplicate layer 3 times, name the layer RED, GREEN and BLUE.

    • For each layer copy the respective channel to all other channels
  2. For each channel make a Color fill layer and multiply the channel by that has the new basis that you want as a color.

enter image description here

  1. Change the multiply layers to match your matrix, so if you had matrix:

    1 0 0

    0 0.5 0.5

    0 0.75 0.5

    Then enter values 255 0 0 for the red mask and 0 128 128 for green mask and 0 191 128 for blue mask. Now before you do this if you want the transform to be sane make sure you use a linear working space. And thsi is what you get:

enter image description here

If you need to be able to use negative values then you need to use channel mixer 3 times. Or 6 layers...

A more exotic transom could be [0 0 1 1 0 0 0 1 0] or swapping of channels:

enter image description here

Oh and image is from Public Domain Pictures

* color profiles have this tool. But how to construct one that is a question for stack exchange or computer graphics.

|improve this answer|||||
  • Rotating colors (uniformly rotating hue) isn't what I'm looking for: A linear transformation could, for example, keep red at red and still change green to red also. Rotations are just one special kind of linear mapping. I also don't see why color spaces aren't vector spaces. I will search for the other terms. – John Apr 7 '16 at 8:51
  • @John They are special spaces because there is not a well defined relation between colors particularly the intermediate colors have surprising nonlinear qualities. I am aware on how linear algebra works, basis transform is not commonly done in color manipulation. Though you can encode this in a profile to profile transform. You can just use any linear algebra package to do this tough such as matlab or numpy for example. You can also do this with calculations in Photoshop but its a bit convoluted or you can use channel mixer – joojaa Apr 7 '16 at 9:38
  • @John Ok ive otlined how you can do this using available functions just remember this is not really often done. Therefore it has no standard tool in the GUI. – joojaa Apr 7 '16 at 10:23
  • Wow, thanks a bunch! This is the answer, and well put. And I think you're right that color profiles is the buzzword I was looking for, as they probably do exactly that: a transformation (not sure yet if only linear) of the color space. – John Apr 7 '16 at 21:09
  • Sigh: Photoshop doesn't actually allow me to specify negative color values. (And Gimp doesn't support floating point color spaces at all.) You don't happen to have another idea for that problem, do you? Do I really have to write my own photoshop plugin for this? – John Apr 9 '16 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.