This will help us build CIE 1931 chromaticity diagrams:
The following diff files, from v6.8.9-6, give changes that implement xyY:
colorspace.h:
Code: Select all
--- /home/Alan/imdevsrc/../ImageMagick-6.8.9-6/magick/colorspace.h 2013-11-18 13:03:16.000000000 +0000
+++ /home/Alan/imdevsrc/magick/colorspace.h 2014-09-29 02:53:40.504147300 +0100
@@ -30,6 +30,7 @@
TransparentColorspace,
OHTAColorspace,
LabColorspace,
+ xyYColorspace,
XYZColorspace,
YCbCrColorspace,
YCCColorspace,
Code: Select all
--- /home/Alan/imdevsrc/../ImageMagick-6.8.9-6/magick/colorspace.c 2014-03-29 15:42:48.000000000 +0000
+++ /home/Alan/imdevsrc/magick/colorspace.c 2014-09-29 03:01:07.675182900 +0100
@@ -195,6 +195,21 @@
*Q=QuantumScale*(0.211456*red-0.522591*green+0.311135*blue)+0.5;
}
+static void ConvertRGBToxyY(const Quantum red,const Quantum green,
+ const Quantum blue,double *lowx,double *lowy,double *capY)
+{
+ double
+ X,
+ Y,
+ Z;
+
+ ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
+
+ *lowx = X / (X+Y+Z);
+ *lowy = Y / (X+Y+Z);
+ *capY = Y;
+}
+
MagickExport MagickBooleanType RGBTransformImage(Image *image,
const ColorspaceType colorspace)
@@ -377,6 +392,7 @@
case LCHuvColorspace:
case LMSColorspace:
case LuvColorspace:
+ case xyYColorspace:
case XYZColorspace:
case YCbCrColorspace:
case YDbDrColorspace:
@@ -502,6 +518,11 @@
ConvertRGBToLuv(red,green,blue,&X,&Y,&Z);
break;
}
+ case xyYColorspace:
+ {
+ ConvertRGBToxyY(red,green,blue,&X,&Y,&Z);
+ break;
+ }
case XYZColorspace:
{
ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
@@ -1131,7 +1152,9 @@
}
else
if ((IsRGBColorspace(colorspace) != MagickFalse) ||
- (colorspace == XYZColorspace))
+ (colorspace == XYZColorspace) ||
+ (colorspace == xyYColorspace)
+ )
image->gamma=1.0;
else
{
@@ -1369,6 +1392,21 @@
4.813762626262513e-04*(V-0.5)));
}
+static inline void ConvertxyYToRGB(const double lowx,const double lowy,
+ const double capY,Quantum *red,Quantum *green,Quantum *blue)
+{
+ double
+ X,
+ Y,
+ Z;
+
+ X = capY / lowy * lowx;
+ Y = capY;
+ Z = capY / lowy * (1.0 - lowx - lowy);
+
+ ConvertXYZToRGB(X,Y,Z,red,green,blue);
+}
+
MagickExport MagickBooleanType TransformRGBImage(Image *image,
const ColorspaceType colorspace)
{
@@ -1786,6 +1824,7 @@
case LCHuvColorspace:
case LMSColorspace:
case LuvColorspace:
+ case xyYColorspace:
case XYZColorspace:
case YCbCrColorspace:
case YDbDrColorspace:
@@ -1911,6 +1950,11 @@
ConvertLuvToRGB(X,Y,Z,&red,&green,&blue);
break;
}
+ case xyYColorspace:
+ {
+ ConvertxyYToRGB(X,Y,Z,&red,&green,&blue);
+ break;
+ }
case XYZColorspace:
{
ConvertXYZToRGB(X,Y,Z,&red,&green,&blue);
Code: Select all
--- /home/Alan/imdevsrc/../ImageMagick-6.8.9-6/magick/option.c 2014-06-30 19:05:31.000000000 +0100
+++ /home/Alan/imdevsrc/magick/option.c 2014-09-29 01:40:46.998158100 +0100
@@ -909,6 +909,7 @@
{ "sRGB", sRGBColorspace, UndefinedOptionFlag, MagickFalse },
{ "Transparent", TransparentColorspace, UndefinedOptionFlag, MagickFalse },
{ "XYZ", XYZColorspace, UndefinedOptionFlag, MagickFalse },
+ { "xyY", xyYColorspace, UndefinedOptionFlag, MagickFalse },
{ "YCbCr", YCbCrColorspace, UndefinedOptionFlag, MagickFalse },
{ "YDbDr", YDbDrColorspace, UndefinedOptionFlag, MagickFalse },
{ "YCC", YCCColorspace, UndefinedOptionFlag, MagickFalse },