GPUImageAnalysis: Spot finder again produces 1-bit result (similar to FPGA) reduced on CPU + mask is not applied on GPU

This commit is contained in:
2023-10-22 13:42:09 +02:00
parent 566ff52bfc
commit fe5b955289
6 changed files with 107 additions and 161 deletions
+1 -64
View File
@@ -73,10 +73,7 @@ TEST_CASE("SpotFinder_GPU", "[GPUImageAnalysis]") {
image[60000] = static_cast<int16_t>(mean + 15 * sqrt(mean));
std::vector<double> threshold_vals = {3,4,6,10};
std::vector<uint8_t> one_byte_mask(experiment.GetPixelsNum(), 1);
GPUImageAnalysis spot_finder(experiment.GetXPixelsNum(), experiment.GetYPixelsNum(),
one_byte_mask);
GPUImageAnalysis spot_finder(experiment.GetXPixelsNum(), experiment.GetYPixelsNum());
spot_finder.SetInputBuffer(image.data());
@@ -112,63 +109,3 @@ TEST_CASE("SpotFinder_GPU", "[GPUImageAnalysis]") {
std::cout << "Common: " << naive_cpu.Common(colspot_gpu) << " fast impl: " << colspot_gpu.Count() << " ref. impl: " << naive_cpu.Count() << std::endl;
}
}
TEST_CASE("SpotFinder_GPU_Mask", "[GPUImageAnalysis]") {
DiffractionExperiment experiment(DetectorGeometry(1));
experiment.Mode(DetectorMode::Raw);
const uint16_t nbx = 5;
const double mean = 30;
std::vector<int16_t> image(512*1024);
// Predictable random number generator, so test always gives the same result
std::mt19937 g1(2023);
// Poissonian distribution, with mean == variance
std::normal_distribution<double> distribution(mean, sqrt(mean));
for (auto &i: image)
i = static_cast<int16_t>(distribution(g1));
image[2000] = static_cast<int16_t>(mean + 15 * sqrt(mean));
image[8000] = static_cast<int16_t>(mean + 15 * sqrt(mean));
image[14000] = static_cast<int16_t>(mean + 15 * sqrt(mean));
image[20000] = static_cast<int16_t>(mean + 15 * sqrt(mean));
image[25000] = static_cast<int16_t>(mean + 15 * sqrt(mean));
image[60000] = static_cast<int16_t>(mean + 15 * sqrt(mean));
std::vector<uint8_t> one_byte_mask(experiment.GetPixelsNum(), 1);
JFJochProtoBuf::DataProcessingSettings settings;
settings.set_local_bkg_size(nbx);
settings.set_photon_count_threshold(1);
settings.set_signal_to_noise_threshold(10);
{
GPUImageAnalysis spot_finder(experiment.GetXPixelsNum(), experiment.GetYPixelsNum(), one_byte_mask);
spot_finder.SetInputBuffer(image.data());
// Without mask
StrongPixelSet colspot_gpu(experiment);
spot_finder.LoadDataToGPU();
spot_finder.RunSpotFinder(settings);
spot_finder.GetSpotFinderResults(colspot_gpu);
REQUIRE(colspot_gpu.Count() == 6);
}
{
one_byte_mask[2000] = 0;
one_byte_mask[25000] = 0;
one_byte_mask[60000] = 0;
GPUImageAnalysis spot_finder(experiment.GetXPixelsNum(), experiment.GetYPixelsNum(), one_byte_mask);
StrongPixelSet colspot_gpu(experiment);
spot_finder.SetInputBuffer(image.data());
spot_finder.LoadDataToGPU();
spot_finder.RunSpotFinder(settings);
spot_finder.GetSpotFinderResults(colspot_gpu);
REQUIRE(colspot_gpu.Count() == 3);
}
}