diff --git a/include/aare/VarClusterFinder.hpp b/include/aare/VarClusterFinder.hpp index d43936c..b3d583c 100644 --- a/include/aare/VarClusterFinder.hpp +++ b/include/aare/VarClusterFinder.hpp @@ -45,7 +45,11 @@ template class VarClusterFinder { {-1, -1, 0, 1}}; // col ### 8-neighbour by scaning from top to bottom const std::array di_{{0, 0, -1, 1, -1, 1, -1, 1}}; // row const std::array dj_{{-1, 1, 0, 0, 1, -1, -1, 1}}; // col - std::map child; // heirachy: key: child; val: parent + std::map child; // heirachy: key: child; val: parent + int numberOfNeighbours = 8; // 4 or 8 + bool empty_surroundingPixels = + true; // whether to set peripheral pixels to 0, to avoid potential + // influence for pedestal updating std::unordered_map h_size; std::vector hits; // std::vector> row @@ -67,6 +71,16 @@ template class VarClusterFinder { void set_peripheralThresholdFactor(int factor) { peripheralThresholdFactor_ = factor; } + void set_numberOfNeighbours(int num) { + if (num == 4 || num == 8) + numberOfNeighbours = num; + else + throw std::runtime_error( + LOCATION + "number of neighbours should be either 4 or 8"); + } + void set_empty_surroundingPixels(bool empty) { + empty_surroundingPixels = empty; + } void find_clusters(NDView img); void find_clusters_X(NDView img); void rec_FillHit(int clusterIndex, int i, int j); @@ -201,7 +215,7 @@ void VarClusterFinder::rec_FillHit(int clusterIndex, int i, int j) { } original_(i, j) = 0; - for (int k = 0; k < 8; ++k) { // 8 for 8-neighbour + for (int k = 0; k < numberOfNeighbours; ++k) { // const auto row = i + di_[k]; const auto col = j + dj_[k]; if (row >= 0 && col >= 0 && row < shape_[0] && col < shape_[1]) { @@ -218,9 +232,11 @@ void VarClusterFinder::rec_FillHit(int clusterIndex, int i, int j) { // h_size[clusterIndex].enes[h_size[clusterIndex].size] = // original_(row, col); // }// ? weather to include peripheral pixels - original_(row, col) = - 0; // remove peripheral pixels, to avoid potential influence - // for pedestal updating + if (empty_surroundingPixels) { + original_(row, col) = + 0; // remove peripheral pixels, to avoid potential + // influence for pedestal updating + } } } } diff --git a/python/src/var_cluster.hpp b/python/src/var_cluster.hpp index 90de908..3437acd 100644 --- a/python/src/var_cluster.hpp +++ b/python/src/var_cluster.hpp @@ -34,6 +34,10 @@ void define_var_cluster_finder_bindings(py::module &m) { auto noise_map_span = make_view_2d(noise_map); self.set_noiseMap(noise_map_span); }) + .def("set_numberOfNeighbours", + &VarClusterFinder::set_numberOfNeighbours) + .def("set_empty_surroundingPixels", + &VarClusterFinder::set_empty_surroundingPixels) .def("set_peripheralThresholdFactor", &VarClusterFinder::set_peripheralThresholdFactor) .def("find_clusters",