mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-12 15:27:13 +02:00
Enable VarClusterFinder (#134)
Co-authored-by: xiangyu.xie <xiangyu.xie@psi.ch>
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "aare/NDArray.hpp"
|
#include "aare/NDArray.hpp"
|
||||||
|
|
||||||
const int MAX_CLUSTER_SIZE = 200;
|
const int MAX_CLUSTER_SIZE = 50;
|
||||||
namespace aare {
|
namespace aare {
|
||||||
|
|
||||||
template <typename T> class VarClusterFinder {
|
template <typename T> class VarClusterFinder {
|
||||||
|
@ -19,7 +19,7 @@ using namespace::aare;
|
|||||||
|
|
||||||
void define_var_cluster_finder_bindings(py::module &m) {
|
void define_var_cluster_finder_bindings(py::module &m) {
|
||||||
PYBIND11_NUMPY_DTYPE(VarClusterFinder<double>::Hit, size, row, col,
|
PYBIND11_NUMPY_DTYPE(VarClusterFinder<double>::Hit, size, row, col,
|
||||||
reserved, energy, max);
|
reserved, energy, max, rows, cols, enes);
|
||||||
|
|
||||||
py::class_<VarClusterFinder<double>>(m, "VarClusterFinder")
|
py::class_<VarClusterFinder<double>>(m, "VarClusterFinder")
|
||||||
.def(py::init<Shape<2>, double>())
|
.def(py::init<Shape<2>, double>())
|
||||||
@ -28,6 +28,15 @@ void define_var_cluster_finder_bindings(py::module &m) {
|
|||||||
auto ptr = new NDArray<int, 2>(self.labeled());
|
auto ptr = new NDArray<int, 2>(self.labeled());
|
||||||
return return_image_data(ptr);
|
return return_image_data(ptr);
|
||||||
})
|
})
|
||||||
|
.def("set_noiseMap",
|
||||||
|
[](VarClusterFinder<double> &self,
|
||||||
|
py::array_t<double, py::array::c_style | py::array::forcecast>
|
||||||
|
noise_map) {
|
||||||
|
auto noise_map_span = make_view_2d(noise_map);
|
||||||
|
self.set_noiseMap(noise_map_span);
|
||||||
|
})
|
||||||
|
.def("set_peripheralThresholdFactor",
|
||||||
|
&VarClusterFinder<double>::set_peripheralThresholdFactor)
|
||||||
.def("find_clusters",
|
.def("find_clusters",
|
||||||
[](VarClusterFinder<double> &self,
|
[](VarClusterFinder<double> &self,
|
||||||
py::array_t<double, py::array::c_style | py::array::forcecast>
|
py::array_t<double, py::array::c_style | py::array::forcecast>
|
||||||
@ -35,6 +44,30 @@ void define_var_cluster_finder_bindings(py::module &m) {
|
|||||||
auto view = make_view_2d(img);
|
auto view = make_view_2d(img);
|
||||||
self.find_clusters(view);
|
self.find_clusters(view);
|
||||||
})
|
})
|
||||||
|
.def("find_clusters_X",
|
||||||
|
[](VarClusterFinder<double> &self,
|
||||||
|
py::array_t<double, py::array::c_style | py::array::forcecast>
|
||||||
|
img) {
|
||||||
|
auto img_span = make_view_2d(img);
|
||||||
|
self.find_clusters_X(img_span);
|
||||||
|
})
|
||||||
|
.def("single_pass",
|
||||||
|
[](VarClusterFinder<double> &self,
|
||||||
|
py::array_t<double, py::array::c_style | py::array::forcecast>
|
||||||
|
img) {
|
||||||
|
auto img_span = make_view_2d(img);
|
||||||
|
self.single_pass(img_span);
|
||||||
|
})
|
||||||
|
.def("hits",
|
||||||
|
[](VarClusterFinder<double> &self) {
|
||||||
|
auto ptr = new std::vector<VarClusterFinder<double>::Hit>(
|
||||||
|
self.steal_hits());
|
||||||
|
return return_vector(ptr);
|
||||||
|
})
|
||||||
|
.def("clear_hits",
|
||||||
|
[](VarClusterFinder<double> &self) {
|
||||||
|
self.clear_hits();
|
||||||
|
})
|
||||||
.def("steal_hits",
|
.def("steal_hits",
|
||||||
[](VarClusterFinder<double> &self) {
|
[](VarClusterFinder<double> &self) {
|
||||||
auto ptr = new std::vector<VarClusterFinder<double>::Hit>(
|
auto ptr = new std::vector<VarClusterFinder<double>::Hit>(
|
||||||
|
Reference in New Issue
Block a user