pub struct GroupCropAnalyzer;Expand description
Group crop region analyzer using Tukey fence for outlier removal
Implementations§
Source§impl GroupCropAnalyzer
impl GroupCropAnalyzer
Sourcepub fn decide_group_crop_region(
bounding_boxes: &[PageBoundingBox],
) -> GroupCropRegion
pub fn decide_group_crop_region( bounding_boxes: &[PageBoundingBox], ) -> GroupCropRegion
Decide the optimal crop region for a group of pages using Tukey fence
Algorithm:
- Collect bounding boxes from all pages
- Calculate Q1, Q3, IQR for each edge (left, top, right, bottom)
- Apply Tukey fence (k=1.5) to identify outliers
- Remove pages where ANY edge is an outlier
- Calculate median of inliers for final crop region
Sourcepub fn unify_odd_even_regions(
bounding_boxes: &[PageBoundingBox],
) -> UnifiedCropRegions
pub fn unify_odd_even_regions( bounding_boxes: &[PageBoundingBox], ) -> UnifiedCropRegions
Unify crop regions for odd and even page groups
Sourcepub fn unify_and_expand_regions(
bounding_boxes: &[PageBoundingBox],
margin_percent: u32,
max_width: u32,
max_height: u32,
) -> UnifiedCropRegions
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:
- Calculate separate crop regions for odd/even pages
- Unify Y coordinates (use min top, max bottom)
- Expand width/height by margin_percent
- Center the expansion
- Clamp to image bounds
Sourcepub fn detect_text_bounding_box(
image_path: &Path,
background_threshold: u8,
) -> Result<ContentRect>
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.
Sourcepub fn detect_all_bounding_boxes(
image_paths: &[PathBuf],
background_threshold: u8,
) -> Vec<PageBoundingBox>
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§
impl Freeze for GroupCropAnalyzer
impl RefUnwindSafe for GroupCropAnalyzer
impl Send for GroupCropAnalyzer
impl Sync for GroupCropAnalyzer
impl Unpin for GroupCropAnalyzer
impl UnwindSafe for GroupCropAnalyzer
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> 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 more