当前位置: 首页>>代码示例>>Python>>正文


Python cm.binary方法代码示例

本文整理汇总了Python中matplotlib.cm.binary方法的典型用法代码示例。如果您正苦于以下问题:Python cm.binary方法的具体用法?Python cm.binary怎么用?Python cm.binary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.cm的用法示例。


在下文中一共展示了cm.binary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pplot

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import binary [as 别名]
def pplot(As, titles):
    # setup
    try: vmin = min([A.min() for A, t in zip(As[:-1], titles) if "missing" not in t]) # for pixel color reference
    except: vmin = As[0].min()
    try: vmax = max([A.max() for A, t in zip(As[:-1], titles) if "missing" not in t])
    except: vmax = As[0].max()
    my_dpi = 96
    plt.figure(figsize=(1.4*(250*len(As))/my_dpi, 250/my_dpi), dpi = my_dpi)
    for i, (A, title) in enumerate(zip(As, titles)):
        plt.subplot(1, len(As), i+1)
        if i == len(As)-1: vmin, vmax = A.min(), A.max()
        if "missing" in title:
            missing = A
            masked_data = ones(As[i-1].shape)
            for j,k in missing:  masked_data[j,k] = 0
            masked_data = masked_where(masked_data > 0.5, masked_data)
            plt.imshow(As[i-1], interpolation = 'nearest', vmin = vmin, vmax = vmax)
            plt.colorbar()
            plt.imshow(masked_data, cmap = cm.binary, interpolation = "nearest")
        else:
            plt.imshow(A, interpolation = 'nearest', vmin = vmin, vmax = vmax)
            plt.colorbar()
        plt.title(title)
        plt.axis("off")
   
    plt.show()
# 
# def unroll_missing(missing, ns):
#     missing_unrolled = []
#     for i, (MM, n) in enumerate(zip(missing, ns)):
#         for m in MM:
#             n2 = m[1] + sum([ns[j] for j in range(i)])
#             missing_unrolled.append((m[0], n2))
#     return missing_unrolled
# 
开发者ID:powerscorinne,项目名称:GLRM,代码行数:37,代码来源:util.py

示例2: plot_activation

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import binary [as 别名]
def plot_activation(model, input_image, layer_name):
    """Plots a mosaic of feature activation.
    
    # Arguments
        model: Keras model
        input_image: Test image which is feed into the network
        layer_name: Layer name of feature map
    """
    from keras import backend as K
    from IPython.display import display
    
    f = K.function(model.inputs, [model.get_layer(layer_name).output])
    output = f([[input_image]])
    output = np.moveaxis(output[0][0], [0,1,2], [1,2,0])
    print('%-20s input_shape: %-16s output_shape: %-16s' % (layer_name, str(input_image.shape), str(output.shape)))
    
    num_y = num_x = int(np.ceil(np.sqrt(output.shape[0])))
    data = mosaic(output, (num_x, num_y), '5%')
    
    #plt.figure(figsize=(12, 12))
    ax = plt.gca()
    divider = make_axes_locatable(ax)
    cax = divider.append_axes('right', size=0.1, pad=0.05)
    im = ax.imshow(data, vmin=data.min(), vmax=data.max(), interpolation='nearest', cmap=cm.binary)
    plt.colorbar(im, cax=cax)
    
    display(plt.gcf())
    plt.close() 
开发者ID:mogoweb,项目名称:aiexamples,代码行数:30,代码来源:ssd_viz.py

示例3: sorting_value_of_zone

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import binary [as 别名]
def sorting_value_of_zone(zone):
    group_value=[[[]],[[]]]  # liste(liste_value, liste_nb_of_this-value)
    for i in range(len(zone)):
        if zone[i] not in group_value[0][0]:
            group_value[0][0].append(zone[i])
            group_value[1][0].append(1)
        else:
            index = group_value[0][0].index(zone[i])
            group_value[1][0][index] += 1
    return group_value




# #
# #
# # plt.imshow(arr_bin, cmap=cm.binary)
# # plt.show()
# plt.imshow(arr_bin, cmap=cm.binary)
# plt.show()


# from scipy.ndimage import gaussian_filter, median_filter
#
# #kernel = np.ones((5,5),np.float32)/25
# #img_smooth_1 = gaussian_filter(img, sigma=(20, 20), order=0)
# img_smooth_2 = median_filter(image, size=(30,30))
# img_smooth_2.astype(dtype='uint8')
#
# im = Image.fromarray(img_smooth_2)
# #im_1 = Image.fromarray(img_1)
# if im.mode != 'RGB':
#     im2 = im.convert('RGB')
# im2.save('gm_white_inv_smooth.png')
#
# plt.subplot(2,1,1)
# plt.imshow(image, cmap=cm.binary)
# # plt.subplot(2,2,2)
# # plt.imshow(img_smooth_1, cmap=cm.binary)
# plt.subplot(2,1,2)
# plt.imshow(img_smooth_2, cmap=cm.binary)
# plt.show()



#=======================================================================================================================
# Start program
#======================================================================================================================= 
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:50,代码来源:concatenate_WM_and_GM_tracts.py


注:本文中的matplotlib.cm.binary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。