42 lines
1.5 KiB
C++
42 lines
1.5 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include "AzIntEngine.h"
|
|
|
|
class AzIntEngineCPU : public AzIntEngine {
|
|
public:
|
|
// image is anything that can be referenced with operator[]
|
|
template <class T>
|
|
void RunAzint(const T &image, AzimuthalIntegrationProfile &profile) {
|
|
for (int i = 0; i < azint_count.size(); i++) {
|
|
azint_sum[i] = 0.0f;
|
|
azint_sum2[i] = 0.0f;
|
|
azint_count[i] = 0;
|
|
}
|
|
|
|
if (image.size() != npixel)
|
|
throw std::runtime_error("ImageSpotFinder::AzimIntegration: Mismatch in size");
|
|
|
|
const uint16_t *pixel_to_bin = integration.GetPixelToBin().data();
|
|
const float *corrections = integration.Corrections().data();
|
|
|
|
for (int i = 0; i < image.size(); i++) {
|
|
const float val = static_cast<float>(image[i]) * corrections[i];
|
|
const float val_sq = val * val;
|
|
const uint16_t bin = pixel_to_bin[i];
|
|
if (bin < azint_bins) {
|
|
azint_sum[bin] += val;
|
|
azint_sum2[bin] += val_sq;
|
|
++azint_count[bin];
|
|
}
|
|
}
|
|
|
|
profile.Clear(integration);
|
|
profile.Add(azint_sum, azint_sum2, azint_count);
|
|
}
|
|
|
|
AzIntEngineCPU(const AzimuthalIntegrationMapping& integration);
|
|
void Run(const ImagePreprocessorBuffer &image, AzimuthalIntegrationProfile &profile) override;
|
|
}; |