# How to mix colors in an RGB image to get a specific black and white picture

Of course this is not about converting an RGB to grayscale.

In most photo-editing software like Photoshop and Affinity etc, there is an option to go from a regular color photo to a black and white photo. Often this is done by a control like the image below that allows you to control the contribution of each color group (Red, Yellow, Green, Cyan, Blue, Magenta) to the final image.

My question is given an RGB image, how would one generate the black and white image, while controlling the contribution of different colors?

What would the implementation look like?

A naive implementation would be like gray = mean(r,g,b) and if you wanted to change contribution of each of the fundamental colors you may have gray = mean(x*r,y*b,z*g) where x+y+z=1 but who about r,g,b,c,m,y as it seems to be the norm?

I know there are several different color schemes or "gamuts". The only one that I have any familiarity with is the NTSC luminance and chroma definitions for the old analog color TVs we had until the 21st century.

$$\begin{bmatrix} Y \\ I \\ Q \end{bmatrix} \triangleq \begin{bmatrix} 0.299 & 0.587 & 0.114 \\ 0.5959 & -0.2746 & -0.3213 \\ 0.2115 & -0.5227 & 0.3112 \end{bmatrix} \begin{bmatrix} R \\ G \\ B \end{bmatrix}$$

$$Y$$ is the luminance (white) and $$I$$ and $$Q$$ are the chroma signals and were defined this way so that $$I$$ and $$Q$$ might require less bandwidth than the $$Y$$ B&W signal.

The magnitude of the chroma signals, $$\sqrt{I^2+Q^2}$$, was scaled by the Color Intensity control knob on your color TV. The angle, $$\arg\{I,Q\}$$, was offset by the Hue control knob.

The inverse matrix is:

$$\begin{bmatrix} R \\ G \\ B \end{bmatrix} = \begin{bmatrix} 1 & 0.956 & 0.619 \\ 1 & -0.272 & -0.647 \\ 1 & -1.106 & 1.703 \end{bmatrix} \begin{bmatrix} Y \\ I \\ Q \end{bmatrix}$$

But there are other mixing definitions than that.

Perhaps this recent question hints about how to «upsample» color from rgb. Simulate chromatic filter on RGB image

After that, I would assume that it is just a linear weighted mixture copied equally into each output channel as you say. Some may prefer to do an additional twist of the mixture (say, make it a bit yellowish).

Note that image editors may work on linear representations of rgb that are different from the gamma encoded srgb that is native to computers and displays.

Also, a dedicated «b/w film plugin» may use all kinds of image processing to get a certain «look» including contrast changes.