diff --git a/image_analysis/beam_stop/ShadowFinder.cpp b/image_analysis/beam_stop/ShadowFinder.cpp index 59a65d9b..b289ab46 100644 --- a/image_analysis/beam_stop/ShadowFinder.cpp +++ b/image_analysis/beam_stop/ShadowFinder.cpp @@ -328,10 +328,14 @@ std::vector ShadowFinder::GetMask() const { // Counting statistics cannot decide this: on a bright dataset the shadow is still well counted. // The comparison is only ever used to answer "is this whole ring inside the stop", never to // judge an individual pixel, so taking the largest background over an outward window is safe - // here in a way it would not be per pixel. + // here in a way it would not be per pixel. It is taken only over the rings this same walk is + // willing to judge, though: at the corner of the detector a ring holds a handful of pixels and + // its median is one pixel's mean, so one recorded reflection out there would otherwise become + // the background every ring inside it is compared against. std::vector outward_max(max_radius + 2, 0.0f); for (int rad = max_radius; rad >= 0; rad--) - outward_max[rad] = std::max(baseline[rad], outward_max[rad + 1]); + outward_max[rad] = std::max(ring_pixels[rad] >= MIN_RING_PIXELS ? baseline[rad] : 0.0f, + outward_max[rad + 1]); int blocked_out_to = -1; for (int rad = 0; rad <= max_radius; rad++) {