4
$\begingroup$

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:

color separate

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?

$\endgroup$
2
  • 1
    $\begingroup$ What not use something like LAB as your color space? That has a luminance built into it $\endgroup$
    – b3m2a1
    Jan 11, 2020 at 21:31
  • $\begingroup$ I'll try that. Thanks. $\endgroup$ Jan 11, 2020 at 21:47

3 Answers 3

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

enter image description here

You can also use ImageMultiply or ImageApply as follows:

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

enter image description here

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

enter image description here

% == %%

True

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

enter image description here

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

enter image description here

% == %%

True

$\endgroup$
6
$\begingroup$

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}]

enter image description here

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

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

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks (+1)... but I think kglr basically solved it (first). $\endgroup$ Jan 12, 2020 at 2:44
  • $\begingroup$ @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. $\endgroup$
    – b3m2a1
    Jan 12, 2020 at 2:45
1
$\begingroup$

I think I figured it out:

enter image description here

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

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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