Skip to content

Commit

Permalink
rename arguments back and remove deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
cospectrum committed May 27, 2024
1 parent d2b8c77 commit f2c133a
Showing 1 changed file with 5 additions and 41 deletions.
46 changes: 5 additions & 41 deletions src/gradients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use crate::map::{ChannelMap, WithChannel};
use image::{GenericImage, GenericImageView, GrayImage, Luma, Pixel};
use itertools::multizip;

/// A special version of `gradient()` function for greyscale images which doesn't require giving a
/// A special version of `gradient()` function for grayscale images which doesn't require giving a
/// pixel mapping function.
pub fn gradients_greyscale<P, F, Q>(
pub fn gradients_grayscale<P, F, Q>(
image: &GrayImage,
kernel1: Kernel<i32>,
kernel2: Kernel<i32>,
horizontal_kernel: Kernel<i32>,
vertical_kernel: Kernel<i32>,
) -> Image<Luma<u16>> {
gradients(image, kernel1, kernel2, |p| p)
gradients(image, horizontal_kernel, vertical_kernel, |p| p)
}

// TODO: Returns directions as well as magnitudes.
Expand Down Expand Up @@ -157,69 +157,41 @@ fn gradient_magnitude(dx: f32, dy: f32) -> u16 {

/// Convolves an image with the [`HORIZONTAL_SOBEL`](static.HORIZONTAL_SOBEL.html)
/// kernel to detect horizontal gradients.
#[deprecated(
since = "0.25.0",
note = "users should instead use `filter_clamped(image, kernel::SOBEL_HORIZONTAL_3X3)` which is more flexible and explicit"
)]
pub fn horizontal_sobel(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped(image, kernel::SOBEL_HORIZONTAL_3X3)
}

/// Convolves an image with the [`VERTICAL_SOBEL`](static.VERTICAL_SOBEL.html)
/// kernel to detect vertical gradients.
#[deprecated(
since = "0.25.0",
note = "users should instead use `filter_clamped(image, kernel::SOBEL_VERTICAL_3X3)` which is more flexible and explicit"
)]
pub fn vertical_sobel(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped(image, kernel::SOBEL_VERTICAL_3X3)
}

/// Convolves an image with the [`HORIZONTAL_SCHARR`](static.HORIZONTAL_SCHARR.html)
/// kernel to detect horizontal gradients.
#[deprecated(
since = "0.25.0",
note = "users should instead use `filter_clamped(image, kernel::SCHARR_HORIZONTAL_3X3)` which is more flexible and explicit"
)]
pub fn horizontal_scharr(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped(image, kernel::SCHARR_HORIZONTAL_3X3)
}

/// Convolves an image with the [`VERTICAL_SCHARR`](static.VERTICAL_SCHARR.html)
/// kernel to detect vertical gradients.
#[deprecated(
since = "0.25.0",
note = "users should instead use `filter_clamped(image, kernel::SCHARR_VERTICAL_3X3)` which is more flexible and explicit"
)]
pub fn vertical_scharr(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped(image, kernel::SCHARR_VERTICAL_3X3)
}

/// Convolves an image with the [`HORIZONTAL_PREWITT`](static.HORIZONTAL_PREWITT.html)
/// kernel to detect horizontal gradients.
#[deprecated(
since = "0.25.0",
note = "users should instead use `filter_clamped(image, kernel::PREWITT_HORIZONTAL_3X3)` which is more flexible and explicit"
)]
pub fn horizontal_prewitt(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped(image, kernel::PREWITT_HORIZONTAL_3X3)
}

/// Convolves an image with the [`VERTICAL_PREWITT`](static.VERTICAL_PREWITT.html)
/// kernel to detect vertical gradients.
#[deprecated(
since = "0.25.0",
note = "users should instead use `filter_clamped(image, kernel::PREWITT_VERTICAL_3X3)` which is more flexible and explicit"
)]
pub fn vertical_prewitt(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped(image, kernel::PREWITT_VERTICAL_3X3)
}

/// Returns the magnitudes of gradients in an image using Sobel filters.
#[deprecated(
since = "0.25.0",
note = "users should instead use `gradients_greyscale(image, kernel::SOBEL_HORIZONTAL_3X3, Kernel::SOBEL_VERTICAL_3X3)` which is more flexible and explicit"
)]
pub fn sobel_gradients(image: &GrayImage) -> Image<Luma<u16>> {
gradients(
image,
Expand All @@ -230,10 +202,6 @@ pub fn sobel_gradients(image: &GrayImage) -> Image<Luma<u16>> {
}

/// Returns the magnitudes of gradients in an image using Prewitt filters.
#[deprecated(
since = "0.25.0",
note = "users should instead use `gradients_greyscale(image, kernel::PREWITT_HORIZONTAL_3X3, Kernel::PREWITT_VERTICAL_3X3)` which is more flexible and explicit"
)]
pub fn prewitt_gradients(image: &GrayImage) -> Image<Luma<u16>> {
gradients(
image,
Expand Down Expand Up @@ -309,10 +277,6 @@ pub fn prewitt_gradients(image: &GrayImage) -> Image<Luma<u16>> {
/// max_gradient
/// );
/// # }
#[deprecated(
since = "0.25.0",
note = "users should instead use `gradients(image, kernel::SOBEL_HORIZONTAL_3X3, Kernel::SOBEL_VERTICAL_3X3, f)` which is more flexible and explicit"
)]
pub fn sobel_gradient_map<P, F, Q>(image: &Image<P>, f: F) -> Image<Q>
where
P: Pixel<Subpixel = u8> + WithChannel<u16> + WithChannel<i16>,
Expand Down

0 comments on commit f2c133a

Please sign in to comment.