Robust multi-band image registration pipeline for aligning target bands (e.g., R/G/B) to a reference band (e.g., NIR). The pipeline detects keypoints, computes descriptors, matches features, filters correspondences (ratio-test, NMS, RANSAC), estimates displacement, and optionally applies pixel translation to align patches. Visualization, diagnostics, and logging are built-in and configurable via YAML.
- Features
- Project Structure
- Installation
- Quick Start
- Configuration
- CLI Usage
- Pipeline Overview
- Module Reference
- Outputs
- Logging
- Troubleshooting
- Roadmap
- Contributing
- License
- Keypoint detectors: ORB, HARRIS (hooks for SIFT/SURF/FAST)
- Descriptors: HOG, Simple (and ORB native descriptors)
- Matchers: Brute-Force, FLANN, correlation, KNN with Lowe's ratio test
- Filters: ratio test, non-maximum suppression, RANSAC (translation/affine/homography)
- Displacement estimation with robust aggregation (median/trimmed-mean/mean)
- Preprocessing: CLAHE, optional histogram equalization, Gaussian blur
- Subpixel shift and configurable interpolation
- Visualizations for keypoints, matches (raw/filtered), and overlays
- YAML configuration, JSON/CSV diagnostics, structured logs
band_registration/
configs/
default.yml # Main pipeline configuration
logs/
registration.log # Runtime logs (created/rotated by app)
outputs/ # Registered images and artifacts
utils/
config_loader.py # YAML → dataclass-like config
data_io.py # I/O, preprocessing, OpenCV helpers
descriptor.py # HOG/Simple descriptors
displacement.py # Displacement estimation & stats
filtering.py # Ratio test, NMS, RANSAC, thresholds
keypoints.py # ORB/HARRIS (extensible)
matching.py # BF/FLANN/correlation/KNN
registration.py # Higher-level registration utilities
visualization.py # Keypoints/matches/overlay plots
main.py # CLI entrypoint
README.md # This file
requirements.txt # Python dependencies
-
Python 3.9+ recommended.
-
Create and activate a virtual environment:
python -m venv .venv
# Windows PowerShell
. .venv\Scripts\Activate.ps1- Install dependencies:
pip install --upgrade pip
pip install -r requirements.txt-
Point the config to your reference and target band files in
configs/default.yml(see Configuration). -
Run the pipeline:
python main.py --config configs/default.yml- Inspect outputs in
outputs/, plots inplots/(if enabled), diagnostics inreports/, and logs inlogs/.
All behavior is driven by a YAML file. Key fields from configs/default.yml:
data:
reference_band: "/path/to/NIR.tif"
target_bands:
- "/path/to/RED.tif"
output_dir: "./outputs"
overwrite: true
driver: "GTiff"
dtype: "float32"
patch:
x: 4556
y: 900
width: 512
height: 512
preprocess:
equalize_hist: false
clahe: true
blur_kernel: 0
detector:
method: "ORB" # SIFT, SURF, ORB, FAST, HARRIS
nfeatures: 1000
descriptor:
method: "HOG" # HOG, Simple
matcher:
method: "BF" # BF, FLANN, CORRELATION, KNN
cross_check: true
norm_type: "L2"
knn_k: 2
ratio: 0.75
filters:
apply_ratio_test: true
apply_nms: true
nms_radius: 8
apply_ransac: true
ransac:
model: "translation" # translation | affine | homography
threshold_px: 3.0
min_inliers: 6
aggregation:
method: "median" # median | trimmed_mean | mean
trim_fraction: 0.1
reject_outliers: true
outlier_sigma: 2.5
transform:
apply_shift: true
subpixel: true
interpolation: "linear" # nearest | linear | cubic
visualization:
show_keypoints: true
show_matches_raw: true
show_matches_filtered: true
show_overlay: true
show_plots: true
save_plots: true
plot_dir: "./plots"
overlay_alpha: 0.5
figsize: [10, 5]
dpi: 150
diagnostics:
save_json: true
save_csv: true
report_dir: "./reports"
logging:
level: "INFO"
log_file: "./logs/registration.log"Notes:
- For ORB, descriptors are produced by the detector; for HARRIS, select a descriptor in
descriptor.method.
python main.py --config <path_to_yaml>
# Example
python main.py --config configs/default.ymlArguments:
--config, -cPath to the YAML config (default:configs/default.yml).
- Load configuration and images
- Extract reference/target patches
- Optional preprocessing (CLAHE, equalization, blur)
- Detect keypoints (e.g., ORB/HARRIS)
- Compute descriptors (HOG/Simple or ORB-native)
- Match features (BF/FLANN/correlation/KNN)
- Filter matches (ratio test, NMS, RANSAC)
- Estimate displacement with robust aggregation
- Optional subpixel shift and write registered outputs
- Visualize keypoints, matches, and overlays; export diagnostics
This example uses ORB (Oriented FAST and Rotated BRIEF) algorithm to extract keypoints and describe them.
Next, BF (Brute-Force) matcher is used to match the keypoints.
Applying RANSAC (Random Sample Consensus) to filter matches.
utils/config_loader.py: Loads YAML into a structured config object.utils/data_io.py: Raster I/O, patch extraction, preprocessing, OpenCV conversions.utils/keypoints.py: Keypoint detection for ORB/HARRIS and extensions.utils/descriptor.py: Descriptor extraction (HOG/Simple) for detector-agnostic workflows.utils/matching.py: BF/FLANN/correlation matching; KNN and ratio test support.utils/filtering.py: Post-match filtering: ratio test, NMS, RANSAC, distance thresholds.utils/displacement.py: Computes displacement and summary statistics.utils/registration.py: Utilities for applying transforms and writing outputs.utils/visualization.py: Plots for keypoints, matches, and overlays.
- Each stage can be visualised by configuring YAMl file in
visualizationsection.
- Logs are written to
logs/registration.logat the level set bylogging.level. - Log file path can be changed via
logging.log_file.
- No/too few matches: Increase
detector.nfeatures, enablepreprocess.clahe, relaxfilters.ransac.threshold_px. - Mismatches: Tighten
matcher.ratio, enablefilters.apply_ransac, reducepreprocess.blur_kernel. - Artifacts in overlay: Use
transform.subpixel: trueandtransform.interpolation: cubic. - Large misalignment: Start with larger patches or try
filters.ransac.model: affine.
- Add SIFT/SURF fallbacks (patent-free implementations or via optional packages)
- Full-image tiling and mosaic alignment
- Automatic patch suggestion and QA metrics
- GPU-accelerated matching and RANSAC
Issues and pull requests are welcome. Please keep changes focused and include before/after visualizations where relevant.



