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

Go to the source code of this file.

Data Structures

struct  _DoublePixelPacket
struct  _NodeInfo
struct  _Nodes
struct  _CubeInfo


#define CacheShift   2
#define ErrorQueueLength   16
#define MaxNodes   266817
#define MaxTreeDepth   8
#define NodesInAList   1920
#define AssignImageTag   "Assign/Image"
#define ClassifyImageTag   "Classify/Image"
#define RedShift(pixel)   (((pixel) >> CacheShift) << (0*(8-CacheShift)))
#define GreenShift(pixel)   (((pixel) >> CacheShift) << (1*(8-CacheShift)))
#define BlueShift(pixel)   (((pixel) >> CacheShift) << (2*(8-CacheShift)))
#define AlphaShift(pixel)   (((pixel) >> CacheShift) << (3*(8-CacheShift)))
#define DitherImageTag   "Dither/Image"
#define DitherImageTag   "Dither/Image"
#define PosterizeImageTag   "Posterize/Image"
#define PosterizePixel(pixel)
#define ReduceImageTag   "Reduce/Image"


typedef struct _DoublePixelPacket DoublePixelPacket
typedef struct _NodeInfo NodeInfo
typedef struct _Nodes Nodes
typedef struct _CubeInfo CubeInfo


static CubeInfoGetCubeInfo (const QuantizeInfo *, const size_t, const size_t)
static NodeInfoGetNodeInfo (CubeInfo *, const size_t, const size_t, NodeInfo *)
static MagickBooleanType AssignImageColors (Image *, CubeInfo *, ExceptionInfo *)
static MagickBooleanType ClassifyImageColors (CubeInfo *, const Image *, ExceptionInfo *)
static MagickBooleanType DitherImage (Image *, CubeInfo *, ExceptionInfo *)
static MagickBooleanType SetGrayscaleImage (Image *, ExceptionInfo *)
static size_t DefineImageColormap (Image *, CubeInfo *, NodeInfo *)
static void ClosestColor (const Image *, CubeInfo *, const NodeInfo *)
static void DestroyCubeInfo (CubeInfo *)
static void PruneLevel (CubeInfo *, const NodeInfo *)
static void PruneToCubeDepth (CubeInfo *, const NodeInfo *)
static void ReduceImageColors (const Image *, CubeInfo *)
MagickExport QuantizeInfoAcquireQuantizeInfo (const ImageInfo *image_info)
static void AssociateAlphaPixel (const Image *image, const CubeInfo *cube_info, const Quantum *pixel, DoublePixelPacket *alpha_pixel)
static void AssociateAlphaPixelInfo (const CubeInfo *cube_info, const PixelInfo *pixel, DoublePixelPacket *alpha_pixel)
static size_t ColorToNodeId (const CubeInfo *cube_info, const DoublePixelPacket *pixel, size_t index)
static void SetAssociatedAlpha (const Image *image, CubeInfo *cube_info)
MagickExport QuantizeInfoCloneQuantizeInfo (const QuantizeInfo *quantize_info)
MagickExport MagickBooleanType CompressImageColormap (Image *image, ExceptionInfo *exception)
MagickExport QuantizeInfoDestroyQuantizeInfo (QuantizeInfo *quantize_info)
static DoublePixelPacket ** DestroyPixelThreadSet (DoublePixelPacket **pixels)
static DoublePixelPacket ** AcquirePixelThreadSet (const size_t count)
static ssize_t CacheOffset (CubeInfo *cube_info, const DoublePixelPacket *pixel)
static MagickBooleanType FloydSteinbergDither (Image *image, CubeInfo *cube_info, ExceptionInfo *exception)
static MagickBooleanType RiemersmaDither (Image *, CacheView *, CubeInfo *, const unsigned int, ExceptionInfo *)
static void Riemersma (Image *image, CacheView *image_view, CubeInfo *cube_info, const size_t level, const unsigned int direction, ExceptionInfo *exception)
MagickExport MagickBooleanType GetImageQuantizeError (Image *image, ExceptionInfo *exception)
MagickExport void GetQuantizeInfo (QuantizeInfo *quantize_info)
static double MagickRound (double x)
MagickExport MagickBooleanType PosterizeImage (Image *image, const size_t levels, const DitherMethod dither_method, ExceptionInfo *exception)
static void PruneChild (CubeInfo *cube_info, const NodeInfo *node_info)
MagickExport MagickBooleanType QuantizeImage (const QuantizeInfo *quantize_info, Image *image, ExceptionInfo *exception)
MagickExport MagickBooleanType QuantizeImages (const QuantizeInfo *quantize_info, Image *images, ExceptionInfo *exception)
static size_t QuantizeErrorFlatten (const CubeInfo *cube_info, const NodeInfo *node_info, const ssize_t offset, double *quantize_error)
static void Reduce (CubeInfo *cube_info, const NodeInfo *node_info)
static int QuantizeErrorCompare (const void *error_p, const void *error_q)
MagickExport MagickBooleanType RemapImage (const QuantizeInfo *quantize_info, Image *image, const Image *remap_image, ExceptionInfo *exception)
MagickExport MagickBooleanType RemapImages (const QuantizeInfo *quantize_info, Image *images, const Image *remap_image, ExceptionInfo *exception)
static int IntensityCompare (const void *x, const void *y)

Macro Definition Documentation

◆ AlphaShift

#define AlphaShift (   pixel)    (((pixel) >> CacheShift) << (3*(8-CacheShift)))

Referenced by CacheOffset().

◆ AssignImageTag

#define AssignImageTag   "Assign/Image"

