From c97b92e7ffbbe6cf66d48ae3919a4c17cd0448d8 Mon Sep 17 00:00:00 2001 From: 5ohue <86558263+5ohue@users.noreply.github.com> Date: Thu, 16 Nov 2023 20:41:19 +0300 Subject: [PATCH] Added sigmoidal contrast function --- src/wand/magick.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 54d4185..7922f0a 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -373,6 +373,30 @@ impl MagickWand { } } + /// Apply sigmoidal contrast to the image + /// Midpoint is a number in range [0, 1] + pub fn sigmoidal_contrast_image( + &self, + sharpen: bool, + contrast: f64, + midpoint: f64, + ) -> Result<()> { + let quantum_range = self.quantum_range()?; + + let result = unsafe { + bindings::MagickSigmoidalContrastImage( + self.wand, + sharpen.to_magick(), + contrast, + midpoint * quantum_range, + ) + }; + match result { + bindings::MagickBooleanType_MagickTrue => Ok(()), + _ => Err(MagickError("Failed to apply sigmoidal contrast to image")), + } + } + /// Extend the image as defined by the geometry, gravity, and wand background color. Set the /// (x,y) offset of the geometry to move the original wand relative to the extended wand. pub fn extend_image(&self, width: usize, height: usize, x: isize, y: isize) -> Result<()> {