Skip to content

API Analysis

ZangoTech edited this page Jun 20, 2026 · 1 revision

Analysis

← Back to API Reference · Home

Namespace: acl::analysis (CPP) / acl::neon::analysis (NEON)

integral

Integral image (Summed Area Table): I(x, y) = ∑ src(i, j), 0 ≤ i ≤ x, 0 ≤ j ≤ y. Used for O(1) rectangular region sums (boxFilter, Haar features, etc.).

Tier: Starter+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
SrcType uint8_t, uint16_t, float
IntegralType int32_t, int64_t, double sizeof(IntegralType) ≥ sizeof(SrcType)

CPP Version

template<class SrcType, class IntegralType>
int integral(
    const SrcType* srcImage, IntegralType* integral,
    int width, int height,
    int srcStride = 0);
Parameter Type Meaning Default
srcImage const SrcType* Input image (single channel) non-null
integral IntegralType* Output integral image, size (width+1) × (height+1) non-null
width, height int Input image size > 0
srcStride int Bytes per row 0 = auto

Row 0 and column 0 of integral are always 0 (implementation sentinel row and column to simplify boundary queries).


NEON Version

template<class SrcType, class IntegralType>
int integral(
    const SrcType* srcImage, IntegralType* integralImage,
    int width, int height,
    int srcStride = 0);

Example

uint8_t srcImage[1920*1080];
int32_t integ[(1920+1)*(1080+1)];

acl::neon::analysis::integral<uint8_t, int32_t>(
    srcImage, integ, 1920, 1080);

// O(1) rectangle (x0,y0)-(x1,y1) sum
auto rectSum = [&](int x0, int y0, int x1, int y1) {
    int W = 1921;
    return integ[(y1+1)*W + (x1+1)]
         - integ[(y1+1)*W + x0]
         - integ[y0*W + (x1+1)]
         + integ[y0*W + x0];
};

histogram

Compute the pixel-value histogram.

Tier: Starter+
Channels: 1ch (packed via runtime hcn × vcn parameters when needed)
Inplace: not supported
Types:

Template parameter Allowed types Constraint
ST {uint8_t, uint16_t}
HT {int, long} (histogram bin count type)

CPP Version

template<class ST, class HT>
int histogram(
    const ST* srcImage, HT* hist,
    int width, int height,
    int srcStride, int histLen,
    int hcn = 1, int vcn = 1);
Parameter Type Meaning Default
srcImage const ST* Input image non-null
hist HT* Output histogram (length histLen, zeroed by the caller) non-null
srcStride int Bytes per row 0 = auto
histLen int Number of histogram bins (u8 → 256, u16 → 65536)
hcn, vcn int Horizontal / vertical channel packing 1, 1

NEON Version (uint8_t only, fixed histLen = 256)

int histogram(
    const uint8_t* srcImage, int* hist,
    int width, int height,
    int srcStride = 0);

hist has a fixed length of 256 int bins; for non-uint8_t or non-256 bins, use the CPP version.


histMatch

Histogram matching (normalization) — adjusts the pixel distribution of src so that it matches the histogram of ref.

Tier: Pro+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
ST uint8_t, uint16_t all params must be the same type
DT uint8_t, uint16_t all params must be the same type
RT uint8_t, uint16_t all params must be the same type

CPP Signature

template<class ST, class DT, class RT>
int histMatch(
    const ST* srcImage, DT* dstImage, const RT* refImage,
    int width, int height,
    int srcStride, int dstStride, int refStride,
    int srcHistLen, int refHistLen,
    double MATCH_TH = 0.0,
    int hcn = 1, int vcn = 1);
Parameter Type Meaning Default
srcImage, dstImage const ST* / DT* input / output non-null
refImage const RT* Reference image (its histogram is used as the target distribution) non-null
srcHistLen, refHistLen int Source / reference bin counts u8: 256
MATCH_TH double Match tolerance threshold [0, 1] 0.0
hcn, vcn int Horizontal / vertical channel packing 1, 1

equalizeHist

Histogram equalization.

Tier: Starter+
Channels: 1ch
Inplace: supported
Types:

Template parameter Allowed types Constraint
T (CPP) uint8_t, uint16_t
T (NEON) uint8_t NEON-only

CPP Version

template<class T>
int equalizeHist(
    const T* srcImage, T* dstImage,
    int width, int height,
    int srcStride = 0, int dstStride = 0);

