# Separate the luminance from the chrominance in an image

My goal is to separate a full-color image into its luminance and chrominance ("color") components and display them as two images: 1) a black and white image (for the luminance) and 2) a color image (for the chrominance).

It would appear that the proper color space for this separation would be CMYK (cyan-magenta-yellow-black), as this separates the black from the others:

This gives me four component images. The last of which is the luminance (like a grayscale) image... half of what I need.

But how do I combine the first three channels to obtain a colored image that has no luminance component... i.e., appears in color but is of uniform lightness?

• What not use something like LAB as your color space? That has a luminance built into it – b3m2a1 Jan 11 at 21:31
• I'll try that. Thanks. – David G. Stork Jan 11 at 21:47

img = Import["https://i.stack.imgur.com/2L3Hc.png"]


You can also use ImageMultiply or ImageApply as follows:

ImageMultiply[ColorConvert[img, "CMYK"], {1, 1, 1, 0}]


ImageApply[{1, 1, 1, 0} # &, ColorConvert[img, "CMYK"]]


% == %%


True

ImageMultiply[ColorConvert[img, "CMYK"], 1 - {1, 1, 1, 0}]


ImageApply[(1 - {1, 1, 1, 0}) # &, ColorConvert[img, "CMYK"]]


% == %%


True

Here's something that uses the "LAB" colorspace:

butterfly = ColorConvert[Import["https://i.stack.imgur.com/2L3Hc.png"], "LAB";


To kill the color channels:

ImageMultiply[butterfly, {1, 0, 0}]


Or to put everything on max "lightness" (an approximate luminance):

ColorCombine[
Prepend[
ColorSeparate[butterfly][[2 ;;]],
ConstantImage[1, ImageDimensions[butterfly]]
],
"LAB"
]


• Thanks (+1)... but I think kglr basically solved it (first). – David G. Stork Jan 12 at 2:44
• @DavidG.Stork yeah not an issue. Just figured it'd be good to have a LAB solution out there since the L is suppose to approximate how people perceive luminance. LUV would likely work just as well. – b3m2a1 Jan 12 at 2:45

I think I figured it out:

This re-combines the CMYK channels, but with the black channel effectively set to 0.

• does ImageMultiply[ ColorConvert[img, "CMYK"], {1, 1, 1, 0}] give the same result? – kglr Jan 11 at 22:01
• also ImageApply[{1, 1, 1, 0} # &, ColorConvert[img, "CMYK"]]? – kglr Jan 11 at 22:04