Skip to content

Commit

Permalink
Merge pull request #117 from yoghurt-x86/master
Browse files Browse the repository at this point in the history
Added MagickNormalizeImage and MagickOrderedDitherImage
  • Loading branch information
nlfiedler authored Apr 18, 2024
2 parents a2d2a5f + 7adf198 commit 7571baa
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/wand/magick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,43 @@ impl MagickWand {
}
}

//MagickNormalizeImage enhances the contrast of a color image by adjusting the pixels color
//to span the entire range of colors available
pub fn normalize_image(
&self,
) -> Result<()> {
let result = unsafe {
bindings::MagickNormalizeImage(
self.wand,
)
};
match result {
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(MagickError("Failed to apply contrast stretch to image")),
}
}

//MagickOrderedDitherImage performs an ordered dither based on a number of pre-defined
//dithering threshold maps, but over multiple intensity levels, which can be different for
//different channels, according to the input arguments.
pub fn ordered_dither_image(
&self,
threshold_map: &str,
) -> Result<()> {
let c_threshold_map = CString::new(threshold_map).unwrap();

let result = unsafe {
bindings::MagickOrderedDitherImage(
self.wand,
c_threshold_map.as_ptr(),
)
};
match result {
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(MagickError("Failed to apply ordered dither to image")),
}
}

/// Apply sigmoidal contrast to the image
/// Midpoint is a number in range [0, 1]
pub fn sigmoidal_contrast_image(
Expand Down

0 comments on commit 7571baa

Please sign in to comment.