utils.py 文件源码

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

项目:pisap 作者: neurospin 项目源码 文件源码
def histogram(image, nbins=256, lower_cut=0., cumulate=0):
    """
    Compute the histogram of an input dataset.

    Parameters
    ----------
    image: Image
        the image that contains the dataset to be analysed.
    nbins: int, default 256
        the histogram number of bins.
    lower_cut: float, default 0
        do not consider the intensities under this threshold.
    cumulate: bool, default False
        if set compute the cumulate histogram.

    Returns
    -------
    hist_im: Image
        the generated histogram.
    """
    hist, bins = np.histogram(image.data[image.data > lower_cut], nbins)
    if cumulate:
        cdf = hist.cumsum()
        cdf_normalized = cdf * hist.max() / cdf.max()
        hist_im = pisap.Image(data=cdf_normalized)
    else:
        hist_im = pisap.Image(data=hist)
    return hist_im
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号