pixel_sum existed only on the FPGA path, so a DECTRIS master file carried an all-zero /entry/image/pixel_sum. The CPU and GPU image preprocessors now compute it in the pass that takes the minimum and maximum, as a signed 64-bit sum, and MXAnalysisWithoutFPGA reports it: Lite, live stills, live rotation and rugnux. On the simulated card it equals the card's own sum, for 16-bit and for summed 32-bit frames. The sum excludes error and saturated pixels and the device mask (detector and calibration). The hot pixels and the beam-stop shadow a run finds on its own frames do not change it, though they stay masked in the image and in the other statistics, so the number does not depend on what a run decided. Those two have bits of their own (PixelMask::RunMaskBits); the byte-per-pixel mask keeps the difference, 1 for the device mask and 2 for the run's alone, and the CPU preprocessor gets a packed mask of the second. Live stills reports this sum of the assembled image in place of the card's, and with the run's mask out of it the two agree on the test frames. Frames a live rotation run does not reach stay 0 in the master file, as before, and have no dataset in the data files. The reader now reads pixel_sum into the dataset and the per-image message; a file without it opens as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
1.3 KiB
C++
25 lines
1.3 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include "ImagePreprocessor.h"
|
|
|
|
class ImagePreprocessorCPU : public ImagePreprocessor {
|
|
|
|
// The pixel mask one bit per pixel, 32 to a word - PixelMask derives it once, so each engine only
|
|
// copies it.
|
|
std::vector<uint32_t> mask_bits;
|
|
std::vector<uint32_t> run_mask_bits;
|
|
|
|
template <class T> void AnalyzeBlock(ImagePreprocessorBuffer &processed_image, size_t first, const uint8_t *input,
|
|
size_t n, T err_value, T sat_value, ImageStatistics &stats);
|
|
public:
|
|
ImagePreprocessorCPU(const DiffractionExperiment &experiment, const PixelMask &mask);
|
|
ImageStatistics Analyze(ImagePreprocessorBuffer &processed_image, const uint8_t *decompressed_image, CompressedImageMode image_mode) override;
|
|
// Analyze for the n pixels from pixel `first` on, whose values `input` holds, adding to stats. The
|
|
// blocks of an image can come in any order and together give Analyze()'s result.
|
|
void AnalyzeBlock(ImagePreprocessorBuffer &processed_image, size_t first, const uint8_t *input, size_t n,
|
|
CompressedImageMode image_mode, ImageStatistics &stats);
|
|
};
|