MagickCore 7.1.0
Convert, Edit, Or Compose Bitmap Images
enhance.c File Reference
Include dependency graph for enhance.c:

Go to the source code of this file.

Data Structures

struct  _RangeInfo
 

Macros

#define BrightnessContastImageTag   "BrightnessContast/Image"
 
#define NumberCLAHEGrays   (65536)
 
#define CLAHEImageTag   "CLAHE/Image"
 
#define ClutImageTag   "Clut/Image"
 
#define ColorDecisionListCorrectImageTag   "ColorDecisionList/Image"
 
#define ContrastImageTag   "Contrast/Image"
 
#define MaxRange(color)   ((double) ScaleQuantumToMap((Quantum) (color)))
 
#define ContrastStretchImageTag   "ContrastStretch/Image"
 
#define EnhanceImageTag   "Enhance/Image"
 
#define EnhancePixel(weight)
 
#define EqualizeImageTag   "Equalize/Image"
 
#define GammaImageTag   "Gamma/Image"
 
#define GrayscaleImageTag   "Grayscale/Image"
 
#define HaldClutImageTag   "Clut/Image"
 
#define LevelImageTag   "Level/Image"
 
#define LevelizeImageTag   "Levelize/Image"
 
#define LevelizeValue(x)
 
#define LinearStretchImageTag   "LinearStretch/Image"
 
#define ModulateImageTag   "Modulate/Image"
 
#define NegateImageTag   "Negate/Image"
 
#define Sigmoidal(a, b, x)   ( 1.0/(1.0+exp((a)*((b)-(x)))) )
 
#define ScaledSigmoidal(a, b, x)
 
#define SigmoidalContrastImageTag   "SigmoidalContrast/Image"
 
#define ScaledSig(x)
 
#define InverseScaledSig(x)
 
#define WhiteBalanceImageTag   "WhiteBalance/Image"
 

Typedefs

typedef struct _RangeInfo RangeInfo
 

Functions

MagickExport MagickBooleanType AutoGammaImage (Image *image, ExceptionInfo *exception)
 
MagickExport MagickBooleanType AutoLevelImage (Image *image, ExceptionInfo *exception)
 
MagickExport MagickBooleanType BrightnessContrastImage (Image *image, const double brightness, const double contrast, ExceptionInfo *exception)
 
static void ClipCLAHEHistogram (const double clip_limit, const size_t number_bins, size_t *histogram)
 
static void GenerateCLAHEHistogram (const RectangleInfo *clahe_info, const RectangleInfo *tile_info, const size_t number_bins, const unsigned short *lut, const unsigned short *pixels, size_t *histogram)
 
static void InterpolateCLAHE (const RectangleInfo *clahe_info, const size_t *Q12, const size_t *Q22, const size_t *Q11, const size_t *Q21, const RectangleInfo *tile, const unsigned short *lut, unsigned short *pixels)
 
static void GenerateCLAHELut (const RangeInfo *range_info, const size_t number_bins, unsigned short *lut)
 
static void MapCLAHEHistogram (const RangeInfo *range_info, const size_t number_bins, const size_t number_pixels, size_t *histogram)
 
static MagickBooleanType CLAHE (const RectangleInfo *clahe_info, const RectangleInfo *tile_info, const RangeInfo *range_info, const size_t number_bins, const double clip_limit, unsigned short *pixels)
 
MagickExport MagickBooleanType CLAHEImage (Image *image, const size_t width, const size_t height, const size_t number_bins, const double clip_limit, ExceptionInfo *exception)
 
MagickExport MagickBooleanType ClutImage (Image *image, const Image *clut_image, const PixelInterpolateMethod method, ExceptionInfo *exception)
 
MagickExport MagickBooleanType ColorDecisionListImage (Image *image, const char *color_correction_collection, ExceptionInfo *exception)
 
static void Contrast (const int sign, double *red, double *green, double *blue)
 
MagickExport MagickBooleanType ContrastImage (Image *image, const MagickBooleanType sharpen, ExceptionInfo *exception)
 
