#include "MagickCore/pixel-private.h"
-#define D50X 0.964221
-#define D50Y 1.0
-#define D50Z 0.825211
-#define CIEEpsilon (216.0f/24389.0f)
-#define CIEK (24389.0f/27.0f)
+#define D65X 0.950456
+#define D65Y 1.0
+#define D65Z 1.088754
+#define CIEEpsilon (216.0/24389.0)
+#define CIEK (24389.0/27.0)
extern MagickPrivate double
GenerateDifferentialNoise(RandomInfo *,const Quantum,const NoiseType,
assert(X != (double *) NULL);
assert(Y != (double *) NULL);
assert(Z != (double *) NULL);
- y=(100.0f*L+16.0f)/116.0f;
- x=y+255.0f*(a-0.5f)/500.0f;
- z=y-255.0f*(b-0.5f)/200.0f;
+ y=(100.0*L+16.0)/116.0;
+ x=y+255.0*(a-0.5)/500.0;
+ z=y-255.0*(b-0.5)/200.0;
if ((x*x*x) > CIEEpsilon)
x=(x*x*x);
else
- x=(116.0f*x-16.0f)/CIEK;
+ x=(116.0*x-16.0)/CIEK;
if ((y*y*y) > CIEEpsilon)
y=(y*y*y);
else
- y=(100.0f*L)/CIEK;
+ y=(100.0*L)/CIEK;
if ((z*z*z) > CIEEpsilon)
z=(z*z*z);
else
- z=(116.0f*z-16.0f)/CIEK;
- *X=D50X*x;
- *Y=D50Y*y;
- *Z=D50Z*z;
+ z=(116.0*z-16.0)/CIEK;
+ *X=D65X*x;
+ *Y=D65Y*y;
+ *Z=D65Z*z;
}
static inline void ConvertLuvToXYZ(const double L,const double u,const double v,
assert(X != (double *) NULL);
assert(Y != (double *) NULL);
assert(Z != (double *) NULL);
- if ((100.0f*L) > (CIEK*CIEEpsilon))
+ if ((100.0*L) > (CIEK*CIEEpsilon))
*Y=(double) pow(((100.0*L)+16.0)/116.0,3.0);
else
- *Y=(100.0f*L)/CIEK;
- *X=((*Y*((39.0f*(100.0f*L)/((262.0f*v-140.0f)+13.0f*(100.0f*L)*(9.0f*D50Y/
- (D50X+15.0f*D50Y+3.0f*D50Z))))-5.0f))+5.0f*(*Y))/((((52.0f*(100.0f*L)/
- ((354.0f*u-134.0f)+13.0f*(100.0f*L)*(4.0f*D50X/(D50X+15.0f*D50Y+3.0f*
- D50Z))))-1.0f)/3.0f)-(-1.0f/3.0f));
- *Z=(*X*(((52.0f*(100.0f*L)/((354.0f*u-134.0f)+13.0f*(100.0f*L)*(4.0f*D50X/
- (D50X+15.0f*D50Y+3.0f*D50Z))))-1.0f)/3.0f))-5.0f*(*Y);
+ *Y=(100.0*L)/CIEK;
+ *X=((*Y*((39.0*(100.0*L)/((262.0*v-140.0)+13.0*(100.0*L)*(9.0*D65Y/
+ (D65X+15.0*D65Y+3.0*D65Z))))-5.0))+5.0*(*Y))/((((52.0f*(100.0*L)/
+ ((354.0*u-134.0)+13.0*(100.0*L)*(4.0*D65X/(D65X+15.0*D65Y+3.0*
+ D65Z))))-1.0f)/3.0)-(-1.0f/3.0));
+ *Z=(*X*(((52.0f*(100.0*L)/((354.0*u-134.0)+13.0*(100.0*L)*(4.0*D65X/
+ (D65X+15.0*D65Y+3.0*D65Z))))-1.0f)/3.0))-5.0*(*Y);
}
static inline void ConvertRGBToXYZ(const double red,const double green,
assert(L != (double *) NULL);
assert(a != (double *) NULL);
assert(b != (double *) NULL);
- if ((X/D50X) > CIEEpsilon)
- x=pow(X/D50X,1.0/3.0);
+ if ((X/D65X) > CIEEpsilon)
+ x=pow(X/D65X,1.0/3.0);
else
- x=(CIEK*X/D50X+16.0f)/116.0f;
- if ((Y/D50Y) > CIEEpsilon)
- y=pow(Y/D50Y,1.0/3.0);
+ x=(CIEK*X/D65X+16.0)/116.0;
+ if ((Y/D65Y) > CIEEpsilon)
+ y=pow(Y/D65Y,1.0/3.0);
else
- y=(CIEK*Y/D50Y+16.0f)/116.0f;
- if ((Z/D50Z) > CIEEpsilon)
- z=pow(Z/D50Z,1.0/3.0);
+ y=(CIEK*Y/D65Y+16.0)/116.0;
+ if ((Z/D65Z) > CIEEpsilon)
+ z=pow(Z/D65Z,1.0/3.0);
else
- z=(CIEK*Z/D50Z+16.0f)/116.0f;
- *L=((116.0f*y)-16.0f)/100.0f;
- *a=(500.0f*(x-y))/255.0f+0.5f;
- *b=(200.0f*(y-z))/255.0f+0.5f;
+ z=(CIEK*Z/D65Z+16.0)/116.0;
+ *L=((116.0*y)-16.0)/100.0;
+ *a=(500.0*(x-y))/255.0+0.5;
+ *b=(200.0*(y-z))/255.0+0.5;
}
static inline void ConvertXYZToLuv(const double X,const double Y,const double Z,
assert(L != (double *) NULL);
assert(u != (double *) NULL);
assert(v != (double *) NULL);
- if ((Y/D50Y) > CIEEpsilon)
- *L=(double) (116.0f*pow(Y/D50Y,1.0/3.0)-16.0f);
+ if ((Y/D65Y) > CIEEpsilon)
+ *L=(double) (116.0*pow(Y/D65Y,1.0/3.0)-16.0);
else
- *L=CIEK*(Y/D50Y);
- alpha=PerceptibleReciprocal(X+15.0f*Y+3.0f*Z);
- *u=13.0f*(*L)*((4.0f*alpha*X)-(4.0f*D50X/(D50X+15.0f*D50Y+3.0f*D50Z)));
- *v=13.0f*(*L)*((9.0f*alpha*Y)-(9.0f*D50Y/(D50X+15.0f*D50Y+3.0f*D50Z)));
- *L/=100.0f;
- *u=(*u+134.0f)/354.0f;
- *v=(*v+140.0f)/262.0f;
+ *L=CIEK*(Y/D65Y);
+ alpha=PerceptibleReciprocal(X+15.0*Y+3.0*Z);
+ *u=13.0*(*L)*((4.0*alpha*X)-(4.0*D65X/(D65X+15.0*D65Y+3.0*D65Z)));
+ *v=13.0*(*L)*((9.0*alpha*Y)-(9.0*D65Y/(D65X+15.0*D65Y+3.0*D65Z)));
+ *L/=100.0;
+ *u=(*u+134.0)/354.0;
+ *v=(*v+140.0)/262.0;
}
static inline void ConvertXYZToRGB(const double x,const double y,const double z,
assert(red != (double *) NULL);
assert(green != (double *) NULL);
assert(blue != (double *) NULL);
- r=3.2406f*x-1.5372f*y-0.4986f*z;
- g=(-0.9689f*x+1.8758f*y+0.0415f*z);
- b=0.0557f*x-0.2040f*y+1.0570f*z;
+ r=3.2406*x-1.5372*y-0.4986*z;
+ g=(-0.9689*x+1.8758*y+0.0415*z);
+ b=0.0557*x-0.2040*y+1.0570*z;
*red=QuantumRange*r;
*green=QuantumRange*g;
*blue=QuantumRange*b;