Magick++  6.9.3
Image.h
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 // Copyright Dirk Lemstra 2013-2015
5 //
6 // Definition of Image, the representation of a single image in Magick++
7 //
8 
9 #if !defined(Magick_Image_header)
10 #define Magick_Image_header
11 
12 #include "Magick++/Include.h"
13 #include <string>
14 #include <list>
15 #include "Magick++/Blob.h"
17 #include "Magick++/Color.h"
18 #include "Magick++/Drawable.h"
19 #include "Magick++/Exception.h"
20 #include "Magick++/Geometry.h"
21 #include "Magick++/TypeMetric.h"
22 
23 namespace Magick
24 {
25  // Forward declarations
26  class Options;
27  class ImageRef;
28 
29  extern MagickPPExport const char *borderGeometryDefault;
30  extern MagickPPExport const char *frameGeometryDefault;
31  extern MagickPPExport const char *raiseGeometryDefault;
32 
33  // Compare two Image objects regardless of LHS/RHS
34  // Image sizes and signatures are used as basis of comparison
35  MagickPPExport int operator ==
36  (const Magick::Image &left_,const Magick::Image &right_);
37  MagickPPExport int operator !=
38  (const Magick::Image &left_,const Magick::Image &right_);
39  MagickPPExport int operator >
40  (const Magick::Image &left_,const Magick::Image &right_);
41  MagickPPExport int operator <
42  (const Magick::Image &left_,const Magick::Image &right_);
43  MagickPPExport int operator >=
44  (const Magick::Image &left_,const Magick::Image &right_);
45  MagickPPExport int operator <=
46  (const Magick::Image &left_,const Magick::Image &right_);
47 
48  //
49  // Image is the representation of an image. In reality, it actually
50  // a handle object which contains a pointer to a shared reference
51  // object (ImageRef). As such, this object is extremely space efficient.
52  //
54  {
55  public:
56 
57  // Obtain image statistics. Statistics are normalized to the range
58  // of 0.0 to 1.0 and are output to the specified ImageStatistics
59  // structure.
60  typedef struct _ImageChannelStatistics
61  {
62  /* Minimum value observed */
63  double maximum;
64  /* Maximum value observed */
65  double minimum;
66  /* Average (mean) value observed */
67  double mean;
68  /* Standard deviation, sqrt(variance) */
70  /* Variance */
71  double variance;
72  /* Kurtosis */
73  double kurtosis;
74  /* Skewness */
75  double skewness;
77 
78  typedef struct _ImageStatistics
79  {
85 
86  // Default constructor
87  Image(void);
88 
89  // Construct Image from in-memory BLOB
90  Image(const Blob &blob_);
91 
92  // Construct Image of specified size from in-memory BLOB
93  Image(const Blob &blob_,const Geometry &size_);
94 
95  // Construct Image of specified size and depth from in-memory BLOB
96  Image(const Blob &blob_,const Geometry &size_,const size_t depth_);
97 
98  // Construct Image of specified size, depth, and format from
99  // in-memory BLOB
100  Image(const Blob &blob_,const Geometry &size_,const size_t depth_,
101  const std::string &magick_);
102 
103  // Construct Image of specified size, and format from in-memory BLOB
104  Image(const Blob &blob_,const Geometry &size_,const std::string &magick_);
105 
106  // Construct a blank image canvas of specified size and color
107  Image(const Geometry &size_,const Color &color_);
108 
109  // Copy constructor
110  Image(const Image &image_);
111 
112  // Copy constructor to copy part of the image
113  Image(const Image &image_,const Geometry &geometry_);
114 
115  // Construct an image based on an array of raw pixels, of
116  // specified type and mapping, in memory
117  Image(const size_t width_,const size_t height_,const std::string &map_,
118  const StorageType type_,const void *pixels_);
119 
120  // Construct from image file or image specification
121  Image(const std::string &imageSpec_);
122 
123  // Destructor
124  virtual ~Image();
125 
126  // Assignment operator
127  Image& operator=(const Image &image_);
128 
129  // Join images into a single multi-image file
130  void adjoin(const bool flag_);
131  bool adjoin(void) const;
132 
133  // Anti-alias Postscript and TrueType fonts (default true)
134  void antiAlias(const bool flag_);
135  bool antiAlias(void) const;
136 
137  // Time in 1/100ths of a second which must expire before
138  // displaying the next image in an animated sequence.
139  void animationDelay(const size_t delay_);
140  size_t animationDelay(void) const;
141 
142  // Number of iterations to loop an animation (e.g. Netscape loop
143  // extension) for.
144  void animationIterations(const size_t iterations_);
145  size_t animationIterations(void) const;
146 
147  // Lessen (or intensify) when adding noise to an image.
148  void attenuate(const double attenuate_);
149 
150  // Image background color
151  void backgroundColor(const Color &color_);
152  Color backgroundColor(void) const;
153 
154  // Name of texture image to tile onto the image background
155  void backgroundTexture(const std::string &backgroundTexture_);
156  std::string backgroundTexture(void) const;
157 
158  // Base image width (before transformations)
159  size_t baseColumns(void) const;
160 
161  // Base image filename (before transformations)
162  std::string baseFilename(void) const;
163 
164  // Base image height (before transformations)
165  size_t baseRows(void) const;
166 
167  // Use black point compensation.
168  void blackPointCompensation(const bool flag_);
169  bool blackPointCompensation(void) const;
170 
171  // Image border color
172  void borderColor(const Color &color_);
173  Color borderColor(void) const;
174 
175  // Return smallest bounding box enclosing non-border pixels. The
176  // current fuzz value is used when discriminating between pixels.
177  // This is the crop bounding box used by crop(Geometry(0,0));
178  Geometry boundingBox(void) const;
179 
180  // Text bounding-box base color (default none)
181  void boxColor(const Color &boxColor_);
182  Color boxColor(void) const;
183 
184  // This method is now deprecated. Please use ResourceLimits instead.
185  static void cacheThreshold(const size_t threshold_);
186 
187  // Image class (DirectClass or PseudoClass)
188  // NOTE: setting a DirectClass image to PseudoClass will result in
189  // the loss of color information if the number of colors in the
190  // image is greater than the maximum palette size (either 256 or
191  // 65536 entries depending on the value of MAGICKCORE_QUANTUM_DEPTH when
192  // ImageMagick was built).
193  void classType(const ClassType class_);
194  ClassType classType(void) const;
195 
196  // Associate a clip mask with the image. The clip mask must be the
197  // same dimensions as the image. Pass an invalid image to unset an
198  // existing clip mask.
199  void clipMask(const Image &clipMask_);
200  Image clipMask(void) const;
201 
202  // Colors within this distance are considered equal
203  void colorFuzz(const double fuzz_);
204  double colorFuzz(void) const;
205 
206  // Colormap size (number of colormap entries)
207  void colorMapSize(const size_t entries_);
208  size_t colorMapSize(void) const;
209 
210  // Image Color Space
211  void colorSpace(const ColorspaceType colorSpace_);
212  ColorspaceType colorSpace(void) const;
213 
214  void colorspaceType(const ColorspaceType colorSpace_);
215  ColorspaceType colorspaceType(void) const;
216 
217  // Image width
218  size_t columns(void) const;
219 
220  // Comment image (add comment string to image)
221  void comment(const std::string &comment_);
222  std::string comment(void) const;
223 
224  // Composition operator to be used when composition is implicitly
225  // used (such as for image flattening).
226  void compose(const CompositeOperator compose_);
227  CompositeOperator compose(void) const;
228 
229  // Compression type
230  void compressType(const CompressionType compressType_);
231  CompressionType compressType(void) const;
232 
233  // Enable printing of debug messages from ImageMagick
234  void debug(const bool flag_);
235  bool debug(void) const;
236 
237  // Vertical and horizontal resolution in pixels of the image
238  void density(const Geometry &geomery_);
239  Geometry density(void) const;
240 
241  // Image depth (bits allocated to red/green/blue components)
242  void depth(const size_t depth_);
243  size_t depth(void) const;
244 
245  // Tile names from within an image montage
246  std::string directory(void) const;
247 
248  // Endianness (little like Intel or big like SPARC) for image
249  // formats which support endian-specific options.
250  void endian(const EndianType endian_);
251  EndianType endian(void) const;
252 
253  // Exif profile (BLOB)
254  void exifProfile(const Blob &exifProfile_);
255  Blob exifProfile(void) const;
256 
257  // Image file name
258  void fileName(const std::string &fileName_);
259  std::string fileName(void) const;
260 
261  // Number of bytes of the image on disk
262  off_t fileSize(void) const;
263 
264  // Color to use when filling drawn objects
265  void fillColor(const Color &fillColor_);
266  Color fillColor(void) const;
267 
268  // Rule to use when filling drawn objects
269  void fillRule(const FillRule &fillRule_);
270  FillRule fillRule(void) const;
271 
272  // Pattern to use while filling drawn objects.
273  void fillPattern(const Image &fillPattern_);
274  Image fillPattern(void) const;
275 
276  // Filter to use when resizing image
277  void filterType(const FilterTypes filterType_);
278  FilterTypes filterType(void) const;
279 
280  // Text rendering font
281  void font(const std::string &font_);
282  std::string font(void) const;
283 
284  // Font family
285  void fontFamily(const std::string &family_);
286  std::string fontFamily(void) const;
287 
288  // Font point size
289  void fontPointsize(const double pointSize_);
290  double fontPointsize(void) const;
291 
292  // Font style
293  void fontStyle(const StyleType style_);
294  StyleType fontStyle(void) const;
295 
296  // Font weight
297  void fontWeight(const size_t weight_);
298  size_t fontWeight(void) const;
299 
300 
301  // Long image format description
302  std::string format(void) const;
303 
304  // Formats the specified expression
305  // More info here: http://www.imagemagick.org/script/escape.php
306  std::string formatExpression(const std::string expression);
307 
308  // Gamma level of the image
309  double gamma(void) const;
310 
311  // Preferred size of the image when encoding
312  Geometry geometry(void) const;
313 
314  // GIF disposal method
315  void gifDisposeMethod(const size_t disposeMethod_);
316  size_t gifDisposeMethod(void) const;
317 
318  // When comparing images, emphasize pixel differences with this color.
319  void highlightColor(const Color color_);
320 
321  // ICC color profile (BLOB)
322  void iccColorProfile(const Blob &colorProfile_);
323  Blob iccColorProfile(void) const;
324 
325  // Type of interlacing to use
326  void interlaceType(const InterlaceType interlace_);
327  InterlaceType interlaceType(void) const;
328 
329  // Pixel color interpolation method to use
330  void interpolate(const InterpolatePixelMethod interpolate_);
331  InterpolatePixelMethod interpolate(void) const;
332 
333  // IPTC profile (BLOB)
334  void iptcProfile(const Blob &iptcProfile_);
335  Blob iptcProfile(void) const;
336 
337  // Returns true if none of the pixels in the image have an alpha value
338  // other than OpaqueAlpha (QuantumRange).
339  bool isOpaque(void) const;
340 
341  // Does object contain valid image?
342  void isValid(const bool isValid_);
343  bool isValid(void) const;
344 
345  // Image label
346  void label(const std::string &label_);
347  std::string label(void) const;
348 
349  // Stroke width for drawing vector objects (default one)
350  // This method is now deprecated. Please use strokeWidth instead.
351  void lineWidth(const double lineWidth_);
352  double lineWidth(void) const;
353 
354  // When comparing images, de-emphasize pixel differences with this color.
355  void lowlightColor(const Color color_);
356 
357  // File type magick identifier (.e.g "GIF")
358  void magick(const std::string &magick_);
359  std::string magick(void) const;
360 
361  // Associate a mask with the image. The mask must be the same dimensions
362  // as the image. Pass an invalid image to unset an existing clip mask.
363  void mask(const Image &mask_);
364  Image mask(void) const;
365 
366  // Image supports transparency (matte channel)
367  void matte(const bool matteFlag_);
368  bool matte(void) const;
369 
370  // Transparent color
371  void matteColor(const Color &matteColor_);
372  Color matteColor(void) const;
373 
374  // The mean error per pixel computed when an image is color reduced
375  double meanErrorPerPixel(void) const;
376 
377  // Image modulus depth (minimum number of bits required to support
378  // red/green/blue components without loss of accuracy)
379  void modulusDepth(const size_t modulusDepth_);
380  size_t modulusDepth(void) const;
381 
382  // Transform image to black and white
383  void monochrome(const bool monochromeFlag_);
384  bool monochrome(void) const;
385 
386  // Tile size and offset within an image montage
387  Geometry montageGeometry(void) const;
388 
389  // The normalized max error per pixel computed when an image is
390  // color reduced.
391  double normalizedMaxError(void) const;
392 
393  // The normalized mean error per pixel computed when an image is
394  // color reduced.
395  double normalizedMeanError(void) const;
396 
397  // Image orientation
398  void orientation(const OrientationType orientation_);
399  OrientationType orientation(void) const;
400 
401  // Preferred size and location of an image canvas.
402  void page(const Geometry &pageSize_);
403  Geometry page(void) const;
404 
405  // Pen color (deprecated, don't use any more)
406  void penColor(const Color &penColor_);
407  Color penColor(void) const;
408 
409  // Pen texture image (deprecated, don't use any more)
410  void penTexture(const Image &penTexture_);
411  Image penTexture(void) const;
412 
413  // JPEG/MIFF/PNG compression level (default 75).
414  void quality(const size_t quality_);
415  size_t quality(void) const;
416 
417  // Maximum number of colors to quantize to
418  void quantizeColors(const size_t colors_);
419  size_t quantizeColors(void) const;
420 
421  // Colorspace to quantize in.
422  void quantizeColorSpace(const ColorspaceType colorSpace_);
423  ColorspaceType quantizeColorSpace(void) const;
424 
425  // Dither image during quantization (default true).
426  void quantizeDither(const bool ditherFlag_);
427  bool quantizeDither(void) const;
428 
429  // Dither method
430  void quantizeDitherMethod(const DitherMethod ditherMethod_);
431  DitherMethod quantizeDitherMethod(void) const;
432 
433  // Quantization tree-depth
434  void quantizeTreeDepth(const size_t treeDepth_);
435  size_t quantizeTreeDepth(void) const;
436 
437  // Suppress all warning messages. Error messages are still reported.
438  void quiet(const bool quiet_);
439  bool quiet(void) const;
440 
441  // The type of rendering intent
442  void renderingIntent(const RenderingIntent renderingIntent_);
443  RenderingIntent renderingIntent(void) const;
444 
445  // Units of image resolution
446  void resolutionUnits(const ResolutionType resolutionUnits_);
447  ResolutionType resolutionUnits(void) const;
448 
449  // The number of pixel rows in the image
450  size_t rows(void) const;
451 
452  // Image scene number
453  void scene(const size_t scene_);
454  size_t scene(void) const;
455 
456  // Width and height of a raw image
457  void size(const Geometry &geometry_);
458  Geometry size(void) const;
459 
460  // enabled/disable stroke anti-aliasing
461  void strokeAntiAlias(const bool flag_);
462  bool strokeAntiAlias(void) const;
463 
464  // Color to use when drawing object outlines
465  void strokeColor(const Color &strokeColor_);
466  Color strokeColor(void) const;
467 
468  // Specify the pattern of dashes and gaps used to stroke
469  // paths. The strokeDashArray represents a zero-terminated array
470  // of numbers that specify the lengths of alternating dashes and
471  // gaps in pixels. If an odd number of values is provided, then
472  // the list of values is repeated to yield an even number of
473  // values. A typical strokeDashArray_ array might contain the
474  // members 5 3 2 0, where the zero value indicates the end of the
475  // pattern array.
476  void strokeDashArray(const double *strokeDashArray_);
477  const double *strokeDashArray(void) const;
478 
479  // While drawing using a dash pattern, specify distance into the
480  // dash pattern to start the dash (default 0).
481  void strokeDashOffset(const double strokeDashOffset_);
482  double strokeDashOffset(void) const;
483 
484  // Specify the shape to be used at the end of open subpaths when
485  // they are stroked. Values of LineCap are UndefinedCap, ButtCap,
486  // RoundCap, and SquareCap.
487  void strokeLineCap(const LineCap lineCap_);
488  LineCap strokeLineCap(void) const;
489 
490  // Specify the shape to be used at the corners of paths (or other
491  // vector shapes) when they are stroked. Values of LineJoin are
492  // UndefinedJoin, MiterJoin, RoundJoin, and BevelJoin.
493  void strokeLineJoin(const LineJoin lineJoin_);
494  LineJoin strokeLineJoin(void) const;
495 
496  // Specify miter limit. When two line segments meet at a sharp
497  // angle and miter joins have been specified for 'lineJoin', it is
498  // possible for the miter to extend far beyond the thickness of
499  // the line stroking the path. The miterLimit' imposes a limit on
500  // the ratio of the miter length to the 'lineWidth'. The default
501  // value of this parameter is 4.
502  void strokeMiterLimit(const size_t miterLimit_);
503  size_t strokeMiterLimit(void) const;
504 
505  // Pattern image to use while stroking object outlines.
506  void strokePattern(const Image &strokePattern_);
507  Image strokePattern(void) const;
508 
509  // Stroke width for drawing vector objects (default one)
510  void strokeWidth(const double strokeWidth_);
511  double strokeWidth(void) const;
512 
513  // Subimage of an image sequence
514  void subImage(const size_t subImage_);
515  size_t subImage(void) const;
516 
517  // Number of images relative to the base image
518  void subRange(const size_t subRange_);
519  size_t subRange(void) const;
520 
521  // Render text right-to-left or left-to-right.
522  void textDirection(DirectionType direction_);
523  DirectionType textDirection() const;
524 
525  // Annotation text encoding (e.g. "UTF-16")
526  void textEncoding(const std::string &encoding_);
527  std::string textEncoding(void) const;
528 
529  // Text gravity.
530  void textGravity(GravityType gravity_);
531  GravityType textGravity() const;
532 
533  // Text inter-line spacing
534  void textInterlineSpacing(double spacing_);
535  double textInterlineSpacing(void) const;
536 
537  // Text inter-word spacing
538  void textInterwordSpacing(double spacing_);
539  double textInterwordSpacing(void) const;
540 
541  // Text inter-character kerning
542  void textKerning(double kerning_);
543  double textKerning(void) const;
544 
545  // Text undercolor box
546  void textUnderColor(const Color &underColor_);
547  Color textUnderColor(void) const;
548 
549  // Tile name
550  void tileName(const std::string &tileName_);
551  std::string tileName(void) const;
552 
553  // Number of colors in the image
554  size_t totalColors(void) const;
555 
556  // Rotation to use when annotating with text or drawing
557  void transformRotation(const double angle_);
558 
559  // Skew to use in X axis when annotating with text or drawing
560  void transformSkewX(const double skewx_);
561 
562  // Skew to use in Y axis when annotating with text or drawing
563  void transformSkewY(const double skewy_);
564 
565  // Image representation type (also see type operation)
566  // Available types:
567  // Bilevel Grayscale GrayscaleMatte
568  // Palette PaletteMatte TrueColor
569  // TrueColorMatte ColorSeparation ColorSeparationMatte
570  void type(const ImageType type_);
571  ImageType type(void) const;
572 
573  // Print detailed information about the image
574  void verbose(const bool verboseFlag_);
575  bool verbose(void) const;
576 
577  // FlashPix viewing parameters
578  void view(const std::string &view_);
579  std::string view(void) const;
580 
581  // Virtual pixel method
582  void virtualPixelMethod(const VirtualPixelMethod virtual_pixel_method_);
583  VirtualPixelMethod virtualPixelMethod(void) const;
584 
585  // X11 display to display to, obtain fonts from, or to capture
586  // image from
587  void x11Display(const std::string &display_);
588  std::string x11Display(void) const;
589 
590  // x resolution of the image
591  double xResolution(void) const;
592 
593  // y resolution of the image
594  double yResolution(void) const;
595 
596  // Adaptive-blur image with specified blur factor
597  // The radius_ parameter specifies the radius of the Gaussian, in
598  // pixels, not counting the center pixel. The sigma_ parameter
599  // specifies the standard deviation of the Laplacian, in pixels.
600  void adaptiveBlur(const double radius_=0.0,const double sigma_=1.0);
601 
602  // This is shortcut function for a fast interpolative resize using mesh
603  // interpolation. It works well for small resizes of less than +/- 50%
604  // of the original image size. For larger resizing on images a full
605  // filtered and slower resize function should be used instead.
606  void adaptiveResize(const Geometry &geometry_);
607 
608  // Adaptively sharpens the image by sharpening more intensely near image
609  // edges and less intensely far from edges. We sharpen the image with a
610  // Gaussian operator of the given radius and standard deviation (sigma).
611  // For reasonable results, radius should be larger than sigma.
612  void adaptiveSharpen(const double radius_=0.0,const double sigma_=1.0);
613  void adaptiveSharpenChannel(const ChannelType channel_,
614  const double radius_=0.0,const double sigma_=1.0);
615 
616  // Local adaptive threshold image
617  // http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm
618  // Width x height define the size of the pixel neighborhood
619  // offset = constant to subtract from pixel neighborhood mean
620  void adaptiveThreshold(const size_t width,const size_t height,
621  const ::ssize_t offset=0);
622 
623  // Add noise to image with specified noise type
624  void addNoise(const NoiseType noiseType_);
625  void addNoiseChannel(const ChannelType channel_,
626  const NoiseType noiseType_);
627 
628  // Transform image by specified affine (or free transform) matrix.
629  void affineTransform(const DrawableAffine &affine);
630 
631  // Activates, deactivates, resets, or sets the alpha channel.
632  void alphaChannel(AlphaChannelType alphaType_);
633 
634  //
635  // Annotate image (draw text on image)
636  //
637  // Gravity effects text placement in bounding area according to rules:
638  // NorthWestGravity text bottom-left corner placed at top-left
639  // NorthGravity text bottom-center placed at top-center
640  // NorthEastGravity text bottom-right corner placed at top-right
641  // WestGravity text left-center placed at left-center
642  // CenterGravity text center placed at center
643  // EastGravity text right-center placed at right-center
644  // SouthWestGravity text top-left placed at bottom-left
645  // SouthGravity text top-center placed at bottom-center
646  // SouthEastGravity text top-right placed at bottom-right
647 
648  // Annotate using specified text, and placement location
649  void annotate(const std::string &text_,const Geometry &location_);
650 
651  // Annotate using specified text, bounding area, and placement
652  // gravity
653  void annotate(const std::string &text_,const Geometry &boundingArea_,
654  const GravityType gravity_);
655 
656  // Annotate with text using specified text, bounding area,
657  // placement gravity, and rotation.
658  void annotate(const std::string &text_,const Geometry &boundingArea_,
659  const GravityType gravity_,const double degrees_);
660 
661  // Annotate with text (bounding area is entire image) and placement
662  // gravity.
663  void annotate(const std::string &text_,const GravityType gravity_);
664 
665  // Inserts the artifact with the specified name and value into
666  // the artifact tree of the image.
667  void artifact(const std::string &name_,const std::string &value_);
668 
669  // Returns the value of the artifact with the specified name.
670  std::string artifact(const std::string &name_) const;
671 
672  // Access/Update a named image attribute
673  void attribute(const std::string name_,const std::string value_);
674  std::string attribute(const std::string name_ ) const;
675 
676  // Extracts the 'mean' from the image and adjust the image to try
677  // make set its gamma appropriatally.
678  void autoGamma(void);
679  void autoGammaChannel(const ChannelType channel_);
680 
681  // Adjusts the levels of a particular image channel by scaling the
682  // minimum and maximum values to the full quantum range.
683  void autoLevel(void);
684  void autoLevelChannel(const ChannelType channel_);
685 
686  // Adjusts an image so that its orientation is suitable for viewing.
687  void autoOrient(void);
688 
689  // Forces all pixels below the threshold into black while leaving all
690  // pixels at or above the threshold unchanged.
691  void blackThreshold(const std::string &threshold_);
692  void blackThresholdChannel(const ChannelType channel_,
693  const std::string &threshold_);
694 
695  // Simulate a scene at nighttime in the moonlight.
696  void blueShift(const double factor_=1.5);
697 
698  // Blur image with specified blur factor
699  // The radius_ parameter specifies the radius of the Gaussian, in
700  // pixels, not counting the center pixel. The sigma_ parameter
701  // specifies the standard deviation of the Laplacian, in pixels.
702  void blur(const double radius_=0.0,const double sigma_=1.0);
703  void blurChannel(const ChannelType channel_,const double radius_=0.0,
704  const double sigma_=1.0);
705 
706  // Border image (add border to image)
707  void border(const Geometry &geometry_=borderGeometryDefault);
708 
709  // Changes the brightness and/or contrast of an image. It converts the
710  // brightness and contrast parameters into slope and intercept and calls
711  // a polynomical function to apply to the image.
712  void brightnessContrast(const double brightness_=0.0,
713  const double contrast_=0.0);
714  void brightnessContrastChannel(const ChannelType channel_,
715  const double brightness_=0.0,const double contrast_=0.0);
716 
717  // Uses a multi-stage algorithm to detect a wide range of edges in images.
718  void cannyEdge(const double radius_=0.0,const double sigma_=1.0,
719  const double lowerPercent_=0.1,const double upperPercent_=0.3);
720 
721  // Accepts a lightweight Color Correction Collection
722  // (CCC) file which solely contains one or more color corrections and
723  // applies the correction to the image.
724  void cdl(const std::string &cdl_);
725 
726  // Extract channel from image
727  void channel(const ChannelType channel_);
728 
729  // Set or obtain modulus channel depth
730  void channelDepth(const ChannelType channel_,const size_t depth_);
731  size_t channelDepth(const ChannelType channel_);
732 
733  // Charcoal effect image (looks like charcoal sketch)
734  // The radius_ parameter specifies the radius of the Gaussian, in
735  // pixels, not counting the center pixel. The sigma_ parameter
736  // specifies the standard deviation of the Laplacian, in pixels.
737  void charcoal(const double radius_=0.0,const double sigma_=1.0);
738 
739  // Chop image (remove vertical or horizontal subregion of image)
740  // FIXME: describe how geometry argument is used to select either
741  // horizontal or vertical subregion of image.
742  void chop(const Geometry &geometry_);
743 
744  // Chromaticity blue primary point (e.g. x=0.15, y=0.06)
745  void chromaBluePrimary(const double x_,const double y_);
746  void chromaBluePrimary(double *x_, double *y_) const;
747 
748  // Chromaticity green primary point (e.g. x=0.3, y=0.6)
749  void chromaGreenPrimary(const double x_,const double y_);
750  void chromaGreenPrimary(double *x_,double *y_) const;
751 
752  // Chromaticity red primary point (e.g. x=0.64, y=0.33)
753  void chromaRedPrimary(const double x_,const double y_);
754  void chromaRedPrimary(double *x_,double *y_) const;
755 
756  // Chromaticity white point (e.g. x=0.3127, y=0.329)
757  void chromaWhitePoint(const double x_,const double y_);
758  void chromaWhitePoint(double *x_,double *y_) const;
759 
760  // Set each pixel whose value is below zero to zero and any the
761  // pixel whose value is above the quantum range to the quantum range (e.g.
762  // 65535) otherwise the pixel value remains unchanged.
763  void clamp(void);
764  void clampChannel(const ChannelType channel_);
765 
766  // Sets the image clip mask based on any clipping path information
767  // if it exists.
768  void clip(void);
769 
770  void clipPath(const std::string pathname_,const bool inside_);
771 
772  // Apply a color lookup table (CLUT) to the image.
773  void clut(const Image &clutImage_);
774  void clutChannel(const ChannelType channel_,const Image &clutImage_);
775 
776  // Colorize image with pen color, using specified percent opacity.
777  void colorize(const unsigned int opacity_,const Color &penColor_);
778 
779  // Colorize image with pen color, using specified percent opacity
780  // for red, green, and blue quantums
781  void colorize(const unsigned int opacityRed_,
782  const unsigned int opacityGreen_,const unsigned int opacityBlue_,
783  const Color &penColor_);
784 
785  // Color at colormap position index_
786  void colorMap(const size_t index_,const Color &color_);
787  Color colorMap(const size_t index_) const;
788 
789  // Apply a color matrix to the image channels. The user supplied
790  // matrix may be of order 1 to 5 (1x1 through 5x5).
791  void colorMatrix(const size_t order_,const double *color_matrix_);
792 
793  // Compare current image with another image
794  // Sets meanErrorPerPixel, normalizedMaxError, and normalizedMeanError
795  // in the current image. False is returned if the images are identical.
796  bool compare(const Image &reference_);
797 
798  // Compare current image with another image
799  // Returns the distortion based on the specified metric.
800  double compare(const Image &reference_,const MetricType metric_);
801  double compareChannel(const ChannelType channel_,const Image &reference_,
802  const MetricType metric_);
803 
804  // Compare current image with another image
805  // Sets the distortion and returns the difference image.
806  Image compare(const Image &reference_,const MetricType metric_,
807  double *distortion);
808  Image compareChannel(const ChannelType channel_,const Image &reference_,
809  const MetricType metric_,double *distortion );
810 
811  // Compose an image onto another at specified offset and using
812  // specified algorithm
813  void composite(const Image &compositeImage_,const Geometry &offset_,
814  const CompositeOperator compose_=InCompositeOp);
815  void composite(const Image &compositeImage_,const GravityType gravity_,
816  const CompositeOperator compose_=InCompositeOp);
817  void composite(const Image &compositeImage_,const ::ssize_t xOffset_,
818  const ::ssize_t yOffset_,const CompositeOperator compose_=InCompositeOp);
819 
820  // Determines the connected-components of the image
821  void connectedComponents(const size_t connectivity_);
822 
823  // Contrast image (enhance intensity differences in image)
824  void contrast(const size_t sharpen_);
825 
826  // A simple image enhancement technique that attempts to improve the
827  // contrast in an image by 'stretching' the range of intensity values
828  // it contains to span a desired range of values. It differs from the
829  // more sophisticated histogram equalization in that it can only apply a
830  // linear scaling function to the image pixel values. As a result the
831  // 'enhancement' is less harsh.
832  void contrastStretch(const double black_point_,const double white_point_);
833  void contrastStretchChannel(const ChannelType channel_,
834  const double black_point_,const double white_point_);
835 
836  // Convolve image. Applies a user-specified convolution to the image.
837  // order_ represents the number of columns and rows in the filter kernel.
838  // kernel_ is an array of doubles representing the convolution kernel.
839  void convolve(const size_t order_,const double *kernel_);
840 
841  // Copies pixels from the source image as defined by the geometry the
842  // destination image at the specified offset.
843  void copyPixels(const Image &source_,const Geometry &geometry_,
844  const Offset &offset_);
845 
846  // Crop image (subregion of original image)
847  void crop(const Geometry &geometry_);
848 
849  // Cycle image colormap
850  void cycleColormap(const ::ssize_t amount_);
851 
852  // Converts cipher pixels to plain pixels.
853  void decipher(const std::string &passphrase_);
854 
855  // Tagged image format define. Similar to the defineValue() method
856  // except that passing the flag_ value 'true' creates a value-less
857  // define with that format and key. Passing the flag_ value 'false'
858  // removes any existing matching definition. The method returns 'true'
859  // if a matching key exists, and 'false' if no matching key exists.
860  void defineSet(const std::string &magick_,const std::string &key_,
861  bool flag_);
862  bool defineSet(const std::string &magick_,const std::string &key_) const;
863 
864  // Tagged image format define (set/access coder-specific option) The
865  // magick_ option specifies the coder the define applies to. The key_
866  // option provides the key specific to that coder. The value_ option
867  // provides the value to set (if any). See the defineSet() method if the
868  // key must be removed entirely.
869  void defineValue(const std::string &magick_,const std::string &key_,
870  const std::string &value_);
871  std::string defineValue(const std::string &magick_,
872  const std::string &key_) const;
873 
874  // Removes skew from the image. Skew is an artifact that occurs in scanned
875  // images because of the camera being misaligned, imperfections in the
876  // scanning or surface, or simply because the paper was not placed
877  // completely flat when scanned. The value of threshold_ ranges from 0
878  // to QuantumRange.
879  void deskew(const double threshold_);
880 
881  // Despeckle image (reduce speckle noise)
882  void despeckle(void);
883 
884  // Determines the color type of the image. This method can be used to
885  // automaticly make the type GrayScale.
886  ImageType determineType(void) const;
887 
888  // Display image on screen
889  void display(void);
890 
891  // Distort image. distorts an image using various distortion methods, by
892  // mapping color lookups of the source image to a new destination image
893  // usally of the same size as the source image, unless 'bestfit' is set to
894  // true.
895  void distort(const DistortImageMethod method_,
896  const size_t number_arguments_,const double *arguments_,
897  const bool bestfit_=false);
898 
899  // Draw on image using a single drawable
900  void draw(const Drawable &drawable_);
901 
902  // Draw on image using a drawable list
903  void draw(const std::list<Magick::Drawable> &drawable_);
904 
905  // Edge image (hilight edges in image)
906  void edge(const double radius_=0.0);
907 
908  // Emboss image (hilight edges with 3D effect)
909  // The radius_ parameter specifies the radius of the Gaussian, in
910  // pixels, not counting the center pixel. The sigma_ parameter
911  // specifies the standard deviation of the Laplacian, in pixels.
912  void emboss(const double radius_=0.0,const double sigma_=1.0);
913 
914  // Converts pixels to cipher-pixels.
915  void encipher(const std::string &passphrase_);
916 
917  // Enhance image (minimize noise)
918  void enhance(void);
919 
920  // Equalize image (histogram equalization)
921  void equalize(void);
922 
923  // Erase image to current "background color"
924  void erase(void);
925 
926  // Extend the image as defined by the geometry.
927  void extent(const Geometry &geometry_);
928  void extent(const Geometry &geometry_,const Color &backgroundColor);
929  void extent(const Geometry &geometry_,const Color &backgroundColor,
930  const GravityType gravity_ );
931  void extent(const Geometry &geometry_,const GravityType gravity_);
932 
933  // Flip image (reflect each scanline in the vertical direction)
934  void flip(void);
935 
936  // Flood-fill color across pixels that match the color of the
937  // target pixel and are neighbors of the target pixel.
938  // Uses current fuzz setting when determining color match.
939  void floodFillColor(const Geometry &point_,const Color &fillColor_);
940  void floodFillColor(const Geometry &point_,const Color &fillColor_,
941  const bool invert_);
942  void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
943  const Color &fillColor_);
944  void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
945  const Color &fillColor_,const bool invert_);
946 
947  // Flood-fill color across pixels starting at target-pixel and
948  // stopping at pixels matching specified border color.
949  // Uses current fuzz setting when determining color match.
950  void floodFillColor(const Geometry &point_,const Color &fillColor_,
951  const Color &borderColor_);
952  void floodFillColor(const Geometry &point_,const Color &fillColor_,
953  const Color &borderColor_,const bool invert_);
954  void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
955  const Color &fillColor_,const Color &borderColor_);
956  void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
957  const Color &fillColor_,const Color &borderColor_,const bool invert_);
958 
959  // Floodfill pixels matching color (within fuzz factor) of target
960  // pixel(x,y) with replacement opacity value using method.
961  void floodFillOpacity(const ::ssize_t x_,const ::ssize_t y_,
962  const unsigned int opacity_,const bool invert_=false);
963  void floodFillOpacity(const ::ssize_t x_,const ::ssize_t y_,
964  const unsigned int opacity_,const PaintMethod method_);
965  void floodFillOpacity(const ::ssize_t x_,const ::ssize_t y_,
966  const unsigned int opacity_,const Color &target_,
967  const bool invert_=false);
968 
969  // Flood-fill texture across pixels that match the color of the
970  // target pixel and are neighbors of the target pixel.
971  // Uses current fuzz setting when determining color match.
972  void floodFillTexture(const Geometry &point_,const Image &texture_);
973  void floodFillTexture(const Geometry &point_,const Image &texture_,
974  const bool invert_);
975  void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
976  const Image &texture_);
977  void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
978  const Image &texture_,const bool invert_);
979 
980  // Flood-fill texture across pixels starting at target-pixel and
981  // stopping at pixels matching specified border color.
982  // Uses current fuzz setting when determining color match.
983  void floodFillTexture(const Geometry &point_,const Image &texture_,
984  const Color &borderColor_);
985  void floodFillTexture(const Geometry &point_,const Image &texture_,
986  const Color &borderColor_,const bool invert_);
987  void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
988  const Image &texture_,const Color &borderColor_);
989  void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
990  const Image &texture_,const Color &borderColor_,const bool invert_);
991 
992  // Flop image (reflect each scanline in the horizontal direction)
993  void flop(void);
994 
995  // Obtain font metrics for text string given current font,
996  // pointsize, and density settings.
997  void fontTypeMetrics(const std::string &text_,TypeMetric *metrics);
998 
999  // Obtain multi line font metrics for text string given current font,
1000  // pointsize, and density settings.
1001  void fontTypeMetricsMultiline(const std::string &text_,
1002  TypeMetric *metrics);
1003 
1004  // Frame image
1005  void frame(const Geometry &geometry_=frameGeometryDefault);
1006  void frame(const size_t width_,const size_t height_,
1007  const ::ssize_t innerBevel_=6, const ::ssize_t outerBevel_=6);
1008 
1009  // Applies a mathematical expression to the image.
1010  void fx(const std::string expression);
1011  void fx(const std::string expression,const Magick::ChannelType channel);
1012 
1013  // Gamma correct image
1014  void gamma(const double gamma_);
1015  void gamma(const double gammaRed_,const double gammaGreen_,
1016  const double gammaBlue_);
1017 
1018  // Gaussian blur image
1019  // The number of neighbor pixels to be included in the convolution
1020  // mask is specified by 'width_'. The standard deviation of the
1021  // gaussian bell curve is specified by 'sigma_'.
1022  void gaussianBlur(const double width_,const double sigma_);
1023  void gaussianBlurChannel(const ChannelType channel_,const double width_,
1024  const double sigma_);
1025 
1026  // Obtain immutable image pixel indexes (valid for PseudoClass images)
1027  const IndexPacket *getConstIndexes(void) const;
1028 
1029  // Transfers read-only pixels from the image to the pixel cache as
1030  // defined by the specified region
1031  const PixelPacket *getConstPixels(const ::ssize_t x_,const ::ssize_t y_,
1032  const size_t columns_,const size_t rows_) const;
1033 
1034  // Obtain mutable image pixel indexes (valid for PseudoClass images)
1035  IndexPacket *getIndexes(void);
1036 
1037  // Transfers pixels from the image to the pixel cache as defined
1038  // by the specified region. Modified pixels may be subsequently
1039  // transferred back to the image via syncPixels. This method is
1040  // valid for DirectClass images.
1041  PixelPacket *getPixels(const ::ssize_t x_,const ::ssize_t y_,
1042  const size_t columns_,const size_t rows_);
1043 
1044  // Converts the colors in the image to gray.
1045  void grayscale(const PixelIntensityMethod method_);
1046 
1047  // Apply a color lookup table (Hald CLUT) to the image.
1048  void haldClut(const Image &clutImage_);
1049 
1050  // Identifies lines in the image.
1051  void houghLine(const size_t width_,const size_t height_,
1052  const size_t threshold_=40);
1053 
1054  // Implode image (special effect)
1055  void implode(const double factor_);
1056 
1057  // Implements the inverse discrete Fourier transform (DFT) of the image
1058  // either as a magnitude / phase or real / imaginary image pair.
1059  void inverseFourierTransform(const Image &phase_);
1060  void inverseFourierTransform(const Image &phase_,const bool magnitude_);
1061 
1062  // An edge preserving noise reduction filter.
1063  void kuwahara(const double radius_=0.0,const double sigma_=1.0);
1064  void kuwaharaChannel(const ChannelType channel_,const double radius_=0.0,
1065  const double sigma_=1.0);
1066 
1067  // Level image. Adjust the levels of the image by scaling the
1068  // colors falling between specified white and black points to the
1069  // full available quantum range. The parameters provided represent
1070  // the black, mid (gamma), and white points. The black point
1071  // specifies the darkest color in the image. Colors darker than
1072  // the black point are set to zero. Mid point (gamma) specifies a
1073  // gamma correction to apply to the image. White point specifies
1074  // the lightest color in the image. Colors brighter than the
1075  // white point are set to the maximum quantum value. The black and
1076  // white point have the valid range 0 to QuantumRange while mid (gamma)
1077  // has a useful range of 0 to ten.
1078  void level(const double black_point,const double white_point,
1079  const double mid_point=1.0);
1080  void levelChannel(const ChannelType channel,const double black_point,
1081  const double white_point,const double mid_point=1.0);
1082 
1083  // Maps the given color to "black" and "white" values, linearly spreading
1084  // out the colors, and level values on a channel by channel bases, as
1085  // per level(). The given colors allows you to specify different level
1086  // ranges for each of the color channels separately.
1087  void levelColors(const Color &blackColor_,const Color &whiteColor_,
1088  const bool invert_=true);
1089  void levelColorsChannel(const ChannelType channel_,
1090  const Color &blackColor_,const Color &whiteColor_,
1091  const bool invert_=true);
1092 
1093  // Levelize applies the reversed level operation to just the specific
1094  // channels specified.It compresses the full range of color values, so
1095  // that they lie between the given black and white points. Gamma is
1096  // applied before the values are mapped.
1097  void levelize(const double blackPoint_,const double whitePoint_,
1098  const double gamma_=1.0);
1099  void levelizeChannel(const ChannelType channel_,const double blackPoint_,
1100  const double whitePoint_,const double gamma_=1.0);
1101 
1102  // Discards any pixels below the black point and above the white point and
1103  // levels the remaining pixels.
1104  void linearStretch(const double blackPoint_,const double whitePoint_);
1105 
1106  // Rescales image with seam carving.
1107  void liquidRescale(const Geometry &geometry_);
1108 
1109  // Local contrast enhancement
1110  void localContrast(const double radius_,const double strength_);
1111 
1112  // Magnify image by integral size
1113  void magnify(void);
1114 
1115  // Remap image colors with closest color from reference image
1116  void map(const Image &mapImage_,const bool dither_=false);
1117 
1118  // Floodfill designated area with replacement opacity value
1119  void matteFloodfill(const Color &target_,const unsigned int opacity_,
1120  const ::ssize_t x_,const ::ssize_t y_,const PaintMethod method_);
1121 
1122  // Filter image by replacing each pixel component with the median
1123  // color in a circular neighborhood
1124  void medianFilter(const double radius_=0.0);
1125 
1126  // Merge image layers (deprecated, don't use any more)
1127  void mergeLayers(const ImageLayerMethod layerType_);
1128 
1129  // Reduce image by integral size
1130  void minify(void);
1131 
1132  // Modulate percent hue, saturation, and brightness of an image
1133  void modulate(const double brightness_,const double saturation_,
1134  const double hue_);
1135 
1136  // Returns the normalized moments of one or more image channels.
1137  ImageMoments moments(void) const;
1138 
1139  // Applies a kernel to the image according to the given mophology method.
1140  void morphology(const MorphologyMethod method_,const std::string kernel_,
1141  const ssize_t iterations_=1);
1142  void morphology(const MorphologyMethod method_,
1143  const KernelInfoType kernel_,const std::string arguments_,
1144  const ssize_t iterations_=1);
1145  void morphologyChannel(const ChannelType channel_,
1146  const MorphologyMethod method_,const std::string kernel_,
1147  const ssize_t iterations_=1);
1148  void morphologyChannel(const ChannelType channel_,
1149  const MorphologyMethod method_,const KernelInfoType kernel_,
1150  const std::string arguments_,const ssize_t iterations_=1);
1151 
1152  // Motion blur image with specified blur factor
1153  // The radius_ parameter specifies the radius of the Gaussian, in
1154  // pixels, not counting the center pixel. The sigma_ parameter
1155  // specifies the standard deviation of the Laplacian, in pixels.
1156  // The angle_ parameter specifies the angle the object appears
1157  // to be comming from (zero degrees is from the right).
1158  void motionBlur(const double radius_,const double sigma_,
1159  const double angle_);
1160 
1161  // Negate colors in image. Set grayscale to only negate grayscale
1162  // values in image.
1163  void negate(const bool grayscale_=false);
1164  void negateChannel(const ChannelType channel_,const bool grayscale_=false);
1165 
1166  // Normalize image (increase contrast by normalizing the pixel
1167  // values to span the full range of color values)
1168  void normalize(void);
1169 
1170  // Oilpaint image (image looks like oil painting)
1171  void oilPaint(const double radius_=3.0);
1172 
1173  // Set or attenuate the opacity channel in the image. If the image
1174  // pixels are opaque then they are set to the specified opacity
1175  // value, otherwise they are blended with the supplied opacity
1176  // value. The value of opacity_ ranges from 0 (completely opaque)
1177  // to QuantumRange. The defines OpaqueOpacity and TransparentOpacity are
1178  // available to specify completely opaque or completely
1179  // transparent, respectively.
1180  void opacity(const unsigned int opacity_);
1181 
1182  // Change color of opaque pixel to specified pen color.
1183  void opaque(const Color &opaqueColor_,const Color &penColor_,
1184  const bool invert_=MagickFalse);
1185 
1186  // Perform a ordered dither based on a number of pre-defined dithering
1187  // threshold maps, but over multiple intensity levels.
1188  void orderedDither(std::string thresholdMap_);
1189  void orderedDitherChannel(const ChannelType channel_,
1190  std::string thresholdMap_);
1191 
1192  // Set each pixel whose value is less than epsilon to epsilon or
1193  // -epsilon (whichever is closer) otherwise the pixel value remains
1194  // unchanged.
1195  void perceptible(const double epsilon_);
1196  void perceptibleChannel(const ChannelType channel_,const double epsilon_);
1197 
1198  // Ping is similar to read except only enough of the image is read
1199  // to determine the image columns, rows, and filesize. Access the
1200  // columns(), rows(), and fileSize() attributes after invoking
1201  // ping. The image data is not valid after calling ping.
1202  void ping(const Blob &blob_);
1203 
1204  // Ping is similar to read except only enough of the image is read
1205  // to determine the image columns, rows, and filesize. Access the
1206  // columns(), rows(), and fileSize() attributes after invoking
1207  // ping. The image data is not valid after calling ping.
1208  void ping(const std::string &imageSpec_);
1209 
1210  // Get/set pixel color at location x & y.
1211  void pixelColor(const ::ssize_t x_,const ::ssize_t y_,const Color &color_);
1212  Color pixelColor(const ::ssize_t x_,const ::ssize_t y_ ) const;
1213 
1214  // Simulates a Polaroid picture.
1215  void polaroid(const std::string &caption_,const double angle_);
1216 
1217  // Reduces the image to a limited number of colors for a "poster" effect.
1218  void posterize(const size_t levels_,const bool dither_=false);
1219  void posterizeChannel(const ChannelType channel_, const size_t levels_,
1220  const bool dither_=false);
1221 
1222  // Execute a named process module using an argc/argv syntax similar to
1223  // that accepted by a C 'main' routine. An exception is thrown if the
1224  // requested process module doesn't exist, fails to load, or fails during
1225  // execution.
1226  void process(std::string name_,const ::ssize_t argc_,const char **argv_);
1227 
1228  // Add or remove a named profile to/from the image. Remove the
1229  // profile by passing an empty Blob (e.g. Blob()). Valid names are
1230  // "*", "8BIM", "ICM", "IPTC", or a user/format-defined profile name.
1231  void profile(const std::string name_,const Blob &colorProfile_);
1232 
1233  // Retrieve a named profile from the image. Valid names are:
1234  // "8BIM", "8BIMTEXT", "APP1", "APP1JPEG", "ICC", "ICM", & "IPTC"
1235  // or an existing user/format-defined profile name.
1236  Blob profile(const std::string name_) const;
1237 
1238  // Quantize image (reduce number of colors)
1239  void quantize(const bool measureError_=false);
1240 
1241  // Apply a value with an arithmetic, relational, or logical operator.
1242  void quantumOperator(const ChannelType channel_,
1243  const MagickEvaluateOperator operator_,double rvalue_);
1244 
1245  // Apply a value with an arithmetic, relational, or logical operator.
1246  void quantumOperator(const ChannelType channel_,
1247  const MagickFunction function_,const size_t number_parameters_,
1248  const double *parameters_);
1249 
1250  // Apply a value with an arithmetic, relational, or logical operator.
1251  void quantumOperator(const ::ssize_t x_,const ::ssize_t y_,
1252  const size_t columns_,const size_t rows_,const ChannelType channel_,
1253  const MagickEvaluateOperator operator_,const double rvalue_);
1254 
1255  // Raise image (lighten or darken the edges of an image to give a
1256  // 3-D raised or lowered effect)
1257  void raise(const Geometry &geometry_=raiseGeometryDefault,
1258  const bool raisedFlag_=false);
1259 
1260  // Random threshold image.
1261  //
1262  // Changes the value of individual pixels based on the intensity
1263  // of each pixel compared to a random threshold. The result is a
1264  // low-contrast, two color image. The thresholds_ argument is a
1265  // geometry containing LOWxHIGH thresholds. If the string
1266  // contains 2x2, 3x3, or 4x4, then an ordered dither of order 2,
1267  // 3, or 4 will be performed instead. If a channel_ argument is
1268  // specified then only the specified channel is altered. This is
1269  // a very fast alternative to 'quantize' based dithering.
1270  void randomThreshold(const Geometry &thresholds_);
1271  void randomThresholdChannel(const Geometry &thresholds_,
1272  const ChannelType channel_);
1273 
1274  // Read single image frame from in-memory BLOB
1275  void read(const Blob &blob_);
1276 
1277  // Read single image frame of specified size from in-memory BLOB
1278  void read(const Blob &blob_,const Geometry &size_);
1279 
1280  // Read single image frame of specified size and depth from
1281  // in-memory BLOB
1282  void read(const Blob &blob_,const Geometry &size_,const size_t depth_);
1283 
1284  // Read single image frame of specified size, depth, and format
1285  // from in-memory BLOB
1286  void read(const Blob &blob_,const Geometry &size_,const size_t depth_,
1287  const std::string &magick_);
1288 
1289  // Read single image frame of specified size, and format from
1290  // in-memory BLOB
1291  void read(const Blob &blob_,const Geometry &size_,
1292  const std::string &magick_);
1293 
1294  // Read single image frame of specified size into current object
1295  void read(const Geometry &size_,const std::string &imageSpec_);
1296 
1297  // Read single image frame from an array of raw pixels, with
1298  // specified storage type (ConstituteImage), e.g.
1299  // image.read( 640, 480, "RGB", 0, pixels );
1300  void read(const size_t width_,const size_t height_,const std::string &map_,
1301  const StorageType type_,const void *pixels_);
1302 
1303  // Read single image frame into current object
1304  void read(const std::string &imageSpec_);
1305 
1306  // Transfers one or more pixel components from a buffer or file
1307  // into the image pixel cache of an image.
1308  // Used to support image decoders.
1309  void readPixels(const QuantumType quantum_,const unsigned char *source_);
1310 
1311  // Reduce noise in image using a noise peak elimination filter
1312  void reduceNoise(void);
1313  void reduceNoise(const double order_);
1314 
1315  // Resets the image page canvas and position.
1316  void repage();
1317 
1318  // Resize image in terms of its pixel size.
1319  void resample(const Geometry &geometry_);
1320 
1321  // Resize image to specified size.
1322  void resize(const Geometry &geometry_);
1323 
1324  // Roll image (rolls image vertically and horizontally) by specified
1325  // number of columnms and rows)
1326  void roll(const Geometry &roll_);
1327  void roll(const size_t columns_,const size_t rows_);
1328 
1329  // Rotate image counter-clockwise by specified number of degrees.
1330  void rotate(const double degrees_);
1331 
1332  // Rotational blur image.
1333  void rotationalBlur(const double angle_);
1334  void rotationalBlurChannel(const ChannelType channel_,
1335  const double angle_);
1336 
1337  // Resize image by using pixel sampling algorithm
1338  void sample(const Geometry &geometry_);
1339 
1340  // Resize image by using simple ratio algorithm
1341  void scale(const Geometry &geometry_);
1342 
1343  // Segment (coalesce similar image components) by analyzing the
1344  // histograms of the color components and identifying units that
1345  // are homogeneous with the fuzzy c-means technique. Also uses
1346  // QuantizeColorSpace and Verbose image attributes
1347  void segment(const double clusterThreshold_=1.0,
1348  const double smoothingThreshold_=1.5);
1349 
1350  // Selectively blur pixels within a contrast threshold. It is similar to
1351  // the unsharpen mask that sharpens everything with contrast above a
1352  // certain threshold.
1353  void selectiveBlur(const double radius_,const double sigma_,
1354  const double threshold_);
1355  void selectiveBlurChannel(const ChannelType channel_,const double radius_,
1356  const double sigma_,const double threshold_);
1357 
1358  // Separates a channel from the image and returns it as a grayscale image.
1359  Image separate(const ChannelType channel_) const;
1360 
1361  // Applies a special effect to the image, similar to the effect achieved in
1362  // a photo darkroom by sepia toning. Threshold ranges from 0 to
1363  // QuantumRange and is a measure of the extent of the sepia toning.
1364  // A threshold of 80% is a good starting point for a reasonable tone.
1365  void sepiaTone(const double threshold_);
1366 
1367  // Allocates a pixel cache region to store image pixels as defined
1368  // by the region rectangle. This area is subsequently transferred
1369  // from the pixel cache to the image via syncPixels.
1370  PixelPacket *setPixels(const ::ssize_t x_,const ::ssize_t y_,
1371  const size_t columns_,const size_t rows_);
1372 
1373  // Shade image using distant light source
1374  void shade(const double azimuth_=30,const double elevation_=30,
1375  const bool colorShading_=false);
1376 
1377  // Simulate an image shadow
1378  void shadow(const double percent_opacity_=80.0,const double sigma_=0.5,
1379  const ssize_t x_=5,const ssize_t y_=5);
1380 
1381  // Sharpen pixels in image
1382  // The radius_ parameter specifies the radius of the Gaussian, in
1383  // pixels, not counting the center pixel. The sigma_ parameter
1384  // specifies the standard deviation of the Laplacian, in pixels.
1385  void sharpen(const double radius_=0.0,const double sigma_=1.0);
1386  void sharpenChannel(const ChannelType channel_,const double radius_=0.0,
1387  const double sigma_=1.0);
1388 
1389  // Shave pixels from image edges.
1390  void shave(const Geometry &geometry_);
1391 
1392  // Shear image (create parallelogram by sliding image by X or Y axis)
1393  void shear(const double xShearAngle_,const double yShearAngle_);
1394 
1395  // adjust the image contrast with a non-linear sigmoidal contrast algorithm
1396  void sigmoidalContrast(const size_t sharpen_,const double contrast,
1397  const double midpoint=QuantumRange/2.0);
1398 
1399  // Image signature. Set force_ to true in order to re-calculate
1400  // the signature regardless of whether the image data has been
1401  // modified.
1402  std::string signature(const bool force_=false) const;
1403 
1404  // Simulates a pencil sketch. We convolve the image with a Gaussian
1405  // operator of the given radius and standard deviation (sigma). For
1406  // reasonable results, radius should be larger than sigma. Use a
1407  // radius of 0 and SketchImage() selects a suitable radius for you.
1408  void sketch(const double radius_=0.0,const double sigma_=1.0,
1409  const double angle_=0.0);
1410 
1411  // Solarize image (similar to effect seen when exposing a
1412  // photographic film to light during the development process)
1413  void solarize(const double factor_=50.0);
1414 
1415  // Sparse color image, given a set of coordinates, interpolates the colors
1416  // found at those coordinates, across the whole image, using various
1417  // methods.
1418  void sparseColor(const ChannelType channel,const SparseColorMethod method,
1419  const size_t number_arguments,const double *arguments);
1420 
1421  // Splice the background color into the image.
1422  void splice(const Geometry &geometry_);
1423  void splice(const Geometry &geometry_,const Color &backgroundColor_);
1424  void splice(const Geometry &geometry_,const Color &backgroundColor_,
1425  const GravityType gravity_);
1426 
1427  // Spread pixels randomly within image by specified ammount
1428  void spread(const size_t amount_=3);
1429 
1430  void statistics(ImageStatistics *statistics) const;
1431 
1432  // Add a digital watermark to the image (based on second image)
1433  void stegano(const Image &watermark_);
1434 
1435  // Create an image which appears in stereo when viewed with
1436  // red-blue glasses (Red image on left, blue on right)
1437  void stereo(const Image &rightImage_);
1438 
1439  // Strip strips an image of all profiles and comments.
1440  void strip(void);
1441 
1442  // Search for the specified image at EVERY possible location in this image.
1443  // This is slow! very very slow.. It returns a similarity image such that
1444  // an exact match location is completely white and if none of the pixels
1445  // match, black, otherwise some gray level in-between.
1446  Image subImageSearch(const Image &reference_,const MetricType metric_,
1447  Geometry *offset_,double *similarityMetric_,
1448  const double similarityThreshold=(-1.0));
1449 
1450  // Swirl image (image pixels are rotated by degrees)
1451  void swirl(const double degrees_);
1452 
1453  // Transfers the image cache pixels to the image.
1454  void syncPixels(void);
1455 
1456  // Channel a texture on image background
1457  void texture(const Image &texture_);
1458 
1459  // Threshold image
1460  void threshold(const double threshold_);
1461 
1462  // Resize image to thumbnail size
1463  void thumbnail(const Geometry &geometry_);
1464 
1465  // Applies a color vector to each pixel in the image. The length of the
1466  // vector is 0 for black and white and at its maximum for the midtones.
1467  // The vector weighting function is f(x)=(1-(4.0*((x-0.5)*(x-0.5))))
1468  void tint(const std::string opacity_);
1469 
1470  // Transform image based on image and crop geometries
1471  // Crop geometry is optional
1472  void transform(const Geometry &imageGeometry_);
1473  void transform(const Geometry &imageGeometry_,
1474  const Geometry &cropGeometry_);
1475 
1476  // Origin of coordinate system to use when annotating with text or drawing
1477  void transformOrigin(const double x_,const double y_);
1478 
1479  // Reset transformation parameters to default
1480  void transformReset(void);
1481 
1482  // Scale to use when annotating with text or drawing
1483  void transformScale(const double sx_,const double sy_);
1484 
1485  // Add matte image to image, setting pixels matching color to
1486  // transparent
1487  void transparent(const Color &color_);
1488 
1489  // Add matte image to image, for all the pixels that lies in between
1490  // the given two color
1491  void transparentChroma(const Color &colorLow_,const Color &colorHigh_);
1492 
1493  // Creates a horizontal mirror image by reflecting the pixels around the
1494  // central y-axis while rotating them by 90 degrees.
1495  void transpose(void);
1496 
1497  // Creates a vertical mirror image by reflecting the pixels around the
1498  // central x-axis while rotating them by 270 degrees.
1499  void transverse(void);
1500 
1501  // Trim edges that are the background color from the image
1502  void trim(void);
1503 
1504  // Returns the unique colors of an image.
1505  Image uniqueColors(void) const;
1506 
1507  // Replace image with a sharpened version of the original image
1508  // using the unsharp mask algorithm.
1509  // radius_
1510  // the radius of the Gaussian, in pixels, not counting the
1511  // center pixel.
1512  // sigma_
1513  // the standard deviation of the Gaussian, in pixels.
1514  // amount_
1515  // the percentage of the difference between the original and
1516  // the blur image that is added back into the original.
1517  // threshold_
1518  // the threshold in pixels needed to apply the diffence amount.
1519  void unsharpmask(const double radius_,const double sigma_,
1520  const double amount_,const double threshold_);
1521  void unsharpmaskChannel(const ChannelType channel_,const double radius_,
1522  const double sigma_,const double amount_,const double threshold_);
1523 
1524  // Softens the edges of the image in vignette style.
1525  void vignette(const double radius_=0.0,const double sigma_=1.0,
1526  const ssize_t x_=0,const ssize_t y_=0);
1527 
1528  // Map image pixels to a sine wave
1529  void wave(const double amplitude_=25.0,const double wavelength_=150.0);
1530 
1531  // Removes noise from the image using a wavelet transform.
1532  void waveletDenoise(const double threshold_,const double softness_);
1533 
1534  // Forces all pixels above the threshold into white while leaving all
1535  // pixels at or below the threshold unchanged.
1536  void whiteThreshold(const std::string &threshold_);
1537  void whiteThresholdChannel(const ChannelType channel_,
1538  const std::string &threshold_);
1539 
1540  // Write single image frame to in-memory BLOB, with optional
1541  // format and adjoin parameters.
1542  void write(Blob *blob_);
1543  void write(Blob *blob_,const std::string &magick_);
1544  void write(Blob *blob_,const std::string &magick_,const size_t depth_);
1545 
1546  // Write single image frame to an array of pixels with storage
1547  // type specified by user (DispatchImage), e.g.
1548  // image.write( 0, 0, 640, 1, "RGB", 0, pixels );
1549  void write(const ::ssize_t x_,const ::ssize_t y_,const size_t columns_,
1550  const size_t rows_,const std::string& map_,const StorageType type_,
1551  void *pixels_);
1552 
1553  // Write single image frame to a file
1554  void write(const std::string &imageSpec_);
1555 
1556  // Transfers one or more pixel components from the image pixel
1557  // cache to a buffer or file.
1558  // Used to support image encoders.
1559  void writePixels(const QuantumType quantum_,unsigned char *destination_);
1560 
1561  // Zoom image to specified size.
1562  void zoom(const Geometry &geometry_);
1563 
1565  //
1566  // No user-serviceable parts beyond this point
1567  //
1569 
1570  // Construct with MagickCore::Image and default options
1571  Image(MagickCore::Image *image_);
1572 
1573  // Retrieve Image*
1574  MagickCore::Image *&image(void);
1575  const MagickCore::Image *constImage(void) const;
1576 
1577  // Retrieve ImageInfo*
1578  MagickCore::ImageInfo *imageInfo(void);
1579  const MagickCore::ImageInfo *constImageInfo(void) const;
1580 
1581  // Retrieve Options*
1582  Options *options(void);
1583  const Options *constOptions(void) const;
1584 
1585  // Retrieve QuantizeInfo*
1586  MagickCore::QuantizeInfo *quantizeInfo(void);
1587  const MagickCore::QuantizeInfo *constQuantizeInfo(void) const;
1588 
1589  // Prepare to update image (copy if reference > 1)
1590  void modifyImage(void);
1591 
1592  // Replace current image (reference counted)
1593  MagickCore::Image *replaceImage(MagickCore::Image *replacement_);
1594 
1595  // Test for ImageMagick error and throw exception if error
1596  void throwImageException(void) const;
1597 
1598  private:
1599 
1600  void read(MagickCore::Image *image,
1601  MagickCore::ExceptionInfo *exceptionInfo);
1602 
1603  void floodFill(const ssize_t x_,const ssize_t y_,
1604  const Magick::Image *fillPattern_,const Color &fill_,
1605  const MagickCore::PixelPacket *target,const bool invert_);
1606 
1607  ImageRef *_imgRef;
1608  };
1609 
1610 } // end of namespace Magick
1611 
1612 //
1613 // Inlines
1614 //
1615 
1616 inline Magick::ClassType Magick::Image::classType(void) const
1617 {
1618  return static_cast<Magick::ClassType>(constImage()->storage_class);
1619 }
1620 
1621 inline size_t Magick::Image::columns(void) const
1622 {
1623  return constImage()->columns;
1624 }
1625 
1626 inline void Magick::Image::lineWidth(const double lineWidth_)
1627 {
1628  strokeWidth(lineWidth_);
1629 }
1630 inline double Magick::Image::lineWidth(void) const
1631 {
1632  return strokeWidth();
1633 }
1634 
1636 {
1637  reduceNoise(3.0);
1638 }
1639 
1640 inline size_t Magick::Image::rows(void) const
1641 {
1642  return constImage()->rows;
1643 }
1644 
1645 #endif // Magick_Image_header
ImageChannelStatistics blue
Definition: Image.h:82
MagickPPExport const char * borderGeometryDefault
Definition: Image.cpp:33
ImageChannelStatistics green
Definition: Image.h:81
MagickPPExport const char * raiseGeometryDefault
Definition: Image.cpp:35
ClassType classType(void) const
Definition: Image.h:1616
void reduceNoise(void)
Definition: Image.h:1635
size_t columns(void) const
Definition: Image.h:1621
ImageChannelStatistics red
Definition: Image.h:80
#define MagickPPExport
Definition: Include.h:255
const MagickCore::Image * constImage(void) const
Definition: Image.cpp:5028
MagickPPExport const char * frameGeometryDefault
Definition: Image.cpp:34
double lineWidth(void) const
Definition: Image.h:1630
class MagickPPExport Image
Definition: Drawable.h:647
Definition: Blob.h:15
size_t rows(void) const
Definition: Image.h:1640
ImageChannelStatistics opacity
Definition: Image.h:83