MagickExport MagickBooleanType ContrastStretchImage (Image *image, const double black_point, const double white_point, ExceptionInfo *exception)
 
MagickExport ImageEnhanceImage (const Image *image, ExceptionInfo *exception)
 
MagickExport MagickBooleanType EqualizeImage (Image *image, ExceptionInfo *exception)
 
static double gamma_pow (const double value, const double gamma)
 
MagickExport MagickBooleanType GammaImage (Image *image, const double gamma, ExceptionInfo *exception)
 
MagickExport MagickBooleanType GrayscaleImage (Image *image, const PixelIntensityMethod method, ExceptionInfo *exception)
 
MagickExport MagickBooleanType HaldClutImage (Image *image, const Image *hald_image, ExceptionInfo *exception)
 
static double LevelPixel (const double black_point, const double white_point, const double gamma, const double pixel)
 
MagickExport MagickBooleanType LevelImage (Image *image, const double black_point, const double white_point, const double gamma, ExceptionInfo *exception)
 
MagickExport MagickBooleanType LevelizeImage (Image *image, const double black_point, const double white_point, const double gamma, ExceptionInfo *exception)
 
MagickExport MagickBooleanType LevelImageColors (Image *image, const PixelInfo *black_color, const PixelInfo *white_color, const MagickBooleanType invert, ExceptionInfo *exception)
 
MagickExport MagickBooleanType LinearStretchImage (Image *image, const double black_point, const double white_point, ExceptionInfo *exception)
 
static void ModulateHCL (const double percent_hue, const double percent_chroma, const double percent_luma, double *red, double *green, double *blue)
 
static void ModulateHCLp (const double percent_hue, const double percent_chroma, const double percent_luma, double *red, double *green, double *blue)
 
static void ModulateHSB (const double percent_hue, const double percent_saturation, const double percent_brightness, double *red, double *green, double *blue)
 
static void ModulateHSI (const double percent_hue, const double percent_saturation, const double percent_intensity, double *red, double *green, double *blue)
 
static void ModulateHSL (const double percent_hue, const double percent_saturation, const double percent_lightness, double *red, double *green, double *blue)
 
static void ModulateHSV (const double percent_hue, const double percent_saturation, const double percent_value, double *red, double *green, double *blue)
 
static void ModulateHWB (const double percent_hue, const double percent_whiteness, const double percent_blackness, double *red, double *green, double *blue)
 
static void ModulateLCHab (const double percent_luma, const double percent_chroma, const double percent_hue, const IlluminantType illuminant, double *red, double *green, double *blue)
 
static void ModulateLCHuv (const double percent_luma, const double percent_chroma, const double percent_hue, const IlluminantType illuminant, double *red, double *green, double *blue)
 
MagickExport MagickBooleanType ModulateImage (Image *image, const char *modulate, ExceptionInfo *exception)
 
MagickExport MagickBooleanType NegateImage (Image *image, const MagickBooleanType grayscale, ExceptionInfo *exception)
 
MagickExport MagickBooleanType NormalizeImage (Image *image, ExceptionInfo *exception)
 
static double InverseScaledSigmoidal (const double a, const double b, const double x)
 
MagickExport MagickBooleanType SigmoidalContrastImage (Image *image, const MagickBooleanType sharpen, const double contrast, const double midpoint, ExceptionInfo *exception)
 
MagickExport MagickBooleanType WhiteBalanceImage (Image *image, ExceptionInfo *exception)
 

Macro Definition Documentation

◆ BrightnessContastImageTag

#define BrightnessContastImageTag   "BrightnessContast/Image"

◆ CLAHEImageTag

#define CLAHEImageTag   "CLAHE/Image"

◆ ClutImageTag

#define ClutImageTag   "Clut/Image"

◆ ColorDecisionListCorrectImageTag

#define ColorDecisionListCorrectImageTag   "ColorDecisionList/Image"

◆ ContrastImageTag

