[][src]Function imageproc::morphology::dilate

pub fn dilate(image: &GrayImage, norm: Norm, k: u8) -> GrayImage

Sets all pixels within distance k of a foreground pixel to white.

A pixel is treated as belonging to the foreground if it has non-zero intensity.

Examples

use image::GrayImage;
use imageproc::morphology::dilate;
use imageproc::distance_transform::Norm;

let image = gray_image!(
    0,   0,   0,   0,   0;
    0,   0,   0,   0,   0;
    0,   0, 255,   0,   0;
    0,   0,   0,   0,   0;
    0,   0,   0,   0,   0
);

// L1 norm
let l1_dilated = 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
);

assert_pixels_eq!(dilate(&image, Norm::L1, 1), l1_dilated);

// LInf norm
let linf_dilated = 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!(dilate(&image, Norm::LInf, 1), linf_dilated);