Skip to content

Commit

Permalink
Merge pull request #112 from 5ohue/master
Browse files Browse the repository at this point in the history
Add sigmoidal_contrast_image
  • Loading branch information
nlfiedler authored Nov 18, 2023
2 parents 857085a + 79f511d commit a7c71e6
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/wand/magick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,31 @@ impl MagickWand {
};
match result {
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(MagickError("failed to set size of wand")),
_ => Err(MagickError("Failed to level the image")),
}
}

/// 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")),
}
}

Expand Down

0 comments on commit a7c71e6

Please sign in to comment.