SRL Archive - OSR Help

[Resolved]CTS2 Hue difference


Boreas

2010-02-24 00:58:28

Edit: Resolved. When working with relatively narrow color ranges with low tols, remember that there are so many more H,S,L combos than colors that a difference of 7 in H results in the same color.


//SCAR
{program New;
var TolSpeed:integer;
begin
TolSpeed := GetColorToleranceSpeed;
Colortolerancespeed(2);
SetColorspeed2Modifiers(5.0, 0.0);
writeln(booltostr(SimilarColors(HSLToColor(7,4,4),HSLToColor(14,4,4),1)));
SetColorspeed2Modifiers(0.2, 0.2);
Colortolerancespeed(TolSpeed);
//5.0 times 1 is 5, so it should result true when the H's are within 5
//yet 14-7 is 7, and it's still true
end.}

//SIMBA
{program new;
var TolSpeed:integer;
HMod, SMod: extended;
begin
TolSpeed := GetToleranceSpeed;
SetColorToleranceSpeed(2);
GetToleranceSpeed2Modifiers(HMod, SMod);
SetToleranceSpeed2Modifiers(5, 0);
writeln(booltostr(SimilarColors(HSLToColor(7,4,4),HSLToColor(14,4,4),1)));
SetToleranceSpeed2Modifiers(HMod, SMod);
SetColorToleranceSpeed(TolSpeed);
//5.0 times 1 is 5, so it should result true when the H's are within 5
//yet 14-7 is 7, and it's still true
end. }

I guess having a bigger range than expected isn't the worst thing in the world, but the thing is I only need a small range (H 99-1 S 96-100 L 49-51). Can anyone explain the difference?

Method

2010-02-24 09:38:23

From the SCAR manual:

These work when ColorToleranceSpeed(2) has been set. Normally Tolerance parameter in this mode applies to Luminance directly. For an example, SimilarColors(c1, c2, 10) would work if both colors differ by 10 max luminance. After calling SetColorspeed2Modifiers(0.2, 2) it would mean that SimilarColors(c1, c2, 10) would check for Hue in range of 2 and Saturation in range of 20. Default huemodifier and saturationmodifier is 0.2.


Perhaps you should try adjusting your huemod to other values.

edit: nevermind, looks like you had it right.

Wizzup?

2010-02-24 10:30:02

From: Simba
Simba news:
We have relocated the place of the binaries.
The updating process should be a lot faster now.
If you experience trouble updating, try removing
settings.xml

Thank you for using Simba,
Hakuna Matata
Compiled succesfully in 12 ms.
False
Succesfully executed


Works here. :)

E: Wait, it returns false on Linux because PS fucks up… Sec.
E2: Nielsie says both the HSLToColor returns the same colour…
E3: I think pascalscript is playing games again…
E4: Is this perhaps a HSL colour space feature…?
E5:
H, S, L: 7.00, 4.00, 4.00, R, G, B: 11, 10, 10
657931
HSLCONV 0.00, 4.76, 4.12
H, S, L: 14.00, 4.00, 4.00, R, G, B: 11, 10, 10
657931
HSLCONV 0.00, 4.76, 4.12



C.MFinder.SetToleranceSpeed(2);
C.MFinder.SetToleranceSpeed2Modifiers(5.0, 0.0);
writeln(C.MFinder.SimilarColors(HSLToColor(7.0, 4.0, 4.0), HSLToColor(14.0,4.0,4.0),1));
ColorToHSL(HSLToColor(7.0,4.0,4.0),H,S,L);
writeln(format('HSLCONV %f, %f, %f', [h,s,l]));
ColorToHSL(HSLToColor(14.0,4.0,4.0),H,S,L);
writeln(format('HSLCONV %f, %f, %f', [h,s,l]));

Gu3st...

2010-02-24 10:32:30

From: Wizzup?
Works here. :)
Doesn't here:
Compiled succesfully in 16 ms.
True
Succesfully executed

EDIT: Wizzup?'s post wasn't edited when I clicked Quote.. >_<

nielsie95

2010-02-24 10:36:25

The colors are the same ;)

Wizzup?

2010-02-24 11:00:23

It's data loss.


>>> hls_to_rgb(7.0,4.0,4.0)
(-8.0, 16.0, 16.0)
>>> rgb_to_hls(-8,16,16)
(0.5, 4.0, -4.0)

>>> hls_to_rgb(14.0,4.0,4.0)
(-8.0, 16.0, 15.99999999999992)
>>> rgb_to_hls(-8,16,15.99999999999992)
(0.49999999999999939, 4.0, -4.0)


Boreas

2010-02-24 11:27:35

Ah cool, thanks guys.

marpis

2010-02-24 15:26:46

Interesting…

program HSL;
var
H, S, L: Extended;
C: Integer;
begin
H := 100.0;
S := 100.0;
L := 100.0;
C := HSLToColor(H, S, L);
WriteLn('C = '+inttostr(C));
ColorToHSL(C, H, S, L);
WriteLn(Replace(FloatToStr(H), ',', '.')+', '+Replace(FloatToStr(S), ',', '.')+', '+Replace(FloatToStr(L), ',', '.'));
end.

Output:

Successfully compiled (48 ms)
C = 16777215
0, 0, 100
Successfully executed

(100, 100, 100) -> (0, 0, 100)
How is this possible? Is Hue/Sat the same as 100 or 0?

Boreas

2010-02-24 15:34:05

Hmm I thought only H wrapped around.

nielsie95

2010-02-24 16:53:10

It's because your Lightness is 100. 100% lightness is white and it doesn't matter what the Hue and Saturation are.

This is from the wiki:

It's the same as when you'd do 0 lightness; it'd just be black.