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