jfjoch_viewer: ROI calculated inside image viewer
This commit is contained in:
@@ -23,8 +23,7 @@ JFJochReaderImage::JFJochReaderImage(const JFJochReaderImage &other)
|
||||
message(other.message),
|
||||
saturated_pixel(other.saturated_pixel),
|
||||
error_pixel(other.error_pixel),
|
||||
valid_pixel(other.valid_pixel),
|
||||
roi(other.roi) {
|
||||
valid_pixel(other.valid_pixel) {
|
||||
// Need to make image use local copy
|
||||
message.image = CompressedImage(image, dataset->experiment.GetXPixelsNum(),
|
||||
dataset->experiment.GetYPixelsNum());
|
||||
@@ -201,48 +200,6 @@ void JFJochReaderImage::AddImage(const JFJochReaderImage &other) {
|
||||
CalcAutoContrast();
|
||||
}
|
||||
|
||||
void JFJochReaderImage::CalcROI(const ROIElement *input) {
|
||||
std::unique_lock ul(roi_mutex);
|
||||
|
||||
if (!input) {
|
||||
roi = {};
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t width = dataset->experiment.GetXPixelsNum();
|
||||
int64_t height = dataset->experiment.GetYPixelsNum();
|
||||
|
||||
int64_t roi_val = 0;
|
||||
uint64_t roi_val_2 = 0;
|
||||
int64_t roi_max = INT64_MIN;
|
||||
uint64_t roi_npixel = 0;
|
||||
|
||||
for (int64_t y = 0; y < height; y++) {
|
||||
for (int64_t x = 0; x < width; x++) {
|
||||
int32_t val = image[x + width * y];
|
||||
if (input->CheckROI(x, y, 0.0) && (val != SATURATED_PXL_VALUE)
|
||||
&& (val != ERROR_PXL_VALUE) && (val != GAP_PXL_VALUE)) {
|
||||
roi_val += val;
|
||||
roi_val_2 += val * val;
|
||||
if (val > roi_max) roi_max = val;
|
||||
roi_npixel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
roi = ROIMessage{
|
||||
.sum = roi_val,
|
||||
.sum_square = roi_val_2,
|
||||
.max_count = roi_max,
|
||||
.pixels = roi_npixel
|
||||
};
|
||||
}
|
||||
|
||||
const std::optional<ROIMessage> &JFJochReaderImage::GetROI() const {
|
||||
std::unique_lock ul(roi_mutex);
|
||||
return roi;
|
||||
}
|
||||
|
||||
std::vector<float> JFJochReaderImage::GetAzInt1D() const {
|
||||
if (dataset->azimuthal_bins <= 1) {
|
||||
return message.az_int_profile;
|
||||
|
||||
Reference in New Issue
Block a user