azrael wrote: > Can somone look at this
> def otsu(hi): > fmax=-1.0 > border=len(hi) > for i in range(border): > if hi[i]!=0:break > for j in range(border-1,0-1,-1): > if hi[j] != 0:break > s = sum([k*hi[k] for k in range(border)]) n = sum(hi) # > product(im.size) > n1=n2=csum=0.0 > for k in range(i,j): > n1 += hi[k] > n2 = n - n1 > csum+= k * hi[k] > m1 = csum/ n1 > m2 = (s - csum)/n2 As I said in my previous post, try replacing this line > sb = n1 * n2 * (m2 - m1) with the original sb = n1 * n2 * (m1 - m2) * (m1 - m2) that has been commented out. > if sb > fmax: > fmax = sb > V=k+1 > print V > I try to implement it from C from this location. Personally, I would start with a literal translation and not try to improve it until it works. Peter -- http://mail.python.org/mailman/listinfo/python-list