Files
Jungfraujoch/common/ROIElement.cpp
2025-05-12 14:17:24 +02:00

35 lines
1.3 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "ROIElement.h"
#include "JFJochException.h"
ROIElement::ROIElement(const std::string &in_name)
: name(in_name) {}
std::string ROIElement::GetName() const {
return name;
}
void ROIElement::MarkROI(std::vector<uint16_t> &v, uint16_t value_to_mark, int64_t xpixel, int64_t ypixel,
const std::vector<float> &resolution_map) const {
if (resolution_map.size() != xpixel * ypixel)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"ROIRectangle: MarkROI mismatch in resolution array size");
if (v.size() < xpixel * ypixel)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"ROICircle::MarkROI mismatch in input array size");
if (value_to_mark >= 16)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"ROICircle: Only 16-bit available for ROI");
for (int64_t y = 0; y < ypixel; y++) {
for (int64_t x = 0; x < xpixel; x++) {
if (CheckROI(x, y, resolution_map[y * xpixel + x]))
v[y * xpixel + x] |= (1<<value_to_mark);
}
}
}