Global and local spectral matching of 2 or more overlapping rasters
Project description
spectralmatch: Global and Local Spectral Matching for Seamless Image Mosaics
[!IMPORTANT] This library is experimental and still under heavy development.
Perform global and local histogram matching for multiple overlapping images to achieve seamless color consistency in mosaicked outputs.
Overview
spectralmatch uses least squares regression to balance colors across all images in a single global solution, then performs finer local adjustments on overlapping blocks. This two-phase process ensures high-quality color normalization with minimal spectral distortion.
Why Use spectralmatch?
- Fully automated color balancing of multiple overlapping images.
- Minimizes color bias by avoiding a strict reference image.
- Improves consistency with local, block-by-block refinements after global correction.
- Easily integrated into new or existing remote sensing and GIS workflows.
Features
-
Global Spectral Matching
Calculates scale and offset across all images to reduce large color differences. -
Local Spectral Matching
Refines global corrections by applying fine-tuned color transformations in overlapping areas. -
Sensor Agnostic
Works on optical imagery from diverse sensors by assuming geometric alignment. -
Parallel Processing
Capable of handling large datasets efficiently on modern CPU cores. -
Minimal Spectral Distortion
Maintains the integrity of real color/spectral information in your data.
Installation
1. System Requirements
Before installing spectralmatch, ensure you have the following system-level prerequisites:
- Python ≥ 3.10
- PROJ ≥ 9.3
- GDAL ≥ 3.6 (verify using:
gdalinfo --version)
2. Install spectralmatch (via PyPI or Source)
The recommended way to install spectralmatch is via PyPI:
pip install spectralmatch
spectralmatch includes a pyproject.toml which defines its Python dependencies. Installing via pip will automatically handle these. If you need to install from source, clone the repository and run:
pip install .
Quick Start
After installation, you can use spectralmatch to perform global and local matching on multiple overlapping images:
from spectralmatch.global_histogram_match import global_histogram_match
from spectralmatch.local_histogram_match import local_histogram_match
# Example: Basic usage
input_image_paths = [
"image1.tif",
"image2.tif",
"image3.tif"
]
# 1. Global Matching
global_histogram_match(
input_images=input_image_paths,
output_folder="data/GlobalMatch",
output_basename="_global",
custom_mean_factor=3, # adjust as needed
custom_std_factor=1 # adjust as needed
)
# 2. Local Matching
local_histogram_match(
input_images=[
"data/GlobalMatch/images/image1_global.tif",
"data/GlobalMatch/images/image2_global.tif",
"data/GlobalMatch/images/image3_global.tif"
],
output_folder="data/LocalMatch",
output_basename="_local",
target_blocks_per_image=100,
projection="EPSG:XXXX", # specify your projection
debug_mode=True # optional debugging
)
print("Done! Check 'data/GlobalMatch' and 'data/LocalMatch' for results.")
Replace mentions of file paths, projection, and parameters as suitable for your data and environment.
Documentation
Comprehensive documentation is forthcoming. In the meantime:
- Refer to function docstrings for usage and parameter details.
- Explore example scripts or tutorials within this repository for guidance.
- Open an issue or discussion if you need further information.
Developer Guides
-
Clone the Repository
git clone https://github.com/yourusername/spectralmatch.git
Then navigate into the project folder:
cd spectralmatch
-
Install in Editable Mode with Dev Extras
spectralmatch provides a[dev]extra in itspyproject.tomlfor development:pip install --upgrade pip pip install -e .[dev] # for developer dependencies pip install -e .[docs] # for documentation dependencies
-
Set Up Pre-commit Hooks (Optional) If you want to maintain consistency and code quality before each commit:
pre-commit install pre-commit run --all-files
Testing
spectralmatch uses pytest for testing. To run all tests:
pytest
Run tests for a specific file or function:
pytest tests/test_global_match.py
Contributing
We welcome all contributions! To get started:
- Fork the repository and create a new feature branch.
- Make your changes and add any necessary tests.
- Open a Pull Request against the main repository.
We appreciate any feedback, suggestions, or pull requests to improve this project.
License
This project is licensed under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spectralmatch-0.0.2.tar.gz.
File metadata
- Download URL: spectralmatch-0.0.2.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83113547892db8a85ca57c088b8c59a922891cf40740598c4555b936318bbabc
|
|
| MD5 |
71748a18f7a8599e6225830c969407b5
|
|
| BLAKE2b-256 |
d9a4e86615b2100c25ee77592dfeb21c32f19e381619c6f72acdc3f88addcfb7
|
File details
Details for the file spectralmatch-0.0.2-py3-none-any.whl.
File metadata
- Download URL: spectralmatch-0.0.2-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf49a4f69035a044c35a5bac37049c7623d7f4a2ad3c7b09bd46039fab16a40a
|
|
| MD5 |
be1ce618b1d6e6d5caf9003697d98691
|
|
| BLAKE2b-256 |
14cc89a5340d921228aa843df621aee2b9d3b4303281f3d971c01b0110589090
|