object counting


In [4]:
import cv2
from matplotlib import pyplot as plt
from skimage import filters
cl=cv2.imread('dataset_predict.png')

In [5]:
%matplotlib inline

In [14]:
a=filters.gaussian(cl.astype(float), sigma=1.5)
plt.imshow(a, cmap=plt.cm.gray)
plt.rcParams['figure.figsize']=(10,7)



In [17]:
from skimage.filters import threshold_otsu
thresh = threshold_otsu(a)
binary = a > thresh
plt.imshow(binary, cmap=plt.cm.gray)
plt.rcParams['figure.figsize']=(10,7)



In [18]:
from skimage import measure
blobs_labels,num = measure.label(binary, background=0,return_num=True,connectivity=2)
print 'totol object is %d'%num


totol object is 170

In [19]:
plt.imshow(blobs_labels, cmap=plt.cm.jet)


Out[19]:
<matplotlib.image.AxesImage at 0x2a4c3550>

In [ ]: