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:
1 parent
c8fb472f4d
commit
fd798cd665
26 files changed
+792
-184
No files matched your search
@@ -11,7 +11,8 @@ ImageSpotFinder::ImageSpotFinder(int32_t width, int32_t height, bool host_bit_bu
|
||||
: width(width),
|
||||
height(height),
|
||||
output_buffer(host_bit_buffer ? width * height / 32 + 1 : 0),
|
||||
res_mask_bits(OutputSize(), 0) {
|
||||
res_mask_bits(OutputSize(), 0),
|
||||
panels(PanelBoxes({}, width, height)) {
|
||||
// Exclude the padding bits of the last word up front, so neither the host scan nor the GPU
|
||||
// compaction needs a separate "is this bit still inside the image?" test.
|
||||
const size_t npixel = static_cast<size_t>(width) * height;
|
||||
@@ -47,6 +48,20 @@ void ImageSpotFinder::SetResolutionMaskBits(const std::vector<uint32_t> &packed_
|
||||
const size_t npixel = static_cast<size_t>(width) * height;
|
||||
if (npixel % 32 != 0)
|
||||
res_mask_bits.back() |= ~((1u << (npixel % 32)) - 1u);
|
||||
for (size_t i = 0; i < off_panel_bits.size(); i++)
|
||||
res_mask_bits[i] |= off_panel_bits[i];
|
||||
}
|
||||
|
||||
void ImageSpotFinder::SetPanels(const DetectorModules &modules) {
|
||||
panels = PanelBoxes(modules, width, height);
|
||||
off_panel_bits.clear();
|
||||
if (!modules.empty()) {
|
||||
off_panel_bits.assign(OutputSize(), UINT32_MAX);
|
||||
modules.ForEachPixel(width, height, [&](int64_t, size_t i, double, double) {
|
||||
off_panel_bits[i / 32] &= ~(1u << (i % 32));
|
||||
});
|
||||
}
|
||||
SetResolutionMaskBits(res_mask_bits);
|
||||
}
|
||||
|
||||
const std::vector<float> &ImageSpotFinder::GetRingBackground() const {
|
||||
@@ -79,10 +94,22 @@ void ImageSpotFinder::ExtractComponentsHost(const ImagePreprocessorBuffer &image
|
||||
|
||||
image.Gather(strong_pixel, strong_pixel_value);
|
||||
|
||||
StrongPixelSet pixel_set;
|
||||
for (size_t i = 0; i < strong_pixel.size(); i++)
|
||||
pixel_set.AddStrongPixel(strong_pixel[i] % width, strong_pixel[i] / width, strong_pixel_value[i]);
|
||||
pixel_set.FindComponentsImage(settings, components);
|
||||
// Panel by panel, as the FPGA path labels module by module: a component never joins pixels of two
|
||||
// panels, however close the image stores them. The strong pixels are in raster order, and so are
|
||||
// those of one box. Every strong pixel is on a panel (off_panel_bits).
|
||||
for (const auto &p: panels) {
|
||||
StrongPixelSet pixel_set;
|
||||
for (size_t i = 0; i < strong_pixel.size(); i++) {
|
||||
const auto col = static_cast<int32_t>(strong_pixel[i] % width);
|
||||
const auto line = static_cast<int32_t>(strong_pixel[i] / width);
|
||||
if (col >= p.x0 && col < p.x1 && line >= p.y0 && line < p.y1)
|
||||
pixel_set.AddStrongPixel(col, line, strong_pixel_value[i]);
|
||||
}
|
||||
const size_t first = components.size();
|
||||
pixel_set.FindComponentsImage(settings, components);
|
||||
for (size_t i = first; i < components.size(); i++)
|
||||
components[i].Panel(p.panel);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<DiffractionSpot> &ImageSpotFinder::ExtractComponents(const ImagePreprocessorBuffer &image,
|
||||
|
||||
Reference in new issue
Block a user