gen_histo.py 文件源码

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

项目:sim 作者: big-data-lab-team 项目源码 文件源码
def create_histo(folder_path, min_val, max_val, num_bins=None):

    if num_bins is None:
        num_bins = int(max_val - min_val)    
        print num_bins

    histogram = {}

    for f in os.listdir(folder_path):

        im = nib.load(os.path.join(folder_path, f))
        data = im.get_data()

        hist, bins = np.histogram(data, num_bins, range=(min_val, max_val))

        count = 0

        for el in bins[0:-1]:
            try:
                histogram[el] += hist[count]
            except:
                histogram[el] = hist[count]
            count += 1

    return histogram.items()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号