Improve plotting
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// Copyright (2019-2024) Paul Scherrer Institute
|
||||
|
||||
#include "ROIMask.h"
|
||||
#include "JFJochException.h"
|
||||
|
||||
ROIMask::ROIMask(int64_t in_xpixel, int64_t in_ypixel)
|
||||
: mask(in_xpixel * in_ypixel, 0),
|
||||
xpixel(in_xpixel), ypixel(in_ypixel) {
|
||||
}
|
||||
|
||||
ROIMask::ROIMask(const DetectorSetup &setup)
|
||||
: ROIMask(setup.GetGeometry().GetWidth(), setup.GetGeometry().GetHeight()) {}
|
||||
|
||||
void ROIMask::UpdateMask() {
|
||||
roi_name_map.clear();
|
||||
|
||||
for (auto &i: mask)
|
||||
i = UINT16_MAX;
|
||||
|
||||
for (int i = 0; i < boxes.size(); i++) {
|
||||
boxes[i].MarkROI(mask, i, xpixel, ypixel);
|
||||
roi_name_map[boxes[i].GetName()] = i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < circles.size(); i++) {
|
||||
size_t id = boxes.size() + i;
|
||||
circles[i].MarkROI(mask, id, xpixel, ypixel);
|
||||
roi_name_map[circles[i].GetName()] = id;
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<uint16_t>& ROIMask::GetMask() const {
|
||||
return mask;
|
||||
}
|
||||
|
||||
const std::map<std::string, uint16_t> &ROIMask::GetROINameMap() const {
|
||||
return roi_name_map;
|
||||
}
|
||||
|
||||
void ROIMask::SetROIBox(const std::vector<ROIBox> &input) {
|
||||
if (boxes.size() > box_array_size)
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Limit of box ROIs exceeded");
|
||||
for (const auto &i: input) {
|
||||
if (i.GetXMax() >= xpixel)
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "ROI box X coordinate out of detector bounds");
|
||||
if (i.GetYMax() >= ypixel)
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "ROI box Y coordinate out of detector bounds");
|
||||
}
|
||||
boxes = input;
|
||||
UpdateMask();
|
||||
|
||||
}
|
||||
|
||||
void ROIMask::SetROICircle(const std::vector<ROICircle> &input) {
|
||||
if (circles.size() > circle_array_size)
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Limit of circular ROIs exceeded");
|
||||
circles = input;
|
||||
UpdateMask();
|
||||
}
|
||||
|
||||
const std::vector<ROIBox> &ROIMask::GetROIBox() const {
|
||||
return boxes;
|
||||
}
|
||||
|
||||
const std::vector<ROICircle> &ROIMask::GetROICircle() const {
|
||||
return circles;
|
||||
}
|
||||
Reference in New Issue
Block a user