Skip to main content

Mahotas: Computer Vision Library

Project description

Mahotas

Python Computer Vision Library

Mahotas is a library of fast computer vision algorithms (all implemented in C++ for speed) operating over numpy arrays.

Travis Coverage Status Downloads License Install with Anaconda Join the chat at https://gitter.im/luispedro/mahotas

Python versions 2.7, 3.4+, are supported.

Notable algorithms:

Mahotas currently has over 100 functions for image processing and computer vision and it keeps growing.

The release schedule is roughly one release a month 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). In a few unfortunate cases, there was a bug in the old code and your results will change for the better.

Please cite the mahotas paper (see details below under Citation) if you use it in a publication.

Examples

This is a simple example (using an example file that is shipped with mahotas) of calling watershed using above threshold regions as a seed (we use Otsu to define threshold).

# import using ``mh`` abbreviation which is common:
import mahotas as mh

# Load one of the demo images
im = mh.demos.load('nuclear')

# Automatically compute a threshold
T_otsu = mh.thresholding.otsu(im)

# Label the thresholded image (thresholding is done with numpy operations
seeds,nr_regions = mh.label(im > T_otsu)

# Call seeded watershed to expand the threshold
labeled = mh.cwatershed(im.max() - im, seeds)

Here is a very simple example of using mahotas.distance (which computes a distance map):

import pylab as p
import numpy as np
import mahotas as mh

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 = mh.distance(f)
p.imshow(dmap)
p.show()

(This is under mahotas/demos/distance.py.)

How to invoke thresholding functions:

import mahotas as mh
import numpy as np
from pylab import imshow, gray, show, subplot
from os import path

# Load photo of mahotas' author in greyscale
photo = mh.demos.load('luispedro', as_grey=True)

# Convert to integer values (using numpy operations)
photo = photo.astype(np.uint8)

# Compute Otsu threshold
T_otsu = mh.otsu(photo)
thresholded_otsu = (photo > T_otsu)

# Compute Riddler-Calvard threshold
T_rc = mh.rc(photo)
thresholded_rc = (photo > T_rc)

# Now call pylab functions to display the image
gray()
subplot(2,1,1)
imshow(thresholded_otsu)
subplot(2,1,2)
imshow(thresholded_rc)
show()

As you can see, we rely on numpy/matplotlib for many operations.

Install

If you are using conda, you can install mahotas from conda-forge using the following commands:

conda config --add channels conda-forge
conda install mahotas

Compilation from source

You will need python (naturally), numpy, and a C++ compiler. Then you should be able to use:

pip install mahotas

You can test your installation by running:

python -c "import mahotas as mh; mh.test()"

If you run into issues, the manual has more extensive documentation on mahotas installation, including how to find pre-built for several platforms.

Citation

If you use mahotas on a published publication, please cite:

Luis Pedro Coelho Mahotas: Open source software for scriptable computer vision in Journal of Open Research Software, vol 1, 2013. [DOI]

In Bibtex format:

