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 XYZcolorSpaceInfo
contains all information about a color space, can be extracted from some ICC color profile