NEON Version (uint8_t only)

int equalizeHist(
    const uint8_t* srcImage, uint8_t* dstImage,
    int width, int height,
    int srcStride = 0, int dstStride = 0);

clahe

Contrast Limited Adaptive Histogram Equalization — divides the image into tilesX × tilesY tiles, performs histogram equalization in each tile and clips the contrast upper bound, then bilinearly interpolates (blends) the results, avoiding the over-contrast from global equalization.

Tier: Pro+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T uint8_t

CPP / NEON Signature (identical)

int clahe(
    const uint8_t* srcImage, uint8_t* dstImage,
    int width, int height,
    int srcStride = 0, int dstStride = 0,
    double clipLimit = 40.0,
    int tilesX = 8, int tilesY = 8);
Parameter Type Meaning Default
srcImage, dstImage const uint8_t* / uint8_t* input / output non-null
width, height int Image size must satisfy width ≥ tilesX, height ≥ tilesY
srcStride, dstStride int Bytes per row 0 = auto
clipLimit double Contrast upper bound (higher = stronger contrast) 40.0 (OpenCV default)
tilesX, tilesY int Horizontal / vertical tile count 8 × 8

minMaxLoc

Find the minimum / maximum value in the image and their locations.

Tier: Starter+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T uint8_t, uint16_t, float

CPP / NEON Signature (identical)

template<class T>
int minMaxLoc(
    const T* srcImage, int width, int height, int srcStride,
    T* minVal, T* maxVal,
    int* minLocX, int* minLocY,
    int* maxLocX, int* maxLocY);
Parameter Type Meaning Default
srcImage const T* Input image non-null
srcStride int Bytes per row 0 = auto
minVal, maxVal T* Output min / max values (may be nullptr)
minLocX, minLocY, maxLocX, maxLocY int* Output corresponding coordinates (may be nullptr)

When any output pointer is nullptr, the corresponding result is skipped.


moments

Spatial moments (orders 0~3). Single-channel image; outputs a Moments struct containing 10 double raw moments: m00, m10, m01, m20, m11, m02, m30, m21, m12, m03.

Tier: Pro+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T (CPP) uint8_t, uint16_t, float

CPP Signature

struct Moments {
    double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
};

template<class T>
int moments(
    const T* srcImage, int width, int height, int srcStride,
    Moments& m,
    bool binaryImage = false);
Parameter Type Meaning Default
srcImage const T* Input image non-null
m Moments& Output moments struct filled by the function
binaryImage bool true = treat all non-zero pixels as 1 (binary evaluation) false

copyMakeBorder

Add a border around the image, supporting multiple border modes. Typical use: padding before convolution.

Tier: Starter+
Channels: 1ch / 3ch / 4ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T uint8_t, uint16_t, float
BorderType: BORDER_REPLICATE / BORDER_REFLECT / BORDER_REFLECT_101 / BORDER_WRAP / BORDER_CONSTANT, etc.

CPP Version

template<class T>
int copyMakeBorder(
    const T* srcImage, T* dstImage,
    int srcWidth, int srcHeight, int channelNum,
    int srcStride, int dstStride,
    int top, int bottom, int left, int right,
    const T* constant = nullptr,
    acl::BorderType bt = acl::BorderType::BORDER_REFLECT_101);
Parameter Type Meaning Default
srcImage const T* Input image non-null
dstImage T* Output image (size (srcWidth + left + right) × (srcHeight + top + bottom)) non-null
channelNum int Channel count
top, bottom, left, right int Padding width in each of the four directions ≥ 0
constant const T* BORDER_CONSTANT fill-value array (length channelNum) nullptr
bt acl::BorderType Border-handling mode BORDER_REFLECT_101

NEON Version

template<class T>
int copyMakeBorder(
    const T* srcImage, T* dstImage,
    int srcWidth, int srcHeight, int channelNum,
    int srcStride = 0, int dstStride = 0,
    int top = 0, int bottom = 0, int left = 0, int right = 0,
    const T* constant = nullptr,
    acl::BorderType bt = acl::BorderType::BORDER_REFLECT_101);

count

Count the number of pixels satisfying a condition.

Tier: Starter+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T uint8_t, uint16_t, float

CPP Signature (3 entry points)