◆ BlueShift

#define BlueShift (   pixel)    (((pixel) >> CacheShift) << (2*(8-CacheShift)))

Referenced by CacheOffset().

◆ CacheShift

#define CacheShift   2

Definition at line 208 of file quantize.c.

Referenced by GetCubeInfo().

◆ ClassifyImageTag

#define ClassifyImageTag   "Classify/Image"

Referenced by ClassifyImageColors().

◆ DitherImageTag [1/2]

#define DitherImageTag   "Dither/Image"

◆ DitherImageTag [2/2]

#define DitherImageTag   "Dither/Image"

◆ ErrorQueueLength

#define ErrorQueueLength   16

Definition at line 212 of file quantize.c.

Referenced by DitherImage(), GetCubeInfo(), and RiemersmaDither().

◆ GreenShift

#define GreenShift (   pixel)    (((pixel) >> CacheShift) << (1*(8-CacheShift)))

Referenced by CacheOffset().

◆ MaxNodes

#define MaxNodes   266817

Definition at line 213 of file quantize.c.

Referenced by ClassifyImageColors().

◆ MaxTreeDepth

◆ NodesInAList

#define NodesInAList   1920

Definition at line 215 of file quantize.c.

Referenced by GetNodeInfo().

◆ PosterizeImageTag

#define PosterizeImageTag   "Posterize/Image"

Referenced by PosterizeImage().

◆ PosterizePixel

#define PosterizePixel (   pixel)
QuantumScale*pixel*(levels-1)))/MagickMax((ssize_t) levels-1,1))
static double MagickRound(double x)
Definition: quantize.c:2332
#define QuantumScale
Definition: magick-type.h:113
#define MagickMax(x, y)
Definition: image-private.h:26
unsigned short Quantum
Definition: magick-type.h:82
#define QuantumRange
Definition: magick-type.h:83

Referenced by PosterizeImage().

◆ RedShift

#define RedShift (   pixel)    (((pixel) >> CacheShift) << (0*(8-CacheShift)))

Referenced by CacheOffset().

◆ ReduceImageTag

#define ReduceImageTag   "Reduce/Image"

Referenced by ReduceImageColors().

Typedef Documentation

◆ CubeInfo

typedef struct _CubeInfo CubeInfo

◆ DoublePixelPacket

◆ NodeInfo

typedef struct _NodeInfo NodeInfo

◆ Nodes

typedef struct _Nodes Nodes

Function Documentation

◆ AcquirePixelThreadSet()

static DoublePixelPacket** AcquirePixelThreadSet ( const size_t  count)

◆ AcquireQuantizeInfo()

◆ AssignImageColors()

static MagickBooleanType AssignImageColors ( Image image,
CubeInfo cube_info,
ExceptionInfo exception 

◆ AssociateAlphaPixel()

◆ AssociateAlphaPixelInfo()

◆ CacheOffset()

◆ ClassifyImageColors()

◆ CloneQuantizeInfo()

◆ ClosestColor()

◆ ColorToNodeId()

static size_t ColorToNodeId ( const CubeInfo cube_info,
const DoublePixelPacket pixel,
size_t  index 

◆ CompressImageColormap()

◆ DefineImageColormap()

◆ DestroyCubeInfo()

◆ DestroyPixelThreadSet()

static DoublePixelPacket** DestroyPixelThreadSet ( DoublePixelPacket **  pixels)

◆ DestroyQuantizeInfo()

◆ DitherImage()

◆ FloydSteinbergDither()

◆ GetCubeInfo()

◆ GetImageQuantizeError()

◆ GetNodeInfo()

static NodeInfo * GetNodeInfo ( CubeInfo cube_info,
const size_t  id,
const size_t  level,
NodeInfo parent 

◆ GetQuantizeInfo()

◆ IntensityCompare()

static int IntensityCompare ( const void *  x,
const void *  y 

Definition at line 3278 of file quantize.c.

References GetPixelInfoIntensity().

Referenced by SetGrayscaleImage().

◆ MagickRound()

static double MagickRound ( double  x)

Definition at line 2332 of file quantize.c.

◆ PosterizeImage()

◆ PruneChild()

◆ PruneLevel()

static void PruneLevel ( CubeInfo cube_info,
const NodeInfo node_info 

◆ PruneToCubeDepth()

static void PruneToCubeDepth ( CubeInfo cube_info,
const NodeInfo node_info 

◆ QuantizeErrorCompare()

static int QuantizeErrorCompare ( const void *  error_p,
const void *  error_q 

Definition at line 3031 of file quantize.c.

References MagickEpsilon.

Referenced by ReduceImageColors().

◆ QuantizeErrorFlatten()

static size_t QuantizeErrorFlatten ( const CubeInfo cube_info,
const NodeInfo node_info,
const ssize_t  offset,
double *  quantize_error 

◆ QuantizeImage()

◆ QuantizeImages()

◆ Reduce()

◆ ReduceImageColors()

◆ RemapImage()

◆ RemapImages()

◆ Riemersma()

static void Riemersma ( Image image,
CacheView image_view,
CubeInfo cube_info,
const size_t  level,
const unsigned int  direction,
ExceptionInfo exception 

Definition at line 1677 of file quantize.c.

References EastGravity, NorthGravity, RiemersmaDither(), SouthGravity, and WestGravity.

Referenced by DitherImage().

◆ RiemersmaDither()

◆ SetAssociatedAlpha()

static void SetAssociatedAlpha ( const Image image,
CubeInfo cube_info 

◆ SetGrayscaleImage()