Panel layout stage 3: per-panel spot finding (CPU+GPU, CCL) and raster algorithms on the plane raster

Spot finding works panel by panel, as the FPGA path does per JUNGFRAU module. PanelBoxes (common/) gives
one box per DetectorModule; an empty table gives one box, the whole image, so every clamp reduces to the
old image bounds in the same evaluation order (rotation sets, EIGER, CCDs, our JUNGFRAU unchanged).
- ImageSpotFinder::SetPanels: the CPU local-box pass (dense, count-threshold and the DetectAt/candidate
  path of the adaptive finder) slides its windows inside each panel box; host CCL labels panel by panel;
  pixels on no panel are folded into the resolution mask.
- GPU: analyze_pixel tiles each panel (warps numbered panel after panel), analyze_candidates and
  union_neighbours clip to the pixel's panel, the device spot carries its panel; the GPU list is put in
  panel order so it equals the host's.
- DiffractionSpot carries its panel; SpotAnalyze maps by ImageToPlane(panel, ...) (d_A on the plane).
- ImagePreprocessorBuffer::GatherTiles (CPU+GPU) clips each square to the panel of its centre.
- MXAnalysisWithoutFPGA and the pre-scan workers hand the module table to finders and buffers.

Raster algorithms: new common/AssembleToPlane.h (PlaneRasterOf, AssembleToPlane nearest-pixel gather with
gaps, GatherFromPlane back to stored pixels; empty table = copy). With panels, ShadowFinder::GetMask runs on
the projection assembled to the plane raster and gathers the mask back per stored pixel (CPU route);
FindBeamCenterFFT scores the assembled projection and reports plane coordinates; the detector diagnostic
JPEG shows the assembled plane. Without panels all three take their old path.

Harness: PanelLayout_SpotsNeverCrossPanels enabled (count threshold and SNR on the edge scene), new
PanelLayout_SpotFinderParity (CPU vs GPU, local box and adaptive, on the stacked layout),
PanelLayout_AssembleToPlane, PanelLayout_ShadowFinder, PanelLayout_BeamCenterFFT,
PanelLayout_DetectorDiagnostic (stacked vs assembled image cut to the raster).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-21 10:29:07 +02:00
1 parent c8fb472f4d
commit fd798cd665
26 files changed
+792 -184

No files matched your search

@@ -23,17 +23,25 @@ const int32_t *ImagePreprocessorBuffer::getGPUBuffer() const {
return nullptr;
}
PanelBox ImagePreprocessorBuffer::TileBox(int32_t x, int32_t y, int width) const {
for (const auto &p: panels)
if (x >= p.x0 && x < p.x1 && y >= p.y0 && y < p.y1)
return p;
return PanelBox{0, 0, width, static_cast<int32_t>(npixels / width), -1};
}
const int32_t *ImagePreprocessorBuffer::GatherTiles(const std::vector<int32_t> &x, const std::vector<int32_t> &y,
int width, int half) {
const int side = 2 * half + 1;
const int height = static_cast<int>(npixels / width);
tiles.resize(x.size() * side * side);
int32_t *out = tiles.data();
for (size_t i = 0; i < x.size(); i++)
for (size_t i = 0; i < x.size(); i++) {
const PanelBox b = TileBox(x[i], y[i], width);
for (int py = y[i] - half; py <= y[i] + half; py++)
for (int px = x[i] - half; px <= x[i] + half; px++)
*out++ = (px < 0 || py < 0 || px >= width || py >= height)
*out++ = (px < b.x0 || py < b.y0 || px >= b.x1 || py >= b.y1)
? INT32_MIN : buffer[static_cast<size_t>(py) * width + px];
}
return tiles.data();
}