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

Color space: boundaries for C #53

Closed
emmanuel-ichbiah opened this issue Jan 20, 2023 · 9 comments
Closed

Color space: boundaries for C #53

emmanuel-ichbiah opened this issue Jan 20, 2023 · 9 comments

Comments

@emmanuel-ichbiah
Copy link

Hi, I really love iWantHue and the HCL color space. Thank you for this wonderful website.

I wanted to point out that the boundaries for C should be: MIN 0 to MAX 134.

I found out using the following code where I convert all possible RGB values to their HCL counterpart in order to calculate min max values for H,C and L:

min H := max double
min C := max double
min L := max double

max H := min double
max C := min double
max L := min double

for R := 0 to 255 do
for G := 0 to 255 do
for B := 0 to 255 do
  begin
      convert (R,G,B) to (H,C,L)

      min H := MIN( min H, H);
      min C := MIN( min C, C);
      min L := MIN( min L, L);

      max H := MAX( max H, H);
      max C := MAX( max C, C);
      max L := MAX( max L, L);
  end;

The current GUI lets you think that 100 is a maximum for C.

And when you select color space All colors it sets the C range to 0 - 100 whereas it should set it to 0 - 134.

@michkowalczuk
Copy link

Also waiting for the answer.
What C=100 means i your app? Do you make any normalization?

@Yomguithereal
Copy link
Member

I am not really sure here, frankly. I have found in the wild at least 3 different bounds for the C parameter: 100, 134 and 180. So if someone wants to investigate a little bit to understand whether iwanthue implementation is correct or not, I'll be grateful.

@emmanuel-ichbiah
Copy link
Author

I have looked at a code a long time ago and what I can say is:

  • I don't recall that there is any normalization occuring for C. It is just the C range selector which is configured for a [0,100] range whereas it should be [0,~134].
  • else the implementation seems correct to me

Yomguithereal added a commit that referenced this issue Jan 10, 2024
@Yomguithereal
Copy link
Member

@emmanuel-ichbiah @michkowalczuk I have edited the range picker on the website to accept max chroma 134. Can you tell me whether this feels right, in which case I will also fix the color validation code in the npm package.

@emmanuel-ichbiah
Copy link
Author

@emmanuel-ichbiah @michkowalczuk I have edited the range picker on the website to accept max chroma 134. Can you tell me whether this feels right, in which case I will also fix the color validation code in the npm package.

Seems perfect to me! Thank you!

@Yomguithereal
Copy link
Member

Thanks @emmanuel-ichbiah. I cannot find any validation problem to accept cmax = 134 in the code of the npm package so I think I will leave it at that. Of course the all preset is a bit misleading because its cmax is set to 100 but you can override it and I feel it will annoy people if I change it without forcing a breaking change.

@michkowalczuk
Copy link

I have looked at a code a long time ago and what I can say is:

  • I don't recall that there is any normalization occuring for C. It is just the C range selector which is configured for a [0,100] range whereas it should be [0,~134].
  • else the implementation seems correct to me

It's not such a simple thing...
Chroma maximum value depends on combination of Hue and Luminance , as you can find here and here.

There is no perfect solution here. The most correct solution seems to be that when selecting colors, it checks whether it is possible to convert the color to RGB for a given combination of l,c,h. You can read about color clamping for example here and here.

@emmanuel-ichbiah
Copy link
Author

«Chroma maximum value depends on combination of Hue and Luminance»
I perfectly know this.

But if you restrain the C selector to a 0 - 100 range you, depending on your H and L range selection you will NOT get all possible colors for that H and L ranges.

Overall I agree that there are not many colors with a C > 100 but nevertheless the former implementation was misleading. It gave the impression that there were NONE.

@michkowalczuk
Copy link

former

It's just a theoretical considerations ;-) Regardless of what the Chroma value is the theoretical upper limit, iWantHue is a great tool. I appreciate your work!

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

No branches or pull requests

3 participants