Merge pull request #16499 from ankit6979:3.4

* Update py_thresholding.markdown

* 📝 Update py_thresholding.markdown
pull/16504/head
ankit6979 5 years ago committed by GitHub
parent 0673866ceb
commit 17fe63446f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      doc/py_tutorials/py_imgproc/py_thresholding/py_thresholding.markdown

@ -188,7 +188,7 @@ blur = cv.GaussianBlur(img,(5,5),0)
# find normalized_histogram, and its cumulative distribution function
hist = cv.calcHist([blur],[0],None,[256],[0,256])
hist_norm = hist.ravel()/hist.max()
hist_norm = hist.ravel()/hist.sum()
Q = hist_norm.cumsum()
bins = np.arange(256)
@ -199,6 +199,8 @@ thresh = -1
for i in xrange(1,256):
p1,p2 = np.hsplit(hist_norm,[i]) # probabilities
q1,q2 = Q[i],Q[255]-Q[i] # cum sum of classes
if q1 < 1.e-6 or q2 < 1.e-6:
continue
b1,b2 = np.hsplit(bins,[i]) # weights
# finding means and variances

Loading…
Cancel
Save