Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jzczhz check for achromatic colors #629

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lloydk
Copy link
Collaborator

@lloydk lloydk commented Jan 11, 2025

The default ε (0.00001) calculated for jzczhz is to low for achromatic colors. The highest az or bz value for an achromatic color is -0.00023625807422922307 for color(rec2100-pq 1 1 1).

The ColorSpace class has been modified to allow setting ε when constructing a ColorSpace and the ε for jzczhz has been set to 0.0002363.

This new ε ensures that all achromatic colors up to the brightest white in req2100-pq have a null hue when converted to jzczhz.

However, with the new ε there are some non-achromatic colors near black in rec2100-pq that will be considered to be achromatic when converted to jzczhz. I think this is ok but I wanted to point them out.

// The non zero values in this list are either 1 / 255, 2 / 255 or 3 / 255.
color(rec2100-pq 0 0 0.00392156862745098)
color(rec2100-pq 0 0 0.00784313725490196)
color(rec2100-pq 0 0.00392156862745098 0)
color(rec2100-pq 0 0.00392156862745098 0.00392156862745098)
color(rec2100-pq 0 0.00392156862745098 0.00784313725490196)
color(rec2100-pq 0 0.00784313725490196 0)
color(rec2100-pq 0 0.00784313725490196 0.00392156862745098)
color(rec2100-pq 0 0.00784313725490196 0.00784313725490196)
color(rec2100-pq 0.00392156862745098 0 0)
color(rec2100-pq 0.00392156862745098 0 0.00392156862745098)
color(rec2100-pq 0.00392156862745098 0 0.00784313725490196)
color(rec2100-pq 0.00392156862745098 0.00392156862745098 0)
color(rec2100-pq 0.00392156862745098 0.00392156862745098 0.00784313725490196)
color(rec2100-pq 0.00392156862745098 0.00784313725490196 0)
color(rec2100-pq 0.00392156862745098 0.00784313725490196 0.00392156862745098)
color(rec2100-pq 0.00392156862745098 0.00784313725490196 0.00784313725490196)
color(rec2100-pq 0.00784313725490196 0 0)
color(rec2100-pq 0.00784313725490196 0 0.00392156862745098)
color(rec2100-pq 0.00784313725490196 0 0.00784313725490196)
color(rec2100-pq 0.00784313725490196 0.00392156862745098 0)
color(rec2100-pq 0.00784313725490196 0.00392156862745098 0.00392156862745098)
color(rec2100-pq 0.00784313725490196 0.00392156862745098 0.00784313725490196)
color(rec2100-pq 0.00784313725490196 0.00784313725490196 0)
color(rec2100-pq 0.00784313725490196 0.00784313725490196 0.00392156862745098)
color(rec2100-pq 0.00784313725490196 0.00784313725490196 0.011764705882352941)
color(rec2100-pq 0.00784313725490196 0.011764705882352941 0.00784313725490196)
color(rec2100-pq 0.00784313725490196 0.011764705882352941 0.011764705882352941)
color(rec2100-pq 0.011764705882352941 0.00784313725490196 0.00392156862745098)
color(rec2100-pq 0.011764705882352941 0.00784313725490196 0.00784313725490196)
color(rec2100-pq 0.011764705882352941 0.00784313725490196 0.011764705882352941)
color(rec2100-pq 0.011764705882352941 0.011764705882352941 0.00784313725490196)

I rounded the ε, I can change it to the exact number if that's a more appropriate value.

The default ε (0.00001) calculated for jzczhz is to low for
achromatic colors. The highest az or bz value for an achromatic
color is -0.00023625807422922307 for color(rec2100-pq 1 1 1).

The ColorSpace class has been modified to allow setting ε when
constructing a ColorSpace and the ε for jzczhz has been set to
0.0002363.

This new ε ensures that all achromatic colors up to the brightest
white in req2100-pq have a null hue when converted to jzczhz.

However, with the new ε there are some non-achromatic colors near
black in rec2100-pq that will be considered to be achromatic when
converted to jzczhz.
Copy link

netlify bot commented Jan 11, 2025

Deploy Preview for colorjs ready!

Name Link
🔨 Latest commit efa227f
🔍 Latest deploy log https://app.netlify.com/sites/colorjs/deploys/6781ce087a97260008dd938c
😎 Deploy Preview https://deploy-preview-629--colorjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@facelessuser
Copy link
Collaborator

However, with the new ε there are some non-achromatic colors near black in rec2100-pq that will be considered to be achromatic when converted to jzczhz. I think this is ok but I wanted to point them out.

Yeah, that means you lose those colors, unfortunately.

This kind of thing crops up with a number of color spaces, especially ones that allow you to adjust the viewing environment and assuming the eye is not fully adapted, such as CAM16, ZCAM, HCT, RLAB, etc. In such spaces, the achromatic colors, those with zero chroma, don't necessarily align with what one would traditionally consider neutral in sRGB due to the influence of the adapting luminance and background luminance.

I think the question becomes is achromatic what is considered neutral in the given space (with the given viewing environment and when chroma is zero) or is it strictly what we would consider achromatic in a given RGB space?

In Jzabz's case, chroma doesn't get anywhere near as big as it does in CAM16 and HCT near white, so you can probably get away with giving it a more relaxed threshold (like is done in this PR) at the expense of some color. Maybe the small loss of colors won't matter?

In spaces like CAM16 and HCT, such an approach simply can't work. You need something more complicated as the traditional achromatic line is more dynamic in these spaces.

I'm not really sure what is preferable. I experimented with such things earlier, and at least in my own color library, I decided to make "achromatic" relative to the space, and when chroma is near zero in those spaces, it is considered achromatic. I think I preferred not losing colors if it could be helped. I at least think that with JzCzhz, if this is the direction we want to go, the impact might not be too large.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants