#undef index
-static inline double CompandsRGB(const double intensity)
+static inline double InversesRGBCompandor(const double pixel)
{
- if (intensity <= 0.0031308)
- return(intensity*12.92);
- return(1.055*pow(intensity,1.0/2.4)-0.055);
+ if (pixel <= (0.04045*QuantumRange))
+ return(pixel/12.92);
+ return(QuantumRange*pow((QuantumScale*pixel+0.055)/1.055,2.4));
}
-static inline double DecompandsRGB(const double intensity)
+static inline double sRGBCompandor(const double pixel)
{
- if (intensity <= 0.04045)
- return(intensity/12.92);
- return(pow((intensity+0.055)/1.055,2.4));
+ if (pixel <= (0.0031308*QuantumRange))
+ return(12.92*pixel);
+ return(QuantumRange*(1.055*pow(QuantumScale*pixel,1.0/2.4)-0.055));
}
static inline Quantum GetPixela(const Image *restrict image,
const Quantum *restrict pixel)
{
if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
- return(0);
+ return((Quantum) 0);
return(pixel[image->channel_map[BlackPixelChannel].offset]);
}
const PixelChannel channel,const Quantum *restrict pixel)
{
if (image->channel_map[channel].traits == UndefinedPixelTrait)
- return(0);
+ return((Quantum) 0);
return(pixel[image->channel_map[channel].offset]);
}
const Quantum *restrict pixel)
{
if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
- return(0);
+ return((Quantum) 0);
return(pixel[image->channel_map[IndexPixelChannel].offset]);
}
if (pixel_info->colorspace != sRGBColorspace)
return(0.298839*pixel_info->red+0.586811*pixel_info->green+
0.114350*pixel_info->blue);
- red=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->red);
- green=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->green);
- blue=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->blue);
+ red=InversesRGBCompandor(pixel_info->red);
+ green=InversesRGBCompandor(pixel_info->green);
+ blue=InversesRGBCompandor(pixel_info->blue);
return(0.298839*red+0.586811*green+0.114350*blue);
}
if (pixel_info->colorspace != sRGBColorspace)
return(0.21267*pixel_info->red+0.71516*pixel_info->green+
0.07217*pixel_info->blue);
- red=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->red);
- green=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->green);
- blue=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->blue);
+ red=InversesRGBCompandor(pixel_info->red);
+ green=InversesRGBCompandor(pixel_info->green);
+ blue=InversesRGBCompandor(pixel_info->blue);
return(0.21267*red+0.71516*green+0.07217*blue);
}
-static inline Quantum GetPixelIntensity(const Image *restrict image,
+static inline double GetPixelIntensity(const Image *restrict image,
const Quantum *restrict pixel)
{
double
red;
if (image->colorspace == GRAYColorspace)
- return(pixel[image->channel_map[GrayPixelChannel].offset]);
+ return((double) pixel[image->channel_map[GrayPixelChannel].offset]);
if (image->colorspace != sRGBColorspace)
- return(ClampToQuantum(
- 0.298839*pixel[image->channel_map[RedPixelChannel].offset]+
+ return(0.298839*pixel[image->channel_map[RedPixelChannel].offset]+
0.586811*pixel[image->channel_map[GreenPixelChannel].offset]+
- 0.114350*pixel[image->channel_map[BluePixelChannel].offset]));
- red=QuantumRange*DecompandsRGB(QuantumScale*
+ 0.114350*pixel[image->channel_map[BluePixelChannel].offset]);
+ red=InversesRGBCompandor((double)
pixel[image->channel_map[RedPixelChannel].offset]);
- green=QuantumRange*DecompandsRGB(QuantumScale*
+ green=InversesRGBCompandor((double)
pixel[image->channel_map[GreenPixelChannel].offset]);
- blue=QuantumRange*DecompandsRGB(QuantumScale*
+ blue=InversesRGBCompandor((double)
pixel[image->channel_map[BluePixelChannel].offset]);
- return(ClampToQuantum(0.298839*red+0.586811*green+0.114350*blue));
+ return(0.298839*red+0.586811*green+0.114350*blue);
}
static inline Quantum GetPixelL(const Image *restrict image,
return(pixel[image->channel_map[LPixelChannel].offset]);
}
-static inline Quantum GetPixelLuminance(const Image *restrict image,
+static inline double GetPixelLuminance(const Image *restrict image,
const Quantum *restrict pixel)
{
double
red;
if (image->colorspace == GRAYColorspace)
- return(pixel[image->channel_map[GrayPixelChannel].offset]);
+ return((double) pixel[image->channel_map[GrayPixelChannel].offset]);
if (image->colorspace != sRGBColorspace)
- return(ClampToQuantum(
- 0.298839*pixel[image->channel_map[RedPixelChannel].offset]+
+ return(0.298839*pixel[image->channel_map[RedPixelChannel].offset]+
0.586811*pixel[image->channel_map[GreenPixelChannel].offset]+
- 0.114350*pixel[image->channel_map[BluePixelChannel].offset]));
- red=QuantumRange*DecompandsRGB(QuantumScale*
+ 0.114350*pixel[image->channel_map[BluePixelChannel].offset]);
+ red=InversesRGBCompandor((double)
pixel[image->channel_map[RedPixelChannel].offset]);
- green=QuantumRange*DecompandsRGB(QuantumScale*
+ green=InversesRGBCompandor((double)
pixel[image->channel_map[GreenPixelChannel].offset]);
- blue=QuantumRange*DecompandsRGB(QuantumScale*
+ blue=InversesRGBCompandor((double)
pixel[image->channel_map[BluePixelChannel].offset]);
- return(ClampToQuantum(0.21267*red+0.71516*green+0.07217*blue));
+ return(0.21267*red+0.71516*green+0.07217*blue);
}
static inline Quantum GetPixelMagenta(const Image *restrict image,
const Quantum *restrict pixel)
{
if (image->channel_map[MaskPixelChannel].traits == UndefinedPixelTrait)
- return(0);
+ return((Quantum) 0);
return(pixel[image->channel_map[MaskPixelChannel].offset]);
}