`imageproc::edges::canny` panics when thresholds are both 0.0
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 979
- Forks
- 181
- Avg merge
- 5m
- Merged PRs (30d)
- 4
Description
let image = image::GrayImage::new(10, 10);
let edges = imageproc::edges::canny(&image, 0.0, 0.0);
result
thread 'main' panicked at /home/jyi/.cargo/git/checkouts/imageproc-15e7df7e968bb8fb/ab9e19c/src/edges.rs:135:26:
attempt to subtract with overflow
stack backtrace:
0: rust_begin_unwind
at /rustc/a4cb3c831823d9baa56c3d90514b75b2660116fa/library/std/src/panicking.rs:681:5
1: core::panicking::panic_fmt
at /rustc/a4cb3c831823d9baa56c3d90514b75b2660116fa/library/core/src/panicking.rs:75:14
2: core::panicking::panic_const::panic_const_sub_overflow
at /rustc/a4cb3c831823d9baa56c3d90514b75b2660116fa/library/core/src/panicking.rs:178:21
3: imageproc::edges::hysteresis
4: imageproc::edges::canny
at /home/jyi/.cargo/git/checkouts/imageproc-15e7df7e968bb8fb/ab9e19c/src/edges.rs:52:5
5: vic::baka
at ./src/main.rs:1021:17
6: vic::main
at ./src/main.rs:1030:5
7: core::ops::function::FnOnce::call_once
at /home/jyi/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/edges.rs at canny and the hysteresis code around line 135, then run the supplied 10x10 GrayImage example with both thresholds set to 0.0. Trace how the threshold values reach the subtraction that overflows and confirm the intended zero-threshold behavior with maintainers; done means the reproduction no longer panics and the behavior is covered by an appropriate regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100