Looks like the relevant _crank8 function for filter.rank.percentile doesn't use p1 at all.


cdef inline dtype_t kernel_percentile(Py_ssize_t * histo, float pop,
                                      dtype_t g, float p0, float p1,
                                      Py_ssize_t s0, Py_ssize_t s1):
    cdef int i
    cdef float sum = 0.

    if pop:
        for i in range(256):
            sum += histo[i]
            if sum >= p0 * pop:
                break

        return <dtype_t>(i)
    else:
        return <dtype_t>(0)

That said, some of the other `percentile_*` functions do in fact use both `p0` and `p1`. At minimum, there is room for docstring clarification here.


On Wednesday, May 8, 2013 9:59:45 PM UTC-5, Juan Nunez-Iglesias wrote:

Hey guys,

I'm wanting to use the rank filter module in skimage, but I'm not sure about the usage of percentile(). My intuition of how a percentile filter should work is:

for each pixel:
    grab all the values in the structuring element centred at that pixel
    sort them
    find the requested percentile; interpolate if necessary
    replace pixel with that value

However, the function doesn't require one percentile but two, p0 and p1. The docstring says "Only levels between percentiles [p0, p1] are used", but I don't understand what this means. What if three different values fall between p0 and p1? What if no values fall between them?