From a01a5ed0238e334d2d55518455bd420319b62722 Mon Sep 17 00:00:00 2001 From: salvatore Date: Sat, 20 Dec 2014 23:54:06 +0100 Subject: [PATCH] Added an example of use of CanvasTools.RectTool to allow generation of docs. RectTool is used to write rectangles over an image (lena). This example also can be useful for set_color explanation using both [RGB] and single value color setting from previous commit indented code in examples is formatted properly. --- skimage/viewer/canvastools/recttool.py | 48 +++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/skimage/viewer/canvastools/recttool.py b/skimage/viewer/canvastools/recttool.py index 62e7d9b3..3f8fbd79 100644 --- a/skimage/viewer/canvastools/recttool.py +++ b/skimage/viewer/canvastools/recttool.py @@ -41,33 +41,33 @@ class RectangleTool(CanvasToolBase, RectangleSelector): Examples -------- - >>>from skimage import data - >>>import matplotlib.pyplot as plt - >>>from skimage.viewer.canvastools import RectangleTool - >>>import numpy as np - >>>from skimage.draw import line - >>>from skimage.draw import set_color + >>> from skimage import data + >>> import matplotlib.pyplot as plt + >>> from skimage.viewer.canvastools import RectangleTool + >>> import numpy as np + >>> from skimage.draw import line + >>> from skimage.draw import set_color - >>>im = data.lena() - >>>[f, ax] = plt.subplots() - >>>ax.imshow(im) + >>> im = data.lena() + >>> [f, ax] = plt.subplots() + >>> ax.imshow(im) - >>>def stampa(extents): - >>>>>>global im,ax - >>>>>>coord = np.int64(extents) - >>>>>>[rr1, cc1] = line(coord[2],coord[0],coord[2],coord[1]) - >>>>>>[rr2, cc2] = line(coord[2],coord[1],coord[3],coord[1]) - >>>>>>[rr3, cc3] = line(coord[3],coord[1],coord[3],coord[0]) - >>>>>>[rr4, cc4] = line(coord[3],coord[0],coord[2],coord[0]) - >>>>>>set_color(im, (rr1, cc1), [255, 255, 0]) - >>>>>>set_color(im, (rr2, cc2), [0, 255, 255]) - >>>>>>set_color(im, (rr3, cc3), [255, 0, 255]) - >>>>>>set_color(im, (rr4, cc4), [0, 0, 0]) - >>>>>>ax.imshow(im) - >>>>>>plt.show() + >>> def stampa(extents): + ... global im,ax + ... coord = np.int64(extents) + ... [rr1, cc1] = line(coord[2],coord[0],coord[2],coord[1]) + ... [rr2, cc2] = line(coord[2],coord[1],coord[3],coord[1]) + ... [rr3, cc3] = line(coord[3],coord[1],coord[3],coord[0]) + ... [rr4, cc4] = line(coord[3],coord[0],coord[2],coord[0]) + ... set_color(im, (rr1, cc1), [255, 255, 0]) + ... set_color(im, (rr2, cc2), [0, 255, 255]) + ... set_color(im, (rr3, cc3), [255, 0, 255]) + ... set_color(im, (rr4, cc4), [0, 0, 0]) + ... ax.imshow(im) + ... plt.show() - >>>rect_tool = RectangleTool(ax, on_enter=stampa) - >>>plt.show() + >>> rect_tool = RectangleTool(ax, on_enter=stampa) + >>> plt.show() """