morphops.lmk_util

Provides common functions used in the module.

morphops.lmk_util.distance_matrix(X, Y)[source]

For (p1,k)-shaped X and (p2,k)-shaped Y, returns the (p1,p2) matrix where the element at [i,j] is the distance between X[i,:] and Y[j,:].

morphops.lmk_util.num_coords(X)[source]

Returns the number of coordinates per landmark k in X.

X can be

  • a 1-D tensor of shape (k,) corresponding to a landmark point having k coordinates.
  • a 2-D tensor of shape (p,k) corresponding to a landmark set of p landmarks, each having k coordinates, or
  • a 3-D tensor of shape (n,p,k) corresponding to a set of n landmark sets, each containing p landmarks, each having k coordinates.
morphops.lmk_util.num_lmk_sets(X)[source]

Returns the number of landmark sets n in X.

X must be a 3-D tensor of shape (n,p,k) corresponding to a set of n landmark sets.

morphops.lmk_util.num_lmks(X)[source]

Returns the number of landmarks per set p in X.

X can be

  • a 2-D tensor of shape (p,k) corresponding to a landmark set of p landmarks, or
  • a 3-D tensor of shape (n,p,k) corresponding to a set of n landmark sets, each containing p landmarks.
morphops.lmk_util.ssqd(X)[source]

Returns the average sum of squared norms of pairwise differences between all lmk sets in X.

morphops.lmk_util.transpose(X)[source]

Swaps the last two axes of a N-D tensor.

So for a 2-D matrix, this returns the transpose. For a 3-D tensor of length n, this returns the array of n transposed matrices.