// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include #include "ImageSpotFinder.h" #include "StrongPixelSet.h" ImageSpotFinder::ImageSpotFinder(int32_t width, int32_t height) : width(width), height(height), output_buffer(width * height / 32 + 1) { } size_t ImageSpotFinder::OutputSize() const { return (width * height) / 32 + ((width * height % 32 != 0) ? 1 : 0); } size_t ImageSpotFinder::OutputByteSize() const { return OutputSize() * sizeof(uint32_t); } std::vector ImageSpotFinder::ExtractSpots(const ImagePreprocessorBuffer &image, const SpotFindingSettings &settings, const std::vector &res_mask) { StrongPixelSet pixel_set; for (int i = 0; i < OutputSize(); i++) { if (output_buffer[i]) { std::bitset<32> bset = output_buffer[i]; for (int bit = 0; bit < 32; bit++) { if (bset.test(bit)) { size_t npixel = i * 32 + bit; size_t col = npixel % width; size_t line = npixel / width; if (line < height && res_mask[npixel] == 0) pixel_set.AddStrongPixel(col, line, image[npixel]); } } } } std::vector vec; pixel_set.FindSpotsImage(settings, vec); return vec; }