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: https://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:
convex points calculations.
Zernike & Haralick, local binary patterns, and TAS features.
convolution.
Sobel edge detection.
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.
See also
mahotas-imread is side project which includes code to read/write images to files
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:
import pylab as p
import numpy as np
import mahotas
f = np.ones((256,256), bool)
f[200:,240:] = False
f[128:144,32:48] = False
# f is basically True with the exception of two islands: one in the lower-right
# corner, another, middle-left
dmap = mahotas.distance(f)
p.imshow(dmap)
p.show()
(Source code
, png
, hires.png
, pdf
)
![_images/index-1.png](_images/index-1.png)
Full Documentation Contents¶
Jump to detailed API Documentation
- How To Install Mahotas
- Finding Wally
- Labeled Image Functions
- Thresholding
- Wavelet Transforms
- Distance Transform
- Polygon Utilities
- Features
- Local Binary Patterns
- Speeded-Up Robust Features
- Implementing SURF-ref With Mahotas
- Morphological Operators
- Color Space Conversions
- Input/Output with Mahotas
- Tutorial: Classification Using Mahotas
- Tutorial: Extended Depth of Field
- mahotas-features.py
- Frequently Asked Questions
- How do I install mahotas with anaconda?
- Who uses mahotas?
- Why did you not simply contribute to
scipy.ndimage
orscikits.image
? - I ran out of memory computing Haralick features on 16 bit images. Is it not supported?
- What are the parameters to Local Binary Patterns?
- I am using mahotas in a scientific publication, is there a citation?
- Imread cannot find FreeImage
- Mahotas Internals
- The Why of mahotas
- Contributing
- Possible Tasks
- History
- Version 1.4.15 (Mar 24 2024)
- Version 1.4.14 (Mar 24 2024)
- Version 1.4.13 (Jun 28 2022)
- Version 1.4.12 (Oct 14 2021)
- Version 1.4.11 (Aug 16 2020)
- Version 1.4.10 (Jun 11 2020)
- Version 1.4.9 (Nov 12 2019)
- Version 1.4.8 (Oct 11 2019)
- Version 1.4.7 (Jul 10 2019)
- Version 1.4.6 (Jul 10 2019)
- Version 1.4.5 (Oct 20 2018)
- Version 1.4.4 (Nov 5 2017)
- Version 1.4.3 (Oct 3 2016)
- Version 1.4.2 (Oct 2 2016)
- Version 1.4.1 (Dec 20 2015)
- Version 1.4.0 (July 8 2015)
- Version 1.3.0 (April 28 2015)
- Version 1.2.4 (December 23 2014)
- Version 1.2.3 (November 8 2014)
- Version 1.2.2 (October 19 2014)
- Version 1.2.1 (July 21 2014)
- Version 1.2 (July 17 2014)
- Version 1.1.1 (July 4 2014)
- 1.1.0 (February 12 2014)
- 1.0.4 (2013-12-15)
- 1.0.3 (2013-10-06)
- 1.0.2 (July 10 2013)
- 1.0.1 (July 9 2013)
- 1.0 (May 21 2013)
- 0.99 (May 4 2013)
- 0.9.8 (April 22 2013)
- 0.9.7 (February 03 2013)
- 0.9.6 (December 02 2012)
- 0.9.5 (November 05 2012)
- 0.9.4 (October 10 2012)
- 0.9.3 (October 9 2012)
- 0.9.2 (September 1 2012)
- 0.9.1 (August 28 2012)
- 0.9 (July 16 2012)
- 0.8.1 (June 6 2012)
- 0.8 (May 7 2012)
- 0.7.3 (March 14 2012)
- 0.7.2 (February 13 2012)
- 0.7.1 (January 6 2012)
- Version .6.6 (August 8 2011)
- For version 0.6.5
- Full API Documentation
- Main Features
as_rgb()
bbox()
border()
borders()
bwperim()
cdilate()
center_of_mass()
cerode()
close()
close_holes()
convolve()
convolve1d()
croptobbox()
cwatershed()
daubechies()
dilate()
disk()
distance()
dog()
erode()
euler()
find()
fullhistogram()
gaussian_filter()
gaussian_filter1d()
get_structuring_elem()
haar()
hitmiss()
idaubechies()
ihaar()
imread()
imresize()
imsave()
label()
labeled_sum()
laplacian_2D()
locmax()
locmin()
majority_filter()
mean_filter()
median_filter()
moments()
open()
otsu()
overlay()
rank_filter()
rc()
regmax()
regmin()
sobel()
stretch()
stretch_rgb()
template_match()
thin()
wavelet_center()
wavelet_decenter()
eccentricity()
ellipse_axes()
haralick()
lbp()
pftas()
roundness()
tas()
zernike()
zernike_moments()
rgb2gray()
rgb2grey()
rgb2lab()
rgb2sepia()
rgb2xyz()
xyz2lab()
xyz2rgb()