#include "aare/calibration.hpp" namespace aare { NDArray count_switching_pixels(NDView raw_data) { NDArray switched( std::array{raw_data.shape(1), raw_data.shape(2)}, 0); for (int frame_nr = 0; frame_nr != raw_data.shape(0); ++frame_nr) { for (int row = 0; row != raw_data.shape(1); ++row) { for (int col = 0; col != raw_data.shape(2); ++col) { auto [value, gain] = get_value_and_gain(raw_data(frame_nr, row, col)); if (gain != 0) { switched(row, col) += 1; } } } } return switched; } NDArray count_switching_pixels(NDView raw_data, ssize_t n_threads) { NDArray switched( std::array{raw_data.shape(1), raw_data.shape(2)}, 0); std::vector>> futures; futures.reserve(n_threads); auto subviews = make_subviews(raw_data, n_threads); for (auto view : subviews) { futures.push_back( std::async(static_cast (*)(NDView)>( &count_switching_pixels), view)); } for (auto &f : futures) { switched += f.get(); } return switched; } } // namespace aare