How to check if a color is out of gamut of a color space

222 views Asked by At

I'm developing a canvas web application converting colors of an image from Display P3 to sRGB using the relative colorimetric gamut mapping algorithm (in-gamut colors are rounded/aligned, out-of-gamut colors are clamped).

Before actual conversion, I need to have a preview figuring out which colors will be out-of-gamut and showing those out-of-gamut pixels with a fallback color (like black or cyan).

So the process blocked here:

function isOutOfGamut(colorXYZ, colorSpaceInfo){
  // TODO
}
  • colorXYZ is a color described in CIE XYZ
  • colorSpaceInfo contains all information about a color space, can be extracted from some ICC color profile
0

There are 0 answers