for the first ``range(max_bin)``
the problem with max_bin = 255 is that the local mean (i.e. ``mu``) will
not take into account the last histogram bin

for the second ``range(1, max_bin)`` if we start at 0, the first loop will
sum both time the first histogram bin which is not needed, but here indeed
the range may stop at max_bin -1 (i.e. 254 for 8-bit) since a threshold a
255 is useless



On Thu, Aug 1, 2013 at 8:41 AM, Johannes Schönberger <
notifications@github.com> wrote:

> In skimage/filter/rank/generic_cy.pyx:
>
> > +
> > +    # compute local mean
> > +    if pop:
> > +        for i in range(max_bin):
> > +            mu += histo[i] * i
> > +        mu = mu / pop
> > +    else:
> > +        return 0
> > +
> > +    # maximizing the between class variance
> > +    max_i = 0
> > +    q1 = histo[0] / pop
> > +    mu1 = 0.
> > +    max_sigma_b = 0.
> > +
> > +    for i in range(1, max_bin):
>
> I checked again and to me it makes for sense to use range(max_bin) for
> both loops?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/scikit-image/scikit-image/pull/626/files#r5523284>
> .
>