JFJochReceiver: Per-data-file radial integration profile
This commit is contained in:
@@ -4,7 +4,7 @@ ADD_LIBRARY(ImageAnalysis STATIC
|
||||
GPUImageAnalysis.h
|
||||
RadialIntegration.cpp RadialIntegration.h
|
||||
RadialIntegrationMapping.cpp RadialIntegrationMapping.h
|
||||
StrongPixelSet.cpp StrongPixelSet.h GPUImageAnalysis_Alt.cpp)
|
||||
StrongPixelSet.cpp StrongPixelSet.h GPUImageAnalysis_Alt.cpp RadialIntegrationProfile.cpp RadialIntegrationProfile.h)
|
||||
|
||||
TARGET_LINK_LIBRARIES(ImageAnalysis CommonFunctions)
|
||||
|
||||
|
||||
37
image_analysis/RadialIntegrationProfile.cpp
Normal file
37
image_analysis/RadialIntegrationProfile.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "RadialIntegrationProfile.h"
|
||||
#include "../common/JFJochException.h"
|
||||
|
||||
RadialIntegrationProfile::RadialIntegrationProfile(RadialIntegrationMapping &mapping)
|
||||
: bin_to_q(mapping.GetBinToQ()),
|
||||
sum(mapping.GetBinNumber(), 0),
|
||||
count(mapping.GetBinNumber(), 0) {
|
||||
|
||||
}
|
||||
|
||||
void RadialIntegrationProfile::Add(const std::vector<int32_t> &in_sum, const std::vector<int32_t> &in_count) {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
|
||||
if ((in_sum.size() == sum.size()) && (in_count.size() == count.size())) {
|
||||
for (int i = 0; i < sum.size(); i++) {
|
||||
sum[i] += in_sum[i];
|
||||
count[i] += in_count[i];
|
||||
}
|
||||
} else if (!in_sum.empty() && !in_count.empty())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Mismatch in size of sum/count datasets");
|
||||
}
|
||||
|
||||
void RadialIntegrationProfile::GetPlot(JFJochProtoBuf::Plot &plot) const {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
|
||||
std::vector<float> rad_int_profile(sum.size());
|
||||
for (int i = 0; i < sum.size(); i++) {
|
||||
if (count[i] > 0)
|
||||
rad_int_profile[i] = static_cast<float>(sum[i]) / static_cast<float>(count[i]);
|
||||
}
|
||||
|
||||
*plot.mutable_x() = {bin_to_q.begin(), bin_to_q.end()};
|
||||
*plot.mutable_y() = {rad_int_profile.begin(), rad_int_profile.end()};
|
||||
}
|
||||
24
image_analysis/RadialIntegrationProfile.h
Normal file
24
image_analysis/RadialIntegrationProfile.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef JUNGFRAUJOCH_RADIALINTEGRATIONPROFILE_H
|
||||
#define JUNGFRAUJOCH_RADIALINTEGRATIONPROFILE_H
|
||||
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <jfjoch.pb.h>
|
||||
|
||||
#include "RadialIntegrationMapping.h"
|
||||
|
||||
class RadialIntegrationProfile {
|
||||
mutable std::mutex m;
|
||||
std::vector<int64_t> sum;
|
||||
std::vector<int64_t> count;
|
||||
std::vector<float> bin_to_q;
|
||||
public:
|
||||
explicit RadialIntegrationProfile(RadialIntegrationMapping &mapping);
|
||||
void Add(const std::vector<int32_t> &sum, const std::vector<int32_t> &count);
|
||||
void GetPlot(JFJochProtoBuf::Plot &plot) const;
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_RADIALINTEGRATIONPROFILE_H
|
||||
Reference in New Issue
Block a user