pub struct SummedAreaTable {
    pub sums: Vec<u32>,
    pub width: usize,
    pub height: usize,
}
Expand description

A data structure to efficiently compute summed pixel values over regions in an image (repeatedly).

Fields§

§sums: Vec<u32>§width: usize§height: usize

Implementations§

source§

impl SummedAreaTable

source

pub fn from_color_image(image: &ColorImage) -> Self

Creates an SAT of the same size of image, where each entry (x,y) is the sum of pixel values of the block of pixels with bottom right corner at (x,y) in image.

This construction takes 1 pass through the pixels in image.

source

pub fn get_bot_right_sum(&self, x: i32, y: i32) -> u32

Returns the entry in the SAT.

If the input point is out of boundary, this function returns 0.

This is only to facilitate the implementation of other functions; avoid calling this function directly.

source

pub fn get_region_sum_top_left_bot_right( &self, top_left: PointI32, bot_right: PointI32 ) -> u32

Computes the sum of pixel values in the specified region in O(1) time.

source

pub fn get_region_sum_x_y_w_h( &self, x: usize, y: usize, w: usize, h: usize ) -> u32

Computes the sum of pixel values in the specified region in O(1) time.

source

pub fn get_region_mean_top_left_bot_right( &self, top_left: PointI32, bot_right: PointI32 ) -> f64

Computes the mean of pixel values in the specified region in O(1) time.

source

pub fn get_region_mean_x_y_w_h( &self, x: usize, y: usize, w: usize, h: usize ) -> f64

Computes the mean of pixel values in the specified region in O(1) time.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.