58 lines
1.9 KiB
C++
58 lines
1.9 KiB
C++
// Copyright (2019-2022) Paul Scherrer Institute
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include <catch2/catch.hpp>
|
|
#include "../image_analysis/StrongPixelSet.h"
|
|
|
|
TEST_CASE("DiffractionSpot_AddOperator","[StrongPixelSet]") {
|
|
DiffractionSpot spot1(4,1,10), spot2(3,4,5);
|
|
|
|
spot1 += spot2;
|
|
|
|
// Spot2 is not changed
|
|
REQUIRE(spot2.Count() == 5);
|
|
|
|
REQUIRE(spot1.Count() == 15);
|
|
REQUIRE(spot1.RawCoord().x == Approx((4*10+3*5)/15.0));
|
|
REQUIRE(spot1.RawCoord().y == Approx((1*10+4*5)/15.0));
|
|
REQUIRE(spot1.MaxCount() == 10);
|
|
REQUIRE(spot1.PixelCount() == 2);
|
|
}
|
|
|
|
TEST_CASE("StrongPixelSet_coord2uint64_t","[StrongPixelSet]") {
|
|
uint32_t val = strong_pixel_coord(15,6667);
|
|
REQUIRE(col_from_strong_pixel(val) == 15);
|
|
REQUIRE(line_from_strong_pixel(val) == 6667);
|
|
}
|
|
|
|
TEST_CASE("StrongPixelSet_BuildSpots","[StrongPixelSet]") {
|
|
DiffractionExperiment experiment;
|
|
experiment.Mode(DetectorMode::Raw);
|
|
|
|
JFJochProtoBuf::DataProcessingSettings settings;
|
|
settings.set_low_resolution_limit(200.0);
|
|
settings.set_high_resolution_limit(0.5);
|
|
settings.set_min_pix_per_spot(3);
|
|
settings.set_max_pix_per_spot(200);
|
|
|
|
std::vector<DiffractionSpot> spots;
|
|
StrongPixelSet strong_pixel_set(experiment);
|
|
strong_pixel_set.AddStrongPixel(7,105);
|
|
strong_pixel_set.AddStrongPixel(7,106);
|
|
strong_pixel_set.AddStrongPixel(7,104);
|
|
strong_pixel_set.AddStrongPixel(6,106);
|
|
strong_pixel_set.AddStrongPixel(6,105);
|
|
strong_pixel_set.AddStrongPixel(6,104);
|
|
strong_pixel_set.AddStrongPixel(8,106);
|
|
strong_pixel_set.AddStrongPixel(8,105);
|
|
strong_pixel_set.AddStrongPixel(8,104);
|
|
strong_pixel_set.FindSpots(experiment, settings, spots);
|
|
REQUIRE(strong_pixel_set.Count() == 0);
|
|
REQUIRE(spots.size() == 1);
|
|
|
|
REQUIRE(spots[0].Count() == 9.0f);
|
|
REQUIRE(spots[0].PixelCount() == 9);
|
|
REQUIRE(spots[0].RawCoord().x == Approx(7.0));
|
|
REQUIRE(spots[0].RawCoord().y == Approx(105.0));
|
|
}
|