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