Skip to content

xfeatures2d_PCTSignatures

xfeatures2dclassOpenCV 5.0.0
import { xfeatures2d_PCTSignatures } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSxfeatures2d_PCTSignatures
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits Algorithm.

Position-Color-Texture signatures Class implementing PCT (position-color-texture) signature extraction as described in [KrulisLS16]. The algorithm is divided to a feature sampler and a clusterizer. Feature sampler produces samples at given set of coordinates. Clusterizer then produces clusters of these samples using k-means algorithm. Resulting set of clusters is the signature of the input image.

  A signature is an array of SIGNATURE_DIMENSION-dimensional points.
  Used dimensions are:
  weight, x, y position; lab color, contrast, entropy.

[KrulisLS16] [BeecksUS10]

Constructors and members

static create

Creates PCTSignatures algorithm using sample and seed count. It generates its own sets of sampling points and clusterization seed indexes.

create(initSampleCount: number, initSeedCount: number, pointDistribution: number): xfeatures2d_PCTSignatures | null;
4 available overloads
create(): xfeatures2d_PCTSignatures | null;
create(initSampleCount: number): xfeatures2d_PCTSignatures | null;
create(initSampleCount: number, initSeedCount: number): xfeatures2d_PCTSignatures | null;
create(initSampleCount: number, initSeedCount: number, pointDistribution: number): xfeatures2d_PCTSignatures | null;
initSampleCount

Number of points used for image sampling.

initSeedCount

Number of initial clusterization seeds. Must be lower or equal to initSampleCount

pointDistribution

Distribution of generated points. Default: UNIFORM. Available: UNIFORM, REGULAR, NORMAL.

Returns

Created algorithm.

static create1

Creates PCTSignatures algorithm using pre-generated sampling points and number of clusterization seeds. It uses the provided sampling points and generates its own clusterization seed indexes.

create1(initSamplingPoints: Point2fVector, initSeedCount: number): xfeatures2d_PCTSignatures | null;
initSamplingPoints

Sampling points used in image sampling.

initSeedCount

Number of initial clusterization seeds. Must be lower or equal to initSamplingPoints.size().

Returns

Created algorithm.

static create2

Creates PCTSignatures algorithm using pre-generated sampling points and clusterization seeds indexes.

create2(initSamplingPoints: Point2fVector, initClusterSeedIndexes: IntVector): xfeatures2d_PCTSignatures | null;
initSamplingPoints

Sampling points used in image sampling.

initClusterSeedIndexes

Indexes of initial clusterization seeds. Its size must be lower or equal to initSamplingPoints.size().

Returns

Created algorithm.

static drawSignature

Draws signature in the source image and outputs the result. Signatures are visualized as a circle with radius based on signature weight and color based on signature color. Contrast and entropy are not visualized.

drawSignature(source: Mat, signature: Mat, result: Mat, radiusToShorterSideRatio: number, borderThickness: number): void;
3 available overloads
drawSignature(source: Mat, signature: Mat, result: Mat): void;
drawSignature(source: Mat, signature: Mat, result: Mat, radiusToShorterSideRatio: number): void;
drawSignature(source: Mat, signature: Mat, result: Mat, radiusToShorterSideRatio: number, borderThickness: number): void;
source

Source image.

signature

Image signature.

result

Output destination, filled by the native operation. Output result.

radiusToShorterSideRatio

Determines maximal radius of signature in the output image.

borderThickness

Border thickness of the visualized signature.

static generateInitPoints

Generates initial sampling points according to selected point distribution.

Note: Generated coordinates are in range [0..1)

generateInitPoints(initPoints: Point2fVector, count: number, pointDistribution: number): void;
initPoints

Output vector where the generated points will be saved.

count

Number of points to generate.

pointDistribution

Point distribution selector. Available: UNIFORM, REGULAR, NORMAL.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

computeSignature

Computes signature of given image.

computeSignature(image: Mat, signature: Mat): void;
image

Input image of CV_8U type.

signature

Output destination, filled by the native operation. Output computed signature.

computeSignatures

Computes signatures for multiple images in parallel.

computeSignatures(images: MatVector, signatures: MatVector): void;
images

Vector of input images of CV_8U type.

signatures

Vector of computed signatures.

getSampleCount

sampler *** Number of initial samples taken from the image.

getSampleCount(): number;
Returns

The number result.

getGrayscaleBits

Color resolution of the greyscale bitmap represented in allocated bits (i.e., value 4 means that 16 shades of grey are used). The greyscale bitmap is used for computing contrast and entropy values.

getGrayscaleBits(): number;
Returns

The number result.

setGrayscaleBits

Color resolution of the greyscale bitmap represented in allocated bits (i.e., value 4 means that 16 shades of grey are used). The greyscale bitmap is used for computing contrast and entropy values.

setGrayscaleBits(grayscaleBits: number): void;
grayscaleBits

grayscale bits argument (number).

getWindowRadius

Size of the texture sampling window used to compute contrast and entropy (center of the window is always in the pixel selected by x,y coordinates of the corresponding feature sample).

getWindowRadius(): number;
Returns

The number result.

setWindowRadius

Size of the texture sampling window used to compute contrast and entropy (center of the window is always in the pixel selected by x,y coordinates of the corresponding feature sample).

setWindowRadius(radius: number): void;
radius

radius argument (number).

getWeightX

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

getWeightX(): number;
Returns

The number result.

setWeightX

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

setWeightX(weight: number): void;
weight

weight argument (number).

getWeightY

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

getWeightY(): number;
Returns

The number result.

