From 6ab6aefebadc1c83de2a2eb59704e6d817c07857 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Fri, 16 Sep 2011 15:09:14 -0700 Subject: [PATCH] Adjust orange snake brightness. Add --no-plot flag. --- scikits_image_logo.py | 56 ++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/scikits_image_logo.py b/scikits_image_logo.py index 81462ea3..e96a7f25 100644 --- a/scikits_image_logo.py +++ b/scikits_image_logo.py @@ -107,8 +107,13 @@ class SnakeLogo(LogoBase): def __init__(self): self.radius = 250 self.origin = (420, 0) - img = sio.imread('data/snake_pixabay.jpg') - self.img = self._crop_image(img) + img = sio.imread('data/snake_pixabay.jpg') + img = self._crop_image(img) + + img = img.astype(float) * 1.1 + img[img > 255] = 255 + self.img = img.astype(np.uint8) + LogoBase.__init__(self) @@ -184,21 +189,38 @@ def green_orange_dark_edges(logo, **kwargs): if __name__ == '__main__': - plotters = (red_light_edges, red_dark_edges, - blue_light_edges, blue_dark_edges, - green_orange_light_edges, green_orange_dark_edges) - f, axes_array = plt.subplots(nrows=2, ncols=len(plotters)) - for plot, ax_col in zip(plotters, axes_array.T): - prepare_axes(ax_col[0]) - plot(snake) - prepare_axes(ax_col[1]) - plot(snake, whiten=True) - plt.tight_layout() + import sys + plot = False + if len(sys.argv) < 2 or sys.argv[1] != '--no-plot': + plot = True - f, ax = plt.subplots() - prepare_axes(ax) - green_orange_dark_edges(snake, whiten=(False, True)) - #plt.savefig('green_orange_snake.pdf', bbox_inches='tight') + print "Run with '--no-plot' flag to generate logo silently." - plt.show() + def plot_all(): + plotters = (red_light_edges, red_dark_edges, + blue_light_edges, blue_dark_edges, + green_orange_light_edges, green_orange_dark_edges) + + f, axes_array = plt.subplots(nrows=2, ncols=len(plotters)) + for plot, ax_col in zip(plotters, axes_array.T): + prepare_axes(ax_col[0]) + plot(snake) + prepare_axes(ax_col[1]) + plot(snake, whiten=True) + plt.tight_layout() + + def plot_snake(): + + f, ax = plt.subplots() + prepare_axes(ax) + green_orange_dark_edges(snake, whiten=(False, True)) + plt.savefig('green_orange_snake.png', bbox_inches='tight') + + if plot: + plot_all() + + plot_snake() + + if plot: + plt.show()