MXAnalysisWithoutFPGA: Azimuthal integration moved to spot finder
This commit is contained in:
@@ -49,7 +49,7 @@ void MXAnalysisWithoutFPGA::Analyze(DataMessage &output,
|
||||
output.preprocessing_time_s = std::chrono::duration<float>(preprocessing_end_time - preprocessing_start_time).count();
|
||||
|
||||
const auto azint_start_time = std::chrono::steady_clock::now();
|
||||
preprocessor->AzimIntegration(integration, profile);
|
||||
spotFinder->AzimIntegration(integration, profile);
|
||||
const auto azint_end_time = std::chrono::steady_clock::now();
|
||||
output.azint_time_s = std::chrono::duration<float>(azint_end_time - azint_start_time).count();
|
||||
|
||||
|
||||
@@ -70,30 +70,3 @@ ImageStatistics ImagePreprocessor::Analyze(const uint8_t *input, T err_pixel_val
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ImagePreprocessor::AzimIntegration(const AzimuthalIntegration &integration, AzimuthalIntegrationProfile &profile) {
|
||||
const auto azint_bins = integration.GetBinNumber();
|
||||
std::vector<float> azint_sum(azint_bins);
|
||||
std::vector<float> azint_sum2(azint_bins);
|
||||
std::vector<uint32_t> azint_count(azint_bins);
|
||||
|
||||
for (int i = 0; i < azint_count.size(); i++) {
|
||||
azint_sum[i] = 0.0f;
|
||||
azint_sum2[i] = 0.0f;
|
||||
azint_count[i] = 0;
|
||||
}
|
||||
|
||||
auto &pixel_to_bin = integration.GetPixelToBin();
|
||||
auto &corrections = integration.Corrections();
|
||||
|
||||
for (int i = 0; i < npixels; i++) {
|
||||
const uint16_t bin = pixel_to_bin[i];
|
||||
if (bin < azint_bins) {
|
||||
float val = static_cast<float>(processed_image[i]) * corrections[i];
|
||||
azint_sum[bin] += val;
|
||||
++azint_count[bin];
|
||||
}
|
||||
}
|
||||
profile.Clear(integration);
|
||||
profile.Add(azint_sum, azint_count);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
#include <cstddef>
|
||||
#include "../common/CompressedImage.h"
|
||||
#include "../common/DiffractionExperiment.h"
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/PixelMask.h"
|
||||
#include "../common/AzimuthalIntegrationProfile.h"
|
||||
|
||||
struct ImageStatistics {
|
||||
size_t error_pixel_count = 0;
|
||||
@@ -33,6 +31,4 @@ public:
|
||||
std::vector<int32_t> &processed_image);
|
||||
|
||||
ImageStatistics Analyze(const uint8_t *decompressed_image, CompressedImageMode image_mode);
|
||||
|
||||
void AzimIntegration(const AzimuthalIntegration &integration, AzimuthalIntegrationProfile &profile);
|
||||
};
|
||||
|
||||
@@ -44,4 +44,34 @@ std::vector<DiffractionSpot> ImageSpotFinder::ExtractSpots(const SpotFindingSett
|
||||
return vec;
|
||||
}
|
||||
|
||||
void ImageSpotFinder::AzimIntegration(const AzimuthalIntegration &integration, AzimuthalIntegrationProfile &profile) {
|
||||
const auto azint_bins = integration.GetBinNumber();
|
||||
std::vector<float> azint_sum(azint_bins);
|
||||
std::vector<float> azint_sum2(azint_bins);
|
||||
std::vector<uint32_t> azint_count(azint_bins);
|
||||
|
||||
for (int i = 0; i < azint_count.size(); i++) {
|
||||
azint_sum[i] = 0.0f;
|
||||
azint_sum2[i] = 0.0f;
|
||||
azint_count[i] = 0;
|
||||
}
|
||||
|
||||
auto &pixel_to_bin = integration.GetPixelToBin();
|
||||
auto &corrections = integration.Corrections();
|
||||
|
||||
if (pixel_to_bin.size() != width * height || corrections.size() != width * height)
|
||||
throw std::runtime_error("ImageSpotFinder::AzimIntegration: Mismatch in size");
|
||||
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
const uint16_t bin = pixel_to_bin[i];
|
||||
if (bin < azint_bins) {
|
||||
float val = static_cast<float>(input_buffer[i]) * corrections[i];
|
||||
azint_sum[bin] += val;
|
||||
++azint_count[bin];
|
||||
}
|
||||
}
|
||||
profile.Clear(integration);
|
||||
profile.Add(azint_sum, azint_count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
|
||||
#include "../../common/DiffractionSpot.h"
|
||||
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/AzimuthalIntegrationProfile.h"
|
||||
|
||||
class ImageSpotFinder {
|
||||
protected:
|
||||
const int32_t width, height;
|
||||
@@ -27,6 +30,8 @@ public:
|
||||
|
||||
virtual ~ImageSpotFinder() = default;
|
||||
virtual std::vector<DiffractionSpot> Run(const SpotFindingSettings &settings, const std::vector<bool> &res_mask) = 0;
|
||||
|
||||
void AzimIntegration(const AzimuthalIntegration &integration, AzimuthalIntegrationProfile &profile);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user