#define ContrastImageTag   "Contrast/Image"

◆ ContrastStretchImageTag

#define ContrastStretchImageTag   "ContrastStretch/Image"

◆ EnhanceImageTag

#define EnhanceImageTag   "Enhance/Image"

◆ EnhancePixel

#define EnhancePixel (   weight)
Value:
mean=QuantumScale*((double) GetPixelRed(image,r)+pixel.red)/2.0; \
distance=QuantumScale*((double) GetPixelRed(image,r)-pixel.red); \
distance_squared=(4.0+mean)*distance*distance; \
mean=QuantumScale*((double) GetPixelGreen(image,r)+pixel.green)/2.0; \
distance=QuantumScale*((double) GetPixelGreen(image,r)-pixel.green); \
distance_squared+=(7.0-mean)*distance*distance; \
mean=QuantumScale*((double) GetPixelBlue(image,r)+pixel.blue)/2.0; \
distance=QuantumScale*((double) GetPixelBlue(image,r)-pixel.blue); \
distance_squared+=(5.0-mean)*distance*distance; \
mean=QuantumScale*((double) GetPixelBlack(image,r)+pixel.black)/2.0; \
distance=QuantumScale*((double) GetPixelBlack(image,r)-pixel.black); \
distance_squared+=(5.0-mean)*distance*distance; \
mean=QuantumScale*((double) GetPixelAlpha(image,r)+pixel.alpha)/2.0; \
distance=QuantumScale*((double) GetPixelAlpha(image,r)-pixel.alpha); \
distance_squared+=(5.0-mean)*distance*distance; \
if (distance_squared < 0.069) \
{ \
aggregate.red+=(weight)*GetPixelRed(image,r); \
aggregate.green+=(weight)*GetPixelGreen(image,r); \
aggregate.blue+=(weight)*GetPixelBlue(image,r); \
aggregate.black+=(weight)*GetPixelBlack(image,r); \
aggregate.alpha+=(weight)*GetPixelAlpha(image,r); \
total_weight+=(weight); \
} \
r+=GetPixelChannels(image);
#define QuantumScale
Definition: magick-type.h:119
static Quantum GetPixelAlpha(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixelGreen(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static size_t GetPixelChannels(const Image *magick_restrict image)
static Quantum GetPixelRed(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixelBlue(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixelBlack(const Image *magick_restrict image, const Quantum *magick_restrict pixel)

◆ EqualizeImageTag

#define EqualizeImageTag   "Equalize/Image"

◆ GammaImageTag

#define GammaImageTag   "Gamma/Image"

◆ GrayscaleImageTag

#define GrayscaleImageTag   "Grayscale/Image"

◆ HaldClutImageTag

#define HaldClutImageTag   "Clut/Image"

◆ InverseScaledSig

#define InverseScaledSig (   x)
Value:
static double InverseScaledSigmoidal(const double a, const double b, const double x)
Definition: enhance.c:4222
#define QuantumRange
Definition: magick-type.h:87
static Quantum ClampToQuantum(const MagickRealType quantum)
Definition: quantum.h:86

◆ LevelImageTag

#define LevelImageTag   "Level/Image"

◆ LevelizeImageTag

#define LevelizeImageTag   "Levelize/Image"

◆ LevelizeValue

#define LevelizeValue (   x)
Value:
(QuantumScale*(x)),gamma))*(white_point-black_point)+black_point)
static double gamma_pow(const double value, const double gamma)
Definition: enhance.c:2310
MagickDoubleType MagickRealType
Definition: magick-type.h:124

◆ LinearStretchImageTag

#define LinearStretchImageTag   "LinearStretch/Image"

◆ MaxRange

#define MaxRange (   color)    ((double) ScaleQuantumToMap((Quantum) (color)))

◆ ModulateImageTag

#define ModulateImageTag   "Modulate/Image"

◆ NegateImageTag

#define NegateImageTag   "Negate/Image"

◆ NumberCLAHEGrays

#define NumberCLAHEGrays   (65536)

◆ ScaledSig

#define ScaledSig (   x)
Value:
ScaledSigmoidal(contrast,QuantumScale*midpoint,QuantumScale*(x))) )
#define ScaledSigmoidal(a, b, x)
Definition: enhance.c:4210

