StagesTransform

ImageDrawBoxes

Annotate a page with detection boxes or NER entities. Drawing is a pipeline stage, so the annotated page is just another image column.

Import
import { ImageDrawBoxes } from '@stabrise/scaledp'
Group
Transform
Reads
image, boxes
Writes
image
Needs
nothing
Note
Terminal — output is for looking at.
import { Pipeline, ImageDrawBoxes } from '@stabrise/scaledp'

new ImageDrawBoxes({
    inputCols: ['image', 'text', 'ner'],
    outputCol: 'annotated',
    displayDataList: ['entity_group', 'score'],
    lineWidth: 2,
})
Open a two-pass overlay in the builder

The first entry in inputCols is the image; every other entry is a box or entity source. A source with entities is drawn as NER, one with bboxes as boxes — so one stage can annotate a page with both.

displayDataList renders fields above each box, joined by :. Valid names are the schema's own: text, score, angle, x, y, width, height for a box; entity_group, word, score for an entity. Numbers are formatted to two decimals.

whiteList and blackList filter entity groups only.

Colours

color: null (the default) colours by group. The colour is a stable hash of the group name, so a given label is the same colour on every render — Python picks a random colour per run, which makes two renders of the same document impossible to compare.

import { colorForGroup } from '@stabrise/scaledp'

colorForGroup('person')   // the same HSL string every time

One stage takes one color for all its sources, which is why a two-colour overlay is two chained passes — the second reading what the first wrote. That is also how the demo speaks its false-colour language: cyan for what was found, magenta for what was understood.

It is a terminal stage

An annotated page is still an image, but feeding it to a detector means detecting through the boxes drawn on top of it. The registry marks the stage terminal for this reason, and column-suggesting interfaces skip it.

Rotated boxes

Drawn as rotated quads, with the label chip riding the box's own top edge. Python places the chip at the envelope corner instead, which detaches it from a steeply rotated box.

Parameters

ParameterTypeDefaultMeaning
inputColsstring[] (2+)['image', 'boxes']The image first, then one or more box, document or entity columns.
colorstringnullOne colour for every box. Unset colours by group instead.
filledbooleanfalseFill boxes as well as outlining them.
lineWidthnumber 0–201Line width
textSizenumber 4–7212Text size
displayDataListstring[][]Rendered above each box, joined by ":". Pick "text" to read the OCR output back off the page.
paddingnumber0Grow each box by this many pixels before drawing.
whiteListstring[][]Draw only these entity groups; empty draws all.
blackListstring[][]Never draw these entity groups.
imageType'png' | 'webp' | 'jpeg''png'Image format

On this page