CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxBinaryImageAnalysis Class Reference

Allocation-free CPU image primitives, shared by SDK and standalone code. More...

#include <ctxImageAnalysis.h>

Static Public Member Functions

static gzBool getPixelCount (const ctxImageByteView &image, gzUInt32 &count)
 Resolve the complete required pixel/work extent without changing count on failure.
static gzBool retainRuns (const ctxImageByteView &image, ctxBinaryImageAxis axis, gzUInt32 minimumLength, gzUByte *output, gzUInt32 outputCount)
 Retain complete maximal horizontal/vertical foreground runs having at least minimumLength pixels.
static gzBool retainCorridorRuns (const ctxImageByteView &image, ctxBinaryImageAxis axis, gzUInt32 minimumLength, gzUInt32 orthogonalRadius, gzUByte *output, gzUByte *scratch, gzUInt32 outputCount)
 Retain original foreground supported by maximal runs in an orthogonal corridor.
static gzBool project (const ctxImageByteView &image, ctxBinaryImageAxis axis, gzUInt32 *output, gzUInt32 outputCount)
 Count foreground along the named axis: HORIZONTAL returns height row counts, VERTICAL returns width column counts.
static gzBool labelComponents (const ctxImageByteView &image, ctxBinaryImageConnectivity connectivity, gzUInt32 *labels, gzUInt32 labelCount, gzUInt32 *queue, gzUInt32 queueCount, ctxBinaryImageComponentSink *sink, gzUInt32 &componentCount)
 Label every foreground pixel with 4/8 connectivity; background is zero.

Detailed Description

Allocation-free CPU image primitives, shared by SDK and standalone code.

All used output/work ranges are caller-owned, contiguous and disjoint from the borrowed input and each other. Invalid arguments leave them unchanged. No operation changes input/padding, performs IO, or interprets image labels.

Definition at line 75 of file ctxImageAnalysis.h.

Member Function Documentation

◆ getPixelCount()

gzBool ctxBinaryImageAnalysis::getPixelCount ( const ctxImageByteView & image,
gzUInt32 & count )
inlinestatic

Resolve the complete required pixel/work extent without changing count on failure.

Dimensions fit signed pixel coordinates and total pixel count fits gzUInt32. The source byte/address extent is checked first.

Definition at line 83 of file ctxImageAnalysis.h.

Referenced by ctxImageResampling::reduce(), and ctxImageResampling::resizeRegion().

◆ labelComponents()

gzBool ctxBinaryImageAnalysis::labelComponents ( const ctxImageByteView & image,
ctxBinaryImageConnectivity connectivity,
gzUInt32 * labels,
gzUInt32 labelCount,
gzUInt32 * queue,
gzUInt32 queueCount,
ctxBinaryImageComponentSink * sink,
gzUInt32 & componentCount )
inlinestatic

Label every foreground pixel with 4/8 connectivity; background is zero.

Label count is exactly width*height; queue capacity is at least that many gzUInt32 elements. Queue contents are unspecified scratch. Source padding is never read. Component count changes only on full success. A null sink requests only labels/count. A declining sink returns FALSE, keeps the count unchanged and leaves partial labels/callbacks; the caller may report that prefix explicitly, but must not call it a completed page/component inventory.

Definition at line 223 of file ctxImageAnalysis.h.

References ctxBinaryImageComponent::area, CTX_BINARY_IMAGE_EIGHT_CONNECTED, CTX_BINARY_IMAGE_FOUR_CONNECTED, ctxBinaryImageComponent::height, ctxImageByteView::height, ctxBinaryImageComponentSink::onComponent(), ctxImageByteView::pixels, ctxImageByteView::rowStride, ctxBinaryImageComponent::sumX, ctxBinaryImageComponent::sumY, ctxBinaryImageComponent::width, ctxImageByteView::width, ctxBinaryImageComponent::x, and ctxBinaryImageComponent::y.

◆ project()

gzBool ctxBinaryImageAnalysis::project ( const ctxImageByteView & image,
ctxBinaryImageAxis axis,
gzUInt32 * output,
gzUInt32 outputCount )
inlinestatic

Count foreground along the named axis: HORIZONTAL returns height row counts, VERTICAL returns width column counts.

All nonzero bytes count once, irrespective of their byte magnitude.

Definition at line 192 of file ctxImageAnalysis.h.

References CTX_BINARY_IMAGE_HORIZONTAL, ctxImageByteView::height, ctxImageByteView::pixels, ctxImageByteView::rowStride, and ctxImageByteView::width.

◆ retainCorridorRuns()

gzBool ctxBinaryImageAnalysis::retainCorridorRuns ( const ctxImageByteView & image,
ctxBinaryImageAxis axis,
gzUInt32 minimumLength,
gzUInt32 orthogonalRadius,
gzUByte * output,
gzUByte * scratch,
gzUInt32 outputCount )
inlinestatic

Retain original foreground supported by maximal runs in an orthogonal corridor.

Before run filtering, nonzero values within orthogonalRadius pixels on either side support the same row/column. Radius saturates at the orthogonal extent minus one; zero matches retainRuns exactly. Output is intersected with the ORIGINAL foreground, so no pixel is added or moved. This observes image support, not a staff or glyph role. Both output and scratch require exactly outputCount=width*height bytes; all three used ranges must be disjoint. Invalid preflight changes neither buffer. Padding/tails are untouched. Work is linear in the pixel count.

Definition at line 149 of file ctxImageAnalysis.h.

References CTX_BINARY_IMAGE_HORIZONTAL, CTX_BINARY_IMAGE_VERTICAL, ctxImageByteView::height, ctxImageByteView::pixels, retainRuns(), ctxImageByteView::rowStride, and ctxImageByteView::width.

◆ retainRuns()

gzBool ctxBinaryImageAnalysis::retainRuns ( const ctxImageByteView & image,
ctxBinaryImageAxis axis,
gzUInt32 minimumLength,
gzUByte * output,
gzUInt32 outputCount )
inlinestatic

Retain complete maximal horizontal/vertical foreground runs having at least minimumLength pixels.

Locations do not shift. Output is 0/255, tightly packed; foreground outside the image is zero. Length one canonicalizes nonzero bytes; a length above the axis extent yields zero.

Definition at line 99 of file ctxImageAnalysis.h.

References CTX_BINARY_IMAGE_HORIZONTAL, ctxImageByteView::height, ctxImageByteView::pixels, and ctxImageByteView::width.

Referenced by retainCorridorRuns().


The documentation for this class was generated from the following file: