v.1.0.0-rc.32

This commit is contained in:
2025-03-24 12:16:33 +01:00
parent 19be3575f0
commit a30707964d
176 changed files with 1360 additions and 710 deletions
+29 -27
View File
@@ -2,41 +2,43 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "ImageSpotFinder.h"
#include "../common/JFJochException.h"
#include "StrongPixelSet.h"
ImageSpotFinder::ImageSpotFinder(const DiffractionGeometry &geom, size_t width, size_t height)
: resolution_map(width*height), width(width), height(height) {
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
resolution_map[row * width + col] = geom.PxlToRes(col, row);
}
}
}
ImageSpotFinder::ImageSpotFinder(std::vector<float> &in_resolution_map, size_t in_width, size_t in_height)
: resolution_map(in_resolution_map), width(in_width), height(in_height) {
ImageSpotFinder::ImageSpotFinder(const std::vector<float> &in_resolution_map, size_t in_width, size_t in_height)
: resolution_map(in_resolution_map), width(in_width), height(in_height) {
if (resolution_map.size() != width * height)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Coordinate mismatch");
}
ImageSpotFinder &ImageSpotFinder::PixelMask(std::vector<uint32_t> &pixel_mask) {
if (pixel_mask.size() != width * height)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Coordinate mismatch");
for (int pxl = 0; pxl < width *height; pxl++) {
if (pixel_mask[pxl] != 0)
resolution_map[pxl] = 0.0f;
}
return *this;
}
ImageSpotFinder::ImageSpotFinder(const AzimuthalIntegration &integration)
: resolution_map(integration.Resolution()),
width(integration.GetWidth()),
height(integration.GetHeight()) {}
void ImageSpotFinder::nbx(int input) {
NBX = input;
}
std::vector<DiffractionSpot> ImageSpotFinder::Run(const int32_t *input,
std::vector<DiffractionSpot> ImageSpotFinder::Run(const int32_t *input, const SpotFindingSettings &settings) const {
return Run<int32_t>(input, INT32_MIN, settings);
}
std::vector<DiffractionSpot> ImageSpotFinder::Run(const int16_t *input, const SpotFindingSettings &settings) const {
return Run<int16_t>(input, INT16_MIN, settings);
}
std::vector<DiffractionSpot> ImageSpotFinder::Run(const uint32_t *input, const SpotFindingSettings &settings) const {
return Run<uint32_t>(input, UINT32_MAX, settings);
}
std::vector<DiffractionSpot> ImageSpotFinder::Run(const uint16_t *input, const SpotFindingSettings &settings) const {
return Run<uint16_t>(input, UINT16_MAX, settings);
}
template <class T>
std::vector<DiffractionSpot> ImageSpotFinder::Run(const T *input,
const T special_value,
const SpotFindingSettings &settings) const {
std::vector<DiffractionSpot> output;
StrongPixelSet strong_pixel_set;
@@ -71,7 +73,7 @@ std::vector<DiffractionSpot> ImageSpotFinder::Run(const int32_t *input,
for (int line = 0; line < NBX; line++) {
for (int col = 0; col < width; col++) {
auto pxl = line * width + col;
mask[pxl] = (input[pxl] == INT32_MIN)
mask[pxl] = (input[pxl] == special_value)
|| (resolution_map[pxl] < settings.high_resolution_limit)
|| (resolution_map[pxl] > settings.low_resolution_limit);
@@ -88,7 +90,7 @@ std::vector<DiffractionSpot> ImageSpotFinder::Run(const int32_t *input,
for (int col = 0; col < width; col++) {
if (line < height - NBX) {
auto pxl = (line + NBX) * width + col;
mask[pxl] = (input[pxl] == INT32_MIN)
mask[pxl] = (input[pxl] == special_value)
|| (resolution_map[pxl] <= settings.high_resolution_limit)
|| (resolution_map[pxl] >= settings.low_resolution_limit);
@@ -134,7 +136,7 @@ std::vector<DiffractionSpot> ImageSpotFinder::Run(const int32_t *input,
valid -= valid_vert[col - NBX - 1];
}
int32_t pxl_val = input[line * width + col];
T pxl_val = input[line * width + col];
int64_t var = valid * sum2 - (sum * sum);
int64_t in_minus_mean = pxl_val * valid - sum;