setWeightY

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

setWeightY(weight: number): void;
weight

weight argument (number).

getWeightL

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

getWeightL(): number;
Returns

The number result.

setWeightL

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

setWeightL(weight: number): void;
weight

weight argument (number).

getWeightA

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

getWeightA(): number;
Returns

The number result.

setWeightA

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

setWeightA(weight: number): void;
weight

weight argument (number).

getWeightB

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

getWeightB(): number;
Returns

The number result.

setWeightB

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

setWeightB(weight: number): void;
weight

weight argument (number).

getWeightContrast

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

getWeightContrast(): number;
Returns

The number result.

setWeightContrast

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

setWeightContrast(weight: number): void;
weight

weight argument (number).

getWeightEntropy

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

getWeightEntropy(): number;
Returns

The number result.

setWeightEntropy

Weights (multiplicative constants) that linearly stretch individual axes of the feature space (x,y = position; L,a,b = color in CIE Lab space; c = contrast. e = entropy)

setWeightEntropy(weight: number): void;
weight

weight argument (number).

getSamplingPoints

Initial samples taken from the image. These sampled features become the input for clustering.

getSamplingPoints(): Point2fVector;
Returns

The Point2fVector result. Release returned native handles with using or delete(), including handles nested in results.

setWeight

Weights (multiplicative constants) that linearly stretch individual axes of the feature space.

Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;

setWeight(idx: number, value: number): void;
idx

ID of the weight

value

Value of the weight

setWeights

Weights (multiplicative constants) that linearly stretch individual axes of the feature space.

Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;

setWeights(weights: FloatVector): void;
weights

Values of all weights.

setTranslation

Translations of the individual axes of the feature space.

Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;

setTranslation(idx: number, value: number): void;
idx

ID of the translation

value

Value of the translation

setTranslations

Translations of the individual axes of the feature space.

Note: WEIGHT_IDX = 0; X_IDX = 1; Y_IDX = 2; L_IDX = 3; A_IDX = 4; B_IDX = 5; CONTRAST_IDX = 6; ENTROPY_IDX = 7;

setTranslations(translations: FloatVector): void;
translations

Values of all translations.

setSamplingPoints

Sets sampling points used to sample the input image.

Note: Number of sampling points must be greater or equal to clusterization seed count.

setSamplingPoints(samplingPoints: Point2fVector): void;
samplingPoints

Vector of sampling points in range [0..1)

getInitSeedIndexes

clusterizer *** Initial seeds (initial number of clusters) for the k-means algorithm.

getInitSeedIndexes(): IntVector;
Returns

The IntVector result. Release returned native handles with using or delete(), including handles nested in results.

setInitSeedIndexes

Initial seed indexes for the k-means algorithm.

setInitSeedIndexes(initSeedIndexes: IntVector): void;
initSeedIndexes

init seed indexes argument (IntVector).

getInitSeedCount

Number of initial seeds (initial number of clusters) for the k-means algorithm.

getInitSeedCount(): number;
Returns

The number result.

getIterationCount

Number of iterations of the k-means clustering. We use fixed number of iterations, since the modified clustering is pruning clusters (not iteratively refining k clusters).

getIterationCount(): number;
Returns

The number result.

setIterationCount

Number of iterations of the k-means clustering. We use fixed number of iterations, since the modified clustering is pruning clusters (not iteratively refining k clusters).

setIterationCount(iterationCount: number): void;
iterationCount

iteration count argument (number).

getMaxClustersCount

Maximal number of generated clusters. If the number is exceeded, the clusters are sorted by their weights and the smallest clusters are cropped.

getMaxClustersCount(): number;
Returns

The number result.

setMaxClustersCount

Maximal number of generated clusters. If the number is exceeded, the clusters are sorted by their weights and the smallest clusters are cropped.

setMaxClustersCount(maxClustersCount: number): void;
maxClustersCount

max clusters count argument (number).

getClusterMinSize

This parameter multiplied by the index of iteration gives lower limit for cluster size. Clusters containing fewer points than specified by the limit have their centroid dismissed and points are reassigned.

getClusterMinSize(): number;
Returns

The number result.

setClusterMinSize

This parameter multiplied by the index of iteration gives lower limit for cluster size. Clusters containing fewer points than specified by the limit have their centroid dismissed and points are reassigned.

setClusterMinSize(clusterMinSize: number): void;
clusterMinSize

cluster min size argument (number).

getJoiningDistance

Threshold euclidean distance between two centroids. If two cluster centers are closer than this distance, one of the centroid is dismissed and points are reassigned.

getJoiningDistance(): number;
Returns

The number result.

setJoiningDistance

Threshold euclidean distance between two centroids. If two cluster centers are closer than this distance, one of the centroid is dismissed and points are reassigned.

setJoiningDistance(joiningDistance: number): void;
joiningDistance

joining distance argument (number).

getDropThreshold

Remove centroids in k-means whose weight is lesser or equal to given threshold.

getDropThreshold(): number;
Returns

The number result.

setDropThreshold

Remove centroids in k-means whose weight is lesser or equal to given threshold.

setDropThreshold(dropThreshold: number): void;
dropThreshold

drop threshold argument (number).

getDistanceFunction

Distance function selector used for measuring distance between two points in k-means.

getDistanceFunction(): number;
Returns

The number result.

setDistanceFunction

Distance function selector used for measuring distance between two points in k-means. Available: L0_25, L0_5, L1, L2, L2SQUARED, L5, L_INFINITY.

setDistanceFunction(distanceFunction: number): void;
distanceFunction

distance function argument (number).

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.