Skip to content

Commit

Permalink
[docs] Improving docstrings center and label_centers
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Dec 11, 2023
1 parent 1913372 commit bcf2fd7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions include/GooseEYE/GooseEYE.h
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,24 @@ inline array_type::array<int> clusters(const T& f, bool periodic = true)
/**
* @brief Return the geometric center of a list of positions.
*
* @note
* The positions are organised as one column per dimension.
* For example, in 2d, the positions are organised as
* `positions = np.hstack((rows.reshape(-1, 1), cols.reshape(-1, 1)))`.
* You can also use `positions = np.argwhere(condition)`.
* This means that the following two calls are equivalent:
*
* >>> centers(shape=labels.shape, positions=np.argwhere(labels == 1), periodic=True)
* >>> labels_centers(labels=labels, names=[1], periodic=True)[0, :]
*
* @details
* For periodic algorithm, see:
* https://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions
*
* @param shape Shape of the array.
* @param positions List of positions (in array coordinates).
* @param shape Shape of the box to which the coordinates below (needed to apply periodicity).
* @param positions List of positions (in array coordinates, e.g. `[rows, columns]`).
* @param periodic Switch to assume array periodic.
* @return Coordinates of the center (in array coordinates).
* @return Coordinates of the center (in array coordinates, e.g. `[center_row, center_col]`).
*/
inline array_type::tensor<double, 1> center(
const array_type::tensor<double, 1>& shape,
Expand Down Expand Up @@ -1132,6 +1142,8 @@ class PositionList {
/**
* @brief Get the position of the center of each label.
*
* @note To compute the center of a single label, you can also use GooseEYE::center().
*
* @param labels An image with labels.
* @param names List of labels to compute the center for.
* @param periodic Switch to assume image periodic.
Expand Down

0 comments on commit bcf2fd7

Please sign in to comment.