diff --git a/docs/src/python/cluster/pyClusterVector.rst b/docs/src/python/cluster/pyClusterVector.rst index 5805fcd8..6778278f 100644 --- a/docs/src/python/cluster/pyClusterVector.rst +++ b/docs/src/python/cluster/pyClusterVector.rst @@ -72,10 +72,10 @@ API. .. py:function:: reduce_to_3x3(clustervector) :noindex: - Return a new vector containing the center adjacent highest sum 3x3 block of every input cluster. + Return a new vector containing the central 3x3 block of every input cluster. Cluster order, coordinates, frame number, and pixel dtype are preserved. - :param ClusterVector clustervector: Input clusters of size 3x3 or larger. + :param ClusterVector clustervector: Input clusters with odd dimensions of 3x3 or larger. :return: Reduced 3x3 clusters. :rtype: ClusterVector diff --git a/include/aare/Cluster.hpp b/include/aare/Cluster.hpp index 061b0b2d..b2a274fe 100755 --- a/include/aare/Cluster.hpp +++ b/include/aare/Cluster.hpp @@ -193,7 +193,8 @@ Cluster reduce_to_2x2(const Cluster &c) { /** * @brief Reduce a cluster to the 3x3 block around its center index. * @param c Cluster to reduce - * @return Reduced cluster with the input coordinates + * @pre ClusterSizeX and ClusterSizeY must both be odd. + * @return Reduced cluster. Input coordinates are preserved. */ template @@ -202,6 +203,8 @@ reduce_to_3x3(const Cluster &c) { static_assert(ClusterSizeX >= 3 && ClusterSizeY >= 3, "Cluster sizes must be at least 3x3 for reduction to 3x3"); + static_assert(ClusterSizeX % 2 == 1 && ClusterSizeY % 2 == 1, + "Cluster sizes must be odd for reduction to 3x3"); Cluster result{}; diff --git a/include/aare/ClusterVector.hpp b/include/aare/ClusterVector.hpp index 9b045d8c..65246ff1 100644 --- a/include/aare/ClusterVector.hpp +++ b/include/aare/ClusterVector.hpp @@ -241,6 +241,7 @@ ClusterVector> reduce_to_2x2( /** * @brief Reduce every cluster to the 3x3 block around its center index. * @param cv ClusterVector containing clusters to reduce + * @pre ClusterSizeX and ClusterSizeY must both be odd. * @return ClusterVector of 3x3 clusters in the original order and with the * original frame number * @note Coordinates are preserved. diff --git a/python/src/bind_Cluster.hpp b/python/src/bind_Cluster.hpp index 2ff37270..f97f42f6 100644 --- a/python/src/bind_Cluster.hpp +++ b/python/src/bind_Cluster.hpp @@ -91,6 +91,7 @@ void reduce_to_3x3(py::module &m) { py::return_value_policy::move, py::arg("cluster"), R"doc( Return the 3x3 block around the cluster's center index. + The input cluster dimensions must both be odd. The input coordinates are preserved and output data is stored in row-major order. )doc"); diff --git a/python/src/bind_ClusterVector.hpp b/python/src/bind_ClusterVector.hpp index 2780eeea..03e0a57b 100644 --- a/python/src/bind_ClusterVector.hpp +++ b/python/src/bind_ClusterVector.hpp @@ -225,6 +225,7 @@ void define_3x3_reduction(py::module &m) { }, R"doc( Reduce every cluster to the 3x3 block around its center index. + The input cluster dimensions must both be odd. Returns a new ClusterVector; cluster order, coordinates, and frame number are preserved. )doc",