PyDIP is a thin wrapper that makes most of the functionality in DIPlib accessible from within Python. Function names and arguments are mostly identical to the C++ functions. The only exception is for indexing into images, which uses the Python slicing syntax. Image objects created by the interface expose their data buffer, and so can be used with most NumPy functions. Likewise, any object that exposes a data buffer (e.g. NumPy arrays) can be used as input to PyDIP functions.
The interface only has automatically generated docstrings that show the names of each of the parameters, except where the syntax differs from that of DIPlib. Use the DIPlib reference to learn how to use each function. Get started by reading the PyDIP User Manual.
Images can be shown using the
Show method, which uses matplotlib.
dip.viewer sub-module gives access to DIPviewer.
When Python is started through the
examples/python/pydip.py script, the
will use the DIPviewer interactive display.
These Jupyter notebooks give a short introduction:
Note! We consider the Python bindings (PyDIP) to be in development. We aim at not making breaking changes, but will sometimes do so when we feel it significantly improves the usability of the module. These changes will always be highlighted in the change logs and the release notification on the DIPlib website. We recommend that you pin your project to use a specific version of the package on PyPI, and carefully read the change logs before upgrading.
To install, simply type
pip install diplib
Windows users might need to install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019.
To read images through the Bio-Formats library, you will need to download it separately:
python -m diplib download_bioformats
We recommend to import the module using
import diplib as dip
All documentation assumes
dip is the module name.
diplib package on PyPI vendors the OpenMP library for some platforms
libomp.dylib on macOS,
libgomp.so on Linux). It is possible, though rare, for another package to vendor
an incompatible OpenMP library, and for the combined use to cause Python to crash.
See for example this issue. If you happen to run into this problem,
please let us know!.
You can find more information about the simultaneous use of multiple OpenMP libraries
on this page.