{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#

     Image plots in Lightning" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##
Setup" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from lightning import Lightning\n", "\n", "from numpy import random, asarray, concatenate\n", "from sklearn import datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Connect to server" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Lightning initialized
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Connected to server at http://public.lightning-viz.org\n" ] }, { "data": { "application/javascript": [ "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error(\"Cannot find module '\"+o+\"'\")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##
Basic image viewing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The image plot type shows an image with zooming and panning. \n", "
\n", "Lightning's image viewer is powered by leaflet, so easily handles panning through very large images." ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "imgs = datasets.load_sample_images().images\n", "lgn.image(imgs[0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Single-channel images will automatically be presented as grayscale." ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "imgs = datasets.load_sample_images().images\n", "lgn.image(imgs[0][:,:,0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The usual sizing arguments can be used to set the image size in pixels." ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "imgs = datasets.load_sample_images().images\n", "lgn.image(imgs[0], width=400)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }