diff --git a/image_analysis/ImageAnalysisCPU.cpp b/image_analysis/ImageAnalysisCPU.cpp index 400b8567..c14a30a1 100644 --- a/image_analysis/ImageAnalysisCPU.cpp +++ b/image_analysis/ImageAnalysisCPU.cpp @@ -18,8 +18,8 @@ ImageAnalysisCPU::ImageAnalysisCPU(const DiffractionExperiment &in_experiment, roi_count(0), npixels(experiment.GetPixelsNum()), xpixels(experiment.GetXPixelsNum()), - mask_1byte(npixels, false), - spotFinder(in_integration), + mask_1bit(npixels, false), + spotFinder(mask_1bit, in_integration), indexer(in_indexer), saturation_limit(experiment.GetSaturationLimit()), mask(in_mask), @@ -30,7 +30,7 @@ ImageAnalysisCPU::ImageAnalysisCPU(const DiffractionExperiment &in_experiment, roi_names = experiment.ROI().GetROINameMap(); for (int i = 0; i < npixels; i++) - mask_1byte[i] = (in_mask.GetMask().at(i) != 0); + mask_1bit[i] = (in_mask.GetMask().at(i) != 0); } void ImageAnalysisCPU::Analyze(DataMessage &output, std::vector &image, AzimuthalIntegrationProfile &profile, @@ -97,7 +97,7 @@ void ImageAnalysisCPU::Analyze(DataMessage &output, profile.Clear(integration); for (int i = 0; i < npixels; i++) { - if (mask_1byte[i] != 0) { + if (mask_1bit[i] != 0) { updated_image[i] = INT32_MIN; ++masked_pixels; } else if (image[i] >= sat_pixel_val) { diff --git a/image_analysis/ImageAnalysisCPU.h b/image_analysis/ImageAnalysisCPU.h index 39a27f13..2441a13e 100644 --- a/image_analysis/ImageAnalysisCPU.h +++ b/image_analysis/ImageAnalysisCPU.h @@ -26,7 +26,7 @@ class ImageAnalysisCPU { size_t npixels; size_t xpixels; - std::vector mask_1byte; + std::vector mask_1bit; ImageSpotFinder spotFinder; IndexerThreadPool *indexer; diff --git a/image_analysis/spot_finding/ImageSpotFinder.cpp b/image_analysis/spot_finding/ImageSpotFinder.cpp index 0a93b565..d7e81ec8 100644 --- a/image_analysis/spot_finding/ImageSpotFinder.cpp +++ b/image_analysis/spot_finding/ImageSpotFinder.cpp @@ -4,20 +4,27 @@ #include "ImageSpotFinder.h" #include "StrongPixelSet.h" -ImageSpotFinder::ImageSpotFinder(const std::vector &in_resolution_map, size_t in_width, size_t in_height) - : width(in_width), height(in_height), - resolution_map(in_resolution_map), - resolution_mask(width * height, 0) { +ImageSpotFinder::ImageSpotFinder(const std::vector &mask, const std::vector &in_resolution_map, size_t in_width, size_t in_height) + : width(in_width), height(in_height), resolution_map(in_resolution_map), + resolution_mask(width * height, 0), + mask(mask) { + if (mask.size() != width * height) + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, + "Coordinate mismatch of mask size"); if (resolution_map.size() != width * height) throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Coordinate mismatch"); } -ImageSpotFinder::ImageSpotFinder(const AzimuthalIntegration &integration) +ImageSpotFinder::ImageSpotFinder(const std::vector &mask, const AzimuthalIntegration &integration) : width(integration.GetWidth()), height(integration.GetHeight()), resolution_map(integration.Resolution()), - resolution_mask(width * height, 0) { + resolution_mask(width * height, 0), + mask(mask) { + if (mask.size() != width * height) + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, + "Coordinate mismatch of mask size"); } void ImageSpotFinder::nbx(int input) { @@ -28,8 +35,9 @@ void ImageSpotFinder::CalcResolutionMap(const SpotFindingSettings &settings) { low_resolution = settings.low_resolution_limit; high_resolution = settings.high_resolution_limit; - for (int i = 0; i < width * height; i++) - resolution_mask[i] = (resolution_map[i] > low_resolution) || (resolution_map[i] < high_resolution); + for (int i = 0; i < width * height; i++) { + resolution_mask[i] = mask[i] || (resolution_map[i] > low_resolution) || (resolution_map[i] < high_resolution); + } } std::vector ImageSpotFinder::Run(const int32_t *input, const SpotFindingSettings &settings) { diff --git a/image_analysis/spot_finding/ImageSpotFinder.h b/image_analysis/spot_finding/ImageSpotFinder.h index 6ffb59ad..fc5f05fb 100644 --- a/image_analysis/spot_finding/ImageSpotFinder.h +++ b/image_analysis/spot_finding/ImageSpotFinder.h @@ -24,6 +24,7 @@ class ImageSpotFinder { mutable std::vector resolution_mask; float high_resolution = -1, low_resolution = -1; + const std::vector &mask; void CalcResolutionMap(const SpotFindingSettings& settings); int NBX = 15; @@ -32,8 +33,8 @@ class ImageSpotFinder { const T special_value, const SpotFindingSettings &settings); public: - explicit ImageSpotFinder(const AzimuthalIntegration &integration); - ImageSpotFinder(const std::vector &resolution_map, size_t width, size_t height); + explicit ImageSpotFinder(const std::vector &mask, const AzimuthalIntegration &integration); + ImageSpotFinder(const std::vector &mask, const std::vector &resolution_map, size_t width, size_t height); void nbx(int input); std::vector Run(const int32_t *input, const SpotFindingSettings &settings); std::vector Run(const int16_t *input, const SpotFindingSettings &settings);