Computer Vision in Python

Overview

Mahotas

Python Computer Vision Library

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

GH Actions Status 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

Issues
  • regmax memory leak

    regmax memory leak

    I ran regmax on a 600x600x600 bool array and once it started, the memory usage slowly increased passed the amount of physical memory that I have (32GB). I realized that I needed to specify a new structuring element for 3D, but even now regmax is using 10GB on a file that is smaller than 1GB. Any ideas as to why this is?

    For the original problem, maybe you could just add

    assert Bc.ndim == f.ndim
    

    into your code

    opened by thanasi 11
  • Could regmax also work on float arrays?

    Could regmax also work on float arrays?

    All's in the title... regmax is currently generated using SAFE_SWITCH_ON_INTEGER_TYPES_OF and checks for integer-ness of the input; is there any specific reason why it doesn't handle float types?

    By the way, the docstring of regmax doesn't mention this limitation.

    opened by anntzer 11
  • Difference of Gaussian (DoG) edge detection added

    Difference of Gaussian (DoG) edge detection added

    Another edge detection method besides sobel. DoG can approximate Laplacian of Gaussian operator. It works as an efficient edge detector.

    Will add a demo soon.

    opened by wang1211 9
  • Add LGTM code quality badges

    Add LGTM code quality badges

    Hi there!

    I thought you might be interested in adding these LGTM code quality badges to your project. They indicate how you care about code quality and encourage your future contributors to do the same. To get an idea of the analyses reflected by these grades, check the alerts discovered by LGTM.

    N.B.: I am on the team behind LGTM.com, I'd appreciate your feedback on this initiative, whether you're interested or not, if you find time to drop me a line. Thanks.

    opened by xcorail 8
  • Building wheels with pip option --user or --prefix fails

    Building wheels with pip option --user or --prefix fails

    When mahotas is installed with pip install mahotas --user building wheels fails with the following error on Ubuntu 16.04 with Python 2.7.12:

        x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -DPY_ARRAY_UNIQUE_SYMBOL=Mahotas_PyArray_API_Symbol -I[] -I/usr/include/python2.7 -c mahotas/_histogram.cpp -o build/temp.linux-x86_64-2.7/mahotas/_histogram.o
        cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
        In file included from mahotas/numpypp/array.hpp:17:0,
                         from mahotas/_histogram.cpp:10:
        mahotas/numpypp/numpy.hpp:11:33: fatal error: numpy/ndarrayobject.h: No such file or directory
        compilation terminated.
        error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
      ----------------------------------------
      Failed building wheel for mahotas
      Running setup.py clean for mahotas
    Failed to build mahotas
    Installing collected packages: numpy, mahotas
      Running setup.py install for mahotas ... done
    Successfully installed mahotas-1.4.3 numpy-1.12.0
    

    This fails:

    docker run -t hackermd/ubuntu-xenial-python pip install mahotas --user
    

    This works:

    docker run -t hackermd/ubuntu-xenial-python sudo pip install mahotas
    
    opened by hackermd 7
  • freeimage may not release memory

    freeimage may not release memory

    I try to convert a huge file of raw video data into many multipage TIFF files by using the "freeimage.write_multipage()" function of the freeimage package from the Mahotas library (Python 2.7). Unfortunately, it seems that this "very easy to use" function doesn't release memory when running the script. So, my script works fine for small input raw files (less than 1 GB) but crashes with bigger files (a 3 GB input file crashes with Win XP pro 32 - ram 3.2 GB). My goal is to convert input files up to 1.5 TB. An extract of the script below:

    python_script

    When I run my script, the Windows Task manager shows an increase of the used ram, output file after output file until the crash which release all the used ram : pb-memoire-creatiff

    An extract of the reported error : erreur_freeimage

    opened by Al92130 7
  • UnicodeDecodeError from setup.py with Python 3.2 on Mac

    UnicodeDecodeError from setup.py with Python 3.2 on Mac

    I get this error on Mac 10.8:

    $ python3.2 setup.py build
    Traceback (most recent call last):
      File "setup.py", line 40, in <module>
        long_description = open('docs/source/readme.rst').read()
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5169: ordinal not in range(128)
    
    opened by cdeil 7
  • cwatershed output dtype should be the dtype of `markers`, not `surface`

    cwatershed output dtype should be the dtype of `markers`, not `surface`

    Currently, the output dtype of cwatershed is the same as the dtype of the surface argument (I think this happens in the declaration of res_a in py_cwatershed), which creates a wraparound issue if e.g. there are more than 255 markers but surface is of dtype uint8 (which is actually the case in the examples given in the doc). I think that a quick fix would be to just use the dtype of the markers argument instead.

    opened by anntzer 7
  • 0.7 won't compile on OS X 10.7

    0.7 won't compile on OS X 10.7

    I've just tried installing via pip and easy_install, and also from the latest git clone, but I always end up with the same set of errors (below). I went back to 0.6.6 and it works OK. I tried figuring out the cause of the problem, but without success. I have the latest XCode gcc (4.2.1) and also macports gcc (4.4.0), but both produce the same problems (below).

    Cheers,

    Ian

    compile options: '-I/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/7.1/include/python2.7 -c' g++: mahotas/_interpolate.cpp In file included from /usr/include/c++/4.2.1/ios:47, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/localefwd.h:58:34: error: macro "isspace" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:70:34: error: macro "isupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:74:34: error: macro "islower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:78:34: error: macro "isalpha" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:94:34: error: macro "isalnum" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:102:34: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:106:34: error: macro "tolower" passed 2 arguments, but takes just 1 In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44, from /usr/include/c++/4.2.1/ios:50, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/locale_facets.h:245:53: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:274:53: error: macro "tolower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:817:53: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:850:53: error: macro "tolower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4614:44: error: macro "isspace" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4632:44: error: macro "isupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4638:44: error: macro "islower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4644:44: error: macro "isalpha" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4668:44: error: macro "isalnum" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4680:44: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4686:44: error: macro "tolower" passed 2 arguments, but takes just 1 In file included from /usr/include/c++/4.2.1/ios:47, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/localefwd.h:58: error: ‘std::isspace’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:58: error: template declaration of ‘bool std::isspace’ /usr/include/c++/4.2.1/bits/localefwd.h:70: error: ‘std::isupper’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:70: error: template declaration of ‘bool std::isupper’ /usr/include/c++/4.2.1/bits/localefwd.h:74: error: ‘std::islower’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:74: error: template declaration of ‘bool std::islower’ /usr/include/c++/4.2.1/bits/localefwd.h:78: error: ‘std::isalpha’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:78: error: template declaration of ‘bool std::isalpha’ /usr/include/c++/4.2.1/bits/localefwd.h:94: error: ‘std::isalnum’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:94: error: template declaration of ‘bool std::isalnum’ /usr/include/c++/4.2.1/bits/localefwd.h:102: error: ‘std::toupper’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:102: error: template declaration of ‘_CharT std::toupper’ /usr/include/c++/4.2.1/bits/localefwd.h:106: error: ‘std::tolower’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:106: error: template declaration of ‘_CharT std::tolower’ In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44, from /usr/include/c++/4.2.1/ios:50, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/locale_facets.h:230: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:245: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:258: error: expected ;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h:259: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:274: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:290: error: expected;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘_CharT std::__ctype_abstract_base<CharT>::towupper(int ()(_CharT)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:231: error: ‘__c’ was not declared in this scope /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘CharT std::__ctype_abstract_base<CharT>::towlower(int ()(CharT)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:260: error: ‘__c’ was not declared in this scope /usr/include/c++/4.2.1/bits/locale_facets.h: At global scope: /usr/include/c++/4.2.1/bits/locale_facets.h:800: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:817: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:832: error: expected ;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h:833: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:850: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:869: error: expected;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘char std::ctype::towupper(int ()(char)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:801: error: ‘__c’ was not declared in this scope /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘char std::ctype::towlower(int ()(char)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:834: error: ‘__c’ was not declared in this scope In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44, from /usr/include/c++/4.2.1/ios:50, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/locale_facets.h: At global scope: /usr/include/c++/4.2.1/bits/locale_facets.h:4614: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4632: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4638: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4644: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4668: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4680: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4686: error: function definition does not declare parameters In file included from /usr/include/c++/4.2.1/ios:47, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/localefwd.h:58:34: error: macro "isspace" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:70:34: error: macro "isupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:74:34: error: macro "islower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:78:34: error: macro "isalpha" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:94:34: error: macro "isalnum" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:102:34: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:106:34: error: macro "tolower" passed 2 arguments, but takes just 1 In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44, from /usr/include/c++/4.2.1/ios:50, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/locale_facets.h:245:53: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:274:53: error: macro "tolower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:817:53: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:850:53: error: macro "tolower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4614:44: error: macro "isspace" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4632:44: error: macro "isupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4638:44: error: macro "islower" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4644:44: error: macro "isalpha" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4668:44: error: macro "isalnum" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4680:44: error: macro "toupper" passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/locale_facets.h:4686:44: error: macro "tolower" passed 2 arguments, but takes just 1 In file included from /usr/include/c++/4.2.1/ios:47, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/localefwd.h:58: error: ‘std::isspace’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:58: error: template declaration of ‘bool std::isspace’ /usr/include/c++/4.2.1/bits/localefwd.h:70: error: ‘std::isupper’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:70: error: template declaration of ‘bool std::isupper’ /usr/include/c++/4.2.1/bits/localefwd.h:74: error: ‘std::islower’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:74: error: template declaration of ‘bool std::islower’ /usr/include/c++/4.2.1/bits/localefwd.h:78: error: ‘std::isalpha’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:78: error: template declaration of ‘bool std::isalpha’ /usr/include/c++/4.2.1/bits/localefwd.h:94: error: ‘std::isalnum’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:94: error: template declaration of ‘bool std::isalnum’ /usr/include/c++/4.2.1/bits/localefwd.h:102: error: ‘std::toupper’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:102: error: template declaration of ‘_CharT std::toupper’ /usr/include/c++/4.2.1/bits/localefwd.h:106: error: ‘std::tolower’ declared as an ‘inline’ variable /usr/include/c++/4.2.1/bits/localefwd.h:106: error: template declaration of ‘_CharT std::tolower’ In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44, from /usr/include/c++/4.2.1/ios:50, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/locale_facets.h:230: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:245: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:258: error: expected ;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h:259: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:274: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:290: error: expected;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘_CharT std::__ctype_abstract_base<CharT>::towupper(int ()(_CharT)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:231: error: ‘__c’ was not declared in this scope /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘CharT std::__ctype_abstract_base<CharT>::towlower(int ()(CharT)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:260: error: ‘__c’ was not declared in this scope /usr/include/c++/4.2.1/bits/locale_facets.h: At global scope: /usr/include/c++/4.2.1/bits/locale_facets.h:800: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:817: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:832: error: expected ;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h:833: error: ‘btowc’ is not a type /usr/include/c++/4.2.1/bits/locale_facets.h:850: error: expected ‘;’ before ‘const’ /usr/include/c++/4.2.1/bits/locale_facets.h:869: error: expected;' before ‘char_type’ /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘char std::ctype::towupper(int ()(char)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:801: error: ‘__c’ was not declared in this scope /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘char std::ctype::towlower(int ()(char)) const’: /usr/include/c++/4.2.1/bits/locale_facets.h:834: error: ‘__c’ was not declared in this scope In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44, from /usr/include/c++/4.2.1/ios:50, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from mahotas/numpypp/array.hpp:9, from mahotas/_filters.h:2, from mahotas/_interpolate.cpp:38: /usr/include/c++/4.2.1/bits/locale_facets.h: At global scope: /usr/include/c++/4.2.1/bits/locale_facets.h:4614: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4632: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4638: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4644: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4668: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4680: error: function definition does not declare parameters /usr/include/c++/4.2.1/bits/locale_facets.h:4686: error: function definition does not declare parameters error: Command "g++ -fno-strict-aliasing -fno-common -dynamic -arch i386 -DNDEBUG -g -O3 -arch i386 -I/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/7.1/include/python2.7 -c mahotas/_interpolate.cpp -o build/temp.macosx-10.5-i386-2.7/mahotas/_interpolate.o" failed with exit status 1

    opened by ijstokes 6
  • Make mode an optional parameter in Euler characteristic calculation

    Make mode an optional parameter in Euler characteristic calculation

    I need to calculate the Euler characteristic with periodic boundary conditions, which works very nicely with 'wrap' mode.

    BTW, I implemented an earlier algorithm for the characteristic (described in http://dx.doi.org/10.1016/S0010-4655(00)00139-9) and it happily gives the same answer as mahotas. But, mahotas is so much faster.

    opened by langner 6
  • "Input data has unexpected types" - Bug in mahotas.features.lbp.lbp

    Stack Trace -

    Traceback (most recent call last):
      File "C:/MS/Courses/CSE 515 MWDB/Project/Phase1/main.py", line 41, in <module>
        elbp.local_binary_pattern(image1)
      File "C:\MS\Courses\CSE 515 MWDB\Project\Phase1\feature_extractor.py", line 66, in local_binary_pattern
        feature = lbp(image, radius=3, points=16)
      File "C:\Users\fateh\anaconda3\envs\Phase1\lib\site-packages\mahotas\features\lbp.py", line 151, in lbp
        codes = lbp_transform(image, radius, points, ignore_zeros=ignore_zeros, preserve_shape=False)
      File "C:\Users\fateh\anaconda3\envs\Phase1\lib\site-packages\mahotas\features\lbp.py", line 75, in lbp_transform
        select(shift(image, [radius*dy,radius*dx], order=1)))
      File "C:\Users\fateh\anaconda3\envs\Phase1\lib\site-packages\mahotas\interpolate.py", line 289, in shift
        _interpolate.zoom_shift(array, None, shift, output, order, mode2int[mode], cval)
    RuntimeError: mahotas.zoom_shift: input data has unexpected types. This may be a bug in mahotas.
    

    Code -

    from mahotas.features.lbp import lbp
    feature = lbp(image, radius=3, points=16)
    
    print(image1.shape)
    

    gives (64, 64) which is as expected (a 2d array)

    print(type(image1)) 
    

    gives <class 'numpy.ndarray'> which is as expected (i.e. 2-D numpy ndarray)

    opened by fateh288 1
  • Update edge.py

    Update edge.py

    added edge detector based on Sujoy's algorithm

    opened by SujoyKG 12
  • different shape has the same Zernike moments value

    different shape has the same Zernike moments value

    11_circle 21_circle

    as picture shows the i have two different shapes (one is part of the other), but it's strange that i got the same Zernike moments for them when i only use same parameter of center of mass and radius (see the green circle) . I don't know the Zernike foundamentals, so is this reasonable or an issue?

    please ignore the green circle and red contour, that's drawed only try to make this question clear. the two original images only have the white object.

    opened by mashuai191 4
  • Fix px vector computation

    Fix px vector computation

    The paper mentions computation of px as 'summing the rows' of cmat (GLCM matrix) i.e sum of values in x (horizontal) direction, which in python corresponds to summation along axis=1; and py as sum of column values or sum of values in y (vertical) direction, which in Python corresponds to summation along axis=0.

    The computation of px in paper is
    here
    and that of py is as shown below:
    here

    opened by databaaz 1
  • Can it display an image of each feature?

    Can it display an image of each feature?

    Can it display an image of each feature? Like this below https://github.com/tzm030329/GLCM

    opened by wu110011 1
  • simple detect line using hough transform

    simple detect line using hough transform

    I try to rename the file LineDetectorByHough to line_detector_by_hough, but test failed. Would you help me? If you rewrite other codes is my pleasure! Thank you very much!

    opened by jasson2001 3
  • Test cases `test_colors` and `test_ellipse_axes` seem to be impure

    Test cases `test_colors` and `test_ellipse_axes` seem to be impure

    The package mahotas is part of the Nix package set which aims to provide reproducible builds. Unfortunately mahotas is broken ATM since two testcases (namely test_colors and test_ellipse_axes) are not fully pure. When running the build, the tests sometimes fail without a predictable pattern.

    See NixOS/nixpkgs#46368 for further reference.

    bug 
    opened by Ma27 2
  • Zernike moments - Getting wiered values after above 20 degree

    Zernike moments - Getting wiered values after above 20 degree

    Trying to extract ZM from two images and compare them with opencv norm function to measure similarity, It works well for below 20 Degree but it doesn't capture detail information of images so for some images i am getting wrong similarity.

    I tried to increase Degree to 60 Degree and found out that same image from different image giving Negative number like -88835.23 which should be between 0 to 1

    can you please look into it and resolve the issue code below desc = mahotas.features.zernike_moments(imres, 200, degree=60, cm=200,200) desc1 = mahotas.features.zernike_moments(imres1, 200, degree=60, cm=200,200) score = cv2.norm(desc, desc1, cv2.NORM_L2)

    Thanks in advance

    opened by sanctusin 2
  • Would you please implement and include the histogram refinement  explained in https://github.com/Ashwani21/Local-texture-descriptors  in this repo.

    Would you please implement and include the histogram refinement explained in https://github.com/Ashwani21/Local-texture-descriptors in this repo.

    Histogram refinement results in https://github.com/Ashwani21/Local-texture-descriptors are very promising.

    enhancement 
    opened by Ashwani21 1
  • Hough transform feature request

    Hough transform feature request

    I've used mahotas for detecting/labeling objects, and now need to add a Hough transform element to it. I'll probably use OpenCV for now, but to reduce dependencies I'd like to stick with only mahotas. I saw that Hough transforms were on the possible features list, and just wanted to make an issue to formally express interest in that.

    Please close this issue if Hough transforms are no longer a planned feature, or if the issue queue isn't the right place to request this!

    enhancement 
    opened by dirtbirb 6
Releases(v1.4.8)
  • v1.4.8(Oct 10, 2019)

  • v1.4.4(Nov 5, 2017)

  • v1.4.3(Oct 4, 2016)

    Release 1.4.3

    The README file changed extension (from rst to md) and this was not reflected in the MANIFEST.in file, which is used for generating the distribution file.

    Release 1.4.2

    Bugfix release. Full ChangeLog:

    • 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)
    Source code(tar.gz)
    Source code(zip)
Python interface to PROJ (cartographic projections and coordinate transformations library)

pyproj Python interface to PROJ (cartographic projections and coordinate transformations library). Documentation Stable: http://pyproj4.github.io/pypr

null 663 Oct 12, 2021
Read images to numpy arrays

mahotas-imread: Read Image Files IO with images and numpy arrays. Mahotas-imread is a simple module with a small number of functions: imread Reads an

Luis Pedro Coelho 62 Jul 27, 2021
Google maps for Jupyter notebooks

gmaps gmaps is a plugin for including interactive Google maps in the IPython Notebook. Let's plot a heatmap of taxi pickups in San Francisco: import g

Pascal Bugnion 719 Sep 16, 2021
geemap - A Python package for interactive mapping with Google Earth Engine, ipyleaflet, and ipywidgets.

A Python package for interactive mapping with Google Earth Engine, ipyleaflet, and folium

Qiusheng Wu 1.4k Oct 22, 2021
A Python package for delineating nested surface depressions from digital elevation data.

Welcome to the lidar package lidar is Python package for delineating the nested hierarchy of surface depressions in digital elevation models (DEMs). I

Qiusheng Wu 102 Oct 1, 2021
Fiona reads and writes geographic data files

Fiona Fiona reads and writes geographic data files and thereby helps Python programmers integrate geographic information systems with other computer s

null 852 Oct 19, 2021
Rasterio reads and writes geospatial raster datasets

Rasterio Rasterio reads and writes geospatial raster data. Geographic information systems use GeoTIFF and other formats to organize and store gridded,

Mapbox 1.6k Oct 22, 2021
Documentation and samples for ArcGIS API for Python

ArcGIS API for Python ArcGIS API for Python is a Python library for working with maps and geospatial data, powered by web GIS. It provides simple and

Esri 1.1k Oct 14, 2021
Solving the Traveling Salesman Problem using Self-Organizing Maps

Solving the Traveling Salesman Problem using Self-Organizing Maps This repository contains an implementation of a Self Organizing Map that can be used

Diego Vicente 1.7k Oct 13, 2021
Asynchronous Client for the worlds fastest in-memory geo-database Tile38

This is an asynchonous Python client for Tile38 that allows for fast and easy interaction with the worlds fastest in-memory geodatabase Tile38.

Ben 34 Oct 13, 2021
WhiteboxTools Python Frontend

whitebox-python Important Note This repository is related to the WhiteboxTools Python Frontend only. You can report issues to this repo if you have pr

Qiusheng Wu 223 Oct 18, 2021
Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.

django-rest-framework-gis Geographic add-ons for Django Rest Framework - Mailing List. Install last stable version from pypi pip install djangorestfra

OpenWISP 884 Oct 20, 2021
Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.

Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.

OpenWISP 882 Oct 14, 2021
A Django application that provides country choices for use with forms, flag icons static files, and a country field for models.

Django Countries A Django application that provides country choices for use with forms, flag icons static files, and a country field for models. Insta

Chris Beaven 1k Oct 19, 2021
Python bindings and utilities for GeoJSON

geojson This Python library contains: Functions for encoding and decoding GeoJSON formatted data Classes for all GeoJSON Objects An implementation of

Jazzband 652 Oct 12, 2021
Python bindings and utilities for GeoJSON

geojson This Python library contains: Functions for encoding and decoding GeoJSON formatted data Classes for all GeoJSON Objects An implementation of

Jazzband 652 Oct 12, 2021
Python Data. Leaflet.js Maps.

folium Python Data, Leaflet.js Maps folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js

null 5.5k Oct 24, 2021
pure-Python (Numpy optional) 3D coordinate conversions for geospace ecef enu eci

Python 3-D coordinate conversions Pure Python (no prerequistes beyond Python itself) 3-D geographic coordinate conversions and geodesy. API similar to

Geospace code 211 Oct 13, 2021
:earth_asia: Python Geocoder

Python Geocoder Simple and consistent geocoding library written in Python. Table of content Overview A glimpse at the API Forward Multiple results Rev

Denis 1.4k Oct 15, 2021