pub fn draw_principal_connected_components(
labelled_image: &ImageBuffer<Luma<u32>, Vec<u32>>,
n: usize,
background_color: Rgba<u8>,
) -> RgbaImageExpand description
Draws the n largest connected components with contrasting colors.
§Arguments
labelled_image- The labelled image generated by a function likeimageproc::region_labelling::connected_components.n- The number of largest components to keep and color.background_color- The color for the background and smaller, unselected components.
§Examples
use image::{ImageBuffer, Luma, Rgba};
use image_debug_utils::region_labelling::draw_principal_connected_components;
let mut labelled_image = ImageBuffer::<Luma<u32>, Vec<u32>>::new(10, 10);
// Simulate a large component (label 1) and a small one (label 2)
labelled_image.put_pixel(0, 0, Luma([1]));
labelled_image.put_pixel(0, 1, Luma([1]));
labelled_image.put_pixel(5, 5, Luma([2]));
// Keep top 1 component, use transparent black for background
let colored = draw_principal_connected_components(&labelled_image, 1, Rgba([0, 0, 0, 0]));§Returns
An RgbaImage where the n largest components are colored and the rest is background.