<p>The mathematical approach to this is to represent the other colors/light sources in terms of your standard primaries in the color space. Represent your target color and available light sources as vectors with, say, the RGB color space as the basis. Figuring out how to display your target color using your available sources then becomes a <a href="https://math.stackexchange.com/a/340991/166490">change of basis</a>, a standard linear algebra operation, where the target basis consists of your LEDs/nonstandard primaries.</p>

<p>If the dimensions of the source and destination bases are different, the change of basis matrix won't be square and thus won't be invertible. In that case, you need to solve a system of linear equations, expressed in matrix form:</p>

<p>$$c_{RGB} = [r, y, b, v] \cdot c_{RYBV}$$</p>

<p>Where $c_{RGB}$ and $c_{RYBV}$ are the coordinate vectors of your desired color expressed in terms of RGB and custom primaries, respectively, and $r$, $y$, $b$ and $v$ are your custom primaries (basis vectors) in RGB coordinates.</p>

<p>Solving this system is another common linear algebra operation, and there are a variety of numerical and symbolical algorithms to do so. The system is over-constrained, so solutions will likely have a free variable, however since we can't physically produce negative light, nor do the primaries have infinite dynamic range, for most practical purposes each coefficient will have to be limited to be within the $[0, 1]$ range. This will render many colors unrepresentable under certain sets of primaries.</p>

CC BY-SA 3.0
2015-08-08T20:58:31.147Z
Yes but how do you handle change of basis to dimensions? If i have is a R^3 -> R^4 or R^5 mapping? Anyway yes this will make it work atleast halfway.
joojaa
CC BY-SA 3.0
2015-08-08T22:39:28.103Z
I've not had to approach this problem before, but I'm skeptical that this answer will work since color spaces aren't always linear.
Jorge Rodriguez
CC BY-SA 3.0
2015-08-09T02:22:05.913Z
Dot product surely will come into play
Alan Wolfe
CC BY-SA 3.0
2015-08-09T04:50:36.953Z
@jorgeRodriguez you can treat the space linear for max values
joojaa
CC BY-SA 3.0
2015-08-10T01:02:36.503Z
@JorgeRodriguez would it work if you first translate to a linear colour space? For more than 3 primary colours there will in general be more than one combination that approximates a given colour, but finding one of those combinations should be possible with this approach, provided that the chosen primary colours form a basis.
trichoplax is on Codidact now
CC BY-SA 3.0
2015-08-10T16:18:55.310Z
I expanded my answer to be explicit about how to deal with bases of differing dimensions. Is there any way to use LaTeX for math here? This will probably be a very common feature request.
yuriks
CC BY-SA 3.0
2015-08-10T16:26:33.650Z
And regarding linearity: afaik most if not all color spaces are linear or have a 1:1 mapping that makes them linear. The CIE XYZ and xyY color spaces (which are supposed to represent all colors visible to the human eye) fit that definition, and are probably what you'd want to use as the "conversion" color space rather than RGB.
yuriks
CC BY-SA 3.0
2015-08-10T16:36:56.713Z
MathJax request is in works you should add your post as a reference to this [meta post](http://meta.computergraphics.stackexchange.com/a/34/38)
joojaa
CC BY-SA 3.0
2015-08-11T02:47:12.823Z
@trichoplax yuriks and joojaa seem to be confident in this answer so I'll defer to them.
Jorge Rodriguez
CC BY-SA 3.0
2015-08-08T19:51:13.280Z
2015-11-03T13:53:01.553Z
2017-04-13T12:19:38.027Z
yuriks
<p>How would one do a color separation if there are more than 3 color primaries, or the primaries are nonstandard. In Standard  CMYK conversion K is relatively easy conceptually to figure out. Its just a constant value off all the channels. </p>

<p>How would one construct a CMY + orange for instance. Or in the case of a led array with say Red, Yellow, Blue and Violet for example. How would one approach this problem. </p>

<p>I'm fine with a conceptual answer no need to do LAB to end result conversion for example. Though that would be nice.</p>

<color><color-separation><conversion>
How to do a color separation with more than 3 primary colors
joojaa
# How to do a color separation with more than 3 primary colors

(Asked by: username_0 on 2015-08-08)

How would one do a color separation if there are more than 3 color primaries, or the primaries are nonstandard. In Standard CMYK conversion K is relatively easy conceptually to figure out. Its just a constant value off all the channels.

How would one construct a CMY + orange for instance. Or in the case of a led array with say Red, Yellow, Blue and Violet for example. How would one approach this problem.

I'm fine with a conceptual answer no need to do LAB to end result conversion for example. Though that would be nice.

**Tags:** color, color-separation, conversion


---

## 1 answers

### Answer by username_1 on 2015-08-08. Score: 5 | Accepted answer

The mathematical approach to this is to represent the other colors/light sources in terms of your standard primaries in the color space. Represent your target color and available light sources as vectors with, say, the RGB color space as the basis. Figuring out how to display your target color using your available sources then becomes a [change of basis](https://math.stackexchange.com/a/340991/166490), a standard linear algebra operation, where the target basis consists of your LEDs/nonstandard primaries.

If the dimensions of the source and destination bases are different, the change of basis matrix won't be square and thus won't be invertible. In that case, you need to solve a system of linear equations, expressed in matrix form:

$$c\_{RGB} = [r, y, b, v] \cdot c\_{RYBV}$$

Where $c\_{RGB}$ and $c\_{RYBV}$ are the coordinate vectors of your desired color expressed in terms of RGB and custom primaries, respectively, and $r$, $y$, $b$ and $v$ are your custom primaries (basis vectors) in RGB coordinates.

Solving this system is another common linear algebra operation, and there are a variety of numerical and symbolical algorithms to do so. The system is over-constrained, so solutions will likely have a free variable, however since we can't physically produce negative light, nor do the primaries have infinite dynamic range, for most practical purposes each coefficient will have to be limited to be within the $[0, 1]$ range. This will render many colors unrepresentable under certain sets of primaries.

> **Comments:**
> **username_0**: Yes but how do you handle change of basis to dimensions? If i have is a R^3 -> R^4 or R^5 mapping? Anyway yes this will make it work atleast halfway.  
> **username_2**: I've not had to approach this problem before, but I'm skeptical that this answer will work since color spaces aren't always linear.  
> **username_3**: Dot product surely will come into play  
> **username_0**: @jorgeRodriguez you can treat the space linear for max values  
> **username_4**: @username_2 would it work if you first translate to a linear colour space? For more than 3 primary colours there will in general be more than one combination that approximates a given colour, but finding one of those combinations should be possible with this approach, provided that the chosen primary colours form a basis.  
> **username_1**: I expanded my answer to be explicit about how to deal with bases of differing dimensions. Is there any way to use LaTeX for math here? This will probably be a very common feature request.  
> **username_1**: And regarding linearity: afaik most if not all color spaces are linear or have a 1:1 mapping that makes them linear. The CIE XYZ and xyY color spaces (which are supposed to represent all colors visible to the human eye) fit that definition, and are probably what you'd want to use as the "conversion" color space rather than RGB.  
> **username_0**: MathJax request is in works you should add your post as a reference to this [meta post](http://meta.computergraphics.stackexchange.com/a/34/38)  
> **username_2**: @username_4 username_1 and username_0 seem to be confident in this answer so I'll defer to them.  

---

