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. One exception is 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, together with the first paragraph of the function’s documentation, 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.
The dip.viewer
submodule gives access to DIPviewer.
When Python is started through the examples/python/pydip.py
script, the Show
function
will use the DIPviewer interactive display.
These Jupyter notebooks replicate much of what is shown in the User Manual:
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.
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.
Note: The 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.