From e48474e97ce3fada7b797200d7ee1a575cbbb230 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Mon, 1 May 2023 18:36:37 +0200 Subject: [PATCH] FrameTransformations: Minor adjustments between functions --- common/FrameTransformation.cpp | 52 +++++++++++++++++----------------- common/FrameTransformation.h | 1 + 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/common/FrameTransformation.cpp b/common/FrameTransformation.cpp index 50d34ec7..05a05e2a 100644 --- a/common/FrameTransformation.cpp +++ b/common/FrameTransformation.cpp @@ -74,34 +74,39 @@ void FrameTransformation::PackSummation() { for (auto &i: summation_buffer[m]) i = 0; } +} - if (binning_2x2) - Bin2x2_sum((int32_t *) precompression_buffer.data(), - (int32_t *) full_image_buffer.data(), - experiment.GetXPixelsNumFullImage(), - experiment.GetYPixelsNumFullImage(), - static_cast(experiment.GetUnderflow()), - static_cast(experiment.GetOverflow())); +void FrameTransformation::Generate16BitPreview() { + // Generate 16-bit preview image + auto arr = (int32_t *) precompression_buffer.data(); - if (pixel_depth == 4) { - // Generate 16-bit preview image - auto arr = (int32_t *) precompression_buffer.data(); - - for (int pxl = 0; pxl < experiment.GetPixelsNum(); pxl++) { - if (arr[pxl] >= INT16_MAX) - image16bit[pxl] = INT16_MAX; - else if (arr[pxl] <= INT16_MIN) - image16bit[pxl] = INT16_MIN; - else - image16bit[pxl] = static_cast(arr[pxl]); - } + for (int pxl = 0; pxl < experiment.GetPixelsNum(); pxl++) { + if (arr[pxl] >= INT16_MAX) + image16bit[pxl] = INT16_MAX; + else if (arr[pxl] <= INT16_MIN) + image16bit[pxl] = INT16_MIN; + else + image16bit[pxl] = static_cast(arr[pxl]); } } size_t FrameTransformation::PackStandardOutput() { - if (summation > 1) + if (standard_output == nullptr) + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Default stream output not initialized"); + + if (summation > 1) { PackSummation(); - else { + if (binning_2x2) + Bin2x2_sum((int32_t *) precompression_buffer.data(), + (int32_t *) full_image_buffer.data(), + experiment.GetXPixelsNumFullImage(), + experiment.GetYPixelsNumFullImage(), + static_cast(experiment.GetUnderflow()), + static_cast(experiment.GetOverflow())); + + if (pixel_depth == 4) + Generate16BitPreview(); + } else { if (binning_2x2) Bin2x2_sum((int16_t *) precompression_buffer.data(), (int16_t *) full_image_buffer.data(), @@ -114,8 +119,6 @@ size_t FrameTransformation::PackStandardOutput() { } void FrameTransformation::ProcessModule(const int16_t *input, uint16_t module_number, int data_stream) { - if (standard_output == nullptr) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Default stream output not initialized"); size_t module_number_abs = experiment.GetFirstModuleOfDataStream(data_stream) + module_number; @@ -151,9 +154,6 @@ int16_t *FrameTransformation::GetPreview16BitImage() { } void FrameTransformation::ProcessModule(JFConversion &conv, const int16_t *input, uint16_t module_number, int data_stream) { - if (standard_output == nullptr) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Default stream output not initialized"); - size_t module_number_abs = experiment.GetFirstModuleOfDataStream(data_stream) + module_number; if (summation == 1) { diff --git a/common/FrameTransformation.h b/common/FrameTransformation.h index 8da6668b..ad463ce7 100644 --- a/common/FrameTransformation.h +++ b/common/FrameTransformation.h @@ -24,6 +24,7 @@ class FrameTransformation { std::vector full_image_buffer; bool binning_2x2; void PackSummation(); // transfer summed image to converted coordinates, clear summation buffer, no compression + void Generate16BitPreview(); public: FrameTransformation(const DiffractionExperiment &experiment); FrameTransformation& SetOutput(void *output);