diff --git a/src/image/color/cie1931.cpp b/src/image/color/cie1931.cpp index 73beb0f4..104b8385 100644 --- a/src/image/color/cie1931.cpp +++ b/src/image/color/cie1931.cpp @@ -28,9 +28,6 @@ float Color::DistanceCIEDE2000(vec3 lab1, vec3 lab2) { float const pi = 3.141592653589793f; - float const deg2rad = 6.28318530718f / 360.f; - float const rad2deg = 360.f / 6.28318530718f; - float C1 = length(lab1.yz); float C2 = length(lab2.yz); float C_ = 0.5f * (C1 + C2); @@ -64,7 +61,7 @@ float Color::DistanceCIEDE2000(vec3 lab1, vec3 lab2) Hp_ = hp1 + hp2; else if (abs(hp1 - hp2) > pi && hp1 + hp2 < 2.f * pi) Hp_ = 0.5f * (hp1 + hp2) + pi; - else if (abs(hp1 - hp2) > 180.f) + else if (abs(hp1 - hp2) > pi) Hp_ = 0.5f * (hp1 + hp2) - pi; else Hp_ = 0.5f * (hp1 + hp2); @@ -78,7 +75,7 @@ float Color::DistanceCIEDE2000(vec3 lab1, vec3 lab2) float SC = 1.f + 0.045f * Cp_; float SH = 1.f + 0.015f * Cp_ * T; float RT = -2.f * sqrt(pow(Cp_, 7.f) / (pow(Cp_, 7.f) + pow(25.f, 7.f))) - * sin(60.f * deg2rad * exp(-pow((Hp_ * rad2deg - 275.f) / 25.f, 2.f))); + * sin(pi / 3.f * exp(-pow((Hp_ * 180.f / pi - 275.f) / 25.f, 2.f))); dLp /= SL; dCp /= SC; diff --git a/test/unit/color.cpp b/test/unit/color.cpp index 86c9d2e5..f1ea2faf 100644 --- a/test/unit/color.cpp +++ b/test/unit/color.cpp @@ -37,8 +37,8 @@ static float const ciede2k[] = //50.0000f, 2.4900f, -0.0010f, 50.0000f, -2.4900f, 0.0011f, 7.2195f, //50.0000f, 2.4900f, -0.0010f, 50.0000f, -2.4900f, 0.0012f, 7.2195f, 50.0000f, -0.0010f, 2.4900f, 50.0000f, 0.0009f, -2.4900f, 4.8045f, - 50.0000f, -0.0010f, 2.4900f, 50.0000f, 0.0010f, -2.4900f, 4.8045f, - //50.0000f, -0.0010f, 2.4900f, 50.0000f, 0.0011f, -2.4900f, 4.7461f, + //50.0000f, -0.0010f, 2.4900f, 50.0000f, 0.0010f, -2.4900f, 4.8045f, + 50.0000f, -0.0010f, 2.4900f, 50.0000f, 0.0011f, -2.4900f, 4.7461f, 50.0000f, 2.5000f, 0.0000f, 50.0000f, 0.0000f, -2.5000f, 4.3065f, 50.0000f, 2.5000f, 0.0000f, 73.0000f, 25.0000f, -18.0000f, 27.1492f, 50.0000f, 2.5000f, 0.0000f, 61.0000f, -5.0000f, 29.0000f, 22.8977f,