diff --git a/doc/logo/Makefile b/doc/logo/Makefile deleted file mode 100644 index 1cf861bd..00000000 --- a/doc/logo/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -.PHONY: logo - -logo: green_orange_snake.png snake_logo.svg - inkscape --export-png=scikit_image_logo.png --export-dpi=100 \ - --export-area-drawing --export-background-opacity=1 \ - snake_logo.svg - python shrink_logo.py - -green_orange_snake.png: - python scikit_image_logo.py --no-plot - diff --git a/doc/logo/data/scipy.png b/doc/logo/data/scipy.png deleted file mode 100644 index 72fa0508..00000000 Binary files a/doc/logo/data/scipy.png and /dev/null differ diff --git a/doc/logo/data/snake_pixabay.jpg b/doc/logo/data/snake_pixabay.jpg deleted file mode 100644 index cb3c337c..00000000 Binary files a/doc/logo/data/snake_pixabay.jpg and /dev/null differ diff --git a/doc/logo/scikit_image_logo.py b/doc/logo/scikit_image_logo.py deleted file mode 100644 index 48e38aad..00000000 --- a/doc/logo/scikit_image_logo.py +++ /dev/null @@ -1,165 +0,0 @@ -""" -Script to draw skimage logo using Scipy logo as stencil. The easiest -starting point is the `plot_colorized_logo`. - -Original snake image from pixabay [1]_ - -.. [1] http://pixabay.com/en/snake-green-toxic-close-yellow-3237/ -""" -import sys -if len(sys.argv) != 2 or sys.argv[1] != '--no-plot': - print("Run with '--no-plot' flag to generate logo silently.") -else: - import matplotlib as mpl - mpl.use('Agg') -import matplotlib.pyplot as plt - -import numpy as np - -import skimage.io as sio -from skimage import img_as_float -from skimage.color import gray2rgb, rgb2gray -from skimage.exposure import rescale_intensity -from skimage.filters import sobel - -import scipy_logo - -# Utility functions -# ================= - -def colorize(image, color, whiten=False): - """Return colorized image from gray scale image. - - The colorized image has values from ranging between black at the lowest - intensity to `color` at the highest. If `whiten=True`, then the color - ranges from `color` to white. - """ - color = np.asarray(color)[np.newaxis, np.newaxis, :] - image = image[:, :, np.newaxis] - if whiten: - # truncate and stretch intensity range to enhance contrast - image = rescale_intensity(image, in_range=(0.3, 1)) - return color * (1 - image) + image - else: - return image * color - - -def prepare_axes(ax): - plt.sca(ax) - ax.xaxis.set_visible(False) - ax.yaxis.set_visible(False) - for spine in ax.spines.values(): - spine.set_visible(False) - - -# Logo generating classes -# ======================= - -class LogoBase(object): - - def __init__(self): - self.logo = scipy_logo.ScipyLogo(radius=self.radius) - self.mask_1 = self.logo.get_mask(self.image.shape, 'upper left') - self.mask_2 = self.logo.get_mask(self.image.shape, 'lower right') - - edges = np.array([sobel(img) for img in self.image.T]).T - # truncate and stretch intensity range to enhance contrast - self.edges = rescale_intensity(edges, in_range=(0, 0.4)) - - def _crop_image(self, image): - w = 2 * self.radius - x, y = self.origin - return image[y:y + w, x:x + w] - - def plot_curve(self, **kwargs): - self.logo.plot_snake_curve(**kwargs) - - -class SnakeLogo(LogoBase): - - radius = 250 - origin = (420, 0) - - def __init__(self): - image = sio.imread('data/snake_pixabay.jpg') - image = self._crop_image(image) - self.image = img_as_float(image) - - LogoBase.__init__(self) - - -snake_color = SnakeLogo() -snake = SnakeLogo() -# turn RGB image into gray image -snake.image = rgb2gray(snake.image) -snake.edges = rgb2gray(snake.edges) - - -# Demo plotting functions -# ======================= - -def plot_colorized_logo(logo, color, edges='light', whiten=False): - """Convenience function to plot artificially-colored logo. - - The upper-left half of the logo is an edge filtered image, while the - lower-right half is unfiltered. - - Parameters - ---------- - 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'} - Specifies whether Sobel edges are drawn light or dark - whiten : bool or 2 bools - If True, a color value less than 1 increases the image intensity. - """ - if not hasattr(color[0], '__iter__'): - color = [color] * 2 # use same color for upper-left & lower-right - if not hasattr(whiten, '__iter__'): - whiten = [whiten] * 2 # use same setting for upper-left & lower-right - - image = gray2rgb(np.ones_like(logo.image)) - mask_img = gray2rgb(logo.mask_2) - mask_edge = gray2rgb(logo.mask_1) - - # Compose image with colorized image and edge-image. - if edges == 'dark': - logo_edge = colorize(1 - logo.edges, color[0], whiten=whiten[0]) - else: - logo_edge = colorize(logo.edges, color[0], whiten=whiten[0]) - logo_img = colorize(logo.image, color[1], whiten=whiten[1]) - image[mask_img] = logo_img[mask_img] - image[mask_edge] = logo_edge[mask_edge] - - logo.plot_curve(lw=5, color='w') # plot snake curve on current axes - plt.imshow(image) - - -if __name__ == '__main__': - # Colors to use for the logo: - red = (1, 0, 0) - blue = (0.35, 0.55, 0.85) - green_orange = ((0.6, 0.8, 0.3), (1, 0.5, 0.1)) - - def plot_all(): - color_list = [red, blue, green_orange] - edge_list = ['light', 'dark'] - f, axes = plt.subplots(nrows=len(edge_list), ncols=len(color_list)) - for axes_row, edges in zip(axes, edge_list): - for ax, color in zip(axes_row, color_list): - prepare_axes(ax) - plot_colorized_logo(snake, color, edges=edges) - plt.tight_layout() - - def plot_official_logo(): - f, ax = plt.subplots() - prepare_axes(ax) - plot_colorized_logo(snake, green_orange, edges='dark', - whiten=(False, True)) - plt.savefig('green_orange_snake.png', bbox_inches='tight') - - plot_all() - plot_official_logo() - - plt.show() diff --git a/doc/logo/scipy_logo.py b/doc/logo/scipy_logo.py deleted file mode 100644 index b23787c8..00000000 --- a/doc/logo/scipy_logo.py +++ /dev/null @@ -1,248 +0,0 @@ -""" -Code used to trace Scipy logo. -""" -import numpy as np -import matplotlib.pyplot as plt - -from skimage import io -from skimage import data - -from skimage.measure import points_in_poly - -class SymmetricAnchorPoint(object): - """Anchor point in a parametric curve with symmetric handles - - Parameters - ---------- - pt : length-2 sequence - (x, y) coordinates of anchor point - theta : float - angle of control handle - length : float - half-length of symmetric control handle. Each control point is `length` - distance away from the anchor point. - use_degrees : bool - If True, convert input `theta` from degrees to radians. - """ - - def __init__(self, pt, theta, length, use_degrees=False): - self.pt = pt - if use_degrees: - theta = theta * np.pi / 180 - self.theta = theta - self.length = length - - def control_points(self): - """Return control points for symmetric handles - - The first point is in the direction of theta and the second is directly - opposite. For example, if `theta = 0`, then the first `p1` will be - directly to the right of the anchor point, and `p2` will be directly - to the left. - """ - theta = self.theta - offset = self.length * np.array([np.cos(theta), np.sin(theta)]) - p1 = self.pt + offset - p2 = self.pt - offset - return p1, p2 - - def __repr__(self): - v = (self.pt, self.theta * 180/np.pi, self.length) - return 'SymmetricAnchorPoint(pt={0}, theta={1}, length={2})'.format(*v) - - -def curve_from_anchor_points(pts): - """Return curve from a list of SymmetricAnchorPoints""" - assert len(pts) > 1 - bezier_pts = [] - for anchor in pts: - c1, c2 = anchor.control_points() - bezier_pts.extend([c2, anchor.pt, c1]) - # clip control points from ends - bezier_pts = bezier_pts[1:-1] - x, y = [], [] - # every third point is an anchor point - for i in range(0, len(bezier_pts)-1, 3): - xi, yi = cubic_curve(*bezier_pts[i:i+4]) - x.append(xi) - y.append(yi) - return np.hstack(x), np.hstack(y) - - -def cubic_curve(p0, p1, p2, p3, npts=20): - """Return points on a cubic Bezier curve - - Parameters - ---------- - p0, p3 : length-2 sequences - end points of curve - p1, p2 : length-2 sequences - control points of curve - npts : int - number of points to return (including end points) - - Returns - ------- - x, y : arrays - points on cubic curve - """ - t = np.linspace(0, 1, npts)[:, np.newaxis] - # cubic bezier curve from http://en.wikipedia.org/wiki/Bezier_curve - b = (1-t)**3 * p0 + 3*t*(1-t)**2 * p1 + 3*t**2*(1-t) * p2 + t**3 * p3 - x, y = b.transpose() - return x, y - - -class Circle(object): - - def __init__(self, center, radius): - self.center = center - self.radius = radius - - def point_from_angle(self, angle): - r = self.radius - # `angle` can be a scalar or 1D array: transpose twice for best results - pts = r * np.array((np.cos(angle), np.sin(angle))).T + self.center - return pts.T - - def plot(self, **kwargs): - ax = kwargs.pop('ax', plt.gca()) - fc = kwargs.pop('fc', 'none') - c = plt.Circle(self.center, self.radius, fc=fc, **kwargs) - ax.add_patch(c) - - -class ScipyLogo(object): - """Object to generate scipy logo - - Parameters - ---------- - center : length-2 array - the Scipy logo will be centered on this point. - radius : float - radius of logo - """ - - CENTER = np.array((254, 246)) - RADIUS = 252.0 - THETA_START = 2.58 - THETA_END = -0.368 - - def __init__(self, center=None, radius=None): - if center is None: - if radius is None: - center = self.CENTER - else: - center = np.array((radius, radius)) - self.center = center - if radius is None: - radius = self.RADIUS - self.radius = radius - - - # calculate end points of curve so that it lies exactly on circle - logo_circle = Circle(self.CENTER, self.RADIUS) - s_start = logo_circle.point_from_angle(self.THETA_START) - s_end = logo_circle.point_from_angle(self.THETA_END) - - self.circle = Circle(self.center, self.radius) - # note that angles are clockwise because of inverted y-axis - self._anchors = [SymmetricAnchorPoint(*t, use_degrees=True) - for t in [(s_start, -37, 90), - ((144, 312), 7, 20), - ((205, 375), 52, 50), - ((330, 380), -53, 60), - ((290, 260),-168, 50), - ((217, 245),-168, 50), - ((182, 118), -50, 60), - ((317, 125), 53, 60), - ((385, 198), 10, 20), - (s_end, -25, 60)]] - # normalize anchors so they have unit radius and are centered at origin - for a in self._anchors: - a.pt = (a.pt - self.CENTER) / self.RADIUS - a.length = a.length / self.RADIUS - - def snake_anchors(self): - """Return list of SymmetricAnchorPoints defining snake curve""" - anchors = [] - for a in self._anchors: - pt = self.radius * a.pt + self.center - length = self.radius * a.length - anchors.append(SymmetricAnchorPoint(pt, a.theta, length)) - return anchors - - def snake_curve(self): - """Return x, y coordinates of snake curve""" - return curve_from_anchor_points(self.snake_anchors()) - - def plot_snake_curve(self, **kwargs): - ax = kwargs.pop('ax', plt.gca()) - x, y = self.snake_curve() - ax.plot(x, y, 'k', **kwargs) - - def plot_circle(self, **kwargs): - self.circle.plot(**kwargs) - - def plot_image(self, **kwargs): - ax = kwargs.pop('ax', plt.gca()) - img = io.imread('data/scipy.png') - ax.imshow(img, **kwargs) - - def get_mask(self, shape, region): - """ - Parameters - ---------- - region : {'upper left', 'lower right'} - """ - if region == 'upper left': - theta = np.linspace(self.THETA_END, self.THETA_START - 2 * np.pi) - elif region == 'lower right': - theta = np.linspace(self.THETA_END, self.THETA_START) - else: - msg = "Expected 'upper left' or 'lower right'; got %s" % region - raise ValueError(msg) - xy_circle = self.circle.point_from_angle(theta).T - x, y = self.snake_curve() - xy_curve = np.array((x, y)).T - xy_poly = np.vstack((xy_curve, xy_circle)) - - h, w = shape[:2] - y_img, x_img = np.mgrid[:h, :w] - xy_points = np.column_stack((x_img.flat, y_img.flat)) - - mask = points_in_poly(xy_points, xy_poly) - return mask.reshape((h, w)) - - -def plot_scipy_trace(): - plt.figure() - logo = ScipyLogo() - logo.plot_snake_curve() - logo.plot_circle() - logo.plot_image() - plot_anchors(logo.snake_anchors()) - - -def plot_anchors(anchors, color='r', alpha=0.7): - for a in anchors: - c = a.control_points() - x, y = np.transpose(c) - plt.plot(x, y, 'o-', color=color, mfc='w', mec=color, alpha=alpha) - plt.plot(a.pt[0], a.pt[1], 'o', color=color, alpha=alpha) - - -def plot_snake_overlay(): - plt.figure() - logo = ScipyLogo((670, 250), 250) - logo.plot_snake_curve() - logo.plot_circle() - img = io.imread('data/snake_pixabay.jpg') - plt.imshow(img) - - -if __name__ == '__main__': - plot_scipy_trace() - plot_snake_overlay() - - plt.show() diff --git a/doc/logo/shrink_logo.py b/doc/logo/shrink_logo.py deleted file mode 100644 index 205e1bf4..00000000 --- a/doc/logo/shrink_logo.py +++ /dev/null @@ -1,16 +0,0 @@ -from skimage import io, transform - -s = 0.7 - -img = io.imread('scikit_image_logo.png') -h, w, c = img.shape - -print "\nScaling down logo by %.1fx..." % s - -img = transform.homography(img, [[s, 0, 0], - [0, s, 0], - [0, 0, 1]], - output_shape=(int(h*s), int(w*s), 4), - order=3) - -io.imsave('scikit_image_logo_small.png', img) diff --git a/doc/logo/snake_logo.svg b/doc/logo/snake_logo.svg deleted file mode 100644 index 5f9f634f..00000000 --- a/doc/logo/snake_logo.svg +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - scikit-image - image processing in python - - -