@article{mahotas, author = {Luis Pedro Coelho}, title = {Mahotas: Open source software for scriptable computer vision}, journal = {Journal of Open Research Software}, year = {2013}, doi = {http://dx.doi.org/10.5334/jors.ac}, month = {July}, volume = {1} }

You can access this information using the mahotas.citation() function.

Development

Development happens on github (http://github.com/luispedro/mahotas).

You can set the DEBUG environment variable before compilation to get a debug version:

export DEBUG=1
python setup.py test

You can set it to the value 2 to get extra checks:

export DEBUG=2
python setup.py test

Be careful not to use this in production unless you are chasing a bug. Debug level 2 is very slow as it adds many runtime checks.

The Makefile that is shipped with the source of mahotas can be useful too. make debug will create a debug build. make fast will create a non-debug build (you need to make clean in between). make test will run the test suite.

Links & Contacts

Documentation: https://mahotas.readthedocs.io/

Issue Tracker: github mahotas issues

Mailing List: Use the pythonvision mailing list for questions, bug submissions, etc. Or ask on stackoverflow (tag mahotas)

Main Author & Maintainer: Luis Pedro Coelho (follow on twitter or github).

Mahotas also includes code by Zachary Pincus [from scikits.image], Peter J. Verveer [from scipy.ndimage], and Davis King [from dlib], Christoph Gohlke, as well as others.

Presentation about mahotas for bioimage informatics

For more general discussion of computer vision in Python, the pythonvision mailing list is a much better venue and generates a public discussion log for others in the future. You can use it for mahotas or general computer vision in Python questions.

Recent Changes

Version 1.4.11 (Aug 16 2020)

  • Convert tests to pytest
  • Fix testing for PyPy

Version 1.4.10 (Jun 11 2020)

Version 1.4.9 (Nov 12 2019)

  • Fix FreeImage detection (issue #108)

Version 1.4.8 (Oct 11 2019)

  • Fix co-occurrence matrix computation (patch by @databaaz)

Version 1.4.7 (Jul 10 2019)

  • Fix compilation on Windows

Version 1.4.6 (Jul 10 2019)

  • Make watershed work for >2³¹ voxels (issue #102)
  • Remove milk from demos
  • Improve performance by avoid unnecessary array copies in cwatershed(), majority_filter(), and color conversions
  • Fix bug in interpolation

Version 1.4.5 (Oct 20 2018)

  • Upgrade code to newer NumPy API (issue #95)

Version 1.4.4 (Nov 5 2017)

  • Fix bug in Bernsen thresholding (issue #84)

Version 1.4.3 (Oct 3 2016)

  • Fix distribution (add missing README.md file)

Version 1.4.2 (Oct 2 2016)

  • Fix resize\_to return exactly the requested size
  • Fix hard crash when computing texture on arrays with negative values (issue #72)
  • Added distance argument to haralick features (pull request #76, by Guillaume Lemaitre)

Version 1.4.1 (Dec 20 2015)

  • Add filter\_labeled function
  • Fix tests on 32 bit platforms and older versions of numpy

Version 1.4.0 (July 8 2015)

  • Added mahotas-features.py script
  • Add short argument to citation() function
  • Add max_iter argument to thin() function
  • Fixed labeled.bbox when there is no background (issue #61, reported by Daniel Haehn)
  • bbox now allows dimensions greater than 2 (including when using the as_slice and border arguments)
  • Extended croptobbox for dimensions greater than 2
  • Added use_x_minus_y_variance option to haralick features
  • Add function lbp_names

Version 1.3.0 (April 28 2015)

  • Improve memory handling in freeimage.write_multipage
  • Fix moments parameter swap
  • Add labeled.bbox function
  • Add return_mean and return_mean_ptp arguments to haralick function
  • Add difference of Gaussians filter (by Jianyu Wang)
  • Add Laplacian filter (by Jianyu Wang)
  • Fix crash in median_filter when mismatched arguments are passed
  • Fix gaussian_filter1d for ndim > 2

Version 1.2.4 (December 23 2014)

  • Add PIL based IO

Version 1.2.3 (November 8 2014)

  • Export mean_filter at top level
  • Fix to Zernike moments computation (reported by Sergey Demurin)
  • Fix compilation in platforms without npy_float128 (patch by Gabi Davar)

Version 1.2.2 (October 19 2014)

  • Add minlength argument to labeled_sum
  • Generalize regmax/regmin to work with floating point images
  • Allow floating point inputs to cwatershed()
  • Correctly check for float16 & float128 inputs
  • Make sobel into a pure function (i.e., do not normalize its input)
  • Fix sobel filtering

Version 1.2.1 (July 21 2014)

  • Explicitly set numpy.include_dirs() in setup.py [patch by Andrew Stromnov]

Version 1.2 (July 17 2014)

  • Export locmax|locmin at the mahotas namespace level
  • Break away ellipse_axes from eccentricity code as it can be useful on its own
  • Add find() function
  • Add mean_filter() function
  • Fix cwatershed() overflow possibility
  • Make labeled functions more flexible in accepting more types
  • Fix crash in close_holes() with nD images (for n > 2)
  • Remove matplotlibwrap
  • Use standard setuptools for building (instead of numpy.distutils)
  • Add overlay() function

Version 1.1.1 (July 4 2014)

  • Fix crash in close_holes() with nD images (for n > 2)

1.1.0 (February 12 2014)

  • Better error checking
  • Fix interpolation of integer images using order 1
  • Add resize_to & resize_rgb_to
  • Add coveralls coverage
  • Fix SLIC superpixels connectivity
  • Add remove_regions_where function
  • Fix hard crash in convolution
  • Fix axis handling in convolve1d
  • Add normalization to moments calculation

See the ChangeLog for older version.

License

FOSSA Status

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mahotas-1.4.11.tar.gz (1.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mahotas-1.4.11-cp38-cp38-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.8Windows x86-64

mahotas-1.4.11-cp38-cp38-win32.whl (1.7 MB view details)

Uploaded CPython 3.8Windows x86

mahotas-1.4.11-cp38-cp38-manylinux2010_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

mahotas-1.4.11-cp38-cp38-macosx_10_14_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

mahotas-1.4.11-cp37-cp37m-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.7mWindows x86-64

mahotas-1.4.11-cp37-cp37m-win32.whl (1.7 MB view details)

Uploaded CPython 3.7mWindows x86

mahotas-1.4.11-cp37-cp37m-manylinux2010_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

mahotas-1.4.11-cp37-cp37m-macosx_10_14_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

mahotas-1.4.11-cp36-cp36m-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.6mWindows x86-64

mahotas-1.4.11-cp36-cp36m-win32.whl (1.7 MB view details)

Uploaded CPython 3.6mWindows x86

mahotas-1.4.11-cp36-cp36m-manylinux2010_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

mahotas-1.4.11-cp36-cp36m-macosx_10_14_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file mahotas-1.4.11.tar.gz.

File metadata

  • Download URL: mahotas-1.4.11.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.4.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.6.8

File hashes

Hashes for mahotas-1.4.11.tar.gz
Algorithm Hash digest
SHA256 3f0109f167fc9b599f77b4d30d57c45bcc34dea019ff79fe29eb43c866d87ce9
MD5 e4be884e4fd9e4ddd141c299f637dac4
BLAKE2b-256 d9b5a601f54b670bf84cb2dca24ca56be2fc7bd8d86a3eb678579956c922981e

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for mahotas-1.4.11-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 22920ea2f5285f8a99a357960fdeed540863d94a47dcfa79bcc3885a29eafab7
MD5 4d6d9ca2aab3cc2beb915af287a0a06e
BLAKE2b-256 099c984dbff32c754866c4c666fa0dceac77ed04f286172ef4ce3d53b6952f2b

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp38-cp38-win32.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp38-cp38-win32.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for mahotas-1.4.11-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 849054bdc095749104f6e13cf3ada97f98f29f0ae2af0e0c05de740b3b532fd0
MD5 ba9b1eda2cd5e0e8b3a3bc6999f0da4c
BLAKE2b-256 805e52c74bf5b7bc9d1dd6286cd53dba3e6f5464556763916851489f7271303c

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 5.5 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.11

File hashes

Hashes for mahotas-1.4.11-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2df8091c037305398ae3e66990398b8f4502c49917536d28f562c88c1d1e53d6
MD5 9528766473c48912eadfa92bde645e70
BLAKE2b-256 4d0f83711c883e6391783d6a556753f1a677e7391e1aa625dcabeda082d6acfc

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for mahotas-1.4.11-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 14dc57b5b2e01e3a3e832eb688a38cd245f8cdbdf382f29b6e07003d79d5f0e7
MD5 84ff030dba1a293ac2eb4e3f9ec6570e
BLAKE2b-256 e6bb53c5fccb07cbefcd92b2da852b7e8934203dbdc95e4056a2f8ce40295dd0

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for mahotas-1.4.11-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0f14399255c39f0f6cf00819e9c3d787f94d87d99c8f1a8ed78079a3c73824d2
MD5 397c8c2a7c0631cd59f9598d8c31cfe8
BLAKE2b-256 659c257976396421bbb2eb73e64c4855e62c1f32774009f98e03c28df627e94d

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp37-cp37m-win32.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for mahotas-1.4.11-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 ed07b14c843900072de039c5ae925c9afcce7cafb6e1a4ffd5e1889502de38f8
MD5 d1b9bba74b83f0d503fb0599fffe3ed6
BLAKE2b-256 2039a73882926a23f4e15b47b043cdb6d93b64a95e991c5595156d2bd16bdc5f

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 5.7 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.11

File hashes

Hashes for mahotas-1.4.11-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5a37ba53dda795f2534251df5887fbb37153b14a516f8a14a1c0c762b6513179
MD5 a46fc6c0bd3f1394e38a7e0a1de2bfe0
BLAKE2b-256 19ad553b246b0a35dccc3ed58dc8889a67124bf5ab858e9c6b7255d56086e70c

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for mahotas-1.4.11-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d923b92f9a286626fe777464c8e6c684c24b2432cd6c6a97ddd5c8f6873ac006
MD5 0c3f88df889c7a4b066e0a4ab6eafb3c
BLAKE2b-256 6d7fb245e7c80f6b5df6740402519607348d429b8e0ba86b180be47fe9aa6a07

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for mahotas-1.4.11-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 315cf7a3e5dd94f9014923fa611b36d999ce7e855b62ffe103613eeeb8cdc319
MD5 53c665a828d5700fd36d3335c9d7080d
BLAKE2b-256 bc630c6d600cc4f8d9b265365e9164eabd32a32ba3f4bf9d46f02c1b1af765f7

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp36-cp36m-win32.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for mahotas-1.4.11-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 d200a8ebe10bd0c07f82d202d1713a96b7596f20adc644955685aafcfa7ae9d3
MD5 c1cefe267cad6ecb74db6a0f55a30fef
BLAKE2b-256 566c5d6e23f02ff20c3a1c7321ea09e8b6647fdc17fefa6c449a52516d6da8b4

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 5.7 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.11

File hashes

Hashes for mahotas-1.4.11-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a6d343b59c56fdc812ac2fa07e9e555ca1fb3fe9b555698e2f0bfae9fd9f2a75
MD5 917bf968c4ad918cbf69c84a90c5de17
BLAKE2b-256 ce3b1f3fe2f86ffdb4a2fbc6baaf4ef0e6cebdd3e127de44ddd188dc2ed0d412

See more details on using hashes here.

File details

Details for the file mahotas-1.4.11-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mahotas-1.4.11-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.11

File hashes

Hashes for mahotas-1.4.11-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4ef9a73062012aac935a4398d91edad4ccddd25f98f61f201cefbe20b6b0aa8b
MD5 d1091b31c315b2a81e453d8cf718b8aa
BLAKE2b-256 916d0dd264723926e39dc3ecbbf79c3b314ddf29dde22487dd7957bcc49bde9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page