//Defining the variables, XYZ (capitalised were defined as floats as well but as a parameter in the function)
float x, y, z;
float Total = X + Y + Z;
x = X / Total;
y = Y / Total;
z = Z / Total;
Hello, I have this bit of maths that I'm trying to do but it gives m the following error:
C:\Users\Nneka\Documents\Arduino\IRP\IRP_MainCode\IRP_MainCode.ino: In function 'void RGBtoCIElab(uint8_t*, uint8_t*, uint8_t*, float*, float*, float*, double*, double*, double*)':
C:\Users\Nneka\Documents\Arduino\IRP\IRP_MainCode\IRP_MainCode.ino:164:19: error: invalid operands of types 'float*' and 'float*' to binary 'operator+'
float Total = X + Y + Z;
~~^~~
C:\Users\Nneka\Documents\Arduino\IRP\IRP_MainCode\IRP_MainCode.ino:165:9: error: invalid operands of types 'float*' and 'float' to binary 'operator/'
x = X / Total;
~~^~~~~~~
C:\Users\Nneka\Documents\Arduino\IRP\IRP_MainCode\IRP_MainCode.ino:166:9: error: invalid operands of types 'float*' and 'float' to binary 'operator/'
y = Y / Total;
~~^~~~~~~
C:\Users\Nneka\Documents\Arduino\IRP\IRP_MainCode\IRP_MainCode.ino:167:9: error: invalid operands of types 'float*' and 'float' to binary 'operator/'
z = Z / Total;
~~^~~~~~~
exit status 1
Compilation error: invalid operands of types 'float*' and 'float*' to binary 'operator+'
This is the entire function for reference:
void RGBtoCIElab(uint8_t *r,uint8_t *g,uint8_t *b, float *X, float *Y, float *Z, double *CIEL, double *CIEa, double *CIEb) {
//Converting the RGB values to XYZ trimstimulus counterparts
float fracX, fracY, fracZ;
float Fx, Fy, Fz;
float x, y, z;
// turning the 0-255 values to 0-1
*r /= 255;
*g /= 255;
*b /= 255;
//Continuity check
Serial.print("value between 0 - 1 R: "); Serial.print(*r); Serial.print(" ");
Serial.print("G: "); Serial.print(*g); Serial.print(" ");
Serial.print("B: "); Serial.print(*b); Serial.print(" ");
Serial.println(" ");
// Using the matrix calculation found in the manufacturer datasheet to find the XYZ trimstimulus values
*X = (-0.14282F * *r) + (1.54924F * *g) + (-0.95641F * *b);
*Y = (-0.32466F * *r) + (1.57837F * *g) + (-0.73191F * *b);
*Z = (-0.68202F * *r) + (0.77073F * *g) + (0.56332F * *b);
// Converting the XYZ trimstimulus values to xyz chromacities values
float Total = X + Y + Z;
x = X / Total;
y = Y / Total;
z = Z / Total;
// Going from CIExyz to CIELab
fracX = *X/Xn;
fracY = *Y/Yn;
fracZ = *Z/Zn;
if (fracX > (6/29)^3) {
Fx = pow(fracX, 1/3);
}
else (fracX <= (6/29)^3); {
Fx = ((841/108)*(fracX)) + (4/29);
}
if (fracY > (6/29)^3) {
Fy = pow(fracY, 1/3);
}
else (fracY <= (6/29)^3); {
Fy = ((841/108)*(fracY)) + (4/29);
}
if (fracZ > (6/29)^3) {
Fz = pow(fracZ, 1/3);
}
else (fracZ <= (6/29)^3); {
Fz = ((841/108)*(fracZ)) + (4/29);
}
*CIEL = (116 * Fy) - 16;
*CIEa = 500 * (Fx - Fy);
*CIEb = 200 * (Fy - Fz);
}