Image polygon plots in Lightning


Setup


In [1]:
from lightning import Lightning

from sklearn import datasets

Connect to server


In [2]:
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')


Lightning initialized
Connected to server at http://public.lightning-viz.org


Region drawing

The image-poly visualization let's you draw polygonal regions on images and then query them in the same notebook!
Try drawing a region on the image. Hold command to pan, and option to edit the region.
Note that we assign the visualization to an output variable, so that we can query it later, but we must print that output to get the image to show.


In [3]:
imgs = datasets.load_sample_images().images
viz = lgn.imagepoly(imgs[0])
viz


Out[3]:

Draw some regions on the image above. Then check the value of viz.coords.


In [4]:
p = viz.polygons()

In [5]:
lgn.imagepoly(imgs[0], polygons=p)


Out[5]:

In this case we drew four regions, so we get four arrays of coordinates (in original image space).
The region overlays themselves do not persist on the image after a refresh, so you'll have to draw your own to see them.