pub struct Polygons { /* private fields */ }Expand description
A polygon container for storing object outlines
The polygons are stored in (N, 2, K) format where N is the number of polygons for a given mask/image, 2 is xy, and K specifies the number of points in each polygon. Note that the polygons can be ragged so K can vary for each polygon.
§Examples
use pineapple_core::im::Polygons;
let data: Vec<Vec<[f32; 2]>> = vec![
vec![[0., 1.], [1., 1.], [1., 2.], [0., 2.]],
vec![[1., 1.], [2., 1.], [2., 2.], [1., 2.]],
];
let polygons = Polygons::new(data);
assert!(polygons.is_ok());
let data: Vec<Vec<[f32; 2]>> = vec![
vec![[0., 1.], [1., 1.]],
vec![[1., 1.], [2., 1.]],
];
let polygons = Polygons::new(data);
assert!(polygons.is_err());Implementations§
Source§impl Polygons
impl Polygons
Sourcepub fn as_points(&self) -> &Vec<Vec<[f32; 2]>>
pub fn as_points(&self) -> &Vec<Vec<[f32; 2]>>
Return a reference to the underlying polygon point
Sourcepub fn to_bounding_boxes(&self) -> Result<BoundingBoxes, PineappleError>
pub fn to_bounding_boxes(&self) -> Result<BoundingBoxes, PineappleError>
Convert the polygons to bounding boxes
Source§impl Polygons
impl Polygons
Sourcepub fn dedup_points(&mut self)
pub fn dedup_points(&mut self)
Deduplicate redundant points in each polygon
Sourcepub fn order_points(&mut self)
pub fn order_points(&mut self)
Order the points in each polygon
Sourcepub fn resample_points(&mut self, n: usize)
pub fn resample_points(&mut self, n: usize)
Resample each polygon to an equal number of equidistant points
Sourcepub fn remove(&mut self, indices: &[usize])
pub fn remove(&mut self, indices: &[usize])
Remove polygons based on an array of pre-sorted (ascending) indices
Sourcepub fn descriptors(&mut self) -> Vec<[f32; 23]>
pub fn descriptors(&mut self) -> Vec<[f32; 23]>
Compute morphological measurements from polygons
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Polygons
impl RefUnwindSafe for Polygons
impl Send for Polygons
impl Sync for Polygons
impl Unpin for Polygons
impl UnwindSafe for Polygons
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.