HDR¶
The HDR module now includes a traditional static Linear RGB fusion baseline for the Open-AISP "Oracle Baseline". It contains no neural network, no noise model, and no motion alignment; it only tests the physical upper bound for fusing perfectly aligned bracketed exposures.
The current data source is MIT-Adobe FiveK / MIT5K DNG imagery. The Expert A-E TIFF files are Lightroom-retouched outputs and are intentionally not used here. DeepHDR moving bursts are reserved for a later AI-HDR module.
Features¶
- Read MIT5K DNG images, decode them to linear RGB with
rawpy, and normalize the result into a stable simulation range. - Estimate over/normal/under exposure gains from the input luminance distribution.
- Simulate three clipped exposure brackets with those gains.
- Compute Gaussian photometric confidence maps with hard saturation rejection.
- Undo exposure gains so all frames return to the same radiance scale.
- Fill clipped samples with the direct oracle estimate before pyramid building, preventing invalid radiance from spreading through Laplacian levels.
- Fuse with Gaussian weight pyramids and Laplacian image pyramids.
- Export fused HDR, GT, and all three simulated exposures as
.hdrfiles plus direct linear RGB PNG previews.
Run¶
Run these commands from the repository root.
pip install -r HDR-fusion/requirements.txt
python HDR-fusion/scripts/download_mit5k.py \
--ids 3
PYTHONPATH=HDR-fusion python -m hdr_fusion.cli \
--input HDR-fusion/datasets/MIT5K/dng/a0003.dng \
--output HDR-fusion/outputs/a0003_fused.hdr \
--metrics HDR-fusion/outputs/a0003_metrics.json
The command writes these files into HDR-fusion/outputs/:
a0003_fused.hdr: fused Linear HDR.a0003_fused.png: Reinhard tone-mapped PNG preview of the fused HDR result.a0003_gt.png: direct linear RGB PNG preview of the normalized GT.a0003_over.hdr/png: simulated over exposure and its preview.a0003_norm.hdr/png: simulated normal exposure and its preview.a0003_under.hdr/png: simulated under exposure and its preview.a0003_weight_over.png: fusion weight for the over exposure.a0003_weight_norm.png: fusion weight for the normal exposure.a0003_weight_under.png: fusion weight for the under exposure.a0003_weight_argmax.png: color map of the dominant exposure.a0003_luminance_hist.png: overlayed luminance histogram for over/norm/under/fused.a0003_metrics.json: error metrics.
Common options:
--exposures 4.0 1.0 0.25: optional fixed over/normal/under exposure gains. If omitted, gains are estimated from luminance percentiles.--input-color-space auto|srgb|linear: input color-space handling for non-DNG files.--sigma 0.2: Gaussian exposure-confidence width.--levels 6: pyramid depth.
Validate¶
PYTHONPATH=HDR-fusion pytest HDR-fusion/tests
The CLI reports:
l1: full-image mean absolute error against the normalized GT.recoverable_l1: mean absolute error excluding pixels where even the under-exposed frame clips.recoverable_ratio: fraction of physically recoverable pixels.exposure_modeandexposure_factors: whether the brackets were automatic or fixed, and the actual gains used.
The fused HDR preview uses Reinhard tone mapping before sRGB encoding. The
simulated exposure previews are not tone-mapped: the writer clips linear RGB
values to [0, 1] and then applies the sRGB transfer function, so clipped
highlights stay white and under-exposed previews remain visibly dark.