cdf.py 文件源码

python
阅读 47 收藏 0 点赞 0 评论 0

项目:imgProcessor 作者: radjkarl 项目源码 文件源码
def cdf(arr, pos=None):
    '''
    Return the cumulative density function of a given array or
    its intensity at a given position (0-1)
    '''

    r = (arr.min(), arr.max())
    hist, bin_edges = np.histogram(arr, bins=2 * int(r[1] - r[0]), range=r)
    hist = np.asfarray(hist) / hist.sum()
    cdf = np.cumsum(hist)
    if pos is None:
        return cdf
    i = np.argmax(cdf > pos)
    return bin_edges[i]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号