Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ many computer vision applications.

```rust
let source_image = image::open("testdata/line-simple.png")
.expect("failed to read image")
.to_luma();
.expect("failed to read image");

let detection = edge_detection::canny(
source_image,
1.2, // sigma
Expand Down
7 changes: 4 additions & 3 deletions src/edge.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use image::{self, GenericImageView};
use image::{self, GenericImageView,DynamicImage, GrayImage};
use rayon::prelude::*;
use std::f32::consts::*;
use std::*;
Expand Down Expand Up @@ -193,13 +193,14 @@ impl Edge {
/// * If either `strong_threshold` or `weak_threshold` are outisde the range of 0 to 1 inclusive.
/// * If `strong_threshold` is less than `weak_threshold`.
/// * If `image` contains no pixels (either it's width or height is 0).
pub fn canny<T: Into<image::GrayImage>>(
pub fn canny<T: Into<DynamicImage>>(
image: T,
sigma: f32,
strong_threshold: f32,
weak_threshold: f32,
) -> Detection {
let gs_image = image.into();
let dyn_img: DynamicImage = image.into();
let gs_image: GrayImage = dyn_img.into_luma8();
assert!(gs_image.width() > 0);
assert!(gs_image.height() > 0);
let edges = detect_edges(&gs_image, sigma);
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
//!
//! ```
//! let source_image = image::open("testdata/line-simple.png")
//! .expect("failed to read image")
//! .to_luma8();
//! .expect("failed to read image");
//!
//! let detection = edge_detection::canny(
//! source_image,
//! 1.2, // sigma
Expand Down
Loading