Environment

  • Windows 10
  • Python 2.7 architecture

Steps

  1. pip install mahotas
  2. install imread on Windows
    1. Go to How To Install Mahotas-imread
    2. Go to binary packages of imread
    3. Download imread?0.6.1?cp27?cp27m?win_amd64.whl
    4. pip install imread?0.6.1?cp27?cp27m?win_amd64.whl
  3. pip install matplotlib
  4. read image code:
import mahotas as mh

image=mh.imread('pexels-photo-531880.jpeg')
image=image-image.mean()
from matplotlib import pyplot as plt
plt.imshow(image)
plt.show()

cv-read-image

  1. otsu
    import mahotas as mh
    import numpy as np
    image=mh.imread('architecture.jpg')
    image=mh.colors.rgb2gray(image,dtype=np.uint8)
    from matplotlib import pyplot as plt
    thresh=mh.thresholding.otsu(image)
    plt.imshow(image>thresh)
    plt.gray()
    plt.show()
    

    cv-otsu

  2. otsubin
    import mahotas as mh
    import numpy as np
    image=mh.imread('architecture.jpg')
    image=mh.colors.rgb2gray(image,dtype=np.uint8)
    from matplotlib import pyplot as plt
    otsubin=(image>thresh)
    otsubin=mh.open(otsubin,np.ones((15,15)))
    plt.imshow(otsubin)
    plt.gray()
    plt.show()
    

    cv-otsubin

  3. rc
    import mahotas as mh
    import numpy as np
    image=mh.imread('architecture.jpg')
    image=mh.colors.rgb2gray(image,dtype=np.uint8)
    from matplotlib import pyplot as plt
    thresh=mh.thresholding.rc(image)
    plt.imshow(image>thresh)
    plt.gray()
    plt.show()
    

    cv-rc