Computer vision
Environment
- Windows 10
- Python 2.7
Steps
- pip install mahotas
- install imread on Windows
- Go to How To Install Mahotas-imread
- Go to binary packages of imread
- Download imread?0.6.1?cp27?cp27m?win_amd64.whl
- pip install imread?0.6.1?cp27?cp27m?win_amd64.whl
- pip install matplotlib
- 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()
- 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()
- 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()
- 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()