Fix loop ranges of rank filter kernel functions