(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 20 Apr 2013 01:11:51 +0000 (01:11 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 20 Apr 2013 01:11:51 +0000 (01:11 +0000)
MagickCore/colorspace.c
MagickCore/gem-private.h

index 3f74447f2f1d2607ecc3f1e09b131d7cc19dbf16..96c7e7045f5e5b6f91a1565a0460ec7035e53b7e 100644 (file)
@@ -1251,7 +1251,7 @@ static MagickBooleanType sRGBTransformImage(Image *image,
       /*
         Initialize YCbCr tables (ITU-R BT.601):
 
-          Y =  0.298839f0*R+0.586811f0*G+0.114350f0*B
+          Y =  0.2988390*R+0.5868110*G+0.1143500*B
           Cb= -0.1687367*R-0.3312640*G+0.5000000*B
           Cr=  0.5000000*R-0.4186880*G-0.0813120*B
 
@@ -1386,7 +1386,7 @@ static MagickBooleanType sRGBTransformImage(Image *image,
       /*
         Initialize YPbPr tables (ITU-R BT.601):
 
-          Y =  0.298839f0*R+0.586811f0*G+0.114350f0*B
+          Y =  0.2988390*R+0.5868110*G+0.1143500*B
           Pb= -0.1687367*R-0.3312640*G+0.5000000*B
           Pr=  0.5000000*R-0.4186880*G-0.0813120*B
 
@@ -1418,7 +1418,7 @@ static MagickBooleanType sRGBTransformImage(Image *image,
       /*
         Initialize YUV tables:
 
-          Y =  0.298839f*R+0.586811f*G+0.114350f*B
+          Y =  0.298839*R+0.586811*G+0.114350*B
           U = -0.147130*R-0.288860*G+0.436000*B
           V =  0.615000*R-0.514990*G-0.100010*B
 
index 8798fab9e568ccf6f2733ece90b266820fdae44a..5cfb2960a6e865855b6eff8c827400cef55ab66a 100644 (file)
@@ -24,11 +24,11 @@ extern "C" {
 
 #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,
@@ -72,24 +72,24 @@ static inline void ConvertLabToXYZ(const double L,const double a,const double b,
   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,
@@ -98,16 +98,16 @@ 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,
@@ -139,21 +139,21 @@ static inline void ConvertXYZToLab(const double X,const double Y,const double Z,
   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,
@@ -165,16 +165,16 @@ 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,
@@ -191,9 +191,9 @@ 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;