Permalink
338cdfd Jul 20, 2016
126 lines (93 sloc) 3.29 KB

Mahotas: Computer Vision in Python

Note

If you are using mahotas in a scientific publication, please cite:

Coelho, L.P. 2013. Mahotas: Open source software for scriptable computer vision. Journal of Open Research Software 1(1):e3, DOI: http://dx.doi.org/10.5334/jors.ac

Mahotas is a computer vision and image processing library for Python.

It includes many algorithms implemented in C++ for speed while operating in numpy arrays and with a very clean Python interface.

Mahotas currently has over 100 functions for image processing and computer vision and it keeps growing. Some examples of mahotas functionality:

The release schedule is roughly one release every few months and each release brings new functionality and improved performance. The interface is very stable, though, and code written using a version of mahotas from years back will work just fine in the current version, except it will be faster (some interfaces are deprecated and will be removed after a few years, but in the meanwhile, you only get a warning).

Bug reports with test cases typically get fixed in 24 hours.

Examples

This is a simple example of loading a file (called test.jpeg) and calling watershed using above threshold regions as a seed (we use Otsu to define threshold).

import numpy as np
import mahotas
import pylab

img = mahotas.imread('test.jpeg')
T_otsu = mahotas.thresholding.otsu(img)
seeds,_ = mahotas.label(img > T_otsu)
labeled = mahotas.cwatershed(img.max() - img, seeds)

pylab.imshow(labeled)

Computing a distance transform is easy too:

Full Documentation Contents

Jump to detailed API Documentation

Indices and tables