Table of Contents

Method DetectFigureRegions

Namespace
LMKit.Document.Layout
Assembly
LM-Kit.NET.dll

DetectFigureRegions(double, (int Lines, int Words))

Locates the horizontal bands of the page that carry no running prose. These are the bands occupied by figures, charts, diagrams and images, whose own labels are short and scattered rather than flowing text.

public List<Rectangle> DetectFigureRegions(double minimumHeightRatio = 0.1, (int Lines, int Words) prose = default)

Parameters

minimumHeightRatio double

Smallest band height to report, as a fraction of page height. Bands below this are inter-paragraph leading rather than content.

prose (int Lines, int Words)

Smallest paragraph, in lines and in words, that counts as running prose. Anything smaller is treated as a label and does not close a band.

Returns

List<Rectangle>

Bands in top-to-bottom order, spanning the full page width, in this page's coordinate space. Empty when prose covers the page.

Examples

var page = await attachment.GetPageElementAsync(0);

foreach (Rectangle band in page.DetectFigureRegions())
{
    Console.WriteLine($"figure band: y={band.Top:F0} to {band.Bottom:F0}");
}

Remarks

Detection is geometric and needs no model: prose paragraphs are projected onto the vertical axis and the gaps between them are the result. A figure therefore does not have to be an embedded image to be found, which matters because charts are commonly drawn as vector graphics and leave no image object behind.

Bands span the full width because a chart's value axis, legend and caption sit outside the plot area and are needed to read it.

Share