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