Skip to main content

AdaptiveLayoutParams

Struct AdaptiveLayoutParams 

Source
pub struct AdaptiveLayoutParams {
    pub xy_cut_min_gap_ratio: f32,
    pub word_gap_threshold: f32,
    pub line_gap_threshold: f32,
    pub column_gap_threshold: f32,
    pub xy_cut_max_depth: u32,
    pub xy_cut_min_region_size: f32,
    pub gaussian_sigma: f32,
}
Expand description

Adaptive layout parameters computed from document properties.

These parameters are used by layout algorithms (XY-Cut, clustering, etc.) and are computed as ratios/multiples of measured document properties rather than fixed absolute values.

Fields§

§xy_cut_min_gap_ratio: f32

Minimum gap for XY-Cut split (as ratio of page dimension).

Typical: 0.05 (5% of page width/height)

§word_gap_threshold: f32

Word clustering threshold (horizontal gap between characters).

Gaps larger than this likely indicate word boundaries. Computed as multiple of median character width.

§line_gap_threshold: f32

Line clustering threshold (vertical gap between characters).

Gaps larger than this likely indicate line boundaries. Computed as multiple of median line spacing.

§column_gap_threshold: f32

Column gap threshold (minimum gap between columns).

Computed as multiple of median font size.

§xy_cut_max_depth: u32

Maximum recursion depth for XY-Cut.

§xy_cut_min_region_size: f32

Minimum region size for XY-Cut split (in PDF units).

Regions smaller than this won’t be split further.

§gaussian_sigma: f32

Gaussian smoothing sigma for projection profiles.

Controls noise reduction in XY-Cut valley detection. Adaptive based on layout density:

  • Dense layouts (short lines): Low sigma (0.5) for sharp peaks
  • Medium layouts: Medium sigma (1.5) balances noise vs detail
  • Sparse layouts (long lines): High sigma (2.5) for broad valleys

Meunier (ICDAR 2005) recommends σ=2.0 as baseline.

Implementations§

Source§

impl AdaptiveLayoutParams

Source

pub fn from_properties(props: &DocumentProperties) -> Self

Compute adaptive parameters from document properties.

§Arguments
  • props - Analyzed document properties
§Returns

Adaptive parameters tuned for the specific document.

§Examples
let page_bbox = Rect::new(0.0, 0.0, 612.0, 792.0);
let props = DocumentProperties::analyze(&chars, page_bbox)?;
let params = AdaptiveLayoutParams::from_properties(&props);

println!("Word gap threshold: {:.1}", params.word_gap_threshold);
println!("Column gap threshold: {:.1}", params.column_gap_threshold);
Source

pub fn default_for_letter_pdf() -> Self

Create default parameters for when document analysis is unavailable.

These are reasonable defaults for typical Letter-sized PDFs with 10-12pt text.

Trait Implementations§

Source§

impl Clone for AdaptiveLayoutParams

Source§

fn clone(&self) -> AdaptiveLayoutParams

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AdaptiveLayoutParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Ungil for T
where T: Send,