if (CIElchOpposite[2] < 180.0) {
CIElchOpposite[2] = CIElchOpposite[2] + 180;
} else {
CIElchOpposite[2] = CIElchOpposite[2] - 180;
}
For a given CIElchOpposite[2] = 82;
the return result is 180
when it should be 262
.
CIELchOpposite
is double []
.
It should be really easy but no matter what the operation is not done correctly.
This is the entire method, mapping a CIELab colour to CIELch space, calculating the opposite colour (just adding or substracting 180º) and then converting it back to CIELab. The mapping has been checked independently and works correctly.
double CIElch[] = MapFromCIElabtoCIElch
.mapLabToLch(inputColorOneCIELAB);
double CIElchOpposite[] = new double[3];
CIElchOpposite[0] = CIElch[0];
CIElchOpposite[1] = CIElch[1];
if (CIElchOpposite[2] < 180.0) {
CIElchOpposite[2] = CIElchOpposite[2] + 180;
} else {
CIElchOpposite[2] = CIElchOpposite[2] - 180;
}
double[] CIElabOpposite = new double[3];
CIElabOpposite = MapFromCIElabtoCIElch.mapLchToLab(CIElchOpposite);
CIElchOpposite[2]
is never assigned any value before the if statement
Perhaps you meant
if (CIElch[2] < 180.0) {
CIElchOpposite[2] = CIElch[2] + 180;
} else {
CIElchOpposite[2] = CIElch[2] - 180;
}
Note Java uses camelCase such as cielchOpposite
and cieLch