Skip to content

Commit

Permalink
improve plot_image_w_colorful_grains function
Browse files Browse the repository at this point in the history
  • Loading branch information
zsylvester committed Nov 1, 2024
1 parent 65f36bb commit 1d78c29
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions segmenteverygrain/segmenteverygrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ def get_grains_from_patches(ax, image, plotting=False):
facecolor=(0,0,1), edgecolor='none', linewidth=0.5, alpha=0.4)
return all_grains, rasterized, mask_all

def plot_image_w_colorful_grains(image, all_grains, ax, cmap='viridis', plot_image=True):
def plot_image_w_colorful_grains(image, all_grains, ax, cmap='viridis', plot_image=True, im_alpha=1.0):
"""
Plot image with randomly colored grain masks.
Expand Down Expand Up @@ -1409,11 +1409,11 @@ def plot_image_w_colorful_grains(image, all_grains, ax, cmap='viridis', plot_ima
# Get the individual colors
colors = [cmap(i) for i in color_indices]
if plot_image:
ax.imshow(image, alpha=0.75)
ax.imshow(image, alpha=im_alpha)
for i in trange(len(all_grains)):
color = colors[i]
ax.fill(all_grains[i].exterior.xy[0], all_grains[i].exterior.xy[1],
facecolor=color, edgecolor='none', linewidth=1, alpha=0.4)
facecolor=color, edgecolor='none', linewidth=1, alpha=0.5)
ax.plot(all_grains[i].exterior.xy[0], all_grains[i].exterior.xy[1],
color='k', linewidth=1)
ax.set_xticks([])
Expand Down

0 comments on commit 1d78c29

Please sign in to comment.