image_hdr/
lib.rs

1//! An implementation of HDR Radiance Estimation using Poisson Photon Noise Estimator for creating HDR image from a set of images
2#![allow(clippy::multiple_crate_versions)]
3
4use image::DynamicImage;
5use poisson::calculate_poisson_estimate;
6
7pub mod error;
8pub mod exif;
9pub mod extensions;
10pub mod input;
11mod io;
12mod poisson;
13pub mod stretch;
14
15use crate::extensions::NDArrayBuffer;
16use crate::input::HDRInputList;
17pub use error::Error;
18
19/// Given a set of file paths, attempt to HDR merge the images
20/// and produce a single [`DynamicImage`] (from image-rs crate).
21///
22/// # Errors
23/// - If image list is empty
24/// - If supplied image is not an RGB image. Non RGB images include images with alpha channel, grayscale images, and images with other color encodings (like CMYK).
25/// - If images are of different dimensions.
26pub fn hdr_merge_images(inputs: &mut HDRInputList) -> Result<DynamicImage, Error> {
27    if inputs.len() < 2 {
28        return Err(Error::InputError {
29            parameter_name: "paths".to_string(),
30            message: "At least two images must be provided".to_string(),
31        });
32    }
33
34    let phi = calculate_poisson_estimate(inputs.as_slice_mut());
35
36    Ok(DynamicImage::from_nd_array_buffer(phi))
37}