pyfli.io.hotpixel#
Hot-pixel masks for gated/SPAD cameras: generate a mask from a dark or background acquisition, save/load it as an image, and replace flagged pixels by the median of their non-hot neighbours.
Functions
|
Boolean hot-pixel mask |
|
Per-pixel total counts |
|
Boolean mask from an image (PNG/JPEG/TIFF; first channel of a colour image, nonzero = hot). |
|
Replace every flagged pixel of an |
|
Write a boolean mask as a grayscale image (hot = white), readable by |
- hotpixel_counts(data)[source]#
Per-pixel total counts
(H, W)of an image, an(H, W, T)cube or an(N, H, W, T)stack.
- generate_hotpixel_mask(data, fraction=0.05, threshold_sigma=None, save_path=None)[source]#
Boolean hot-pixel mask
(H, W)from a dark/background acquisition (image, cube or stack, summed to per-pixel counts).With threshold_sigma a pixel is hot when its counts exceed
median + threshold_sigma * 1.4826 * MAD(asDataIOUtils.hot_pixels()); otherwise theround(fraction * n_pixels)pixels with the most counts are flagged (fraction=0.05gives a “5 per 100” mask). Ties at the cut are broken by pixel order, so the count is exact. save_path writes the mask as an image (save_hotpixel_mask()).
- save_hotpixel_mask(mask, path)[source]#
Write a boolean mask as a grayscale image (hot = white), readable by
load_hotpixel_mask().
- load_hotpixel_mask(path, shape=None)[source]#
Boolean mask from an image (PNG/JPEG/TIFF; first channel of a colour image, nonzero = hot). With shape
(H, W)a transposed mask is turned to match, otherwise a mismatch raises.
- remove_hotpixels(data, mask, max_radius=2)[source]#
Replace every flagged pixel of an
(H, W)image or(H, W, T)cube by the median of its non-hot neighbours in the 3x3 window (per time gate), widening the window up to max_radius when all neighbours are hot; a pixel with no valid neighbour keeps its value. Uses only unflagged pixels, so the result does not depend on processing order. Returns float32.