Build Packages / Unit tests (push) Successful in 1h31m59s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 8m43s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m5s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 9m27s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m56s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 9m24s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 10m27s
Build Packages / build:rpm (rocky8) (push) Successful in 9m20s
Build Packages / build:rpm (rocky9) (push) Successful in 10m50s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m54s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m38s
Build Packages / DIALS test (push) Successful in 12m13s
Build Packages / XDS test (durin plugin) (push) Successful in 7m8s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 7m8s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m50s
Build Packages / Generate python client (push) Successful in 16s
Build Packages / Build documentation (push) Successful in 50s
Build Packages / Create release (push) Skipped
This is an UNSTABLE release. It includes many experimental features, as well as many AI generated fixes. We recommend using rc.152 for production use. * jfjoch_broker: Add EXPERIMENTAL pixelrefine mode for image processing * jfjoch_broker: Allow to load user mask from 8-bit and 16-bit TIFF files * jfjoch_broker: Add ROI calculation in non-FPGA workflow * jfjoch_broker: Fixes to TCP image pusher * jfjoch_broker: Remove NUMA bindings * jfjoch_broker: Improvements to indexing * jfjoch_broker: For PSI EIGER, trimming energies are taken from the detector configuration (now compulsory) instead of hardcoded values * jfjoch_writer: Save ROI definitions and the per-pixel ROI bitmap in the master file; azimuthal ROIs support phi (angular) sectors * jfjoch_viewer: Major redesign with dockable panels and saved layouts, plus on-canvas creation/move/resize of box, circle and azimuthal ROIs * jfjoch_viewer: Run jfjoch_process reprocessing jobs from inside the GUI and overlay per-run results Reviewed-on: #63
72 lines
2.6 KiB
C++
72 lines
2.6 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <limits>
|
|
#include <type_traits>
|
|
|
|
#include "ROIIntegration.h"
|
|
#include "../../common/JFJochException.h"
|
|
|
|
class ROIIntegrationCPU : public ROIIntegration {
|
|
public:
|
|
explicit ROIIntegrationCPU(const DiffractionExperiment &experiment);
|
|
|
|
// image is anything indexable with operator[] and size(). Templated on the
|
|
// pixel type so a future narrow-integer (e.g. 16-bit) path works as well.
|
|
template <class T>
|
|
void RunROI(const T &image, std::map<std::string, ROIMessage> &out) {
|
|
if (image.size() != npixel)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"ROIIntegration: mismatch in image size");
|
|
|
|
for (uint16_t r = 0; r < roi_count; r++) {
|
|
roi_sum[r] = 0;
|
|
roi_sum2[r] = 0;
|
|
roi_pixels[r] = 0;
|
|
roi_x_weighted[r] = 0;
|
|
roi_y_weighted[r] = 0;
|
|
roi_max[r] = INT64_MIN;
|
|
}
|
|
|
|
using pixel_t = std::remove_cv_t<std::remove_reference_t<decltype(image[0])>>;
|
|
|
|
for (size_t i = 0; i < npixel; i++) {
|
|
const uint16_t mask = roi_map[i];
|
|
if (mask == 0)
|
|
continue;
|
|
|
|
const pixel_t v = image[i];
|
|
// masked/bad pixels (signed types only) are excluded entirely
|
|
if constexpr (std::is_signed_v<pixel_t>) {
|
|
if (v == std::numeric_limits<pixel_t>::min())
|
|
continue;
|
|
}
|
|
// saturated pixels still count towards the max, but not the sums
|
|
const bool saturated = (v == std::numeric_limits<pixel_t>::max());
|
|
|
|
const int64_t val = static_cast<int64_t>(v);
|
|
const int64_t x = static_cast<int64_t>(i % width);
|
|
const int64_t y = static_cast<int64_t>(i / width);
|
|
|
|
for (uint16_t r = 0; r < roi_count; r++) {
|
|
if (!(mask & (1u << r)))
|
|
continue;
|
|
if (!saturated) {
|
|
roi_sum[r] += val;
|
|
roi_sum2[r] += static_cast<uint64_t>(val * val);
|
|
roi_pixels[r] += 1;
|
|
roi_x_weighted[r] += val * x;
|
|
roi_y_weighted[r] += val * y;
|
|
}
|
|
if (val > roi_max[r])
|
|
roi_max[r] = val;
|
|
}
|
|
}
|
|
Export(out);
|
|
}
|
|
|
|
void Run(const ImagePreprocessorBuffer &image, std::map<std::string, ROIMessage> &out) override;
|
|
};
|