Skip to content

Commit

Permalink
regenerate the transparent logo using the Python script
Browse files Browse the repository at this point in the history
  • Loading branch information
grlee77 committed May 12, 2021
1 parent 05e8bdb commit 59f13b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Binary file modified logo/green_orange_snake_transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 20 additions & 3 deletions logo/scikit_image_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def __init__(self):
# Demo plotting functions
# =======================

def plot_colorized_logo(logo, color, edges='light', whiten=False):
def plot_colorized_logo(logo, color, edges='light', whiten=False,
transparent_corners=False):
"""Convenience function to plot artificially-colored logo.
The upper-left half of the logo is an edge filtered image, while the
Expand All @@ -109,10 +110,12 @@ def plot_colorized_logo(logo, color, edges='light', whiten=False):
logo : LogoBase instance
color : length-3 sequence of floats or 2 length-3 sequences
RGB color spec. Float values should be between 0 and 1.
edges : {'light'|'dark'}
edges : {'light'|'dark'}, optional
Specifies whether Sobel edges are drawn light or dark
whiten : bool or 2 bools
whiten : bool or 2 bools, optional
If True, a color value less than 1 increases the image intensity.
transparent_corners : bool, optional
If True, set the corners to be transparent.
"""
if not hasattr(color[0], '__iter__'):
color = [color] * 2 # use same color for upper-left & lower-right
Expand All @@ -132,6 +135,11 @@ def plot_colorized_logo(logo, color, edges='light', whiten=False):
image[mask_img] = logo_img[mask_img]
image[mask_edge] = logo_edge[mask_edge]

if transparent_corners:
# add alpha channel with alpha=0.0 in the corners
alpha = (logo.mask_1 | logo.mask_2).astype(image.dtype)
image = np.concatenate((image, alpha[..., np.newaxis]), axis=-1)

logo.plot_curve(lw=5, color='w') # plot snake curve on current axes
plt.imshow(image)

Expand Down Expand Up @@ -159,6 +167,14 @@ def plot_official_logo():
whiten=(False, True))
plt.savefig('green_orange_snake.png', bbox_inches='tight')

def plot_official_logo_with_transparent_corners():
f, ax = plt.subplots()
prepare_axes(ax)
plot_colorized_logo(snake, green_orange, edges='dark',
whiten=(False, True), transparent_corners=True)
plt.savefig('green_orange_snake_transparent.png', bbox_inches='tight',
transparent=True)

def plot_favicon():
f, ax = plt.subplots()
prepare_axes(ax)
Expand All @@ -168,6 +184,7 @@ def plot_favicon():

plot_all()
plot_official_logo()
plot_official_logo_with_transparent_corners()
plot_favicon()

plt.show()

0 comments on commit 59f13b9

Please sign in to comment.