mtb_align/lib.rs
1//! Median threshold bitmap alignment for handheld HDR exposures.
2//!
3//! Ward (2003). Thresholding each exposure at its own median gives a bitmap that
4//! survives any monotonic change of exposure, so frames can be registered before
5//! the camera response is solved. Integer translation only.
6//!
7//! ```
8//! use mtb_align::{Gray, Options, Shift, shift};
9//!
10//! let scene = |x: i64, y: i64| (((x / 16) * 61) ^ ((y / 16) * 37)) as u8;
11//! let read = |dx: i64, dy: i64| {
12//! let samples = (0..256 * 256).map(|i| scene(i % 256 + dx, i / 256 + dy)).collect();
13//! Gray::from_vec(samples, 256, 256)
14//! };
15//! let options = Options { bits: 4, ..Options::default() };
16//!
17//! assert_eq!(shift(&read(0, 0), &read(5, -3), &options), Ok(Shift::new(5, -3)));
18//! ```
19//!
20//! [`align_stack`] does a whole bracket, [`common_crop`] the region left over.
21
22mod align;
23mod bitmap;
24mod difference;
25mod error;
26mod geometry;
27mod gray;
28mod shrink;
29mod strips;
30mod threshold;
31
32pub use align::{Options, align_stack, shift};
33pub use bitmap::Bitmap;
34pub use difference::disagreement;
35pub use error::Error;
36pub use geometry::{Rect, Shift, common_crop};
37pub use gray::Gray;
38pub use shrink::{Shrink, shrink2};
39pub use threshold::{Bitmaps, Percentile, compute_bitmaps, threshold};