pub fn threshold(image: &GrayImage, threshold: u8, threshold_type: ThresholdType) -> GrayImage {
    let mut out = image.clone();
    threshold_mut(&mut out, threshold, threshold_type);
    out
}
Applies a threshold to each pixel in a grayscale image. The action taken depends on
`threshold_type` - see [`ThresholdType`].

# Examples
```
# extern crate image;
# #[macro_use]
# extern crate imageproc;
# fn main() {
use imageproc::contrast::{threshold, ThresholdType};

let image = gray_image!(
10, 80, 20;
50, 90, 70);

// Binary threshold
let threshold_binary = gray_image!(
0, 255,   0;
0, 255, 255);

assert_pixels_eq!(
threshold(&image, 50, ThresholdType::Binary),
threshold_binary);

// Inverted binary threshold
let threshold_binary_inverted = gray_image!(
255,   0, 255;
255,   0,   0);

assert_pixels_eq!(
threshold(&image, 50, ThresholdType::BinaryInverted),
threshold_binary_inverted);

// Truncate
let threshold_truncate = gray_image!(
10, 50, 20;
50, 50, 50);

assert_pixels_eq!(
threshold(&image, 50, ThresholdType::Truncate),
threshold_truncate);

// To zero
let threshold_to_zero = gray_image!(
10,  0, 20;
50,  0,  0);

assert_pixels_eq!(
threshold(&image, 50, ThresholdType::ToZero),
threshold_to_zero);

// To zero inverted
let threshold_to_zero_inverted = gray_image!(
0, 80,  0;
0, 90, 70);

assert_pixels_eq!(
threshold(&image, 50, ThresholdType::ToZeroInverted),
threshold_to_zero_inverted);
# }
```
src/contrast.rs