ScalarFieldEmbedding

ScalarFieldEmbedding

new ScalarFieldEmbedding(parameters, scalarfield|distancesopt)

Description:
  • Implements a scalar-field numerical embedding (preliminary implementation).

    ScalarFieldEmbedding parameters

    General parameter

    • NaN: ... If true take also into account scalar-field points with undefined values. Default is false.
    • verbose: ... If true print the interpolation, extrapolation and barycenter intermediate values. Default is false.

    ScalarField parameter

    • The underlying scalar-field parameters if the scalar-field is ommitied but defined here by its parameters.
Parameters:
Name Type Attributes Description
parameters JSON | String

The scalar-field embedding parameters.

scalarfield|distances ScalarField | Mat <optional>

The scalar-field parameters or directly the distance matrix where the lower-triangle part i < j, D[i, j] is defined.

Throws:

illegal-argument If distance triangle inequality is not verified.

Methods

getParameters() → {JSON}

Description:
  • Returns the trajectory parameters.

Returns:

The trajectory parameters.

Type
JSON

setParameters(parameters) → {ScalarField}

Description:
  • Modifies some ScalarField parameters.

    • All parameters but the type can be modified.
    • The ScalarField points are preserved when changing the parameters, thus using the points field simply adds the points.
Parameters:
Name Type Description
parameters JSON

The Trajectory parameters.

Returns:

This value allowing to chain methods.

Type
ScalarField

getScalarField() → {ScalarField}

Description:
  • Returns the underlying scalar-field.

Returns:

The scalar-field read-only pointer, if defined NULL otherwise.

Type
ScalarField

getDistances() → {Mat}

Description:
  • Returns the underlying distances-field.

Returns:

The cv::Mat read-only distances matrix.

Type
Mat

(static) getEmbedding(dimension) → {Embedding}

Description:
  • Calculates and returns an approximate affine embedding.

Parameters:
Name Type Description
dimension uint

Affine embedding dimension. If 0, return the minimal dimension of the best approximation.

Returns:

The embedding as a C++ data struture.

struct Embedding {
  // Exponent of the phi(d) : d -> d^(1/n) function, so that phi(d_ij) = ||x_i-x_j||.
  unsigned int phi_n;
  // Circumscribing hypersphere radius and vector magnitudes
  double d_c;
  // The embedding coordinates of the obtained dimension = X.rows for count = X.cols vectors.
  cv::Mat X;
  // The embedding labels
  std::vector <std::string> labels;
  // The embedding chosen dimension and obtained rank
  unsigned int dimension, rank;
};
Type
Embedding

(static) getAtlas() → {Atlas}

Description:
  • Calculates and returns the embedding atlas.

Returns:

The embedding atlas as a C++ data struture.

struct Atlas {
  // The embedding labels
  std::vector <std::string> labels;
  // The index <-> value correspondences, if a scalarfield is defined
  std::vector < wjson::Value > index2value;
  std::map < wjson::Value, unsigned int > value2index;
  // Defines a chart
  struct Chart {
	   // The chart value indexes, as given by index2value
	   // - The chart size is indexes.size()
	   // - The chart value index is indexes.at(0)
    std::vector < unsigned int > indexes;
    // The chart value increasing distances to the chart origin
    std::vector < double > distances;
    // The chart coordinates as a size columns matrix of size-1 rows
    cv::Mat coordinates;
  };
  std::vector < Chart > charts;
  struct Transition {
	   // The charts indexes of this transition map
	   std::pair < unsigned int, unsigned int > charts;
	   // The points indexes that are in the intersection
	   std::vector < unsigned int > indexes;
	   // The transition map, of the form X_q = matrix * X_p + vector
	   cv::Mat matrix, vector;
    // Transform properties
    unsigned int affine_matrix_rank, affine_isometric_rank, rigid_matrix_rank;
  };
  std::vector < std::vector < Transition >> transitions;
};
Type
Atlas

(static) asJSON() → {JSON}

Description:
  • Returns the vector embedding and affine embedding atlas as a wJSON data structure.

Returns:

The embedding atlas as a wJSON data structure.

Type
JSON

(static) asImage() → {Mat}

Description:
  • Returns the vector embedding drawn in a 2D image. The cv::imwrite("filename.png", embedding.asImage()); construct allows to save the image.

Returns:

A BGR CV_8UC3 cv::Mat image with the drawn data structure.

Type
Mat