Failing cli-colorspace(12) test - double value equality
Posted: 2016-06-24T05:27:18-07:00
Hi,
I am trying to compile Imagemagick 6.9.4-9 on solaris 10. There are 7 tests failing
FAIL: tests/cli-colorspace.tap 12
FAIL: tests/validate-formats-disk.tap 1
FAIL: tests/validate-formats-map.tap 1
FAIL: tests/validate-formats-memory.tap 1
FAIL: tests/wandtest.tap 1
FAIL: Magick++/demo/demos.tap 3
FAIL: Magick++/demo/demos.tap 6
I started to look at the first failure, ignoring the rest for now. The test 12 is about HSL <-> sRGB conversion.
If I run the test by hand, I get "137,80,146" which is not equal to the original value "146,89,80".
It turns out that the problem is in comparing double values in ConvertRGBToHSL
The function says:
The condition does not match, because the difference between the values is -3.171291e-17.
I have replaced all the eqality comparisons with (I would attach patch if I could find how) and the test is now passing. But I'm not sure whether it's generally good approach. Since you do a lot of floating math, I guess you had to tackle such problems in the past. What would you recommend to do to fix the issue?
Thank you
__
Vlad
I am trying to compile Imagemagick 6.9.4-9 on solaris 10. There are 7 tests failing
FAIL: tests/cli-colorspace.tap 12
FAIL: tests/validate-formats-disk.tap 1
FAIL: tests/validate-formats-map.tap 1
FAIL: tests/validate-formats-memory.tap 1
FAIL: tests/wandtest.tap 1
FAIL: Magick++/demo/demos.tap 3
FAIL: Magick++/demo/demos.tap 6
I started to look at the first failure, ignoring the rest for now. The test 12 is about HSL <-> sRGB conversion.
If I run the test by hand, I get "137,80,146" which is not equal to the original value "146,89,80".
It turns out that the problem is in comparing double values in ConvertRGBToHSL
The function says:
Code: Select all
...
if (c <= 0.0)
{
*hue=0.0;
*saturation=0.0;
return;
}
if (max == (QuantumScale*red))
{
*hue=(QuantumScale*green-QuantumScale*blue)/c;
if ((QuantumScale*green) < (QuantumScale*blue))
*hue+=6.0;
}
else
...
Code: Select all
max == (QuantumScale*red)
I have replaced all the eqality comparisons with
Code: Select all
fabs(a-b) < 0.00001
Thank you
__
Vlad