// == threshold
template<class T>
int countEQ(const T* srcImage, int width, int height, int stride, const T& threshold);

// <= threshold
template<class T>
int countLET(const T* srcImage, int width, int height, int stride, const T& threshold);

// < threshold
template<class T>
int countLT(const T* srcImage, int width, int height, int stride, const T& threshold);

The return value is the count (not an error code); srcImage == nullptr returns 0.


mean

Per-pixel mean of two or N images: dst[i] = (A[i] + B[i] + …) / N.

Tier: Starter+
Channels: 1ch / 3ch / 4ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
AT uint8_t, uint16_t, float
BT uint8_t, uint16_t, float
DT uint8_t, uint16_t, float

CPP Signature (two overloads: 2-image + N-image)

// 2-image
template<class AT, class BT, class DT>
int mean(
    const AT* src1Image, const BT* src2Image, DT* dstImage,
    int width, int height, int cn = 1,
    int src1Stride = 0, int src2Stride = 0, int dstStride = 0);

// N-image
template<class ST, class DT>
int mean(
    const ST* const* srcImages, int srcNum, DT* dstImage,
    int width, int height, int cn = 1,
    int srcStride = 0, int dstStride = 0);

matchTemplate

Template matching (6 similarity metrics). FFT-accelerated; suitable for large image × small template.

Tier: Pro+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T (CPP) {uint8_t, float}
T (NEON) uint8_t NEON-only

TemplateMatchMethod:

  • TM_SQDIFF — sum of squared differences
  • TM_SQDIFF_NORMED — normalized squared differences
  • TM_CCORR — cross-correlation
  • TM_CCORR_NORMED — normalized cross-correlation
  • TM_CCOEFF — correlation coefficient
  • TM_CCOEFF_NORMED — normalized correlation coefficient

CPP Version

template<class T>
int matchTemplate(
    const T* srcImage, int srcW, int srcH, int srcStride,
    const T* templ, int templW, int templH, int templStride,
    float* result, int resultStride,
    acl::TemplateMatchMethod tm = acl::TemplateMatchMethod::TM_SQDIFF);

NEON Version (uint8_t only)

template<class T>
int matchTemplate(
    const T* srcImage, int srcW, int srcH, int srcStride,
    const T* templ, int templW, int templH, int templStride,
    float* result, int resultStride,
    acl::TemplateMatchMethod tm = acl::TemplateMatchMethod::TM_SQDIFF);
Parameter Type Meaning Default
srcImage, templ const T* Search image, template image non-null, templW ≤ srcW, templH ≤ srcH
result float* Output score map, size (srcW - templW + 1) × (srcH - templH + 1) non-null
*Stride int Bytes per row (result counted as float) 0 = auto
tm acl::TemplateMatchMethod Similarity metric TM_SQDIFF

connectedComponent_8n_dfs

8-connected component labeling (DFS). Takes a binary image as input; outputs the pixel coordinate list for each connected component.

Tier: Business
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T uint8_t, uint16_t
LabelType int

CPP Signature

template<class T>
int connectedComponent_8n_dfs(
    T* binaryImage, int width, int height, int stride,
    std::vector<std::vector<std::pair<int, int>>>& regions,
    int minArea, int maxArea,
    int frontFlag = 255, int backFlag = 0);
Parameter Type Meaning
binaryImage T* Input binary image (the algorithm may overwrite pixels as markers)
regions vector<vector<pair<int, int>>>& Output list of (x, y) pixel coordinates for each connected component
minArea, maxArea int Filter: only retain components with area ∈ [minArea, maxArea]
frontFlag, backFlag int Foreground / background pixel value used as DFS markers (defaults 255 / 0)

connectedComponentLabeling

Connected component labeling with a label image (union-find). Outputs a label image (per-pixel label) + a label list sorted by area.

Tier: Business
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
DataInType uint8_t, uint16_t
LabelType int

CPP Signature

template<class DataInType, class LabelType>
int connectedComponentLabeling(
    DataInType* dataIn, LabelType* label,
    std::vector<std::pair<LabelType, int>>& sortLabelHist,
    DataInType threshold,
    int topAreaCnt, int minArea,
    int width, int height,
    int inStride = 0, int labelStride = 0);
