pub fn open(image: &GrayImage, norm: Norm, k: u8) -> GrayImage
Expand description
Erosion followed by dilation.
See the erode
and dilate
documentation for definitions of dilation and erosion.
ยงExamples
use imageproc::morphology::open;
use imageproc::distance_transform::Norm;
// Isolated regions of foreground pixels are removed.
let cross = gray_image!(
0, 0, 0, 0, 0;
0, 0, 255, 0, 0;
0, 255, 255, 255, 0;
0, 0, 255, 0, 0;
0, 0, 0, 0, 0
);
let opened_cross = gray_image!(
0, 0, 0, 0, 0;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0
);
assert_pixels_eq!(
open(&cross, Norm::LInf, 1),
opened_cross
);
// Large blocks survive unchanged.
let blob = gray_image!(
0, 0, 0, 0, 0;
0, 255, 255, 255, 0;
0, 255, 255, 255, 0;
0, 255, 255, 255, 0;
0, 0, 0, 0, 0
);
assert_pixels_eq!(
open(&blob, Norm::LInf, 1),
blob
);