pub fn remove_hypotenuse_in_place<T>(
contours: &mut Vec<Contour<T>>,
max_aspect_ratio: f32,
border_type: Option<BorderType>,
)Expand description
Filters a vector of contours in-place based on shape properties.
This function removes contours that do not meet the specified criteria. The filtering is done based on two optional conditions:
- Border Type: If
border_typeisSome, only contours with a matchingborder_typeare kept. - Aspect Ratio: Contours whose minimum area bounding rectangle has an
aspect ratio (long side / short side) greater than or equal to
max_aspect_ratioare removed.
§Arguments
contours: A mutable reference to aVec<Contour>to be filtered.max_aspect_ratio: The maximum allowed aspect ratio. Must be a positive value.border_type: AnOption<BorderType>to filter contours by their border type.
§Examples
use imageproc::contours::{Contour, BorderType};
use imageproc::point::Point;
use image_debug_utils::contours::remove_hypotenuse_in_place;
let mut contours = vec![
// Square, aspect ratio 1.0 (keep)
Contour {
parent: None,
border_type: BorderType::Outer,
points: vec![Point::new(0,0), Point::new(10,0), Point::new(10,10), Point::new(0,10)]
},
// Thin strip, high aspect ratio > 5.0 (remove)
Contour {
parent: None,
border_type: BorderType::Outer,
points: vec![Point::new(0,0), Point::new(100,0), Point::new(100,2), Point::new(0,2)]
}
];
remove_hypotenuse_in_place(&mut contours, 5.0, None);
assert_eq!(contours.len(), 1);§Panics
§Type Parameters
T: The numeric type of the point coordinates. Must implementNum,Copy,AsPrimitive<f32>, and be compatible withmin_area_rect.
§Panics
Panics if max_aspect_ratio is not a positive finite number.