def test_paint_tool(img): viewer = ImageViewer(img) tool = PaintTool(viewer, img.shape) tool.radius = 10 assert_equal(tool.radius, 10) tool.label = 2 assert_equal(tool.label, 2) assert_equal(tool.shape, img.shape[:2]) do_event(viewer, 'mouse_press', xdata=100, ydata=100) do_event(viewer, 'move', xdata=110, ydata=110) do_event(viewer, 'mouse_release') assert_equal(tool.overlay[tool.overlay == 2].size, 761) tool.label = 5 do_event(viewer, 'mouse_press', xdata=20, ydata=20) do_event(viewer, 'move', xdata=40, ydata=40) do_event(viewer, 'mouse_release') assert_equal(tool.overlay[tool.overlay == 5].size, 881) assert_equal(tool.overlay[tool.overlay == 2].size, 761) do_event(viewer, 'key_press', key='enter') tool.overlay = tool.overlay * 0 assert_equal(tool.overlay.sum(), 0) assert_equal(tool.cmap.N, tool._overlay_plot.norm.vmax)
def test_paint_tool(): img = data.moon() viewer = ImageViewer(img) tool = PaintTool(viewer, img.shape) tool.radius = 10 assert_equal(tool.radius, 10) tool.label = 2 assert_equal(tool.label, 2) assert_equal(tool.shape, img.shape) do_event(viewer, 'mouse_press', xdata=100, ydata=100) do_event(viewer, 'move', xdata=110, ydata=110) do_event(viewer, 'mouse_release') assert_equal(tool.overlay[tool.overlay == 2].size, 761) tool.label = 5 do_event(viewer, 'mouse_press', xdata=20, ydata=20) do_event(viewer, 'move', xdata=40, ydata=40) do_event(viewer, 'mouse_release') assert_equal(tool.overlay[tool.overlay == 5].size, 881) assert_equal(tool.overlay[tool.overlay == 2].size, 761) do_event(viewer, 'key_press', key='enter') tool.overlay = tool.overlay * 0 assert_equal(tool.overlay.sum(), 0)
def test_paint_tool(): img = data.moon() viewer = ImageViewer(img) tool = PaintTool(viewer.ax, img.shape) tool.radius = 10 assert_equal(tool.radius, 10) tool.label = 2 assert_equal(tool.label, 2) assert_equal(tool.shape, img.shape) start = create_mouse_event(viewer.ax, xdata=100, ydata=100) tool.on_mouse_press(start) move = create_mouse_event(viewer.ax, xdata=110, ydata=110) tool.on_move(move) tool.on_mouse_release(move) assert_equal(tool.overlay[tool.overlay == 2].size, 761) tool.label = 5 start = create_mouse_event(viewer.ax, xdata=20, ydata=20) tool.on_mouse_press(start) move = create_mouse_event(viewer.ax, xdata=40, ydata=40) tool.on_move(move) tool.on_mouse_release(move) assert_equal(tool.overlay[tool.overlay == 5].size, 881) assert_equal(tool.overlay[tool.overlay == 2].size, 761) enter = create_mouse_event(viewer.ax, key='enter') tool.on_mouse_press(enter) tool.overlay = tool.overlay * 0 assert_equal(tool.overlay.sum(), 0)
def test_paint_tool(): img = data.moon() viewer = ImageViewer(img) tool = PaintTool(viewer.ax, img.shape) tool.radius = 10 assert_equal(tool.radius, 10) tool.label = 2 assert_equal(tool.label, 2) assert_equal(tool.shape, img.shape) start = create_mouse_event(viewer.ax, xdata=100, ydata=100) tool.on_mouse_press(start) move = create_mouse_event(viewer.ax, xdata=110, ydata=110) tool.on_move(move) tool.on_mouse_release(move) assert_equal(tool.overlay[tool.overlay == 2].size, 761) tool.label = 5 start = create_mouse_event(viewer.ax, xdata=20, ydata=20) tool.on_mouse_press(start) move = create_mouse_event(viewer.ax, xdata=40, ydata=40) tool.on_move(move) tool.on_mouse_release(move) assert_equal(tool.overlay[tool.overlay == 5].size, 881) assert_equal(tool.overlay[tool.overlay == 2].size, 761) enter = create_mouse_event(viewer.ax, key='enter') tool.on_mouse_press(enter) tool.overlay = tool.overlay * 0 assert_equal(tool.overlay.sum(), 0)
def test_paint_tool(): img = data.moon() viewer = ImageViewer(img) tool = PaintTool(viewer, img.shape) tool.radius = 10 assert_equal(tool.radius, 10) tool.label = 2 assert_equal(tool.label, 2) assert_equal(tool.shape, img.shape) do_event(viewer, "mouse_press", xdata=100, ydata=100) do_event(viewer, "move", xdata=110, ydata=110) do_event(viewer, "mouse_release") assert_equal(tool.overlay[tool.overlay == 2].size, 761) tool.label = 5 do_event(viewer, "mouse_press", xdata=20, ydata=20) do_event(viewer, "move", xdata=40, ydata=40) do_event(viewer, "mouse_release") assert_equal(tool.overlay[tool.overlay == 5].size, 881) assert_equal(tool.overlay[tool.overlay == 2].size, 761) do_event(viewer, "key_press", key="enter") tool.overlay = tool.overlay * 0 assert_equal(tool.overlay.sum(), 0)