diff options
| -rw-r--r-- | dmagick/Image.d | 51 | ||||
| -rw-r--r-- | dmagick/Options.d | 17 |
2 files changed, 67 insertions, 1 deletions
diff --git a/dmagick/Image.d b/dmagick/Image.d index 87cf0fd..77183a9 100644 --- a/dmagick/Image.d +++ b/dmagick/Image.d @@ -2108,6 +2108,27 @@ class Image } /** + * 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. /** diff --git a/dmagick/Options.d b/dmagick/Options.d index 05d957b..6e6ae6b 100644 --- a/dmagick/Options.d +++ b/dmagick/Options.d @@ -1113,6 +1113,22 @@ class Options } /** + * The basic strategy of dithering is to trade intensity resolution for + * spatial resolution by averaging the intensities of several neighboring + * pixels. Images which suffer from severe contouring when reducing + * colors can be improved with this option. + */ + void quantizeDitherMethod(DitherMethod method) + { + quantizeInfo.dither_method = method; + } + ///ditto + DitherMethod quantizeDitherMethod() + { + return quantizeInfo.dither_method; + } + + /** * Depth of the quantization color classification tree. * Values of 0 or 1 allow selection of the optimal tree _depth * for the color reduction algorithm. Values between 2 and 8 @@ -1130,5 +1146,4 @@ class Options //MagickBooleanType measure_error; //size_t signature; - //DitherMethod dither_method; } |