◆ ScaledSigmoidal

#define ScaledSigmoidal (   a,
  b,
 
)
Value:
( \
(Sigmoidal((a),(b),(x))-Sigmoidal((a),(b),0.0)) / \
(Sigmoidal((a),(b),1.0)-Sigmoidal((a),(b),0.0)) )
#define Sigmoidal(a, b, x)
Definition: enhance.c:4191

Definition at line 4210 of file enhance.c.

◆ Sigmoidal

#define Sigmoidal (   a,
  b,
 
)    ( 1.0/(1.0+exp((a)*((b)-(x)))) )

Definition at line 4191 of file enhance.c.

◆ SigmoidalContrastImageTag

#define SigmoidalContrastImageTag   "SigmoidalContrast/Image"

◆ WhiteBalanceImageTag

#define WhiteBalanceImageTag   "WhiteBalance/Image"

Typedef Documentation

◆ RangeInfo

typedef struct _RangeInfo RangeInfo

Function Documentation

◆ AutoGammaImage()

◆ AutoLevelImage()

MagickExport MagickBooleanType AutoLevelImage ( Image image,
ExceptionInfo exception 
)

Definition at line 185 of file enhance.c.

References MinMaxStretchImage().

Referenced by AdaptiveBlurImage(), and AdaptiveSharpenImage().

◆ BrightnessContrastImage()

MagickExport MagickBooleanType BrightnessContrastImage ( Image image,
const double  brightness,
const double  contrast,
ExceptionInfo exception 
)

◆ CLAHE()

◆ CLAHEImage()

◆ ClipCLAHEHistogram()

static void ClipCLAHEHistogram ( const double  clip_limit,
const size_t  number_bins,
size_t *  histogram 
)
static

Definition at line 302 of file enhance.c.

Referenced by CLAHE().

◆ ClutImage()

◆ ColorDecisionListImage()

◆ Contrast()

static void Contrast ( const int  sign,
double *  red,
double *  green,
double *  blue 
)
static

Definition at line 1372 of file enhance.c.

References ConvertHSBToRGB(), ConvertRGBToHSB(), and MagickPI.

Referenced by ContrastImage().

◆ ContrastImage()

◆ ContrastStretchImage()

◆ EnhanceImage()

◆ EqualizeImage()

◆ gamma_pow()

static double gamma_pow ( const double  value,
const double  gamma 
)
inlinestatic

Definition at line 2310 of file enhance.c.

Referenced by LevelPixel().

◆ GammaImage()

◆ GenerateCLAHEHistogram()

static void GenerateCLAHEHistogram ( const RectangleInfo clahe_info,
const RectangleInfo tile_info,
const size_t  number_bins,
const unsigned short *  lut,
const unsigned short *  pixels,
size_t *  histogram 
)
static

Definition at line 379 of file enhance.c.

References _RectangleInfo::height, and _RectangleInfo::width.

Referenced by CLAHE().

◆ GenerateCLAHELut()

static void GenerateCLAHELut ( const RangeInfo range_info,
const size_t  number_bins,
unsigned short *  lut 
)
static

Definition at line 438 of file enhance.c.

References _RangeInfo::max, and _RangeInfo::min.

Referenced by CLAHE().

◆ GrayscaleImage()

◆ HaldClutImage()

◆ InterpolateCLAHE()

static void InterpolateCLAHE ( const RectangleInfo clahe_info,
const size_t *  Q12,
const size_t *  Q22,
const size_t *  Q11,
const size_t *  Q21,
const RectangleInfo tile,
const unsigned short *  lut,
unsigned short *  pixels 
)
static

Definition at line 408 of file enhance.c.

References _RectangleInfo::height, PerceptibleReciprocal(), and _RectangleInfo::width.

