From bd91f8f1e8aedbb8d892463cb67ec66ffce55458 Mon Sep 17 00:00:00 2001 From: Mike Wey Date: Wed, 13 Jul 2011 23:33:25 +0200 Subject: Add randomThreshold, reduceNoise and remap --- dmagick/Image.d | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'dmagick/Image.d') diff --git a/dmagick/Image.d b/dmagick/Image.d index 87cf0fd..77183a9 100644 --- a/dmagick/Image.d +++ b/dmagick/Image.d @@ -2107,6 +2107,27 @@ class Image DMagickException.throwException(&(imageRef.exception)); } + /** + * Changes the value of individual pixels based on the intensity of + * each pixel compared to a random threshold. The result is a + * low-contrast, two color image. + * + * Params: + * thresholds = A geometry string containing LOWxHIGH thresholds. + * The string is in the form `XxY'. The Y value may be + * omitted, in which case it is assigned the value + * QuantumRange-X. If an % appears in the string then + * the values are assumed to be percentages of + * QuantumRange. If the string contains 2x2, 3x3, or + * 4x4, then an ordered dither of order 2, 3, or 4 + * will be performed instead. + * channel = The affected channels. + */ + void randomThreshold(Geometry thresholds, ChannelType channel = ChannelType.DefaultChannels) + { + RandomThresholdImageChannel(imageRef, channel, toStringz(thresholds.toString()), DMagickExceptionInfo()); + } + /** * Read an Image by reading from the file or * URL specified by filename. @@ -2217,6 +2238,36 @@ class Image imageRef = ImageRef(image); } + /** + * Smooths the contours of an image while still preserving edge + * information. The algorithm works by replacing each pixel with its + * neighbor closest in value. + * + * Params: + * radius = A neighbor is defined by radius. Use a radius of 0 + * and reduceNoise selects a suitable radius for you. + */ + void reduceNoise(size_t radius = 0) + { + MagickCoreImage* image = + StatisticImage(imageRef, StatisticType.NonpeakStatistic, radius, radius, DMagickExceptionInfo()); + + imageRef = ImageRef(image); + } + + /** + * Reduce the number of colors in img to the colors used by reference. + * If a dither method is set then the given colors are dithered over + * the image as necessary, otherwise the closest color + * (in RGB colorspace) is selected to replace that pixel in the image. + */ + void remap(Image reference) + { + RemapImage(options.quantizeInfo, imageRef, reference.imageRef); + + DMagickException.throwException(&(imageRef.exception)); + } + //TODO: set process monitor. /** -- cgit v1.2.3