Skip to content

LabForComputationalVision/pyrtools

Repository files navigation

pyrtools: tools for multi-scale image processing

PyPI Version License: MIT Python version Build Status Documentation Status DOI Binder codecov

Briefly, the tools include:

  • Recursive multi-scale image decompositions (pyramids), including Laplacian pyramids, QMFs, Wavelets, and steerable pyramids. These operate on 1D or 2D signals of arbitrary dimension.
  • Fast 2D convolution routines, with subsampling and boundary-handling.
  • Fast point-operations, histograms, histogram-matching.
  • Fast synthetic image generation: sine gratings, zone plates, fractals, etc.
  • Display routines for images and pyramids. These include several auto-scaling options, rounding to integer zoom factors to avoid resampling artifacts, and useful labeling (dimensions and gray-range).

This is a python 3 port of Eero Simoncelli's matlabPyrTools, but it does not attempt to recreate all of the matlab code from matlabPyrTools. The goal is to create a Python interface for the C code at the heart of matlabPyrTools.

NOTE: If you are only interested in the complex steerable pyramid, we have a pytorch implementation in the plenoptic package; the implementation in plenoptic is differentiable.

Citing us

If you use pyrtools in a published academic article or presentation, please cite us! You can find the link to the most recent release on Zenodo here (though please specify the version you used not the most recent one!). You can also get a formatted citation at the top right of our GitHub repo

Installation

It's recommended you install from pip: pip install pyrtools.

If you wish to install from the main branch, it's still recommended to use pip, just run pip install . (or pip install -e . if you want the changes you make in the directory to be reflected in your install) from the root directory of this project. The core of this code is the C code, and the pip install will compile it nicely.

Pyramid resources

If you would like to learn more about pyramids and why they're helpful for image processing, here are some resources to get you started:

Usage:

  • load modules:
import pyrtools as pt
  • create pyramid:
pyr = pt.pyramids.LaplacianPyramid(img)
  • reconstruct image from pyramid:
recon_img = pyr.recon_pyr()

Please see TUTORIALS/02_pyramids.ipynb for more examples.

For developres

Testing

You can find unit tests in TESTS/unitTests.py and run them with python TESTS/unitTests.py.

Build the documentation

NOTE: If you just want to read the documentation, you do not need to do this; documentation is built automatically on readthedocs.

However, it can be built locally as well. You would do this if you've made changes locally to the documentation (or the docstrings) that you would like to examine before pushing.

# create a new virtual environment and then...
# install pyrtools with sphinx and documentation-related dependencies
pip install -e .[docs]
# build documentation
cd docs/
make html

The index page of the documentation will then be located at docs/_build/html/index.html, open it in your browser to navigate around.