From 1ddf6cf4b9f123f81cccedf9a9cd914209b10d01 Mon Sep 17 00:00:00 2001 From: Dan Norris Date: Sun, 22 Oct 2023 22:44:29 -0400 Subject: [PATCH] Add auto_threshold --- src/wand/magick.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 61877bd..54d4185 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -1017,6 +1017,17 @@ impl MagickWand { res == bindings::MagickBooleanType_MagickTrue } + /// Automatically performs threshold method to reduce grayscale data + /// down to a binary black & white image. Included algorithms are + /// Kapur, Otsu, and Triangle methods. + /// See for more information. + pub fn auto_threshold(&self, method: bindings::AutoThresholdMethod) -> Result<()> { + match unsafe { bindings::MagickAutoThresholdImage(self.wand, method) } { + bindings::MagickBooleanType_MagickTrue => Ok(()), + _ => Err(MagickError("unable to auto threshold image")), + } + } + mutations!( /// Set the image colorspace, transforming (unlike `set_image_colorspace`) image data in /// the process.