Skip to content

Commit

Permalink
replaced docs with the doc-macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed May 25, 2024
1 parent 9c0304e commit 1fb2e77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
27 changes: 3 additions & 24 deletions src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,8 @@ where

out
}

#[cfg(feature = "rayon")]
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
/// Returns 2d correlation of an image. Intermediate calculations are performed
/// at type K, and the results converted to pixel Q via f. Pads by continuity.
/// This version uses rayon to parallelize the computation.
#[doc = generate_parallel_doc_comment!("filter")]
pub fn filter_parallel<P, K, F, Q>(image: &Image<P>, kernel: Kernel<K>, f: F) -> Image<Q>
where
P: Pixel + Sync,
Expand Down Expand Up @@ -279,13 +275,8 @@ where
{
filter(image, kernel, S::clamp)
}

/// Returns 2d correlation of an image with a 3x3 row-major kernel. Intermediate calculations are
/// performed at type K, and the results clamped to subpixel type S. Pads by continuity.
/// This version uses rayon to parallelize the computation.
#[must_use = "the function does not modify the original image"]
#[cfg(feature = "rayon")]
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
#[doc = generate_parallel_doc_comment!("filter_clamped")]
pub fn filter_clamped_parallel<P, K, S>(
image: &Image<P>,
kernel: Kernel<K>,
Expand Down Expand Up @@ -529,19 +520,8 @@ where
pub fn laplacian_filter(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped(image, kernel::FOUR_LAPLACIAN_3X3)
}

/// Calculates the Laplacian of an image.
/// This version uses rayon to parallelize the computation.
///
/// The Laplacian is computed by filtering the image using the following 3x3 kernel:
/// ```notrust
/// 0, 1, 0,
/// 1, -4, 1,
/// 0, 1, 0
/// ```
#[must_use = "the function does not modify the original image"]
#[cfg(feature = "rayon")]
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
pub fn laplacian_filter_parallel(image: &GrayImage) -> Image<Luma<i16>> {
filter_clamped_parallel(image, kernel::FOUR_LAPLACIAN_3X3)
}
Expand Down Expand Up @@ -1058,8 +1038,7 @@ mod benches {
], 3, 3);

b.iter(|| {
let filtered: Image<Luma<i16>> =
filter_clamped_parallel::<_, _, i16>(&image, kernel);
let filtered: Image<Luma<i16>> = filter_clamped_parallel::<_, _, i16>(&image, kernel);
black_box(filtered);
});
}
Expand Down
5 changes: 1 addition & 4 deletions src/filter/sharpen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ pub fn sharpen3x3(image: &GrayImage) -> GrayImage {
let identity_minus_laplacian = Kernel::new(&[0, -1, 0, -1, 5, -1, 0, -1, 0], 3, 3);
filter_clamped(image, identity_minus_laplacian)
}

/// Sharpens a grayscale image by applying a 3x3 approximation to the Laplacian.
/// This version uses rayon to parallelize the computation.
#[must_use = "the function does not modify the original image"]
#[cfg(feature = "rayon")]
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
#[doc = generate_parallel_doc_comment!("sharpen3x3")]
pub fn sharpen3x3_parallel(image: &GrayImage) -> GrayImage {
let identity_minus_laplacian = Kernel::new(&[0, -1, 0, -1, 5, -1, 0, -1, 0], 3, 3);
filter_clamped_parallel(image, identity_minus_laplacian)
Expand Down

0 comments on commit 1fb2e77

Please sign in to comment.