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: f32Minimum gap for XY-Cut split (as ratio of page dimension).
Typical: 0.05 (5% of page width/height)
word_gap_threshold: f32Word clustering threshold (horizontal gap between characters).
Gaps larger than this likely indicate word boundaries. Computed as multiple of median character width.
line_gap_threshold: f32Line clustering threshold (vertical gap between characters).
Gaps larger than this likely indicate line boundaries. Computed as multiple of median line spacing.
column_gap_threshold: f32Column gap threshold (minimum gap between columns).
Computed as multiple of median font size.
xy_cut_max_depth: u32Maximum recursion depth for XY-Cut.
xy_cut_min_region_size: f32Minimum region size for XY-Cut split (in PDF units).
Regions smaller than this won’t be split further.
gaussian_sigma: f32Gaussian 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
impl AdaptiveLayoutParams
Sourcepub fn from_properties(props: &DocumentProperties) -> Self
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);Sourcepub fn default_for_letter_pdf() -> Self
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
impl Clone for AdaptiveLayoutParams
Source§fn clone(&self) -> AdaptiveLayoutParams
fn clone(&self) -> AdaptiveLayoutParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more