大津阈值(otsuthresh)的Python实现
参照《数字图像处理》中对大津阈值的理论描述,Python可如下实现import numpy as npdef otsuthresh(h): h = h/sum(h) i = np.arange(1,h.size+1) P1 = np.cumsum(h) m = np.cumsum(i*h) mG = m[-1] eps = 2.2204*pow(10,-16) sigSquared = np.power((mG*P1-m),2)/(P1*(1-P1