Skip to main content

GroupCropAnalyzer

Struct GroupCropAnalyzer 

Source
pub struct GroupCropAnalyzer;
Expand description

Group crop region analyzer using Tukey fence for outlier removal

Implementations§

Source§

impl GroupCropAnalyzer

Source

pub fn decide_group_crop_region( bounding_boxes: &[PageBoundingBox], ) -> GroupCropRegion

Decide the optimal crop region for a group of pages using Tukey fence

Algorithm:

  1. Collect bounding boxes from all pages
  2. Calculate Q1, Q3, IQR for each edge (left, top, right, bottom)
  3. Apply Tukey fence (k=1.5) to identify outliers
  4. Remove pages where ANY edge is an outlier
  5. Calculate median of inliers for final crop region
Source

pub fn unify_odd_even_regions( bounding_boxes: &[PageBoundingBox], ) -> UnifiedCropRegions

Unify crop regions for odd and even page groups

Source

pub fn unify_and_expand_regions( bounding_boxes: &[PageBoundingBox], margin_percent: u32, max_width: u32, max_height: u32, ) -> UnifiedCropRegions

Unify crop regions with Y coordinate unification, margin expansion, and size limits

This function implements the full C# algorithm:

  1. Calculate separate crop regions for odd/even pages
  2. Unify Y coordinates (use min top, max bottom)
  3. Expand width/height by margin_percent
  4. Center the expansion
  5. Clamp to image bounds
Source

pub fn detect_text_bounding_box( image_path: &Path, background_threshold: u8, ) -> Result<ContentRect>

Detect text bounding box from image using edge detection

This function detects the content area by finding non-background pixels and returning the minimal bounding box.

Source

pub fn detect_all_bounding_boxes( image_paths: &[PathBuf], background_threshold: u8, ) -> Vec<PageBoundingBox>

Detect bounding boxes for all pages in parallel

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.