Referenced by CLAHE().

◆ InverseScaledSigmoidal()

static double InverseScaledSigmoidal ( const double  a,
const double  b,
const double  x 
)
inlinestatic

Definition at line 4222 of file enhance.c.

References MagickEpsilon, and Sigmoidal.

◆ LevelImage()

◆ LevelImageColors()

◆ LevelizeImage()

◆ LevelPixel()

static double LevelPixel ( const double  black_point,
const double  white_point,
const double  gamma,
const double  pixel 
)
inlinestatic

Definition at line 2896 of file enhance.c.

References gamma_pow(), PerceptibleReciprocal(), and QuantumRange.

Referenced by LevelImage().

◆ LinearStretchImage()

◆ MapCLAHEHistogram()

static void MapCLAHEHistogram ( const RangeInfo range_info,
const size_t  number_bins,
const size_t  number_pixels,
size_t *  histogram 
)
static

Definition at line 455 of file enhance.c.

References _RangeInfo::max, and _RangeInfo::min.

Referenced by CLAHE().

◆ ModulateHCL()

static void ModulateHCL ( const double  percent_hue,
const double  percent_chroma,
const double  percent_luma,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3454 of file enhance.c.

References ConvertHCLToRGB(), and ConvertRGBToHCL().

Referenced by ModulateImage().

◆ ModulateHCLp()

static void ModulateHCLp ( const double  percent_hue,
const double  percent_chroma,
const double  percent_luma,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3473 of file enhance.c.

References ConvertHCLpToRGB(), and ConvertRGBToHCLp().

Referenced by ModulateImage().

◆ ModulateHSB()

static void ModulateHSB ( const double  percent_hue,
const double  percent_saturation,
const double  percent_brightness,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3492 of file enhance.c.

References ConvertHSBToRGB(), and ConvertRGBToHSB().

Referenced by ModulateImage().

◆ ModulateHSI()

static void ModulateHSI ( const double  percent_hue,
const double  percent_saturation,
const double  percent_intensity,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3511 of file enhance.c.

References ConvertHSIToRGB(), and ConvertRGBToHSI().

Referenced by ModulateImage().

◆ ModulateHSL()

static void ModulateHSL ( const double  percent_hue,
const double  percent_saturation,
const double  percent_lightness,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3530 of file enhance.c.

References ConvertHSLToRGB(), and ConvertRGBToHSL().

Referenced by ModulateImage().

◆ ModulateHSV()

static void ModulateHSV ( const double  percent_hue,
const double  percent_saturation,
const double  percent_value,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3549 of file enhance.c.

References ConvertHSVToRGB(), and ConvertRGBToHSV().

Referenced by ModulateImage().

◆ ModulateHWB()

static void ModulateHWB ( const double  percent_hue,
const double  percent_whiteness,
const double  percent_blackness,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3568 of file enhance.c.

References ConvertHWBToRGB(), and ConvertRGBToHWB().

Referenced by ModulateImage().

◆ ModulateImage()

◆ ModulateLCHab()

static void ModulateLCHab ( const double  percent_luma,
const double  percent_chroma,
const double  percent_hue,
const IlluminantType  illuminant,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3587 of file enhance.c.

References ConvertLCHabToRGB(), and ConvertRGBToLCHab().

Referenced by ModulateImage().

◆ ModulateLCHuv()

static void ModulateLCHuv ( const double  percent_luma,
const double  percent_chroma,
const double  percent_hue,
const IlluminantType  illuminant,
double *  red,
double *  green,
double *  blue 
)
inlinestatic

Definition at line 3606 of file enhance.c.

References ConvertLCHuvToRGB(), and ConvertRGBToLCHuv().

Referenced by ModulateImage().

◆ NegateImage()

◆ NormalizeImage()

MagickExport MagickBooleanType NormalizeImage ( Image image,
ExceptionInfo exception 
)

◆ SigmoidalContrastImage()

◆ WhiteBalanceImage()