Parameter Type Meaning
dataIn DataInType* Input image (binarized via threshold)
label LabelType* Output label image
sortLabelHist vector<pair<LabelType, int>>& Output (label, area) list sorted by descending area
threshold DataInType Input binarization threshold
topAreaCnt int Only retain the topAreaCnt components with the largest area

findContours

Find contours in a binary image (Suzuki-Abe algorithm, OpenCV compatible).

Tier: Pro+
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T uint8_t

CPP Signature

enum ContourRetrMode {
    CONTOUR_RETR_EXTERNAL = 0,  // only the outermost layer
    CONTOUR_RETR_LIST     = 1,  // all contours, no hierarchy
    CONTOUR_RETR_CCOMP    = 2,  // two layers (outer + inner holes)
    CONTOUR_RETR_TREE     = 3   // full hierarchy tree
};

enum ContourApproxMethod {
    CONTOUR_CHAIN_APPROX_NONE   = 1,  // retain all contour points
    CONTOUR_CHAIN_APPROX_SIMPLE = 2   // compress intermediate points on horizontal / vertical / diagonal segments
};

struct Point2i { int x, y; };
struct HierarchyEntry { int next, prev, first_child, parent; };

int findContours(
    const uint8_t* srcImage, int width, int height, int srcStride,
    std::vector<std::vector<Point2i>>& contours,
    std::vector<HierarchyEntry>* hierarchy = nullptr,
    ContourRetrMode mode = CONTOUR_RETR_LIST,
    ContourApproxMethod method = CONTOUR_CHAIN_APPROX_SIMPLE,
    int offsetX = 0, int offsetY = 0);
Parameter Type Meaning
contours vector<vector<Point2i>>& Output contours; each contour is an array of Point2i
hierarchy vector<HierarchyEntry>* (optional) hierarchy info [next, prev, first_child, parent]
offsetX, offsetY int Offset added to all contour point coordinates

distanceTransform

Distance transform — each pixel outputs the distance to its nearest 0 pixel (L1 / L2 / L∞).

Tier: Business
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
Input uint8_t
Output float

DistanceType: DIST_L1 (Manhattan) / DIST_L2 (Euclidean, exact algorithm) / DIST_LINF (chessboard)


CPP Signature (2 entry points: float or u8 output)

// float output (high precision)
int distanceTransform(
    const uint8_t* srcImage, float* dstImage,
    int width, int height,
    int srcStride = 0, int dstStride = 0,
    DistanceType distType = DIST_L2);

// u8 output (normalized to 0-255, suitable for visualization)
int distanceTransformU8(
    const uint8_t* srcImage, uint8_t* dstImage,
    int width, int height,
    int srcStride = 0, int dstStride = 0,
    DistanceType distType = DIST_L2);

DIST_L2 uses the Felzenszwalb-Huttenlocher exact Euclidean algorithm (not an approximation).


blockAverage

Take the mean over each U × V block as output (image downsampling). U = V = 2 corresponds to 2×2 averaging.

Tier: Starter+
Channels: 1ch / 3ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
T uint8_t, uint16_t, float

Commercial package type availability:

Tier Callable T in delivered <acl/api.h>
Starter uint8_t
Pro uint8_t, uint16_t
Business uint8_t, uint16_t, float

CPP / NEON Signature (identical)

template<class T>
int blockAverage(
    const T* srcImage, T* dstImage,
    int srcWidth, int srcHeight,
    int U, int V,
    int srcStride = 0, int dstStride = 0,
    bool round = true,
    int hcn = 1, int vcn = 1);
Parameter Type Meaning Default
U, V int Block horizontal / vertical size
round bool true = round to nearest, false = truncate true
hcn, vcn int Horizontal / vertical channel packing 1, 1

extractBlockPixels

Extract the pixel at (u, v) from every U × V block (i.e. downsample while specifying the sampling point).

Tier: Business
Channels: 1ch
Inplace: not supported
Types:

Template parameter Allowed types Constraint
ST uint8_t, uint16_t, float
DT uint8_t, uint16_t, float

CPP Signature

template<class ST, class DT>
int extractBlockPixels(
    const ST* srcImage, DT* dstImage,
    int srcWidth, int srcHeight,
    int srcStride, int dstStride,
    int U, int V, int u, int v);
Parameter Type Meaning
U, V int Block size
u, v int Pixel position sampled from each block (0 ≤ u < U, 0 ≤ v < V); auto-clamped

Clone this wiki locally