Skip to content

Commit

Permalink
increased accuracy for XYZ color conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Feb 1, 2025
1 parent 0d4d4e9 commit 3359ec0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions magick/gem-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ static inline void ConvertRGBToXYZ(const Quantum red,const Quantum green,
r=QuantumScale*DecodePixelGamma((MagickRealType) red);
g=QuantumScale*DecodePixelGamma((MagickRealType) green);
b=QuantumScale*DecodePixelGamma((MagickRealType) blue);
*X=0.4124564*r+0.3575761*g+0.1804375*b;
*Y=0.2126729*r+0.7151522*g+0.0721750*b;
*Z=0.0193339*r+0.1191920*g+0.9503041*b;
*X=(0.41239079926595*r)+(0.35758433938387*g)+(0.18048078840183*b);
*Y=(0.21263900587151*r)+(0.71516867876775*g)+(0.072192315360733*b);
*Z=(0.019330818715591*r)+(0.11919477979462*g)+(0.95053215224966*b);
}

static inline void ConvertXYZToLab(const double X,const double Y,const double Z,
Expand Down Expand Up @@ -162,9 +162,9 @@ static inline void ConvertXYZToRGB(const double X,const double Y,const double Z,
assert(red != (Quantum *) NULL);
assert(green != (Quantum *) NULL);
assert(blue != (Quantum *) NULL);
r=3.2404542*X-1.5371385*Y-0.4985314*Z;
g=(-0.9692660)*X+1.8760108*Y+0.0415560*Z;
b=0.0556434*X-0.2040259*Y+1.0572252*Z;
r=(3.240969941904521*X)+(-1.537383177570093*Y)+(-0.498610760293*Z);
g=(-0.96924363628087*X)+(1.87596750150772*Y)+(0.041555057407175*Z);
b=(0.055630079696993*X)+(-0.20397695888897*Y)+(1.056971514242878*Z);
*red=ClampToQuantum((MagickRealType) EncodePixelGamma((MagickRealType)
QuantumRange*r));
*green=ClampToQuantum((MagickRealType) EncodePixelGamma((MagickRealType)
Expand Down

0 comments on commit 3359ec0

Please sign in to comment.