Python matplotlib.cm.binary() Examples
The following are 3
code examples of matplotlib.cm.binary().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.cm
, or try the search function
.
Example #1
Source File: util.py From GLRM with MIT License | 5 votes |
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 #
Example #2
Source File: ssd_viz.py From aiexamples with Apache License 2.0 | 5 votes |
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()
Example #3
Source File: concatenate_WM_and_GM_tracts.py From spinalcordtoolbox with MIT License | 4 votes |
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 #=======================================================================================================================