Chain together components for Canny edge detection
This commit is contained in:
1 parent
0c44ce6396
commit
c95d05f1ac
2 files changed
+24
No files matched your search
@@ -1,3 +1,5 @@
|
||||
pub mod canny;
|
||||
pub mod sobel;
|
||||
|
||||
pub use canny::canny;
|
||||
pub use sobel::sobel;
|
||||
@@ -0,0 +1,22 @@
|
||||
mod double_threshold;
|
||||
mod gradient_threshold;
|
||||
mod hysteresis;
|
||||
|
||||
use double_threshold::*;
|
||||
use gradient_threshold::*;
|
||||
use hysteresis::*;
|
||||
|
||||
use crate::image::*;
|
||||
use crate::kernel::Kernel;
|
||||
use crate::*;
|
||||
|
||||
pub fn canny(img: Image<Luminance>) -> Image<Luminance> {
|
||||
let blurred = kernel::gaussian::<5>(2.0).convolve(&img);
|
||||
let sobel = filter::sobel(blurred);
|
||||
let maxima = gradient_threshold(sobel);
|
||||
let candidates = double_threshold(maxima);
|
||||
let edges = hysteresis(candidates);
|
||||
edges.map(|p| Luminance {
|
||||
y: if p { 1.0 } else { 0.0 },
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user